@gdjiami/cli
Version:
CLI for build front end project.
31 lines (30 loc) • 1.46 kB
JavaScript
;
/**
* Copyright (c) 2015-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
Object.defineProperty(exports, "__esModule", { value: true });
// This Webpack plugin ensures `npm install <library>` forces a project rebuild.
// We’re not sure why this isn't Webpack's default behavior.
// See https://github.com/facebook/create-react-app/issues/186.
var WatchMissingNodeModulesPlugin = /** @class */ (function () {
function WatchMissingNodeModulesPlugin(nodeModulesPath) {
this.nodeModulesPath = nodeModulesPath;
}
WatchMissingNodeModulesPlugin.prototype.apply = function (compiler) {
var _this = this;
compiler.hooks.emit.tap('WatchMissingNodeModulesPlugin', function (compilation) {
var missingDeps = Array.from(compilation.missingDependencies);
var nodeModulesPath = _this.nodeModulesPath;
// If any missing files are expected to appear in node_modules...
if (missingDeps.some(function (file) { return file.includes(nodeModulesPath); })) {
// ...tell webpack to watch node_modules recursively until they appear.
compilation.contextDependencies.add(nodeModulesPath);
}
});
};
return WatchMissingNodeModulesPlugin;
}());
exports.default = WatchMissingNodeModulesPlugin;