webpack-cli
Advanced tools
Comparing version 4.9.2 to 4.10.0
@@ -0,15 +1,16 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
// eslint-disable-next-line @typescript-eslint/no-var-requires | ||
const WebpackCLI = require("./webpack-cli"); | ||
const runCLI = async (args) => { | ||
// Create a new instance of the CLI object | ||
const cli = new WebpackCLI(); | ||
try { | ||
await cli.run(args); | ||
} catch (error) { | ||
cli.logger.error(error); | ||
process.exit(2); | ||
} | ||
// Create a new instance of the CLI object | ||
const cli = new WebpackCLI(); | ||
try { | ||
await cli.run(args); | ||
} | ||
catch (error) { | ||
cli.logger.error(error); | ||
process.exit(2); | ||
} | ||
}; | ||
module.exports = runCLI; |
@@ -0,5 +1,22 @@ | ||
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
o[k2] = m[k]; | ||
})); | ||
var __exportStar = (this && this.__exportStar) || function(m, exports) { | ||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__exportStar(require("./types"), exports); | ||
// eslint-disable-next-line @typescript-eslint/no-var-requires | ||
const CLI = require("./webpack-cli"); | ||
module.exports = CLI; | ||
// TODO remove after drop `@webpack-cli/migrate` | ||
module.exports.utils = { logger: console }; |
@@ -0,132 +1,99 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.CLIPlugin = void 0; | ||
class CLIPlugin { | ||
constructor(options) { | ||
this.options = options; | ||
} | ||
setupHotPlugin(compiler) { | ||
const { HotModuleReplacementPlugin } = compiler.webpack || require("webpack"); | ||
const hotModuleReplacementPlugin = Boolean( | ||
compiler.options.plugins.find((plugin) => plugin instanceof HotModuleReplacementPlugin), | ||
); | ||
if (!hotModuleReplacementPlugin) { | ||
new HotModuleReplacementPlugin().apply(compiler); | ||
constructor(options) { | ||
this.options = options; | ||
} | ||
} | ||
setupPrefetchPlugin(compiler) { | ||
const { PrefetchPlugin } = compiler.webpack || require("webpack"); | ||
new PrefetchPlugin(null, this.options.prefetch).apply(compiler); | ||
} | ||
async setupBundleAnalyzerPlugin(compiler) { | ||
// eslint-disable-next-line node/no-extraneous-require | ||
const { BundleAnalyzerPlugin } = require("webpack-bundle-analyzer"); | ||
const bundleAnalyzerPlugin = Boolean( | ||
compiler.options.plugins.find((plugin) => plugin instanceof BundleAnalyzerPlugin), | ||
); | ||
if (!bundleAnalyzerPlugin) { | ||
new BundleAnalyzerPlugin().apply(compiler); | ||
setupHotPlugin(compiler) { | ||
const { HotModuleReplacementPlugin } = compiler.webpack || require("webpack"); | ||
const hotModuleReplacementPlugin = Boolean(compiler.options.plugins.find((plugin) => plugin instanceof HotModuleReplacementPlugin)); | ||
if (!hotModuleReplacementPlugin) { | ||
new HotModuleReplacementPlugin().apply(compiler); | ||
} | ||
} | ||
} | ||
setupProgressPlugin(compiler) { | ||
const { ProgressPlugin } = compiler.webpack || require("webpack"); | ||
const progressPlugin = Boolean( | ||
compiler.options.plugins.find((plugin) => plugin instanceof ProgressPlugin), | ||
); | ||
if (!progressPlugin) { | ||
new ProgressPlugin({ | ||
profile: this.options.progress === "profile", | ||
}).apply(compiler); | ||
setupPrefetchPlugin(compiler) { | ||
const { PrefetchPlugin } = compiler.webpack || require("webpack"); | ||
new PrefetchPlugin(null, this.options.prefetch).apply(compiler); | ||
} | ||
} | ||
setupHelpfulOutput(compiler) { | ||
const pluginName = "webpack-cli"; | ||
const getCompilationName = () => (compiler.name ? `'${compiler.name}'` : ""); | ||
const logCompilation = (message) => { | ||
if (process.env.WEBPACK_CLI_START_FINISH_FORCE_LOG) { | ||
process.stderr.write(message); | ||
} else { | ||
this.logger.log(message); | ||
} | ||
}; | ||
const { configPath } = this.options; | ||
compiler.hooks.run.tap(pluginName, () => { | ||
const name = getCompilationName(); | ||
logCompilation(`Compiler${name ? ` ${name}` : ""} starting... `); | ||
if (configPath) { | ||
this.logger.log(`Compiler${name ? ` ${name}` : ""} is using config: '${configPath}'`); | ||
} | ||
}); | ||
compiler.hooks.watchRun.tap(pluginName, (compiler) => { | ||
const { bail, watch } = compiler.options; | ||
if (bail && watch) { | ||
this.logger.warn( | ||
'You are using "bail" with "watch". "bail" will still exit webpack when the first error is found.', | ||
); | ||
} | ||
const name = getCompilationName(); | ||
logCompilation(`Compiler${name ? ` ${name}` : ""} starting... `); | ||
if (configPath) { | ||
this.logger.log(`Compiler${name ? ` ${name}` : ""} is using config: '${configPath}'`); | ||
} | ||
}); | ||
compiler.hooks.invalid.tap(pluginName, (filename, changeTime) => { | ||
const date = new Date(changeTime * 1000); | ||
this.logger.log(`File '${filename}' was modified`); | ||
this.logger.log(`Changed time is ${date} (timestamp is ${changeTime})`); | ||
}); | ||
(compiler.webpack ? compiler.hooks.afterDone : compiler.hooks.done).tap(pluginName, () => { | ||
const name = getCompilationName(); | ||
logCompilation(`Compiler${name ? ` ${name}` : ""} finished`); | ||
process.nextTick(() => { | ||
if (compiler.watchMode) { | ||
this.logger.log(`Compiler${name ? `${name}` : ""} is watching files for updates...`); | ||
async setupBundleAnalyzerPlugin(compiler) { | ||
// eslint-disable-next-line node/no-extraneous-require,@typescript-eslint/no-var-requires | ||
const { BundleAnalyzerPlugin } = require("webpack-bundle-analyzer"); | ||
const bundleAnalyzerPlugin = Boolean(compiler.options.plugins.find((plugin) => plugin instanceof BundleAnalyzerPlugin)); | ||
if (!bundleAnalyzerPlugin) { | ||
new BundleAnalyzerPlugin().apply(compiler); | ||
} | ||
}); | ||
}); | ||
} | ||
apply(compiler) { | ||
this.logger = compiler.getInfrastructureLogger("webpack-cli"); | ||
if (this.options.progress) { | ||
this.setupProgressPlugin(compiler); | ||
} | ||
if (this.options.hot) { | ||
this.setupHotPlugin(compiler); | ||
setupProgressPlugin(compiler) { | ||
const { ProgressPlugin } = compiler.webpack || require("webpack"); | ||
const progressPlugin = Boolean(compiler.options.plugins.find((plugin) => plugin instanceof ProgressPlugin)); | ||
if (!progressPlugin) { | ||
new ProgressPlugin({ | ||
profile: this.options.progress === "profile", | ||
}).apply(compiler); | ||
} | ||
} | ||
if (this.options.prefetch) { | ||
this.setupPrefetchPlugin(compiler); | ||
setupHelpfulOutput(compiler) { | ||
const pluginName = "webpack-cli"; | ||
const getCompilationName = () => (compiler.name ? `'${compiler.name}'` : ""); | ||
const logCompilation = (message) => { | ||
if (process.env.WEBPACK_CLI_START_FINISH_FORCE_LOG) { | ||
process.stderr.write(message); | ||
} | ||
else { | ||
this.logger.log(message); | ||
} | ||
}; | ||
const { configPath } = this.options; | ||
compiler.hooks.run.tap(pluginName, () => { | ||
const name = getCompilationName(); | ||
logCompilation(`Compiler${name ? ` ${name}` : ""} starting... `); | ||
if (configPath) { | ||
this.logger.log(`Compiler${name ? ` ${name}` : ""} is using config: '${configPath}'`); | ||
} | ||
}); | ||
compiler.hooks.watchRun.tap(pluginName, (compiler) => { | ||
const { bail, watch } = compiler.options; | ||
if (bail && watch) { | ||
this.logger.warn('You are using "bail" with "watch". "bail" will still exit webpack when the first error is found.'); | ||
} | ||
const name = getCompilationName(); | ||
logCompilation(`Compiler${name ? ` ${name}` : ""} starting... `); | ||
if (configPath) { | ||
this.logger.log(`Compiler${name ? ` ${name}` : ""} is using config: '${configPath}'`); | ||
} | ||
}); | ||
compiler.hooks.invalid.tap(pluginName, (filename, changeTime) => { | ||
const date = new Date(changeTime); | ||
this.logger.log(`File '${filename}' was modified`); | ||
this.logger.log(`Changed time is ${date} (timestamp is ${changeTime})`); | ||
}); | ||
(compiler.webpack ? compiler.hooks.afterDone : compiler.hooks.done).tap(pluginName, () => { | ||
const name = getCompilationName(); | ||
logCompilation(`Compiler${name ? ` ${name}` : ""} finished`); | ||
process.nextTick(() => { | ||
if (compiler.watchMode) { | ||
this.logger.log(`Compiler${name ? `${name}` : ""} is watching files for updates...`); | ||
} | ||
}); | ||
}); | ||
} | ||
if (this.options.analyze) { | ||
this.setupBundleAnalyzerPlugin(compiler); | ||
apply(compiler) { | ||
this.logger = compiler.getInfrastructureLogger("webpack-cli"); | ||
if (this.options.progress) { | ||
this.setupProgressPlugin(compiler); | ||
} | ||
if (this.options.hot) { | ||
this.setupHotPlugin(compiler); | ||
} | ||
if (this.options.prefetch) { | ||
this.setupPrefetchPlugin(compiler); | ||
} | ||
if (this.options.analyze) { | ||
this.setupBundleAnalyzerPlugin(compiler); | ||
} | ||
this.setupHelpfulOutput(compiler); | ||
} | ||
this.setupHelpfulOutput(compiler); | ||
} | ||
} | ||
exports.CLIPlugin = CLIPlugin; | ||
module.exports = CLIPlugin; |
@@ -0,13 +1,13 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
function dynamicImportLoader() { | ||
let importESM; | ||
try { | ||
importESM = new Function("id", "return import(id);"); | ||
} catch (e) { | ||
importESM = null; | ||
} | ||
return importESM; | ||
let importESM; | ||
try { | ||
importESM = new Function("id", "return import(id);"); | ||
} | ||
catch (e) { | ||
importESM = null; | ||
} | ||
return importESM; | ||
} | ||
module.exports = dynamicImportLoader; |
{ | ||
"name": "webpack-cli", | ||
"version": "4.9.2", | ||
"version": "4.10.0", | ||
"description": "CLI for webpack & friends", | ||
@@ -11,2 +11,7 @@ "license": "MIT", | ||
"homepage": "https://github.com/webpack/webpack-cli/tree/master/packages/webpack-cli", | ||
"bugs": "https://github.com/webpack/webpack-cli/issues", | ||
"funding": { | ||
"type": "opencollective", | ||
"url": "https://opencollective.com/webpack" | ||
}, | ||
"bin": { | ||
@@ -34,8 +39,8 @@ "webpack-cli": "./bin/cli.js" | ||
"@discoveryjs/json-ext": "^0.5.0", | ||
"@webpack-cli/configtest": "^1.1.1", | ||
"@webpack-cli/info": "^1.4.1", | ||
"@webpack-cli/serve": "^1.6.1", | ||
"@webpack-cli/configtest": "^1.2.0", | ||
"@webpack-cli/info": "^1.5.0", | ||
"@webpack-cli/serve": "^1.7.0", | ||
"colorette": "^2.0.14", | ||
"commander": "^7.0.0", | ||
"execa": "^5.0.0", | ||
"cross-spawn": "^7.0.3", | ||
"fastest-levenshtein": "^1.0.12", | ||
@@ -64,3 +69,3 @@ "import-local": "^3.0.2", | ||
}, | ||
"gitHead": "fb50f766851f500ca12867a2aa9de81fa6e368f9" | ||
"gitHead": "20882d463450d010bb76e0824fe555e9785e9561" | ||
} |
Sorry, the diff of this file is too big to display
109137
16
2316
+ Addedcross-spawn@^7.0.3
+ Added@types/node@20.12.7(transitive)
+ Addedcaniuse-lite@1.0.30001613(transitive)
+ Addedelectron-to-chromium@1.4.750(transitive)
+ Addedenvinfo@7.12.0(transitive)
+ Addedterser@5.30.4(transitive)
+ Addedupdate-browserslist-db@1.0.13(transitive)
- Removedexeca@^5.0.0
- Removed@types/node@20.12.8(transitive)
- Removedcaniuse-lite@1.0.30001615(transitive)
- Removedelectron-to-chromium@1.4.754(transitive)
- Removedenvinfo@7.13.0(transitive)
- Removedexeca@5.1.1(transitive)
- Removedget-stream@6.0.1(transitive)
- Removedhuman-signals@2.1.0(transitive)
- Removedis-stream@2.0.1(transitive)
- Removedmimic-fn@2.1.0(transitive)
- Removednpm-run-path@4.0.1(transitive)
- Removedonetime@5.1.2(transitive)
- Removedsignal-exit@3.0.7(transitive)
- Removedstrip-final-newline@2.0.0(transitive)
- Removedterser@5.31.0(transitive)
- Removedupdate-browserslist-db@1.0.14(transitive)
Updated@webpack-cli/info@^1.5.0
Updated@webpack-cli/serve@^1.7.0