diff --git a/bin/convert-argv.js b/bin/convert-argv.js index 3fce2f18c30..6af6487b4b2 100644 --- a/bin/convert-argv.js +++ b/bin/convert-argv.js @@ -5,7 +5,8 @@ const interpret = require("interpret"); const prepareOptions = require("./prepareOptions"); const webpackConfigurationSchema = require("../schemas/webpackConfigurationSchema.json"); const validateSchema = require("webpack").validateSchema; -const WebpackOptionsValidationError = require("webpack").WebpackOptionsValidationError; +const WebpackOptionsValidationError = require("webpack") + .WebpackOptionsValidationError; module.exports = function(...args) { const argv = args[1] || args[0]; @@ -40,12 +41,12 @@ module.exports = function(...args) { argv["output-path"] = path.dirname(output); } - var configFileLoaded = false; - var configFiles = []; - var extensions = Object.keys(interpret.extensions).sort(function(a, b) { + let configFileLoaded = false; + let configFiles = []; + const extensions = Object.keys(interpret.extensions).sort(function(a, b) { return a === ".js" ? -1 : b === ".js" ? 1 : a.length - b.length; }); - var defaultConfigFiles = ["webpack.config", "webpackfile"] + const defaultConfigFiles = ["webpack.config", "webpackfile"] .map(function(filename) { return extensions.map(function(ext) { return { @@ -98,14 +99,14 @@ module.exports = function(...args) { } } if (configFiles.length > 0) { - var registerCompiler = function registerCompiler(moduleDescriptor) { + const registerCompiler = function registerCompiler(moduleDescriptor) { if (moduleDescriptor) { if (typeof moduleDescriptor === "string") { require(moduleDescriptor); } else if (!Array.isArray(moduleDescriptor)) { moduleDescriptor.register(require(moduleDescriptor.module)); } else { - for (var i = 0; i < moduleDescriptor.length; i++) { + for (let i = 0; i < moduleDescriptor.length; i++) { try { registerCompiler(moduleDescriptor[i]); break; @@ -117,8 +118,8 @@ module.exports = function(...args) { } }; - var requireConfig = function requireConfig(configPath) { - var options = (function WEBPACK_OPTIONS() { + const requireConfig = function requireConfig(configPath) { + let options = (function WEBPACK_OPTIONS() { if (argv.configRegister && argv.configRegister.length) { module.paths.unshift( path.resolve(process.cwd(), "node_modules"), @@ -152,12 +153,12 @@ module.exports = function(...args) { } function processConfiguredOptions(options) { - var webpackConfigurationValidationErrors = validateSchema( + const webpackConfigurationValidationErrors = validateSchema( webpackConfigurationSchema, options ); if (webpackConfigurationValidationErrors.length) { - var error = new WebpackOptionsValidationError( + const error = new WebpackOptionsValidationError( webpackConfigurationValidationErrors ); console.error( @@ -179,7 +180,7 @@ module.exports = function(...args) { // filter multi-config by name if (Array.isArray(options) && argv["config-name"]) { - var namedOptions = options.filter(function(opt) { + const namedOptions = options.filter(function(opt) { return opt.name === argv["config-name"]; }); if (namedOptions.length === 0) { @@ -257,7 +258,7 @@ module.exports = function(...args) { ifArg( name, function(content, idx) { - var i = content.indexOf("="); + const i = content.indexOf("="); if (i < 0) { return fn(null, content, idx); } else { @@ -285,10 +286,10 @@ module.exports = function(...args) { } function loadPlugin(name) { - var loadUtils = require("loader-utils"); - var args; + const loadUtils = require("loader-utils"); + let args; try { - var p = name && name.indexOf("?"); + const p = name && name.indexOf("?"); if (p > -1) { args = loadUtils.parseQuery(name.substring(p)); name = name.substring(0, p); @@ -298,15 +299,15 @@ module.exports = function(...args) { process.exit(-1); // eslint-disable-line } - var path; + let path; try { - var resolve = require("enhanced-resolve"); + const resolve = require("enhanced-resolve"); path = resolve.sync(process.cwd(), name); } catch (e) { console.log("Cannot resolve plugin " + name + "."); process.exit(-1); // eslint-disable-line } - var Plugin; + let Plugin; try { Plugin = require(path); } catch (e) { @@ -367,7 +368,7 @@ module.exports = function(...args) { name = binding; binding += "-loader"; } - var rule = { + const rule = { test: new RegExp( "\\." + name.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&") + @@ -392,7 +393,7 @@ module.exports = function(...args) { bindRules("module-bind-pre"); bindRules("module-bind-post"); - var defineObject; + let defineObject; ifArgPair( "define", function(name, value) { @@ -406,7 +407,7 @@ module.exports = function(...args) { defineObject = {}; }, function() { - var DefinePlugin = require("webpack/lib/DefinePlugin"); + const DefinePlugin = require("webpack").DefinePlugin; addPlugin(options, new DefinePlugin(defineObject)); } ); @@ -476,12 +477,13 @@ module.exports = function(...args) { mapArgToBoolean("cache"); ifBooleanArg("hot", function() { - var HotModuleReplacementPlugin = require("webpack/lib/HotModuleReplacementPlugin"); + const HotModuleReplacementPlugin = require("webpack") + .HotModuleReplacementPlugin; addPlugin(options, new HotModuleReplacementPlugin()); }); ifBooleanArg("debug", function() { - var LoaderOptionsPlugin = require("webpack/lib/LoaderOptionsPlugin"); + const LoaderOptionsPlugin = require("webpack").LoaderOptionsPlugin; addPlugin( options, new LoaderOptionsPlugin({ @@ -517,7 +519,8 @@ module.exports = function(...args) { }); ifArg("optimize-max-chunks", function(value) { - var LimitChunkCountPlugin = require("webpack/lib/optimize/LimitChunkCountPlugin"); + const LimitChunkCountPlugin = require("webpack").optimize + .LimitChunkCountPlugin; addPlugin( options, new LimitChunkCountPlugin({ @@ -527,7 +530,7 @@ module.exports = function(...args) { }); ifArg("optimize-min-chunk-size", function(value) { - var MinChunkSizePlugin = require("webpack/lib/optimize/MinChunkSizePlugin"); + const MinChunkSizePlugin = require("webpack").optimize.MinChunkSizePlugin; addPlugin( options, new MinChunkSizePlugin({ @@ -537,7 +540,7 @@ module.exports = function(...args) { }); ifBooleanArg("optimize-minimize", function() { - var LoaderOptionsPlugin = require("webpack/lib/LoaderOptionsPlugin"); + const LoaderOptionsPlugin = require("webpack").LoaderOptionsPlugin; addPlugin( options, new LoaderOptionsPlugin({ @@ -547,20 +550,20 @@ module.exports = function(...args) { }); ifArg("prefetch", function(request) { - var PrefetchPlugin = require("webpack/lib/PrefetchPlugin"); + const PrefetchPlugin = require("webpack").PrefetchPlugin; addPlugin(options, new PrefetchPlugin(request)); }); ifArg("provide", function(value) { - var idx = value.indexOf("="); - var name; + const idx = value.indexOf("="); + let name; if (idx >= 0) { name = value.substr(0, idx); value = value.substr(idx + 1); } else { name = value; } - var ProvidePlugin = require("webpack/lib/ProvidePlugin"); + const ProvidePlugin = require("webpack").ProvidePlugin; addPlugin(options, new ProvidePlugin(name, value)); }); @@ -580,7 +583,7 @@ module.exports = function(...args) { } ensureObject(options, "entry"); - var addTo = function addTo(name, entry) { + const addTo = function addTo(name, entry) { if (options.entry[name]) { if (!Array.isArray(options.entry[name])) { options.entry[name] = [options.entry[name]]; @@ -591,10 +594,10 @@ module.exports = function(...args) { } }; argv._.forEach(function(content) { - var i = content.indexOf("="); - var j = content.indexOf("?"); + const i = content.indexOf("="); + const j = content.indexOf("?"); if (i < 0 || (j >= 0 && j < i)) { - var resolved = path.resolve(content); + const resolved = path.resolve(content); if (fs.existsSync(resolved)) { addTo( "main", diff --git a/bin/errorHelpers.js b/bin/errorHelpers.js index 0c5029a8f16..2c776a70aa1 100644 --- a/bin/errorHelpers.js +++ b/bin/errorHelpers.js @@ -4,21 +4,16 @@ */ "use strict"; -const loaderFlag = "LOADER_EXECUTION"; - const webpackOptionsFlag = "WEBPACK_OPTIONS"; exports.cutOffByFlag = (stack, flag) => { stack = stack.split("\n"); for (let i = 0; i < stack.length; i++) - if (stack[i].includes(flag)) stack.length = i; + if (stack[i].indexOf(flag) >= 0) stack.length = i; return stack.join("\n"); }; -exports.cutOffLoaderExecution = stack => - exports.cutOffByFlag(stack, loaderFlag); - -exports.cutOffWebpackOptinos = stack => +exports.cutOffWebpackOptions = stack => exports.cutOffByFlag(stack, webpackOptionsFlag); exports.cutOffMultilineMessage = (stack, message) => { @@ -28,30 +23,16 @@ exports.cutOffMultilineMessage = (stack, message) => { return stack .reduce( (acc, line, idx) => - line.includes(message[idx]) ? acc : acc.concat(line), + line === message[idx] || line === `Error: ${message[idx]}` + ? acc + : acc.concat(line), [] ) .join("\n"); }; -exports.cutOffMessage = (stack, message) => { - const nextLine = stack.indexOf("\n"); - if (nextLine === -1) { - return stack === message ? "" : stack; - } else { - const firstLine = stack.substr(0, nextLine); - return firstLine === message ? stack.substr(nextLine + 1) : stack; - } -}; - -exports.cleanUp = (stack, message) => { - stack = exports.cutOffLoaderExecution(stack); - stack = exports.cutOffMessage(stack, message); - return stack; -}; - exports.cleanUpWebpackOptions = (stack, message) => { - stack = exports.cutOffWebpackOptinos(stack); + stack = exports.cutOffWebpackOptions(stack); stack = exports.cutOffMultilineMessage(stack, message); return stack; }; diff --git a/bin/process-options.js b/bin/process-options.js index 92fee2955e5..9a62a2890ec 100644 --- a/bin/process-options.js +++ b/bin/process-options.js @@ -22,11 +22,13 @@ module.exports = function processOptions(yargs, argv) { const firstOptions = Array.isArray(options) ? options[0] || {} : options; if (typeof options.stats === "boolean" || typeof options.stats === "string") { - const statsPresetToOptions = require("webpack/lib/Stats.js").presetToOptions; + const statsPresetToOptions = require("webpack").Stats.presetToOptions; options.stats = statsPresetToOptions(options.stats); } - const outputOptions = Object.create(options.stats || firstOptions.stats || {}); + const outputOptions = Object.create( + options.stats || firstOptions.stats || {} + ); if (typeof outputOptions.context === "undefined") outputOptions.context = firstOptions.context; @@ -127,7 +129,7 @@ module.exports = function processOptions(yargs, argv) { } }); - const webpack = require("webpack/lib/webpack.js"); + const webpack = require("webpack"); Error.stackTraceLimit = 30; let lastHash = null; @@ -135,7 +137,9 @@ module.exports = function processOptions(yargs, argv) { try { compiler = webpack(options); } catch (e) { - const WebpackOptionsValidationError = require("webpack/lib/WebpackOptionsValidationError"); + const WebpackOptionsValidationError = require("webpack") + .WebpackOptionsValidationError; + if (e instanceof WebpackOptionsValidationError) { if (argv.color) console.error( @@ -148,7 +152,7 @@ module.exports = function processOptions(yargs, argv) { } if (argv.progress) { - const ProgressPlugin = require("webpack/lib/ProgressPlugin"); + const ProgressPlugin = require("webpack").ProgressPlugin; compiler.apply( new ProgressPlugin({ profile: argv.profile diff --git a/bin/webpack.js b/bin/webpack.js index a7dd4aee216..bfb0a28836d 100755 --- a/bin/webpack.js +++ b/bin/webpack.js @@ -272,8 +272,7 @@ } const firstOptions = [].concat(options)[0]; - const statsPresetToOptions = require("webpack/lib/Stats.js") - .presetToOptions; + const statsPresetToOptions = require("webpack").Stats.presetToOptions; let outputOptions = options.stats; if ( @@ -415,7 +414,7 @@ outputOptions.infoVerbosity = value; }); - const webpack = require("webpack/lib/webpack.js"); + const webpack = require("webpack"); let lastHash = null; let compiler; @@ -427,8 +426,7 @@ console.error( `\u001b[1m\u001b[31m${err.message}\u001b[39m\u001b[22m` ); - else - console.error(err.message); + else console.error(err.message); // eslint-disable-next-line no-process-exit process.exit(1); } @@ -437,7 +435,7 @@ } if (argv.progress) { - const ProgressPlugin = require("webpack/lib/ProgressPlugin"); + const ProgressPlugin = require("webpack").ProcessPlugin; compiler.apply( new ProgressPlugin({ profile: argv.profile diff --git a/lib/commands/migrate.js b/lib/commands/migrate.js index e6a6d28cfc0..68314cac057 100644 --- a/lib/commands/migrate.js +++ b/lib/commands/migrate.js @@ -7,9 +7,9 @@ const inquirer = require("inquirer"); const PLazy = require("p-lazy"); const Listr = require("listr"); -const validateSchema = require("webpack/lib/validateSchema"); -const WebpackOptionsValidationError = require("webpack/lib/WebpackOptionsValidationError"); -const webpackOptionsSchema = require("webpack/schemas/WebpackOptions.json"); +const validate = require("webpack").validate; +const WebpackOptionsValidationError = require("webpack") + .WebpackOptionsValidationError; const runPrettier = require("../utils/run-prettier"); @@ -121,8 +121,7 @@ module.exports = function migrate( }); if (answer["confirmValidation"]) { - const webpackOptionsValidationErrors = validateSchema( - webpackOptionsSchema, + const webpackOptionsValidationErrors = validate( require(outputConfigPath) ); if (webpackOptionsValidationErrors.length) { diff --git a/package.json b/package.json index 92fe412e32b..cac9eea0767 100644 --- a/package.json +++ b/package.json @@ -100,7 +100,7 @@ "nyc": "^11.4.1", "prettier-eslint-cli": "^4.6.1", "schema-utils": "^0.4.2", - "webpack": "^4.0.0-alpha.3", + "webpack": "^4.0.0-beta.1", "webpack-dev-server": "^2.9.7" } } diff --git a/test/binCases/config-name/found-many/stdin.js b/test/binCases/config-name/found-many/stdin.js index 809d2b0ca08..92101fe6e75 100644 --- a/test/binCases/config-name/found-many/stdin.js +++ b/test/binCases/config-name/found-many/stdin.js @@ -3,7 +3,7 @@ module.exports = function testAssertions(code, stdout, stderr) { expect(code).toBe(0); expect(stdout).toEqual(expect.anything()); - expect(stdout[7]).toContain("./index2.js"); - expect(stdout[13]).toContain("./index3.js"); + expect(stdout[9]).toContain("./index2.js"); + expect(stdout[17]).toContain("./index3.js"); expect(stderr).toHaveLength(0); }; diff --git a/test/binCases/config-name/found-one/stdin.js b/test/binCases/config-name/found-one/stdin.js index 11b81e410d6..05f976aea03 100644 --- a/test/binCases/config-name/found-one/stdin.js +++ b/test/binCases/config-name/found-one/stdin.js @@ -4,6 +4,6 @@ module.exports = function testAssertions(code, stdout, stderr) { expect(code).toBe(0); expect(stdout).toEqual(expect.anything()); - expect(stdout[5]).toContain("./index2.js"); + expect(stdout[7]).toContain("./index2.js"); expect(stderr).toHaveLength(0); }; diff --git a/test/binCases/config-type/array/stdin.js b/test/binCases/config-type/array/stdin.js index 9cc68ab5089..37b57fac4ae 100644 --- a/test/binCases/config-type/array/stdin.js +++ b/test/binCases/config-type/array/stdin.js @@ -6,8 +6,8 @@ module.exports = function testAssertions(code, stdout, stderr) { expect(stdout[0]).toContain("Hash: "); expect(stdout[1]).toContain("Version: "); expect(stdout[2]).toContain("Child"); - expect(stdout[6]).toContain("entry-a.bundle.js"); - expect(stdout[8]).toContain("Child"); - expect(stdout[12]).toContain("entry-b.bundle.js"); + expect(stdout[7]).toContain("entry-a.bundle.js"); + expect(stdout[10]).toContain("Child"); + expect(stdout[15]).toContain("entry-b.bundle.js"); expect(stderr).toHaveLength(0); }; diff --git a/test/binCases/config-type/function-promise/stdin.js b/test/binCases/config-type/function-promise/stdin.js index 4b5b0e80168..13447dea8c8 100644 --- a/test/binCases/config-type/function-promise/stdin.js +++ b/test/binCases/config-type/function-promise/stdin.js @@ -6,6 +6,6 @@ module.exports = function testAssertions(code, stdout, stderr) { expect(stdout[0]).toContain("Hash: "); expect(stdout[1]).toContain("Version: "); expect(stdout[2]).toContain("Time: "); - expect(stdout[4]).toContain("entry.bundle.js"); + expect(stdout[5]).toContain("entry.bundle.js"); expect(stderr).toHaveLength(0); }; diff --git a/test/binCases/config-type/function/stdin.js b/test/binCases/config-type/function/stdin.js index 4b5b0e80168..13447dea8c8 100644 --- a/test/binCases/config-type/function/stdin.js +++ b/test/binCases/config-type/function/stdin.js @@ -6,6 +6,6 @@ module.exports = function testAssertions(code, stdout, stderr) { expect(stdout[0]).toContain("Hash: "); expect(stdout[1]).toContain("Version: "); expect(stdout[2]).toContain("Time: "); - expect(stdout[4]).toContain("entry.bundle.js"); + expect(stdout[5]).toContain("entry.bundle.js"); expect(stderr).toHaveLength(0); }; diff --git a/test/binCases/config-type/object/stdin.js b/test/binCases/config-type/object/stdin.js index 4b5b0e80168..13447dea8c8 100644 --- a/test/binCases/config-type/object/stdin.js +++ b/test/binCases/config-type/object/stdin.js @@ -6,6 +6,6 @@ module.exports = function testAssertions(code, stdout, stderr) { expect(stdout[0]).toContain("Hash: "); expect(stdout[1]).toContain("Version: "); expect(stdout[2]).toContain("Time: "); - expect(stdout[4]).toContain("entry.bundle.js"); + expect(stdout[5]).toContain("entry.bundle.js"); expect(stderr).toHaveLength(0); }; diff --git a/test/binCases/config-type/promise/stdin.js b/test/binCases/config-type/promise/stdin.js index 4b5b0e80168..13447dea8c8 100644 --- a/test/binCases/config-type/promise/stdin.js +++ b/test/binCases/config-type/promise/stdin.js @@ -6,6 +6,6 @@ module.exports = function testAssertions(code, stdout, stderr) { expect(stdout[0]).toContain("Hash: "); expect(stdout[1]).toContain("Version: "); expect(stdout[2]).toContain("Time: "); - expect(stdout[4]).toContain("entry.bundle.js"); + expect(stdout[5]).toContain("entry.bundle.js"); expect(stderr).toHaveLength(0); }; diff --git a/test/binCases/configFile/plugins-presedence/stdin.js b/test/binCases/configFile/plugins-presedence/stdin.js index baa5c1567db..c068bcc1464 100644 --- a/test/binCases/configFile/plugins-presedence/stdin.js +++ b/test/binCases/configFile/plugins-presedence/stdin.js @@ -3,6 +3,6 @@ module.exports = function testAssertions(code, stdout, stderr) { expect(code).toBe(0); expect(stdout).toEqual(expect.anything()); - expect(stdout[5]).toContain("ok.js"); + expect(stdout[7]).toContain("ok.js"); expect(stderr).toHaveLength(0); }; diff --git a/test/binCases/configFile/plugins-presedence/webpack.config.js b/test/binCases/configFile/plugins-presedence/webpack.config.js index 931c6855100..9f94b2dbacc 100644 --- a/test/binCases/configFile/plugins-presedence/webpack.config.js +++ b/test/binCases/configFile/plugins-presedence/webpack.config.js @@ -1,4 +1,4 @@ -var DefinePlugin = require("webpack/lib/DefinePlugin"); +var DefinePlugin = require("webpack").DefinePlugin; var path = require("path"); module.exports = { diff --git a/test/binCases/configFile/profile/stdin.js b/test/binCases/configFile/profile/stdin.js index 100438d3af6..39d46bb07aa 100644 --- a/test/binCases/configFile/profile/stdin.js +++ b/test/binCases/configFile/profile/stdin.js @@ -4,8 +4,8 @@ module.exports = function testAssertions(code, stdout, stderr) { expect(code).toBe(0); expect(stdout).toEqual(expect.anything()); - expect(stdout[6]).toContain("factory:"); expect(stdout[8]).toContain("factory:"); expect(stdout[10]).toContain("factory:"); + expect(stdout[12]).toContain("factory:"); expect(stderr).toHaveLength(0); }; diff --git a/test/binCases/entry/multi-file/stdin.js b/test/binCases/entry/multi-file/stdin.js index e9f753e3282..1353cfcaf43 100644 --- a/test/binCases/entry/multi-file/stdin.js +++ b/test/binCases/entry/multi-file/stdin.js @@ -3,9 +3,9 @@ module.exports = function testAssertions(code, stdout, stderr) { expect(code).toBe(0); expect(stdout).toEqual(expect.anything()); - expect(stdout[4]).toContain("null.js"); - expect(stdout[5]).toMatch(/a\.js.*\{0\}/); - expect(stdout[6]).toMatch(/index\.js.*\{0\}/); - expect(stdout[7]).toMatch(/multi.*index\.js.*a\.js/); // should have multi-file entry + expect(stdout[5]).toContain("null.js"); + expect(stdout[7]).toMatch(/a\.js.*\{0\}/); + expect(stdout[8]).toMatch(/index\.js.*\{0\}/); + expect(stdout[9]).toMatch(/multi.*index\.js.*a\.js/); // should have multi-file entry expect(stderr).toHaveLength(0); }; diff --git a/test/binCases/entry/named-entry/stdin.js b/test/binCases/entry/named-entry/stdin.js index 094063a5674..c9fce1444ac 100644 --- a/test/binCases/entry/named-entry/stdin.js +++ b/test/binCases/entry/named-entry/stdin.js @@ -3,9 +3,9 @@ module.exports = function testAssertions(code, stdout, stderr) { expect(code).toBe(0); expect(stdout).toEqual(expect.anything()); - expect(stdout[4]).toContain("null.js"); - expect(stdout[5]).toContain("foo.js"); // named entry from --entry foo=./a.js - expect(stdout[6]).toMatch(/index\.js.*\{0\}/); - expect(stdout[7]).toMatch(/a\.js.*\{1\}/); + expect(stdout[5]).toContain("null.js"); + expect(stdout[7]).toContain("foo.js"); // named entry from --entry foo=./a.js + expect(stdout[9]).toMatch(/index\.js.*\{0\}/); + expect(stdout[10]).toMatch(/a\.js.*\{1\}/); expect(stderr).toHaveLength(0); }; diff --git a/test/binCases/entry/non-hyphenated-args/stdin.js b/test/binCases/entry/non-hyphenated-args/stdin.js index 67ccbc2c6de..279533547fd 100644 --- a/test/binCases/entry/non-hyphenated-args/stdin.js +++ b/test/binCases/entry/non-hyphenated-args/stdin.js @@ -3,9 +3,9 @@ module.exports = function testAssertions(code, stdout, stderr) { expect(code).toBe(0); expect(stdout).toEqual(expect.anything()); - expect(stdout[4]).toContain("main.js"); // non-hyphenated arg ./a.js should create chunk "main" - expect(stdout[5]).toContain("null.js"); - expect(stdout[6]).toMatch(/a\.js.*\{0\}/); // a.js should be in chunk 0 - expect(stdout[7]).toMatch(/index\.js.*\{1\}/); // index.js should be in chunk 1 + expect(stdout[5]).toContain("main.js"); // non-hyphenated arg ./a.js should create chunk "main" + expect(stdout[7]).toContain("null.js"); + expect(stdout[9]).toMatch(/a\.js.*\{0\}/); // a.js should be in chunk 0 + expect(stdout[10]).toMatch(/index\.js.*\{1\}/); // index.js should be in chunk 1 expect(stderr).toHaveLength(0); }; diff --git a/test/binCases/env/complex/stdin.js b/test/binCases/env/complex/stdin.js index 0d320f6d44d..212d1c91774 100644 --- a/test/binCases/env/complex/stdin.js +++ b/test/binCases/env/complex/stdin.js @@ -6,13 +6,13 @@ module.exports = function testAssertions(code, stdout, stderr) { expect(stdout[0]).toContain("Hash: "); expect(stdout[1]).toContain("Version: "); expect(stdout[2]).toContain("Time: "); - expect(stdout[3]).toContain("Environment (--env): {"); - expect(stdout[4]).toContain("\"prod\": ["); - expect(stdout[7]).toContain("],"); - expect(stdout[8]).toContain("\"baz\": true"); - expect(stdout[9]).toContain("}"); - expect(stdout[11]).toContain("null.js"); - expect(stdout[12]).toContain("./index.js"); - expect(stdout[12]).toContain("[built]"); + expect(stdout[4]).toContain("Environment (--env): {"); + expect(stdout[5]).toContain("\"prod\": ["); + expect(stdout[8]).toContain("],"); + expect(stdout[9]).toContain("\"baz\": true"); + expect(stdout[10]).toContain("}"); + expect(stdout[12]).toContain("null.js"); + expect(stdout[14]).toContain("./index.js"); + expect(stdout[14]).toContain("[built]"); expect(stderr).toHaveLength(0); }; diff --git a/test/binCases/env/string/stdin.js b/test/binCases/env/string/stdin.js index bce70339052..59c88390c5f 100644 --- a/test/binCases/env/string/stdin.js +++ b/test/binCases/env/string/stdin.js @@ -6,7 +6,7 @@ module.exports = function testAssertions(code, stdout, stderr) { expect(stdout[0]).toContain("Hash: "); expect(stdout[1]).toContain("Version: "); expect(stdout[2]).toContain("Time: "); - expect(stdout[3]).toContain("Environment (--env): \"foo\""); - expect(stdout[5]).toContain("null.js"); + expect(stdout[4]).toContain("Environment (--env): \"foo\""); + expect(stdout[7]).toContain("null.js"); expect(stderr).toHaveLength(0); }; diff --git a/test/binCases/errors/clean-webpack-options/index.js b/test/binCases/errors/clean-webpack-options/index.js new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/binCases/errors/clean-webpack-options/stdin.js b/test/binCases/errors/clean-webpack-options/stdin.js new file mode 100644 index 00000000000..2b99feef0d1 --- /dev/null +++ b/test/binCases/errors/clean-webpack-options/stdin.js @@ -0,0 +1,13 @@ +"use strict"; + +module.exports = function testAssertions(code, stdout, stderr) { + expect(code).toBe(1); + + expect(stdout).toHaveLength(0); + + expect(stderr[0]).toContain("Invalid configuration object."); + expect(stderr[1]).toContain("configuration.context should be a string"); + expect(stderr[2]).toContain("The base directory "); + + expect(stderr).toHaveLength(4); +}; diff --git a/test/binCases/errors/clean-webpack-options/webpack.config.js b/test/binCases/errors/clean-webpack-options/webpack.config.js new file mode 100644 index 00000000000..e30b9ee7c28 --- /dev/null +++ b/test/binCases/errors/clean-webpack-options/webpack.config.js @@ -0,0 +1,4 @@ +module.exports = { + context: [__dirname], + entry: "./index" +}; diff --git a/test/binCases/errors/issue-5576/stdin.js b/test/binCases/errors/issue-5576/stdin.js index b211d95a820..0e6d89366ea 100644 --- a/test/binCases/errors/issue-5576/stdin.js +++ b/test/binCases/errors/issue-5576/stdin.js @@ -5,7 +5,7 @@ module.exports = function testAssertions(code, stdout, stderr) { expect(stdout[0]).toContain("Hash: "); expect(stdout[1]).toContain("Version: "); expect(stdout[2]).toContain("Time: "); - expect(stdout[4]).toContain("bundle.js"); + expect(stdout[6]).toContain("bundle.js"); expect(stderr).toHaveLength(0); }; diff --git a/test/binCases/errors/parse/stdin.js b/test/binCases/errors/parse/stdin.js index 3d2b934362b..1c5c713ae6b 100644 --- a/test/binCases/errors/parse/stdin.js +++ b/test/binCases/errors/parse/stdin.js @@ -5,12 +5,12 @@ module.exports = function testAssertions(code, stdout, stderr) { expect(stdout[0]).toContain("Hash: "); expect(stdout[1]).toContain("Version: "); expect(stdout[2]).toContain("Time: "); - expect(stdout[4]).toContain("./index.js"); - expect(stdout[4]).toContain("[built]"); - expect(stdout[4]).toContain("[failed]"); - expect(stdout[4]).toContain("[1 error]"); - expect(stdout[6]).toContain("ERROR in ./index.js"); - expect(stdout[7]).toContain("Module parse failed:"); + expect(stdout[6]).toContain("./index.js"); + expect(stdout[6]).toContain("[built]"); + expect(stdout[6]).toContain("[failed]"); + expect(stdout[6]).toContain("[1 error]"); + expect(stdout[8]).toContain("ERROR in ./index.js"); + expect(stdout[9]).toContain("Module parse failed:"); expect(stderr).toHaveLength(0); }; diff --git a/test/binCases/output/output-argument/stdin.js b/test/binCases/output/output-argument/stdin.js index f3d52056f5f..b862191c563 100644 --- a/test/binCases/output/output-argument/stdin.js +++ b/test/binCases/output/output-argument/stdin.js @@ -3,7 +3,7 @@ module.exports = function testAssertions(code, stdout, stderr) { expect(code).toBe(0); expect(stdout).toEqual(expect.anything()); - expect(stdout[4]).toContain("bundle.js"); - expect(stdout[5]).toMatch(/index\.js.*\{0\}/); + expect(stdout[5]).toContain("bundle.js"); + expect(stdout[7]).toMatch(/index\.js.*\{0\}/); expect(stderr).toHaveLength(0); }; diff --git a/test/binCases/plugins/uglifyjsplugin-empty-args/stdin.js b/test/binCases/plugins/uglifyjsplugin-empty-args/stdin.js index f99dbf070f3..d93be12976d 100644 --- a/test/binCases/plugins/uglifyjsplugin-empty-args/stdin.js +++ b/test/binCases/plugins/uglifyjsplugin-empty-args/stdin.js @@ -4,7 +4,7 @@ module.exports = function testAssertions(code, stdout, stderr) { expect(code).toBe(0); expect(stdout).toEqual(expect.anything()); - expect(stdout[4]).toContain("bytes"); // without uglifyjs it's multiple kBs + expect(stdout[5]).toContain("bytes"); // without uglifyjs it's multiple kBs expect(stderr).toHaveLength(0); }; diff --git a/test/binCases/stats/single-config/stdin.js b/test/binCases/stats/single-config/stdin.js index e0cf0717163..5395e9fceb6 100644 --- a/test/binCases/stats/single-config/stdin.js +++ b/test/binCases/stats/single-config/stdin.js @@ -6,11 +6,11 @@ module.exports = function testAssertions(code, stdout, stderr) { expect(stdout[0]).toContain("Hash: "); expect(stdout[1]).toContain("Version: "); expect(stdout[2]).toContain("Time: "); - expect(stdout[4]).toContain("\u001b[1m\u001b[32mnull.js\u001b[39m\u001b[22m"); - expect(stdout[5]).toContain("chunk"); - expect(stdout[6]).not.toContain("./index.js"); - expect(stdout[6]).not.toContain("[built]"); - expect(stdout[6]).toContain("1 module"); + expect(stdout[5]).toContain("\u001b[1m\u001b[32mnull.js\u001b[39m\u001b[22m"); + expect(stdout[7]).toContain("chunk"); + expect(stdout[7]).not.toContain("./index.js"); + expect(stdout[7]).not.toContain("[built]"); + expect(stdout[8]).toContain("1 module"); expect(stderr).toHaveLength(0); }; diff --git a/test/binCases/watch/info-verbosity-verbose/stdin.js b/test/binCases/watch/info-verbosity-verbose/stdin.js index 29b25f3ff02..00e305aa30b 100644 --- a/test/binCases/watch/info-verbosity-verbose/stdin.js +++ b/test/binCases/watch/info-verbosity-verbose/stdin.js @@ -7,7 +7,7 @@ module.exports = function testAssertions(stdout, stderr, done) { expect(stdout[2]).toContain(""); expect(stdout[3]).toContain(""); expect(stdout[4]).toContain("Webpack is watching the files…"); - expect(stdout[5]).toContain(""); + expect(stdout[6]).toContain(""); expect(stdout[6]).toContain(""); expect(stdout[7]).toContain("Compilation finished"); expect(stdout[8]).toContain(""); diff --git a/yarn.lock b/yarn.lock index 8a7e955775f..055f8c30f31 100644 --- a/yarn.lock +++ b/yarn.lock @@ -17,11 +17,11 @@ accepts@~1.3.4: mime-types "~2.1.16" negotiator "0.6.1" -acorn-dynamic-import@^2.0.0: - version "2.0.2" - resolved "https://registry.yarnpkg.com/acorn-dynamic-import/-/acorn-dynamic-import-2.0.2.tgz#c752bd210bef679501b6c6cb7fc84f8f47158cc4" +acorn-dynamic-import@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/acorn-dynamic-import/-/acorn-dynamic-import-3.0.0.tgz#901ceee4c7faaef7e07ad2a47e890675da50a278" dependencies: - acorn "^4.0.3" + acorn "^5.0.0" acorn-globals@^3.1.0: version "3.1.0" @@ -39,7 +39,7 @@ acorn@^3.0.4: version "3.3.0" resolved "https://registry.yarnpkg.com/acorn/-/acorn-3.3.0.tgz#45e37fb39e8da3f25baee3ff5369e2bb5f22017a" -acorn@^4.0.3, acorn@^4.0.4: +acorn@^4.0.4: version "4.0.13" resolved "https://registry.yarnpkg.com/acorn/-/acorn-4.0.13.tgz#105495ae5361d697bd195c825192e1ad7f253787" @@ -47,10 +47,14 @@ acorn@^5.0.0, acorn@^5.2.1: version "5.3.0" resolved "https://registry.yarnpkg.com/acorn/-/acorn-5.3.0.tgz#7446d39459c54fb49a80e6ee6478149b940ec822" -ajv-keywords@^2.0.0, ajv-keywords@^2.1.0: +ajv-keywords@^2.1.0: version "2.1.1" resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-2.1.1.tgz#617997fc5f60576894c435f940d819e135b80762" +ajv-keywords@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-3.1.0.tgz#ac2b27939c543e95d2c06e7f7f5c27be4aa543be" + ajv@^4.9.1: version "4.11.8" resolved "https://registry.yarnpkg.com/ajv/-/ajv-4.11.8.tgz#82ffb02b29e662ae53bdc20af15947706739c536" @@ -58,7 +62,7 @@ ajv@^4.9.1: co "^4.6.0" json-stable-stringify "^1.0.1" -ajv@^5.0.0, ajv@^5.1.5, ajv@^5.2.3, ajv@^5.3.0: +ajv@^5.0.0, ajv@^5.2.3, ajv@^5.3.0: version "5.5.2" resolved "https://registry.yarnpkg.com/ajv/-/ajv-5.5.2.tgz#73b5eeca3fab653e3d3f9422b341ad42205dc965" dependencies: @@ -67,6 +71,14 @@ ajv@^5.0.0, ajv@^5.1.5, ajv@^5.2.3, ajv@^5.3.0: fast-json-stable-stringify "^2.0.0" json-schema-traverse "^0.3.0" +ajv@^6.1.0: + version "6.1.1" + resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.1.1.tgz#978d597fbc2b7d0e5a5c3ddeb149a682f2abfa0e" + dependencies: + fast-deep-equal "^1.0.0" + fast-json-stable-stringify "^2.0.0" + json-schema-traverse "^0.3.0" + align-text@^0.1.1, align-text@^0.1.3: version "0.1.4" resolved "https://registry.yarnpkg.com/align-text/-/align-text-0.1.4.tgz#0cd90a561093f35d0a99256c22b7069433fad117" @@ -1298,6 +1310,10 @@ chownr@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/chownr/-/chownr-1.0.1.tgz#e2a75042a9551908bebd25b8523d5f9769d79181" +chrome-trace-event@^0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/chrome-trace-event/-/chrome-trace-event-0.1.1.tgz#651f4d115902160b0b33aca136574b17d1519c98" + ci-info@^1.0.0: version "1.1.2" resolved "https://registry.yarnpkg.com/ci-info/-/ci-info-1.1.2.tgz#03561259db48d0474c8bdc90f5b47b068b6bbfb4" @@ -6530,15 +6546,16 @@ webpack-sources@^1.0.1, webpack-sources@^1.1.0: source-list-map "^2.0.0" source-map "~0.6.1" -webpack@^4.0.0-alpha.3: - version "4.0.0-alpha.4" - resolved "https://registry.yarnpkg.com/webpack/-/webpack-4.0.0-alpha.4.tgz#55e7eb97c5b7fb0f2527d7acf07f63fc05cfd821" +webpack@^4.0.0-beta.1: + version "4.0.0-beta.1" + resolved "https://registry.yarnpkg.com/webpack/-/webpack-4.0.0-beta.1.tgz#a7a39c794d46005eaeeadae94d8e8ce0caf9a1a2" dependencies: acorn "^5.0.0" - acorn-dynamic-import "^2.0.0" - ajv "^5.1.5" - ajv-keywords "^2.0.0" + acorn-dynamic-import "^3.0.0" + ajv "^6.1.0" + ajv-keywords "^3.1.0" async "^2.1.2" + chrome-trace-event "^0.1.1" enhanced-resolve "^4.0.0-beta.2" eslint-scope "^3.7.1" loader-runner "^2.3.0" @@ -6793,9 +6810,9 @@ yeoman-environment@^2.0.0: text-table "^0.2.0" untildify "^3.0.2" -"yeoman-generator@git://github.com/ev1stensberg/generator.git#Feature-getArgument": +"yeoman-generator@https://github.com/ev1stensberg/generator.git#Feature-getArgument": version "1.1.1" - resolved "git://github.com/ev1stensberg/generator.git#9e24fa31c85302ca1145ae34fc68b4f133251ca0" + resolved "https://github.com/ev1stensberg/generator.git#9e24fa31c85302ca1145ae34fc68b4f133251ca0" dependencies: async "^2.0.0" chalk "^1.0.0"