Skip to content

Instantly share code, notes, and snippets.

@taisa831
Created May 7, 2018 04:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save taisa831/4ab5338cc736f7d504268ac8e2600d00 to your computer and use it in GitHub Desktop.
Save taisa831/4ab5338cc736f7d504268ac8e2600d00 to your computer and use it in GitHub Desktop.
This file has been truncated, but you can view the full file.
diff --git a/.editorconfig b/.editorconfig
index 012966bd..7228de40 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -12,6 +12,10 @@ max_line_length = 233
indent_style = space
indent_size = 2
+[.prettierrc]
+indent_style = space
+indent_size = 2
+
[*.yml]
indent_style = space
indent_size = 2
diff --git a/.eslintrc.js b/.eslintrc.js
index 63a642c2..12149e7f 100644
--- a/.eslintrc.js
+++ b/.eslintrc.js
@@ -1,14 +1,18 @@
module.exports = {
"root": true,
- "plugins": ["node"],
+ "plugins": [
+ "prettier",
+ "node"
+ ],
"extends": ["eslint:recommended", "plugin:node/recommended"],
"env": {
"node": true,
"es6": true,
+ "mocha": true,
},
"parserOptions": { "ecmaVersion": 2017 },
"rules": {
- "quotes": ["error", "double"],
+ "prettier/prettier": "error",
"no-undef": "error",
"no-extra-semi": "error",
"semi": "error",
@@ -20,38 +24,15 @@ module.exports = {
"brace-style": "error",
"eol-last": "error",
"no-extra-bind": "warn",
- "no-empty": "off",
- "no-multiple-empty-lines": "error",
- "no-multi-spaces": "error",
"no-process-exit": "warn",
- "space-in-parens": "error",
- "no-trailing-spaces": "error",
"no-use-before-define": "off",
"no-unused-vars": ["error", { "args": "none" }],
- "key-spacing": "error",
- "space-infix-ops": "error",
"no-unsafe-negation": "error",
"no-loop-func": "warn",
- "space-before-function-paren": ["error", "never"],
- "space-before-blocks": "error",
- "object-curly-spacing": ["error", "always"],
"indent": "off",
- "keyword-spacing": ["error", {
- "after": false,
- "overrides": {
- "const": { "after": true },
- "try": { "after": true },
- "else": { "after": true },
- "throw": { "after": true },
- "case": { "after": true },
- "return": { "after": true },
- "finally": { "after": true },
- "do": { "after": true }
- }
- }],
"no-console": "off",
"valid-jsdoc": "error",
- "node/no-unsupported-features": ["error", { version: 4 }],
+ "node/no-unsupported-features": "error",
"node/no-deprecated-api": "error",
"node/no-missing-import": "error",
"node/no-missing-require": [
diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md
index 98922e44..1deb4ada 100644
--- a/.github/ISSUE_TEMPLATE.md
+++ b/.github/ISSUE_TEMPLATE.md
@@ -19,4 +19,4 @@
**If this is a feature request, what is motivation or use case for changing the behavior?**
-**Please mention other relevant information such as the browser version, Node.js version, webpack version and Operating System.**
+**Please mention other relevant information such as the browser version, Node.js version, webpack version, and Operating System.**
diff --git a/.gitignore b/.gitignore
index e405d924..1142de1e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,7 +4,7 @@
/test/fixtures/temp-cache-fixture
/benchmark/js
/benchmark/fixtures
-/examples/**/js
+/examples/**/dist
/coverage
.DS_Store
*.log
diff --git a/.prettierrc b/.prettierrc
new file mode 100644
index 00000000..d2702b8a
--- /dev/null
+++ b/.prettierrc
@@ -0,0 +1,4 @@
+{
+ "tabWidth": 2,
+ "useTabs": true
+}
diff --git a/.travis.yml b/.travis.yml
index 84d23609..a1f10e14 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -24,9 +24,6 @@ matrix:
- os: linux
node_js: "6"
env: NO_WATCH_TESTS=1 JOB_PART=integration
- - os: linux
- node_js: "4"
- env: NO_WATCH_TESTS=1 JOB_PART=integration
- os: osx
node_js: "8"
env: NO_WATCH_TESTS=1 JOB_PART=integration
@@ -35,7 +32,9 @@ matrix:
fast_finish: true
install:
- - bash ./ci/travis-install.sh
+ - yarn --frozen-lockfile
+ - yarn link --frozen-lockfile || true
+ - yarn link webpack --frozen-lockfile
script: npm run travis:$JOB_PART
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 8d04385d..369ab7a8 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -13,7 +13,7 @@ If you are still having difficulty after looking over your configuration careful
a question to [StackOverflow with the webpack tag](http://stackoverflow.com/tags/webpack). Questions
that include your webpack.config.js and relevant files are more likely to receive responses.
-**If you have discovered a bug or have a feature suggestion, feel free to create an issue on Github.**
+**If you have discovered a bug or have a feature suggestion, please [create an issue on GitHub](https://github.com/webpack/webpack/issues/new).**
## Contributing to the webpack ecosystem
@@ -60,4 +60,4 @@ documentation.
## Discussions
-Gitters is only for small questions. To discuss in long a subject, please send on gitters a link to your forum or blog.
+Gitter is only for small questions. To discuss a subject in detail, please send a link to your forum or blog in the Gitter chat.
diff --git a/README.md b/README.md
index 2db44291..dd6f7baa 100644
--- a/README.md
+++ b/README.md
@@ -52,7 +52,7 @@ yarn add webpack --dev
<h2 align="center">Introduction</h2>
-> This README reflects Webpack v2.x and v3.x. The Webpack v1.x [documentation can be found here](https://webpack.github.io/docs/?utm_source=github&utm_medium=readme&utm_campaign=top).
+> This README reflects Webpack v2.x and v3.x. The Webpack v1.x documentation has been deprecated and deleted.
webpack is a bundler for modules. The main purpose is to bundle JavaScript
files for usage in a browser, yet it is also capable of transforming, bundling,
@@ -432,7 +432,7 @@ src="https://static.monei.net/monei-logo.svg" height="30" alt="MONEI"></a>
<h2 align="center">Silver Sponsors</h2>
-[Become a sliver sponsor](https://opencollective.com/webpack#sponsor) and get your logo on our README on Github with a link to your site.
+[Become a silver sponsor](https://opencollective.com/webpack#sponsor) and get your logo on our README on Github with a link to your site.
<div align="center">
diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js
index 49240b4c..03adf58a 100644
--- a/benchmark/benchmark.js
+++ b/benchmark/benchmark.js
@@ -15,7 +15,7 @@ const benchmarkOptions = {
function runTimes(compiler, times, deferred) {
fs.writeFileSync(path.join(fixtures, "0.js"), "module.exports = " + Math.random(), "utf-8");
- compiler.run((err, stats) => {
+ compiler.run(err => {
if(err) throw err;
if(times === 1)
deferred.resolve();
@@ -30,12 +30,12 @@ const tests = {
(size, deferred) => {
webpack({
context: fixtures,
- entry: "./" + size + ".js",
+ entry: `./${size}.js`,
output: {
path: outputPath,
filename: "bundle.js"
}
- }, (err, stats) => {
+ }, err => {
if(err) throw err;
deferred.resolve();
});
@@ -46,16 +46,16 @@ const tests = {
(size, deferred) => {
webpack({
context: fixtures,
- entry: "./" + size + ".big.js",
+ entry: `./${size}.big.js`,
output: {
path: outputPath,
filename: "bundle.js"
},
devtool: "eval"
- }, (err, stats) => {
+ }, err => {
if(err) throw err;
deferred.resolve();
- })
+ });
}
],
"sourcemap build": [
@@ -63,16 +63,16 @@ const tests = {
(size, deferred) => {
webpack({
context: fixtures,
- entry: "./" + size + ".big.js",
+ entry: `./${size}.big.js`,
output: {
path: outputPath,
filename: "bundle.js"
},
devtool: "source-map"
- }, (err, stats) => {
+ }, err => {
if(err) throw err;
deferred.resolve();
- })
+ });
}
],
"cheap sourcemap build": [
@@ -80,16 +80,16 @@ const tests = {
(size, deferred) => {
webpack({
context: fixtures,
- entry: "./" + size + ".big.js",
+ entry: `./${size}.big.js`,
output: {
path: outputPath,
filename: "bundle.js"
},
devtool: "cheap-source-map"
- }, function(err, stats) {
+ }, err => {
if(err) throw err;
deferred.resolve();
- })
+ });
}
],
"build w/ chunks": [
@@ -97,15 +97,15 @@ const tests = {
(size, deferred) => {
webpack({
context: fixtures,
- entry: "./" + size + ".async.js",
+ entry: `./${size}.async.js`,
output: {
path: outputPath,
filename: "bundle.js"
}
- }, function(err, stats) {
+ }, err => {
if(err) throw err;
deferred.resolve();
- })
+ });
}
],
"build w/ chunks": [
@@ -118,10 +118,10 @@ const tests = {
path: outputPath,
filename: "bundle.js"
}
- }, function(err, stats) {
+ }, err => {
if(err) throw err;
deferred.resolve();
- })
+ });
}
],
"incremental": [
@@ -161,7 +161,7 @@ const tests = {
var compiler = webpack({
cache: true,
context: fixtures,
- entry: "./" + size + ".js",
+ entry: `./${size}.js`,
output: {
path: outputPath,
filename: "bundle.js"
@@ -176,7 +176,7 @@ const tests = {
var compiler = webpack({
cache: true,
context: fixtures,
- entry: "./" + size + ".js",
+ entry: `./${size}.js`,
output: {
path: outputPath,
filename: "bundle.js"
@@ -191,7 +191,7 @@ const tests = {
var compiler = webpack({
cache: true,
context: fixtures,
- entry: "./" + size + ".js",
+ entry: `./${size}.js`,
output: {
path: outputPath,
filename: "bundle.js"
@@ -204,17 +204,17 @@ const tests = {
const suite = new Benchmark.Suite;
-Object.keys(tests).filter((name) => (process.argv.length > 2) ? name.indexOf(process.argv[2]) >= 0 : true)
- .forEach((name) => {
+Object.keys(tests).filter(name => process.argv.length > 2 ? name.includes(process.argv[2]) : true)
+ .forEach(name => {
const test = tests[name];
- test[0].forEach((size) => {
- suite.add(name + " " + size, (deferred) => {
+ test[0].forEach(size => {
+ suite.add(`${name} ${size}`, deferred => {
test[1](size, deferred);
}, benchmarkOptions);
});
});
-suite.on("cycle", (event) => {
+suite.on("cycle", event => {
process.stderr.write("\n");
const b = event.target;
console.log(b.name + "\t" + Math.floor(1000 * (b.stats.mean - b.stats.moe)) + "\t" + Math.floor(1000 * (b.stats.mean + b.stats.moe)));
diff --git a/benchmark/createFixtures.js b/benchmark/createFixtures.js
index 9b9855e4..06e566ac 100644
--- a/benchmark/createFixtures.js
+++ b/benchmark/createFixtures.js
@@ -7,16 +7,21 @@ try {
fs.mkdirSync(fixtures);
} catch(e) {}
+function generateRequireString(conditional, suffix) {
+ const prefixedSuffix = suffix ? `.${suffix}` : "";
+ return `require(${JSON.stringify(`./${conditional}${prefixedSuffix}.js`)});`;
+}
+
for(let i = 0; i < 10000; i++) {
const source = [];
if(i > 8)
- source.push("require(" + JSON.stringify("./" + (i / 8 | 0) + ".js") + ");");
+ source.push(generateRequireString((i / 8 | 0)));
if(i > 4)
- source.push("require(" + JSON.stringify("./" + (i / 4 | 0) + ".js") + ");");
+ source.push(generateRequireString((i / 4 | 0)));
if(i > 2)
- source.push("require(" + JSON.stringify("./" + (i / 2 | 0) + ".js") + ");");
+ source.push(generateRequireString((i / 2 | 0)));
if(i > 0)
- source.push("require(" + JSON.stringify("./" + (i - 1) + ".js") + ");");
+ source.push(generateRequireString((i - 1)));
source.push("module.exports = " + i + ";");
fs.writeFileSync(path.join(fixtures, i + ".js"), source.join("\n"), "utf-8");
}
@@ -25,13 +30,13 @@ for(let i = 0; i < 10000; i++) {
const source = [];
source.push("require.ensure([], function(require) {");
if(i > 8)
- source.push("require(" + JSON.stringify("./" + (i / 8 | 0) + ".async.js") + ");");
+ source.push(generateRequireString((i / 8 | 0), "async"));
if(i > 4)
- source.push("require(" + JSON.stringify("./" + (i / 4 | 0) + ".async.js") + ");");
+ source.push(generateRequireString((i / 4 | 0), "async"));
if(i > 2)
- source.push("require(" + JSON.stringify("./" + (i / 2 | 0) + ".async.js") + ");");
+ source.push(generateRequireString((i / 2 | 0), "async"));
if(i > 0)
- source.push("require(" + JSON.stringify("./" + (i - 1) + ".async.js") + ");");
+ source.push(generateRequireString((i - 1), "async"));
source.push("});");
source.push("module.exports = " + i + ";");
fs.writeFileSync(path.join(fixtures, i + ".async.js"), source.join("\n"), "utf-8");
@@ -40,13 +45,13 @@ for(let i = 0; i < 10000; i++) {
for(let i = 0; i < 100; i++) {
const source = [];
if(i > 8)
- source.push("require(" + JSON.stringify("./" + (i / 8 | 0) + ".big.js") + ");");
+ source.push(generateRequireString((i / 8 | 0), "big"));
if(i > 4)
- source.push("require(" + JSON.stringify("./" + (i / 4 | 0) + ".big.js") + ");");
+ source.push(generateRequireString((i / 4 | 0), "big"));
if(i > 2)
- source.push("require(" + JSON.stringify("./" + (i / 2 | 0) + ".big.js") + ");");
+ source.push(generateRequireString((i / 2 | 0), "big"));
if(i > 0)
- source.push("require(" + JSON.stringify("./" + (i - 1) + ".big.js") + ");");
+ source.push(generateRequireString((i - 1), "big"));
for(let j = 0; j < 300; j++)
source.push("if(Math.random())hello.world();test.a.b.c.d();x(1,2,3,4);var a,b,c,d,e,f;");
source.push("module.exports = " + i + ";");
diff --git a/bin/config-optimist.js b/bin/config-optimist.js
deleted file mode 100644
index 6ec4d62c..00000000
--- a/bin/config-optimist.js
+++ /dev/null
@@ -1,48 +0,0 @@
-module.exports = function(optimist) {
- optimist
- .boolean("help").alias("help", "h").alias("help", "?").describe("help")
- .string("config").describe("config", "Path to the config file")
- .string("config-name").describe("config-name", "Name of the config to use")
- .string("env").describe("env", "Environment passed to the config, when it is a function")
- .string("context").describe("context", "The root directory for resolving entry point and stats")
- .string("entry").describe("entry", "The entry point")
- .string("module-bind").describe("module-bind", "Bind an extension to a loader")
- .string("module-bind-post").describe("module-bind-post")
- .string("module-bind-pre").describe("module-bind-pre")
- .string("output-path").describe("output-path", "The output path for compilation assets")
- .string("output-filename").describe("output-filename", "The output filename of the bundle")
- .string("output-chunk-filename").describe("output-chunk-filename", "The output filename for additional chunks")
- .string("output-source-map-filename").describe("output-source-map-filename", "The output filename for the SourceMap")
- .string("output-public-path").describe("output-public-path", "The public path for the assets")
- .string("output-jsonp-function").describe("output-jsonp-function", "The name of the jsonp function used for chunk loading")
- .boolean("output-pathinfo").describe("output-pathinfo", "Include a comment with the request for every dependency")
- .string("output-library").describe("output-library", "Expose the exports of the entry point as library")
- .string("output-library-target").describe("output-library-target", "The type for exposing the exports of the entry point as library")
- .string("records-input-path").describe("records-input-path", "Path to the records file (reading)")
- .string("records-output-path").describe("records-output-path", "Path to the records file (writing)")
- .string("records-path").describe("records-path", "Path to the records file")
- .string("define").describe("define", "Define any free var in the bundle")
- .string("target").describe("target", "The targeted execution environment")
- .boolean("cache").describe("cache", "Enable in memory caching").default("cache", true)
- .boolean("watch").alias("watch", "w").describe("watch", "Watch the filesystem for changes")
- .boolean("watch-stdin").alias("watch-stdin", "stdin").describe("Exit the process when stdin is closed")
- .describe("watch-aggregate-timeout", "Timeout for gathering changes while watching")
- .describe("watch-poll", "The polling interval for watching (also enable polling)")
- .boolean("hot").describe("hot", "Enables Hot Module Replacement")
- .boolean("debug").describe("debug", "Switch loaders to debug mode")
- .string("devtool").describe("devtool", "Enable devtool for better debugging experience")
- .boolean("progress").describe("progress", "Print compilation progress in percentage")
- .string("resolve-alias").describe("resolve-alias", "Setup a module alias for resolving")
- .string("resolve-extensions").describe("resolve-extensions", "Setup extensions that should be used to resolve modules")
- .string("resolve-loader-alias").describe("resolve-loader-alias", "Setup a loader alias for resolving")
- .describe("optimize-max-chunks", "Try to keep the chunk count below a limit")
- .describe("optimize-min-chunk-size", "Try to keep the chunk size above a limit")
- .boolean("optimize-minimize").describe("optimize-minimize", "Minimize javascript and switches loaders to minimizing")
- .string("prefetch").describe("prefetch", "Prefetch this request")
- .string("provide").describe("provide", "Provide these modules as free vars in all modules")
- .string("plugin").describe("plugin", "Load this plugin")
- .boolean("bail").describe("bail", "Abort the compilation on first error")
- .boolean("profile").describe("profile", "Profile the compilation and include information in stats")
- .boolean("d").describe("d", "shortcut for --debug --devtool eval-check-module-source-map --output-pathinfo")
- .boolean("p").describe("p", "shortcut for --optimize-minimize --define process.env.NODE_ENV=\"production\"");
-};
diff --git a/bin/config-yargs.js b/bin/config-yargs.js
deleted file mode 100644
index 0f44fdeb..00000000
--- a/bin/config-yargs.js
+++ /dev/null
@@ -1,274 +0,0 @@
-var CONFIG_GROUP = "Config options:";
-var BASIC_GROUP = "Basic options:";
-var MODULE_GROUP = "Module options:";
-var OUTPUT_GROUP = "Output options:";
-var ADVANCED_GROUP = "Advanced options:";
-var RESOLVE_GROUP = "Resolving options:";
-var OPTIMIZE_GROUP = "Optimizing options:";
-
-module.exports = function(yargs) {
- yargs
- .help("help")
- .alias("help", "h")
- .version()
- .alias("version", "v")
- .options({
- "config": {
- type: "string",
- describe: "Path to the config file",
- group: CONFIG_GROUP,
- defaultDescription: "webpack.config.js or webpackfile.js",
- requiresArg: true
- },
- "config-name": {
- type: "string",
- describe: "Name of the config to use",
- group: CONFIG_GROUP,
- requiresArg: true
- },
- "env": {
- describe: "Environment passed to the config, when it is a function",
- group: CONFIG_GROUP
- },
- "context": {
- type: "string",
- describe: "The root directory for resolving entry point and stats",
- group: BASIC_GROUP,
- defaultDescription: "The current directory",
- requiresArg: true
- },
- "entry": {
- type: "string",
- describe: "The entry point",
- group: BASIC_GROUP,
- requiresArg: true
- },
- "module-bind": {
- type: "string",
- describe: "Bind an extension to a loader",
- group: MODULE_GROUP,
- requiresArg: true
- },
- "module-bind-post": {
- type: "string",
- describe: "",
- group: MODULE_GROUP,
- requiresArg: true
- },
- "module-bind-pre": {
- type: "string",
- describe: "",
- group: MODULE_GROUP,
- requiresArg: true
- },
- "output-path": {
- type: "string",
- describe: "The output path for compilation assets",
- group: OUTPUT_GROUP,
- defaultDescription: "The current directory",
- requiresArg: true
- },
- "output-filename": {
- type: "string",
- describe: "The output filename of the bundle",
- group: OUTPUT_GROUP,
- defaultDescription: "[name].js",
- requiresArg: true
- },
- "output-chunk-filename": {
- type: "string",
- describe: "The output filename for additional chunks",
- group: OUTPUT_GROUP,
- defaultDescription: "filename with [id] instead of [name] or [id] prefixed",
- requiresArg: true
- },
- "output-source-map-filename": {
- type: "string",
- describe: "The output filename for the SourceMap",
- group: OUTPUT_GROUP,
- requiresArg: true
- },
- "output-public-path": {
- type: "string",
- describe: "The public path for the assets",
- group: OUTPUT_GROUP,
- requiresArg: true
- },
- "output-jsonp-function": {
- type: "string",
- describe: "The name of the jsonp function used for chunk loading",
- group: OUTPUT_GROUP,
- requiresArg: true
- },
- "output-pathinfo": {
- type: "boolean",
- describe: "Include a comment with the request for every dependency (require, import, etc.)",
- group: OUTPUT_GROUP
- },
- "output-library": {
- type: "string",
- describe: "Expose the exports of the entry point as library",
- group: OUTPUT_GROUP,
- requiresArg: true
- },
- "output-library-target": {
- type: "string",
- describe: "The type for exposing the exports of the entry point as library",
- group: OUTPUT_GROUP,
- requiresArg: true
- },
- "records-input-path": {
- type: "string",
- describe: "Path to the records file (reading)",
- group: ADVANCED_GROUP,
- requiresArg: true
- },
- "records-output-path": {
- type: "string",
- describe: "Path to the records file (writing)",
- group: ADVANCED_GROUP,
- requiresArg: true
- },
- "records-path": {
- type: "string",
- describe: "Path to the records file",
- group: ADVANCED_GROUP,
- requiresArg: true
- },
- "define": {
- type: "string",
- describe: "Define any free var in the bundle",
- group: ADVANCED_GROUP,
- requiresArg: true
- },
- "target": {
- type: "string",
- describe: "The targeted execution environment",
- group: ADVANCED_GROUP,
- requiresArg: true
- },
- "cache": {
- type: "boolean",
- describe: "Enable in memory caching",
- default: null,
- group: ADVANCED_GROUP,
- defaultDescription: "It's enabled by default when watching"
- },
- "watch": {
- type: "boolean",
- alias: "w",
- describe: "Watch the filesystem for changes",
- group: BASIC_GROUP
- },
- "watch-stdin": {
- type: "boolean",
- alias: "stdin",
- describe: "Exit the process when stdin is closed",
- group: ADVANCED_GROUP
- },
- "watch-aggregate-timeout": {
- describe: "Timeout for gathering changes while watching",
- group: ADVANCED_GROUP,
- requiresArg: true
- },
- "watch-poll": {
- type: "string",
- describe: "The polling interval for watching (also enable polling)",
- group: ADVANCED_GROUP
- },
- "hot": {
- type: "boolean",
- describe: "Enables Hot Module Replacement",
- group: ADVANCED_GROUP
- },
- "debug": {
- type: "boolean",
- describe: "Switch loaders to debug mode",
- group: BASIC_GROUP
- },
- "devtool": {
- type: "string",
- describe: "Enable devtool for better debugging experience (Example: --devtool eval-cheap-module-source-map)",
- group: BASIC_GROUP,
- requiresArg: true
- },
- "resolve-alias": {
- type: "string",
- describe: "Setup a module alias for resolving (Example: jquery-plugin=jquery.plugin)",
- group: RESOLVE_GROUP,
- requiresArg: true
- },
- "resolve-extensions": {
- "type": "array",
- describe: "Setup extensions that should be used to resolve modules (Example: --resolve-extensions .es6,.js)",
- group: RESOLVE_GROUP,
- requiresArg: true
- },
- "resolve-loader-alias": {
- type: "string",
- describe: "Setup a loader alias for resolving",
- group: RESOLVE_GROUP,
- requiresArg: true
- },
- "optimize-max-chunks": {
- describe: "Try to keep the chunk count below a limit",
- group: OPTIMIZE_GROUP,
- requiresArg: true
- },
- "optimize-min-chunk-size": {
- describe: "Try to keep the chunk size above a limit",
- group: OPTIMIZE_GROUP,
- requiresArg: true
- },
- "optimize-minimize": {
- type: "boolean",
- describe: "Minimize javascript and switches loaders to minimizing",
- group: OPTIMIZE_GROUP
- },
- "prefetch": {
- type: "string",
- describe: "Prefetch this request (Example: --prefetch ./file.js)",
- group: ADVANCED_GROUP,
- requiresArg: true
- },
- "provide": {
- type: "string",
- describe: "Provide these modules as free vars in all modules (Example: --provide jQuery=jquery)",
- group: ADVANCED_GROUP,
- requiresArg: true
- },
- "labeled-modules": {
- type: "boolean",
- describe: "Enables labeled modules",
- group: ADVANCED_GROUP
- },
- "plugin": {
- type: "string",
- describe: "Load this plugin",
- group: ADVANCED_GROUP,
- requiresArg: true
- },
- "bail": {
- type: "boolean",
- describe: "Abort the compilation on first error",
- group: ADVANCED_GROUP,
- default: null
- },
- "profile": {
- type: "boolean",
- describe: "Profile the compilation and include information in stats",
- group: ADVANCED_GROUP,
- default: null
- },
- "d": {
- type: "boolean",
- describe: "shortcut for --debug --devtool eval-cheap-module-source-map --output-pathinfo",
- group: BASIC_GROUP
- },
- "p": {
- type: "boolean",
- describe: "shortcut for --optimize-minimize --define process.env.NODE_ENV=\"production\"",
- group: BASIC_GROUP
- }
- }).strict();
-};
diff --git a/bin/convert-argv.js b/bin/convert-argv.js
deleted file mode 100644
index db68f76a..00000000
--- a/bin/convert-argv.js
+++ /dev/null
@@ -1,562 +0,0 @@
-var path = require("path");
-var fs = require("fs");
-fs.existsSync = fs.existsSync || path.existsSync;
-var interpret = require("interpret");
-var prepareOptions = require("../lib/prepareOptions");
-
-module.exports = function(yargs, argv, convertOptions) {
-
- var options = [];
-
- // Shortcuts
- if(argv.d) {
- argv.debug = true;
- argv["output-pathinfo"] = true;
- if(!argv.devtool) {
- argv.devtool = "eval-cheap-module-source-map";
- }
- }
- if(argv.p) {
- argv["optimize-minimize"] = true;
- argv["define"] = [].concat(argv["define"] || []).concat("process.env.NODE_ENV=\"production\"");
- }
-
- var configFileLoaded = false;
- var configFiles = [];
- var 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"].map(function(filename) {
- return extensions.map(function(ext) {
- return {
- path: path.resolve(filename + ext),
- ext: ext
- };
- });
- }).reduce(function(a, i) {
- return a.concat(i);
- }, []);
-
- var i;
- if(argv.config) {
- var getConfigExtension = function getConfigExtension(configPath) {
- for(i = extensions.length - 1; i >= 0; i--) {
- var tmpExt = extensions[i];
- if(configPath.indexOf(tmpExt, configPath.length - tmpExt.length) > -1) {
- return tmpExt;
- }
- }
- return path.extname(configPath);
- };
-
- var mapConfigArg = function mapConfigArg(configArg) {
- var resolvedPath = path.resolve(configArg);
- var extension = getConfigExtension(resolvedPath);
- return {
- path: resolvedPath,
- ext: extension
- };
- };
-
- var configArgList = Array.isArray(argv.config) ? argv.config : [argv.config];
- configFiles = configArgList.map(mapConfigArg);
- } else {
- for(i = 0; i < defaultConfigFiles.length; i++) {
- var webpackConfig = defaultConfigFiles[i].path;
- if(fs.existsSync(webpackConfig)) {
- configFiles.push({
- path: webpackConfig,
- ext: defaultConfigFiles[i].ext
- });
- break;
- }
- }
- }
-
- if(configFiles.length > 0) {
- var 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++) {
- try {
- registerCompiler(moduleDescriptor[i]);
- break;
- } catch(e) {
- // do nothing
- }
- }
- }
- }
- };
-
- var requireConfig = function requireConfig(configPath) {
- var options = require(configPath);
- options = prepareOptions(options, argv);
- return options;
- };
-
- configFiles.forEach(function(file) {
- registerCompiler(interpret.extensions[file.ext]);
- options.push(requireConfig(file.path));
- });
- configFileLoaded = true;
- }
-
- if(!configFileLoaded) {
- return processConfiguredOptions({});
- } else if(options.length === 1) {
- return processConfiguredOptions(options[0]);
- } else {
- return processConfiguredOptions(options);
- }
-
- function processConfiguredOptions(options) {
- if(options === null || typeof options !== "object") {
- console.error("Config did not export an object or a function returning an object.");
- process.exit(-1); // eslint-disable-line
- }
-
- // process Promise
- if(typeof options.then === "function") {
- return options.then(processConfiguredOptions);
- }
-
- // process ES6 default
- if(typeof options === "object" && typeof options.default === "object") {
- return processConfiguredOptions(options.default);
- }
-
- // filter multi-config by name
- if(Array.isArray(options) && argv["config-name"]) {
- var namedOptions = options.filter(function(opt) {
- return opt.name === argv["config-name"];
- });
- if(namedOptions.length === 0) {
- console.error("Configuration with name '" + argv["config-name"] + "' was not found.");
- process.exit(-1); // eslint-disable-line
- } else if(namedOptions.length === 1) {
- return processConfiguredOptions(namedOptions[0]);
- }
- options = namedOptions;
- }
-
- if(Array.isArray(options)) {
- options.forEach(processOptions);
- } else {
- processOptions(options);
- }
-
- if(argv.context) {
- options.context = path.resolve(argv.context);
- }
- if(!options.context) {
- options.context = process.cwd();
- }
-
- if(argv.watch) {
- options.watch = true;
- }
-
- if(argv["watch-aggregate-timeout"]) {
- options.watchOptions = options.watchOptions || {};
- options.watchOptions.aggregateTimeout = +argv["watch-aggregate-timeout"];
- }
-
- if(typeof argv["watch-poll"] !== "undefined") {
- options.watchOptions = options.watchOptions || {};
- if(argv["watch-poll"] === "true" || argv["watch-poll"] === "")
- options.watchOptions.poll = true;
- else if(!isNaN(argv["watch-poll"]))
- options.watchOptions.poll = +argv["watch-poll"];
- }
-
- if(argv["watch-stdin"]) {
- options.watchOptions = options.watchOptions || {};
- options.watchOptions.stdin = true;
- options.watch = true;
- }
-
- return options;
- }
-
- function processOptions(options) {
- var noOutputFilenameDefined = !options.output || !options.output.filename;
-
- function ifArg(name, fn, init, finalize) {
- if(Array.isArray(argv[name])) {
- if(init) {
- init();
- }
- argv[name].forEach(fn);
- if(finalize) {
- finalize();
- }
- } else if(typeof argv[name] !== "undefined" && argv[name] !== null) {
- if(init) {
- init();
- }
- fn(argv[name], -1);
- if(finalize) {
- finalize();
- }
- }
- }
-
- function ifArgPair(name, fn, init, finalize) {
- ifArg(name, function(content, idx) {
- var i = content.indexOf("=");
- if(i < 0) {
- return fn(null, content, idx);
- } else {
- return fn(content.substr(0, i), content.substr(i + 1), idx);
- }
- }, init, finalize);
- }
-
- function ifBooleanArg(name, fn) {
- ifArg(name, function(bool) {
- if(bool) {
- fn();
- }
- });
- }
-
- function mapArgToBoolean(name, optionName) {
- ifArg(name, function(bool) {
- if(bool === true)
- options[optionName || name] = true;
- else if(bool === false)
- options[optionName || name] = false;
- });
- }
-
- function loadPlugin(name) {
- var loadUtils = require("loader-utils");
- var args;
- try {
- var p = name && name.indexOf("?");
- if(p > -1) {
- args = loadUtils.parseQuery(name.substring(p));
- name = name.substring(0, p);
- }
- } catch(e) {
- console.log("Invalid plugin arguments " + name + " (" + e + ").");
- process.exit(-1); // eslint-disable-line
- }
-
- var path;
- try {
- var 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;
- try {
- Plugin = require(path);
- } catch(e) {
- console.log("Cannot load plugin " + name + ". (" + path + ")");
- throw e;
- }
- try {
- return new Plugin(args);
- } catch(e) {
- console.log("Cannot instantiate plugin " + name + ". (" + path + ")");
- throw e;
- }
- }
-
- function ensureObject(parent, name) {
- if(typeof parent[name] !== "object" || parent[name] === null) {
- parent[name] = {};
- }
- }
-
- function ensureArray(parent, name) {
- if(!Array.isArray(parent[name])) {
- parent[name] = [];
- }
- }
-
- ifArgPair("entry", function(name, entry) {
- if(typeof options.entry[name] !== "undefined" && options.entry[name] !== null) {
- options.entry[name] = [].concat(options.entry[name]).concat(entry);
- } else {
- options.entry[name] = entry;
- }
- }, function() {
- ensureObject(options, "entry");
- });
-
- function bindRules(arg) {
- ifArgPair(arg, function(name, binding) {
- if(name === null) {
- name = binding;
- binding += "-loader";
- }
- var rule = {
- test: new RegExp("\\." + name.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&") + "$"), // eslint-disable-line no-useless-escape
- loader: binding
- };
- if(arg === "module-bind-pre") {
- rule.enforce = "pre";
- } else if(arg === "module-bind-post") {
- rule.enforce = "post";
- }
- options.module.rules.push(rule);
- }, function() {
- ensureObject(options, "module");
- ensureArray(options.module, "rules");
- });
- }
- bindRules("module-bind");
- bindRules("module-bind-pre");
- bindRules("module-bind-post");
-
- var defineObject;
- ifArgPair("define", function(name, value) {
- if(name === null) {
- name = value;
- value = true;
- }
- defineObject[name] = value;
- }, function() {
- defineObject = {};
- }, function() {
- ensureArray(options, "plugins");
- var DefinePlugin = require("../lib/DefinePlugin");
- options.plugins.push(new DefinePlugin(defineObject));
- });
-
- ifArg("output-path", function(value) {
- ensureObject(options, "output");
- options.output.path = path.resolve(value);
- });
-
- ifArg("output-filename", function(value) {
- ensureObject(options, "output");
- options.output.filename = value;
- noOutputFilenameDefined = false;
- });
-
- ifArg("output-chunk-filename", function(value) {
- ensureObject(options, "output");
- options.output.chunkFilename = value;
- });
-
- ifArg("output-source-map-filename", function(value) {
- ensureObject(options, "output");
- options.output.sourceMapFilename = value;
- });
-
- ifArg("output-public-path", function(value) {
- ensureObject(options, "output");
- options.output.publicPath = value;
- });
-
- ifArg("output-jsonp-function", function(value) {
- ensureObject(options, "output");
- options.output.jsonpFunction = value;
- });
-
- ifBooleanArg("output-pathinfo", function() {
- ensureObject(options, "output");
- options.output.pathinfo = true;
- });
-
- ifArg("output-library", function(value) {
- ensureObject(options, "output");
- options.output.library = value;
- });
-
- ifArg("output-library-target", function(value) {
- ensureObject(options, "output");
- options.output.libraryTarget = value;
- });
-
- ifArg("records-input-path", function(value) {
- options.recordsInputPath = path.resolve(value);
- });
-
- ifArg("records-output-path", function(value) {
- options.recordsOutputPath = path.resolve(value);
- });
-
- ifArg("records-path", function(value) {
- options.recordsPath = path.resolve(value);
- });
-
- ifArg("target", function(value) {
- options.target = value;
- });
-
- mapArgToBoolean("cache");
-
- ifBooleanArg("hot", function() {
- ensureArray(options, "plugins");
- var HotModuleReplacementPlugin = require("../lib/HotModuleReplacementPlugin");
- options.plugins.push(new HotModuleReplacementPlugin());
- });
-
- ifBooleanArg("debug", function() {
- ensureArray(options, "plugins");
- var LoaderOptionsPlugin = require("../lib/LoaderOptionsPlugin");
- options.plugins.push(new LoaderOptionsPlugin({
- debug: true
- }));
- });
-
- ifArg("devtool", function(value) {
- options.devtool = value;
- });
-
- function processResolveAlias(arg, key) {
- ifArgPair(arg, function(name, value) {
- if(!name) {
- throw new Error("--" + arg + " <string>=<string>");
- }
- ensureObject(options, key);
- ensureObject(options[key], "alias");
- options[key].alias[name] = value;
- });
- }
- processResolveAlias("resolve-alias", "resolve");
- processResolveAlias("resolve-loader-alias", "resolveLoader");
-
- ifArg("resolve-extensions", function(value) {
- ensureObject(options, "resolve");
- if(Array.isArray(value)) {
- options.resolve.extensions = value;
- } else {
- options.resolve.extensions = value.split(/,\s*/);
- }
- });
-
- ifArg("optimize-max-chunks", function(value) {
- ensureArray(options, "plugins");
- var LimitChunkCountPlugin = require("../lib/optimize/LimitChunkCountPlugin");
- options.plugins.push(new LimitChunkCountPlugin({
- maxChunks: parseInt(value, 10)
- }));
- });
-
- ifArg("optimize-min-chunk-size", function(value) {
- ensureArray(options, "plugins");
- var MinChunkSizePlugin = require("../lib/optimize/MinChunkSizePlugin");
- options.plugins.push(new MinChunkSizePlugin({
- minChunkSize: parseInt(value, 10)
- }));
- });
-
- ifBooleanArg("optimize-minimize", function() {
- ensureArray(options, "plugins");
- var UglifyJsPlugin = require("../lib/optimize/UglifyJsPlugin");
- var LoaderOptionsPlugin = require("../lib/LoaderOptionsPlugin");
- options.plugins.push(new UglifyJsPlugin({
- sourceMap: options.devtool && (options.devtool.indexOf("sourcemap") >= 0 || options.devtool.indexOf("source-map") >= 0)
- }));
- options.plugins.push(new LoaderOptionsPlugin({
- minimize: true
- }));
- });
-
- ifArg("prefetch", function(request) {
- ensureArray(options, "plugins");
- var PrefetchPlugin = require("../lib/PrefetchPlugin");
- options.plugins.push(new PrefetchPlugin(request));
- });
-
- ifArg("provide", function(value) {
- ensureArray(options, "plugins");
- var idx = value.indexOf("=");
- var name;
- if(idx >= 0) {
- name = value.substr(0, idx);
- value = value.substr(idx + 1);
- } else {
- name = value;
- }
- var ProvidePlugin = require("../lib/ProvidePlugin");
- options.plugins.push(new ProvidePlugin(name, value));
- });
-
- ifArg("plugin", function(value) {
- ensureArray(options, "plugins");
- options.plugins.push(loadPlugin(value));
- });
-
- mapArgToBoolean("bail");
-
- mapArgToBoolean("profile");
-
- if(noOutputFilenameDefined) {
- ensureObject(options, "output");
- if(convertOptions && convertOptions.outputFilename) {
- options.output.path = path.resolve(path.dirname(convertOptions.outputFilename));
- options.output.filename = path.basename(convertOptions.outputFilename);
- } else if(argv._.length > 0) {
- options.output.filename = argv._.pop();
- options.output.path = path.resolve(path.dirname(options.output.filename));
- options.output.filename = path.basename(options.output.filename);
- } else if(configFileLoaded) {
- throw new Error("'output.filename' is required, either in config file or as --output-filename");
- } else {
- console.error("No configuration file found and no output filename configured via CLI option.");
- console.error("A configuration file could be named 'webpack.config.js' in the current directory.");
- console.error("Use --help to display the CLI options.");
- process.exit(-1); // eslint-disable-line
- }
- }
-
- if(argv._.length > 0) {
- if(Array.isArray(options.entry) || typeof options.entry === "string") {
- options.entry = {
- main: options.entry
- };
- }
- ensureObject(options, "entry");
-
- var addTo = function addTo(name, entry) {
- if(options.entry[name]) {
- if(!Array.isArray(options.entry[name])) {
- options.entry[name] = [options.entry[name]];
- }
- options.entry[name].push(entry);
- } else {
- options.entry[name] = entry;
- }
- };
- argv._.forEach(function(content) {
- var i = content.indexOf("=");
- var j = content.indexOf("?");
- if(i < 0 || (j >= 0 && j < i)) {
- var resolved = path.resolve(content);
- if(fs.existsSync(resolved)) {
- addTo("main", `${resolved}${fs.statSync(resolved).isDirectory() ? path.sep : ""}`);
- } else {
- addTo("main", content);
- }
- } else {
- addTo(content.substr(0, i), content.substr(i + 1));
- }
- });
- }
-
- if(!options.entry) {
- if(configFileLoaded) {
- console.error("Configuration file found but no entry configured.");
- } else {
- console.error("No configuration file found and no entry configured via CLI option.");
- console.error("When using the CLI you need to provide at least two arguments: entry and output.");
- console.error("A configuration file could be named 'webpack.config.js' in the current directory.");
- }
- console.error("Use --help to display the CLI options.");
- process.exit(-1); // eslint-disable-line
- }
- }
-};
diff --git a/bin/webpack.js b/bin/webpack.js
index 1fec3731..22f08e0e 100644
--- a/bin/webpack.js
+++ b/bin/webpack.js
@@ -1,399 +1,21 @@
#!/usr/bin/env node
-/*
- MIT License http://www.opensource.org/licenses/mit-license.php
- Author Tobias Koppers @sokra
-*/
-var path = require("path");
-
-// Local version replace global one
+let webpackCliInstalled = false;
try {
- var localWebpack = require.resolve(path.join(process.cwd(), "node_modules", "webpack", "bin", "webpack.js"));
- if(__filename !== localWebpack) {
- return require(localWebpack);
- }
-} catch(e) {}
-var yargs = require("yargs")
- .usage("webpack " + require("../package.json").version + "\n" +
- "Usage: https://webpack.js.org/api/cli/\n" +
- "Usage without config file: webpack <entry> [<entry>] <output>\n" +
- "Usage with config file: webpack");
-
-require("./config-yargs")(yargs);
-
-var DISPLAY_GROUP = "Stats options:";
-var BASIC_GROUP = "Basic options:";
-
-yargs.options({
- "json": {
- type: "boolean",
- alias: "j",
- describe: "Prints the result as JSON."
- },
- "progress": {
- type: "boolean",
- describe: "Print compilation progress in percentage",
- group: BASIC_GROUP
- },
- "color": {
- type: "boolean",
- alias: "colors",
- default: function supportsColor() {
- return require("supports-color");
- },
- group: DISPLAY_GROUP,
- describe: "Enables/Disables colors on the console"
- },
- "sort-modules-by": {
- type: "string",
- group: DISPLAY_GROUP,
- describe: "Sorts the modules list by property in module"
- },
- "sort-chunks-by": {
- type: "string",
- group: DISPLAY_GROUP,
- describe: "Sorts the chunks list by property in chunk"
- },
- "sort-assets-by": {
- type: "string",
- group: DISPLAY_GROUP,
- describe: "Sorts the assets list by property in asset"
- },
- "hide-modules": {
- type: "boolean",
- group: DISPLAY_GROUP,
- describe: "Hides info about modules"
- },
- "display-exclude": {
- type: "string",
- group: DISPLAY_GROUP,
- describe: "Exclude modules in the output"
- },
- "display-modules": {
- type: "boolean",
- group: DISPLAY_GROUP,
- describe: "Display even excluded modules in the output"
- },
- "display-max-modules": {
- type: "number",
- group: DISPLAY_GROUP,
- describe: "Sets the maximum number of visible modules in output"
- },
- "display-chunks": {
- type: "boolean",
- group: DISPLAY_GROUP,
- describe: "Display chunks in the output"
- },
- "display-entrypoints": {
- type: "boolean",
- group: DISPLAY_GROUP,
- describe: "Display entry points in the output"
- },
- "display-origins": {
- type: "boolean",
- group: DISPLAY_GROUP,
- describe: "Display origins of chunks in the output"
- },
- "display-cached": {
- type: "boolean",
- group: DISPLAY_GROUP,
- describe: "Display also cached modules in the output"
- },
- "display-cached-assets": {
- type: "boolean",
- group: DISPLAY_GROUP,
- describe: "Display also cached assets in the output"
- },
- "display-reasons": {
- type: "boolean",
- group: DISPLAY_GROUP,
- describe: "Display reasons about module inclusion in the output"
- },
- "display-depth": {
- type: "boolean",
- group: DISPLAY_GROUP,
- describe: "Display distance from entry point for each module"
- },
- "display-used-exports": {
- type: "boolean",
- group: DISPLAY_GROUP,
- describe: "Display information about used exports in modules (Tree Shaking)"
- },
- "display-provided-exports": {
- type: "boolean",
- group: DISPLAY_GROUP,
- describe: "Display information about exports provided from modules"
- },
- "display-optimization-bailout": {
- type: "boolean",
- group: DISPLAY_GROUP,
- describe: "Display information about why optimization bailed out for modules"
- },
- "display-error-details": {
- type: "boolean",
- group: DISPLAY_GROUP,
- describe: "Display details about errors"
- },
- "display": {
- type: "string",
- group: DISPLAY_GROUP,
- describe: "Select display preset (verbose, detailed, normal, minimal, errors-only, none)"
- },
- "verbose": {
- type: "boolean",
- group: DISPLAY_GROUP,
- describe: "Show more details"
- }
-});
-
-// yargs will terminate the process early when the user uses help or version.
-// This causes large help outputs to be cut short (https://github.com/nodejs/node/wiki/API-changes-between-v0.10-and-v4#process).
-// To prevent this we use the yargs.parse API and exit the process normally
-yargs.parse(process.argv.slice(2), (err, argv, output) => {
-
- // arguments validation failed
- if(err && output) {
- console.error(output);
- process.exitCode = 1;
- return;
- }
-
- // help or version info
- if(output) {
- console.log(output);
- return;
- }
-
- if(argv.verbose) {
- argv["display"] = "verbose";
- }
-
- var options = require("./convert-argv")(yargs, argv);
-
- function ifArg(name, fn, init) {
- if(Array.isArray(argv[name])) {
- if(init) init();
- argv[name].forEach(fn);
- } else if(typeof argv[name] !== "undefined") {
- if(init) init();
- fn(argv[name], -1);
- }
- }
-
- function processOptions(options) {
- // process Promise
- if(typeof options.then === "function") {
- options.then(processOptions).catch(function(err) {
- console.error(err.stack || err);
- process.exit(1); // eslint-disable-line
- });
- return;
- }
-
- var firstOptions = [].concat(options)[0];
- var statsPresetToOptions = require("../lib/Stats.js").presetToOptions;
-
- var outputOptions = options.stats;
- if(typeof outputOptions === "boolean" || typeof outputOptions === "string") {
- outputOptions = statsPresetToOptions(outputOptions);
- } else if(!outputOptions) {
- outputOptions = {};
- }
-
- ifArg("display", function(preset) {
- outputOptions = statsPresetToOptions(preset);
- });
-
- outputOptions = Object.create(outputOptions);
- if(Array.isArray(options) && !outputOptions.children) {
- outputOptions.children = options.map(o => o.stats);
- }
- if(typeof outputOptions.context === "undefined")
- outputOptions.context = firstOptions.context;
-
- ifArg("env", function(value) {
- if(outputOptions.env) {
- outputOptions._env = value;
- }
- });
-
- ifArg("json", function(bool) {
- if(bool)
- outputOptions.json = bool;
- });
-
- if(typeof outputOptions.colors === "undefined")
- outputOptions.colors = require("supports-color");
-
- ifArg("sort-modules-by", function(value) {
- outputOptions.modulesSort = value;
- });
-
- ifArg("sort-chunks-by", function(value) {
- outputOptions.chunksSort = value;
- });
-
- ifArg("sort-assets-by", function(value) {
- outputOptions.assetsSort = value;
- });
-
- ifArg("display-exclude", function(value) {
- outputOptions.exclude = value;
- });
-
- if(!outputOptions.json) {
- if(typeof outputOptions.cached === "undefined")
- outputOptions.cached = false;
- if(typeof outputOptions.cachedAssets === "undefined")
- outputOptions.cachedAssets = false;
-
- ifArg("display-chunks", function(bool) {
- if(bool) {
- outputOptions.modules = false;
- outputOptions.chunks = true;
- outputOptions.chunkModules = true;
- }
- });
-
- ifArg("display-entrypoints", function(bool) {
- if(bool)
- outputOptions.entrypoints = true;
- });
-
- ifArg("display-reasons", function(bool) {
- if(bool)
- outputOptions.reasons = true;
- });
-
- ifArg("display-depth", function(bool) {
- if(bool)
- outputOptions.depth = true;
- });
-
- ifArg("display-used-exports", function(bool) {
- if(bool)
- outputOptions.usedExports = true;
- });
-
- ifArg("display-provided-exports", function(bool) {
- if(bool)
- outputOptions.providedExports = true;
- });
-
- ifArg("display-optimization-bailout", function(bool) {
- if(bool)
- outputOptions.optimizationBailout = bool;
- });
-
- ifArg("display-error-details", function(bool) {
- if(bool)
- outputOptions.errorDetails = true;
- });
-
- ifArg("display-origins", function(bool) {
- if(bool)
- outputOptions.chunkOrigins = true;
- });
-
- ifArg("display-max-modules", function(value) {
- outputOptions.maxModules = +value;
- });
-
- ifArg("display-cached", function(bool) {
- if(bool)
- outputOptions.cached = true;
- });
-
- ifArg("display-cached-assets", function(bool) {
- if(bool)
- outputOptions.cachedAssets = true;
- });
-
- if(!outputOptions.exclude)
- outputOptions.exclude = ["node_modules", "bower_components", "components"];
-
- if(argv["display-modules"]) {
- outputOptions.maxModules = Infinity;
- outputOptions.exclude = undefined;
- outputOptions.modules = true;
- }
- }
-
- ifArg("hide-modules", function(bool) {
- if(bool) {
- outputOptions.modules = false;
- outputOptions.chunkModules = false;
- }
- });
-
- var webpack = require("../lib/webpack.js");
-
- Error.stackTraceLimit = 30;
- var lastHash = null;
- var compiler;
- try {
- compiler = webpack(options);
- } catch(err) {
- if(err.name === "WebpackOptionsValidationError") {
- if(argv.color)
- console.error(
- `\u001b[1m\u001b[31m${err.message}\u001b[39m\u001b[22m`
- );
- else
- console.error(err.message);
- // eslint-disable-next-line no-process-exit
- process.exit(1);
- }
-
- throw err;
- }
-
- if(argv.progress) {
- var ProgressPlugin = require("../lib/ProgressPlugin");
- compiler.apply(new ProgressPlugin({
- profile: argv.profile
- }));
- }
-
- function compilerCallback(err, stats) {
- if(!options.watch || err) {
- // Do not keep cache anymore
- compiler.purgeInputFileSystem();
- }
- if(err) {
- lastHash = null;
- console.error(err.stack || err);
- if(err.details) console.error(err.details);
- process.exitCode = 1;
- return;
- }
- if(outputOptions.json) {
- process.stdout.write(JSON.stringify(stats.toJson(outputOptions), null, 2) + "\n");
- } else if(stats.hash !== lastHash) {
- lastHash = stats.hash;
- var statsString = stats.toString(outputOptions);
- if(statsString)
- process.stdout.write(statsString + "\n");
- }
- if(!options.watch && stats.hasErrors()) {
- process.exitCode = 2;
- }
- }
- if(firstOptions.watch || options.watch) {
- var watchOptions = firstOptions.watchOptions || firstOptions.watch || options.watch || {};
- if(watchOptions.stdin) {
- process.stdin.on("end", function() {
- process.exit(); // eslint-disable-line
- });
- process.stdin.resume();
- }
- compiler.watch(watchOptions, compilerCallback);
- console.log("\nWebpack is watching the files…\n");
- } else
- compiler.run(compilerCallback);
-
- }
-
- processOptions(options);
-
-});
+ require.resolve("webpack-cli");
+ webpackCliInstalled = true;
+} catch (e) {
+ webpackCliInstalled = false;
+}
+
+if (webpackCliInstalled) {
+ require("webpack-cli"); // eslint-disable-line node/no-missing-require, node/no-extraneous-require, node/no-unpublished-require
+} else {
+ console.error("The CLI moved into a separate package: webpack-cli.");
+ console.error(
+ "Please install 'webpack-cli' in addition to webpack itself to use the CLI."
+ );
+ console.error("-> When using npm: npm install webpack-cli -D");
+ console.error("-> When using yarn: yarn add webpack-cli -D");
+ process.exitCode = 1;
+}
diff --git a/buildin/global.js b/buildin/global.js
index 8b23b86c..35f3144e 100644
--- a/buildin/global.js
+++ b/buildin/global.js
@@ -7,11 +7,10 @@ g = (function() {
try {
// This works if eval is allowed (see CSP)
- g = g || Function("return this")() || (1,eval)("this");
-} catch(e) {
+ g = g || Function("return this")() || (1, eval)("this");
+} catch (e) {
// This works if the window reference is available
- if(typeof window === "object")
- g = window;
+ if (typeof window === "object") g = window;
}
// g can still be undefined, but nothing to do about it...
diff --git a/buildin/harmony-module.js b/buildin/harmony-module.js
index 0f5678b2..c1614658 100644
--- a/buildin/harmony-module.js
+++ b/buildin/harmony-module.js
@@ -1,8 +1,8 @@
module.exports = function(originalModule) {
- if(!originalModule.webpackPolyfill) {
+ if (!originalModule.webpackPolyfill) {
var module = Object.create(originalModule);
// module.parent = undefined by default
- if(!module.children) module.children = [];
+ if (!module.children) module.children = [];
Object.defineProperty(module, "loaded", {
enumerable: true,
get: function() {
@@ -16,7 +16,7 @@ module.exports = function(originalModule) {
}
});
Object.defineProperty(module, "exports", {
- enumerable: true,
+ enumerable: true
});
module.webpackPolyfill = 1;
}
diff --git a/buildin/module.js b/buildin/module.js
index 518a8c68..c92808b6 100644
--- a/buildin/module.js
+++ b/buildin/module.js
@@ -1,9 +1,9 @@
module.exports = function(module) {
- if(!module.webpackPolyfill) {
+ if (!module.webpackPolyfill) {
module.deprecate = function() {};
module.paths = [];
// module.parent = undefined by default
- if(!module.children) module.children = [];
+ if (!module.children) module.children = [];
Object.defineProperty(module, "loaded", {
enumerable: true,
get: function() {
diff --git a/ci/travis-install.sh b/ci/travis-install.sh
deleted file mode 100755
index 69ba4da1..00000000
--- a/ci/travis-install.sh
+++ /dev/null
@@ -1,12 +0,0 @@
-#!/bin/bash
-set -ev
-
-curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version 1.0.1
-
-export PATH=$HOME/.yarn/bin:$PATH
-
-yarn link --frozen-lockfile || true;
-
-yarn --frozen-lockfile
-
-yarn link webpack --frozen-lockfile
diff --git a/circle.yml b/circle.yml
index 10c07fe8..769cc725 100644
--- a/circle.yml
+++ b/circle.yml
@@ -8,7 +8,7 @@ machine:
dependencies:
pre:
- - case $CIRCLE_NODE_INDEX in 0) NODE_VERSION=4 ;; 1) NODE_VERSION=8 ;; esac; nvm install $NODE_VERSION && nvm alias default $NODE_VERSION
+ - case $CIRCLE_NODE_INDEX in 0) NODE_VERSION=6 ;; 1) NODE_VERSION=8 ;; esac; nvm install $NODE_VERSION && nvm alias default $NODE_VERSION
override:
- yarn
- yarn link || true && yarn link webpack
diff --git a/examples/README.md b/examples/README.md
index 5551b76c..3ab122ed 100644
--- a/examples/README.md
+++ b/examples/README.md
@@ -106,6 +106,9 @@
## Scope Hoisting
[scope-hoisting](scope-hoisting)
+## Side Effects
+[side-effects](side-effects)
+
## Source Map
[source-map](source-map)
diff --git a/examples/aggressive-merging/README.md b/examples/aggressive-merging/README.md
index 77129971..055f66b1 100644
--- a/examples/aggressive-merging/README.md
+++ b/examples/aggressive-merging/README.md
@@ -32,113 +32,122 @@ a big file...
var path = require("path");
var AggressiveMergingPlugin = require("../../lib/optimize/AggressiveMergingPlugin");
module.exports = {
+ // mode: "development" || "production",
entry: {
pageA: "./pageA",
pageB: "./pageB",
pageC: "./pageC"
},
output: {
- path: path.join(__dirname, "js"),
+ path: path.join(__dirname, "dist"),
filename: "[name].bundle.js",
chunkFilename: "[id].chunk.js"
},
plugins: [
new AggressiveMergingPlugin({
- minSizeReduce: 1.5,
- moveToParents: true
+ minSizeReduce: 1.5
})
- ]
+ ],
+ optimization: {
+ occurrenceOrder: true // To keep filename consistent between different modes (for example building only)
+ }
};
```
# Info
-## Uncompressed
+## Unoptimized
```
-Hash: 75bcce350a8b5f748873
-Version: webpack 3.5.1
+Hash: 0a1b2c3d4e5f6a7b8c9d
+Version: webpack 4.0.0-beta.2
Asset Size Chunks Chunk Names
- 0.chunk.js 5.76 kB 0 [emitted]
- 1.chunk.js 403 bytes 1 [emitted]
-pageB.bundle.js 6.42 kB 2 [emitted] pageB
-pageA.bundle.js 6.39 kB 3 [emitted] pageA
-pageC.bundle.js 6.18 kB 4 [emitted] pageC
+ 0.chunk.js 5.98 KiB 0 [emitted]
+ 1.chunk.js 405 bytes 1 [emitted]
+pageC.bundle.js 7.05 KiB 2 [emitted] pageC
+pageB.bundle.js 7.05 KiB 3 [emitted] pageB
+pageA.bundle.js 7.05 KiB 4 [emitted] pageA
Entrypoint pageA = pageA.bundle.js
Entrypoint pageB = pageB.bundle.js
Entrypoint pageC = pageC.bundle.js
-chunk {0} 0.chunk.js 5.55 kB {2} {3} [rendered]
- > aggressive-merge [3] ./pageA.js 1:0-3:2
- > aggressive-merge [4] ./pageB.js 1:0-3:2
- [2] ./common.js 5.55 kB {0} [built]
- amd require ./common [3] ./pageA.js 1:0-3:2
- amd require ./common [4] ./pageB.js 1:0-3:2
-chunk {1} 1.chunk.js 42 bytes {4} [rendered]
- > [5] ./pageC.js 1:0-3:2
- [0] ./a.js 21 bytes {1} {3} [built]
- cjs require ./a [3] ./pageA.js 2:8-22
- amd require ./a [5] ./pageC.js 1:0-3:2
- [1] ./b.js 21 bytes {1} {2} [built]
+chunk {0} 0.chunk.js 5.46 KiB <{3}> <{4}> [rendered]
+ > ./common [4] ./pageB.js 1:0-3:2
+ > ./common [5] ./pageA.js 1:0-3:2
+ [0] ./b.js 21 bytes {0} {1} [built]
+ cjs require ./b [3] ./pageC.js 2:17-31
cjs require ./b [4] ./pageB.js 2:8-22
- cjs require ./b [5] ./pageC.js 2:17-31
-chunk {2} pageB.bundle.js (pageB) 92 bytes [entry] [rendered]
- > pageB [4] ./pageB.js
- [1] ./b.js 21 bytes {1} {2} [built]
+ [1] ./a.js 21 bytes {0} {1} [built]
+ amd require ./a [3] ./pageC.js 1:0-3:2
+ cjs require ./a [5] ./pageA.js 2:8-22
+ [2] ./common.js 5.42 KiB {0} [built]
+ amd require ./common [4] ./pageB.js 1:0-3:2
+ amd require ./common [5] ./pageA.js 1:0-3:2
+chunk {1} 1.chunk.js 42 bytes <{2}> [rendered]
+ > ./a [3] ./pageC.js 1:0-3:2
+ [0] ./b.js 21 bytes {0} {1} [built]
+ cjs require ./b [3] ./pageC.js 2:17-31
cjs require ./b [4] ./pageB.js 2:8-22
- cjs require ./b [5] ./pageC.js 2:17-31
- [4] ./pageB.js 71 bytes {2} [built]
-chunk {3} pageA.bundle.js (pageA) 92 bytes [entry] [rendered]
- > pageA [3] ./pageA.js
- [0] ./a.js 21 bytes {1} {3} [built]
- cjs require ./a [3] ./pageA.js 2:8-22
- amd require ./a [5] ./pageC.js 1:0-3:2
- [3] ./pageA.js 71 bytes {3} [built]
-chunk {4} pageC.bundle.js (pageC) 70 bytes [entry] [rendered]
- > pageC [5] ./pageC.js
- [5] ./pageC.js 70 bytes {4} [built]
+ [1] ./a.js 21 bytes {0} {1} [built]
+ amd require ./a [3] ./pageC.js 1:0-3:2
+ cjs require ./a [5] ./pageA.js 2:8-22
+chunk {2} pageC.bundle.js (pageC) 70 bytes >{1}< [entry] [rendered]
+ > ./pageC pageC
+ [3] ./pageC.js 70 bytes {2} [built]
+ single entry ./pageC pageC
+chunk {3} pageB.bundle.js (pageB) 71 bytes >{0}< [entry] [rendered]
+ > ./pageB pageB
+ [4] ./pageB.js 71 bytes {3} [built]
+ single entry ./pageB pageB
+chunk {4} pageA.bundle.js (pageA) 71 bytes >{0}< [entry] [rendered]
+ > ./pageA pageA
+ [5] ./pageA.js 71 bytes {4} [built]
+ single entry ./pageA pageA
```
-## Minimized (uglify-js, no zip)
+## Production mode
```
-Hash: 75bcce350a8b5f748873
-Version: webpack 3.5.1
- Asset Size Chunks Chunk Names
- 0.chunk.js 75 bytes 0 [emitted]
- 1.chunk.js 78 bytes 1 [emitted]
-pageB.bundle.js 1.46 kB 2 [emitted] pageB
-pageA.bundle.js 1.46 kB 3 [emitted] pageA
-pageC.bundle.js 1.44 kB 4 [emitted] pageC
+Hash: 0a1b2c3d4e5f6a7b8c9d
+Version: webpack 4.0.0-beta.2
+ Asset Size Chunks Chunk Names
+ 0.chunk.js 173 bytes 0, 1 [emitted]
+ 1.chunk.js 118 bytes 1 [emitted]
+pageC.bundle.js 1.68 KiB 2 [emitted] pageC
+pageB.bundle.js 1.66 KiB 3 [emitted] pageB
+pageA.bundle.js 1.66 KiB 4 [emitted] pageA
Entrypoint pageA = pageA.bundle.js
Entrypoint pageB = pageB.bundle.js
Entrypoint pageC = pageC.bundle.js
-chunk {0} 0.chunk.js 5.55 kB {2} {3} [rendered]
- > aggressive-merge [3] ./pageA.js 1:0-3:2
- > aggressive-merge [4] ./pageB.js 1:0-3:2
- [2] ./common.js 5.55 kB {0} [built]
- amd require ./common [3] ./pageA.js 1:0-3:2
- amd require ./common [4] ./pageB.js 1:0-3:2
-chunk {1} 1.chunk.js 42 bytes {4} [rendered]
- > [5] ./pageC.js 1:0-3:2
- [0] ./a.js 21 bytes {1} {3} [built]
- cjs require ./a [3] ./pageA.js 2:8-22
- amd require ./a [5] ./pageC.js 1:0-3:2
- [1] ./b.js 21 bytes {1} {2} [built]
+chunk {0} 0.chunk.js 5.46 KiB <{3}> <{4}> [rendered]
+ > ./common [4] ./pageB.js 1:0-3:2
+ > ./common [5] ./pageA.js 1:0-3:2
+ [0] ./b.js 21 bytes {0} {1} [built]
+ cjs require ./b [3] ./pageC.js 2:17-31
cjs require ./b [4] ./pageB.js 2:8-22
- cjs require ./b [5] ./pageC.js 2:17-31
-chunk {2} pageB.bundle.js (pageB) 92 bytes [entry] [rendered]
- > pageB [4] ./pageB.js
- [1] ./b.js 21 bytes {1} {2} [built]
+ [1] ./a.js 21 bytes {0} {1} [built]
+ amd require ./a [3] ./pageC.js 1:0-3:2
+ cjs require ./a [5] ./pageA.js 2:8-22
+ [2] ./common.js 5.42 KiB {0} [built]
+ amd require ./common [4] ./pageB.js 1:0-3:2
+ amd require ./common [5] ./pageA.js 1:0-3:2
+chunk {1} 1.chunk.js 42 bytes <{2}> [rendered]
+ > ./a [3] ./pageC.js 1:0-3:2
+ [0] ./b.js 21 bytes {0} {1} [built]
+ cjs require ./b [3] ./pageC.js 2:17-31
cjs require ./b [4] ./pageB.js 2:8-22
- cjs require ./b [5] ./pageC.js 2:17-31
- [4] ./pageB.js 71 bytes {2} [built]
-chunk {3} pageA.bundle.js (pageA) 92 bytes [entry] [rendered]
- > pageA [3] ./pageA.js
- [0] ./a.js 21 bytes {1} {3} [built]
- cjs require ./a [3] ./pageA.js 2:8-22
- amd require ./a [5] ./pageC.js 1:0-3:2
- [3] ./pageA.js 71 bytes {3} [built]
-chunk {4} pageC.bundle.js (pageC) 70 bytes [entry] [rendered]
- > pageC [5] ./pageC.js
- [5] ./pageC.js 70 bytes {4} [built]
+ [1] ./a.js 21 bytes {0} {1} [built]
+ amd require ./a [3] ./pageC.js 1:0-3:2
+ cjs require ./a [5] ./pageA.js 2:8-22
+chunk {2} pageC.bundle.js (pageC) 70 bytes >{1}< [entry] [rendered]
+ > ./pageC pageC
+ [3] ./pageC.js 70 bytes {2} [built]
+ single entry ./pageC pageC
+chunk {3} pageB.bundle.js (pageB) 71 bytes >{0}< [entry] [rendered]
+ > ./pageB pageB
+ [4] ./pageB.js 71 bytes {3} [built]
+ single entry ./pageB pageB
+chunk {4} pageA.bundle.js (pageA) 71 bytes >{0}< [entry] [rendered]
+ > ./pageA pageA
+ [5] ./pageA.js 71 bytes {4} [built]
+ single entry ./pageA pageA
```
diff --git a/examples/aggressive-merging/template.md b/examples/aggressive-merging/template.md
index fbe03602..5d330393 100644
--- a/examples/aggressive-merging/template.md
+++ b/examples/aggressive-merging/template.md
@@ -28,14 +28,14 @@ a big file...
# Info
-## Uncompressed
+## Unoptimized
```
{{stdout}}
```
-## Minimized (uglify-js, no zip)
+## Production mode
```
-{{min:stdout}}
+{{production:stdout}}
```
diff --git a/examples/aggressive-merging/webpack.config.js b/examples/aggressive-merging/webpack.config.js
index 9b651f2f..46ab6e9c 100644
--- a/examples/aggressive-merging/webpack.config.js
+++ b/examples/aggressive-merging/webpack.config.js
@@ -1,20 +1,23 @@
var path = require("path");
var AggressiveMergingPlugin = require("../../lib/optimize/AggressiveMergingPlugin");
module.exports = {
+ // mode: "development" || "production",
entry: {
pageA: "./pageA",
pageB: "./pageB",
pageC: "./pageC"
},
output: {
- path: path.join(__dirname, "js"),
+ path: path.join(__dirname, "dist"),
filename: "[name].bundle.js",
chunkFilename: "[id].chunk.js"
},
plugins: [
new AggressiveMergingPlugin({
- minSizeReduce: 1.5,
- moveToParents: true
+ minSizeReduce: 1.5
})
- ]
+ ],
+ optimization: {
+ occurrenceOrder: true // To keep filename consistent between different modes (for example building only)
+ }
};
diff --git a/examples/build-common.js b/examples/build-common.js
index 24b61463..afca1e4d 100644
--- a/examples/build-common.js
+++ b/examples/build-common.js
@@ -8,31 +8,44 @@ const cp = require("child_process");
const path = require("path");
const tc = require("./template-common");
const fs = require("fs");
+const async = require("neo-async");
const extraArgs = "";
-const targetArgs = global.NO_TARGET_ARGS ? "" : " ./example.js js/output.js";
+const targetArgs = global.NO_TARGET_ARGS ? "" : " ./example.js -o dist/output.js ";
const displayReasons = global.NO_REASONS ? "" : " --display-reasons --display-used-exports --display-provided-exports";
-cp.exec(`node ${path.resolve(__dirname, "../bin/webpack.js")} ${displayReasons} --display-chunks --display-max-modules 99999 --display-origins --display-entrypoints --output-public-path "js/" -p ${extraArgs} ${targetArgs}`, function(error, stdout, stderr) {
- if(stderr)
- console.log(stderr);
- if(error !== null)
- console.log(error);
- let readme;
- try {
- readme = tc.replaceResults(fs.readFileSync(require("path").join(process.cwd(), "template.md"), "utf-8"), process.cwd(), stdout.replace(/[\r\n]*$/, ""), "min");
- } catch(e) {
- console.log(stderr);
- throw e;
+const commonArgs = `--display-chunks --display-max-modules 99999 --display-origins --display-entrypoints --output-public-path "dist/" ${extraArgs} ${targetArgs}`;
+
+let readme = fs.readFileSync(require("path").join(process.cwd(), "template.md"), "utf-8");
+
+const doCompileAndReplace = (args, prefix, callback) => {
+ if(!tc.needResults(readme, prefix)) {
+ callback();
+ return;
}
- cp.exec(`node ${path.resolve(__dirname, "../bin/webpack.js")} ${displayReasons} --display-chunks --display-max-modules 99999 --display-origins --display-entrypoints --output-public-path "js/" --output-pathinfo ${extraArgs} ${targetArgs}`, function(error, stdout, stderr) {
- console.log(stdout);
+ if(fs.existsSync("dist"))
+ for(const file of fs.readdirSync("dist"))
+ fs.unlinkSync(`dist/${file}`);
+ cp.exec(`node ${path.resolve(__dirname, "../bin/webpack.js")} ${args} ${displayReasons} ${commonArgs}`, (error, stdout, stderr) => {
if(stderr)
console.log(stderr);
if(error !== null)
console.log(error);
- readme = tc.replaceResults(readme, process.cwd(), stdout.replace(/[\r\n]*$/, ""));
- readme = tc.replaceBase(readme);
- fs.writeFile("README.md", readme, "utf-8", function() {});
+ try {
+ readme = tc.replaceResults(readme, process.cwd(), stdout.replace(/[\r?\n]*$/, ""), prefix);
+ } catch(e) {
+ console.log(stderr);
+ throw e;
+ }
+ callback();
});
+};
+
+async.series([
+ callback => doCompileAndReplace("--mode production", "production", callback),
+ callback => doCompileAndReplace("--mode development --devtool none", "development", callback),
+ callback => doCompileAndReplace("--mode none --output-pathinfo", "", callback)
+], () => {
+ readme = tc.replaceBase(readme);
+ fs.writeFile("README.md", readme, "utf-8", function() {});
});
diff --git a/examples/buildAll.js b/examples/buildAll.js
index 5065695e..7ff3a9e3 100644
--- a/examples/buildAll.js
+++ b/examples/buildAll.js
@@ -7,9 +7,17 @@ const cmds = examples.map(function(dirname) {
return "cd " + dirname + " && node build.js";
});
+let failed = 0;
let i = 0;
for(const cmd of cmds) {
console.log(`[${++i}/${cmds.length}] ${cmd}`);
- cp.execSync(cmd, { encoding: "utf-8" });
+ try {
+ cp.execSync(cmd, { encoding: "utf-8" });
+ } catch(e) {
+ failed++;
+ console.log(e);
+ }
}
console.log("done");
+if(failed > 0)
+ console.log(`${failed} failed`);
diff --git a/examples/chunkhash/README.md b/examples/chunkhash/README.md
index f4cdfb21..526465a3 100644
--- a/examples/chunkhash/README.md
+++ b/examples/chunkhash/README.md
@@ -1,54 +1,37 @@
A common challenge with combining `[chunkhash]` and Code Splitting is that the entry chunk includes the webpack runtime and with it the chunkhash mappings. This means it's always updated and the `[chunkhash]` is pretty useless, because this chunk won't be cached.
-A very simple solution to this problem is to create another chunk which contains only the webpack runtime (including chunkhash map). This can be achieved by the CommonsChunkPlugin (or if the CommonsChunkPlugin is already used by passing multiple names to the CommonChunkPlugin). To avoid the additional request for another chunk, this pretty small chunk can be inlined into the HTML page.
+A very simple solution to this problem is to create another chunk which contains only the webpack runtime (including chunkhash map). This can be achieved with the `optimization.runtimeChunk` options. To avoid the additional request for another chunk, this pretty small chunk can be inlined into the HTML page.
The configuration required for this is:
* use `[chunkhash]` in `output.filename` (Note that this example doesn't do this because of the example generator infrastructure, but you should)
-* use `[chunkhash]` in `output.chunkFilename`
-* `CommonsChunkPlugin`
+* use `[chunkhash]` in `output.chunkFilename` (Note that this example doesn't do this because of the example generator infrastructure, but you should)
# example.js
``` javascript
-import vendor from "./vendor";
// some module
import("./async1");
import("./async2");
```
-# vendor.js
-
-``` javascript
-// some vendor lib (should be in common chunk)
-export default 123;
-```
-
# webpack.config.js
``` javascript
var path = require("path");
-var webpack = require("../../");
module.exports = {
+ // mode: "development || "production",
entry: {
- main: "./example",
- common: ["./vendor"] // optional
+ main: "./example"
+ },
+ optimization: {
+ runtimeChunk: true
},
output: {
- path: path.join(__dirname, "js"),
+ path: path.join(__dirname, "dist"),
filename: "[name].[chunkhash].js",
- chunkFilename: "[chunkhash].js"
- },
- plugins: [
- new webpack.optimize.CommonsChunkPlugin({
- names: ["common", "manifest"]
- })
- /* without the "common" chunk:
- new webpack.optimize.CommonsChunkPlugin({
- name: "manifest"
- })
- */
- ]
+ chunkFilename: "[name].[chunkhash].js"
+ }
};
```
@@ -60,149 +43,296 @@ module.exports = {
</head>
<body>
-<!-- inlined minimized file "manifest.[chunkhash].js" -->
+<!-- inlined minimized file "runtime~main.[chunkhash].js" -->
<script>
-!function(e){function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}var r=window.webpackJsonp;window.webpackJsonp=function(t,c,a){for(var u,i,f,d=0,s=[];d<t.length;d++)i=t[d],o[i]&&s.push(o[i][0]),o[i]=0;for(u in c)Object.prototype.hasOwnProperty.call(c,u)&&(e[u]=c[u]);for(r&&r(t,c,a);s.length;)s.shift()();if(a)for(d=0;d<a.length;d++)f=n(n.s=a[d]);return f};var t={},o={4:0};n.e=function(e){function r(){u.onerror=u.onload=null,clearTimeout(i);var n=o[e];0!==n&&(n&&n[1](new Error("Loading chunk "+e+" failed.")),o[e]=void 0)}var t=o[e];if(0===t)return new Promise(function(e){e()});if(t)return t[2];var c=new Promise(function(n,r){t=o[e]=[n,r]});t[2]=c;var a=document.getElementsByTagName("head")[0],u=document.createElement("script");u.type="text/javascript",u.charset="utf-8",u.async=!0,u.timeout=12e4,n.nc&&u.setAttribute("nonce",n.nc),u.src=n.p+""+{0:"3db3fdaf96bbdadce99a",1:"7c1138cf80dd374c367e",2:"543257d0ba12aefbc71b",3:"15bdf078724c793dc604"}[e]+".js";var i=setTimeout(r,12e4);return u.onerror=u.onload=r,a.appendChild(u),c},n.m=e,n.c=t,n.d=function(e,r,t){n.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:t})},n.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(r,"a",r),r},n.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},n.p="js/",n.oe=function(e){throw console.error(e),e}}([]);
+!function(e){function r(r){for(var n,o,i=r[0],c=r[1],s=r[2],p=0,f=[];p<i.length;p++)o=i[p],u[o]&&f.push(u[o][0]),u[o]=0;for(n in c)Object.prototype.hasOwnProperty.call(c,n)&&(e[n]=c[n]);for(l&&l(r);f.length;)f.shift()();return a.push.apply(a,s||[]),t()}function t(){for(var e,r=0;r<a.length;r++){for(var t=a[r],o=!0,i=1;i<t.length;i++){var c=t[i];0!==u[c]&&(o=!1)}o&&(a.splice(r--,1),e=n(n.s=t[0]))}return e}function n(r){if(o[r])return o[r].exports;var t=o[r]={i:r,l:!1,exports:{}};return e[r].call(t.exports,t,t.exports,n),t.l=!0,t.exports}var o={},u={2:0},a=[];n.e=function(e){var r=[],t=u[e];if(0!==t)if(t)r.push(t[2]);else{var o=new Promise(function(r,n){t=u[e]=[r,n]});r.push(t[2]=o);var a=document.getElementsByTagName("head")[0],i=document.createElement("script");i.charset="utf-8",i.timeout=12e4,n.nc&&i.setAttribute("nonce",n.nc),i.src=n.p+""+({}[e]||e)+".[chunkhash].js";var c=setTimeout(function(){s({type:"timeout",target:i})},12e4);i.onerror=i.onload=s;function s(r){i.onerror=i.onload=null,clearTimeout(c);var t=u[e];if(0!==t){if(t){var n=r&&("load"===r.type?"missing":r.type),o=r&&r.target&&r.target.src,a=new Error("Loading chunk "+e+" failed.\n("+n+": "+o+")");a.type=n,a.request=o,t[1](a)}u[e]=void 0}}a.appendChild(i)}return Promise.all(r)},n.m=e,n.c=o,n.d=function(e,r,t){n.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:t})},n.r=function(e){Object.defineProperty(e,"__esModule",{value:!0})},n.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(r,"a",r),r},n.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},n.p="dist/",n.oe=function(e){throw console.error(e),e};var i=window.webpackJsonp=window.webpackJsonp||[],c=i.push.bind(i);i.push=r,i=i.slice();for(var s=0;s<i.length;s++)r(i[s]);var l=c;t()}([]);
</script>
-<!-- optional when using the CommonChunkPlugin for vendor modules -->
-<script src="js/common.[chunkhash].js"></script>
-
-<script src="js/main.[chunkhash].js"></script>
+<script src="dist/main.[chunkhash].js"></script>
</body>
</html>
```
-# js/common.[chunkhash].js
+# dist/runtime~main.[chunkhash].js
-``` javascript
-webpackJsonp([2],[
-/* 0 */
-/*!*******************!*\
- !*** ./vendor.js ***!
- \*******************/
-/*! exports provided: default */
-/*! all exports used */
-/***/ (function(module, __webpack_exports__, __webpack_require__) {
-
-"use strict";
-Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
-// some vendor lib (should be in common chunk)
-/* harmony default export */ __webpack_exports__["default"] = (123);
-
-
-/***/ }),
-/* 1 */,
-/* 2 */
-/*!**********************!*\
- !*** multi ./vendor ***!
- \**********************/
-/*! no static exports found */
-/*! all exports used */
-/***/ (function(module, exports, __webpack_require__) {
+<details><summary><code>/******/ (function(modules) { /* webpackBootstrap */ })</code></summary>
-module.exports = __webpack_require__(/*! ./vendor */0);
+``` javascript
+/******/ (function(modules) { // webpackBootstrap
+/******/ // install a JSONP callback for chunk loading
+/******/ function webpackJsonpCallback(data) {
+/******/ var chunkIds = data[0];
+/******/ var moreModules = data[1]
+/******/ var executeModules = data[2];
+/******/ // add "moreModules" to the modules object,
+/******/ // then flag all "chunkIds" as loaded and fire callback
+/******/ var moduleId, chunkId, i = 0, resolves = [];
+/******/ for(;i < chunkIds.length; i++) {
+/******/ chunkId = chunkIds[i];
+/******/ if(installedChunks[chunkId]) {
+/******/ resolves.push(installedChunks[chunkId][0]);
+/******/ }
+/******/ installedChunks[chunkId] = 0;
+/******/ }
+/******/ for(moduleId in moreModules) {
+/******/ if(Object.prototype.hasOwnProperty.call(moreModules, moduleId)) {
+/******/ modules[moduleId] = moreModules[moduleId];
+/******/ }
+/******/ }
+/******/ if(parentJsonpFunction) parentJsonpFunction(data);
+/******/ while(resolves.length) {
+/******/ resolves.shift()();
+/******/ }
+/******/
+/******/ // add entry modules from loaded chunk to deferred list
+/******/ deferredModules.push.apply(deferredModules, executeModules || []);
+/******/
+/******/ // run deferred modules when all chunks ready
+/******/ return checkDeferredModules();
+/******/ };
+/******/ function checkDeferredModules() {
+/******/ var result;
+/******/ for(var i = 0; i < deferredModules.length; i++) {
+/******/ var deferredModule = deferredModules[i];
+/******/ var fullfilled = true;
+/******/ for(var j = 1; j < deferredModule.length; j++) {
+/******/ var depId = deferredModule[j];
+/******/ if(installedChunks[depId] !== 0) fullfilled = false;
+/******/ }
+/******/ if(fullfilled) {
+/******/ deferredModules.splice(i--, 1);
+/******/ result = __webpack_require__(__webpack_require__.s = deferredModule[0]);
+/******/ }
+/******/ }
+/******/ return result;
+/******/ }
+/******/
+/******/ // The module cache
+/******/ var installedModules = {};
+/******/
+/******/ // object to store loaded and loading chunks
+/******/ var installedChunks = {
+/******/ 3: 0
+/******/ };
+/******/
+/******/ var deferredModules = [];
+/******/
+/******/ // The require function
+/******/ function __webpack_require__(moduleId) {
+/******/
+/******/ // Check if module is in cache
+/******/ if(installedModules[moduleId]) {
+/******/ return installedModules[moduleId].exports;
+/******/ }
+/******/ // Create a new module (and put it into the cache)
+/******/ var module = installedModules[moduleId] = {
+/******/ i: moduleId,
+/******/ l: false,
+/******/ exports: {}
+/******/ };
+/******/
+/******/ // Execute the module function
+/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
+/******/
+/******/ // Flag the module as loaded
+/******/ module.l = true;
+/******/
+/******/ // Return the exports of the module
+/******/ return module.exports;
+/******/ }
+/******/
+/******/ // This file contains only the entry chunk.
+/******/ // The chunk loading function for additional chunks
+/******/ __webpack_require__.e = function requireEnsure(chunkId) {
+/******/ var promises = [];
+/******/
+/******/
+/******/ // JSONP chunk loading for javascript
+/******/
+/******/ var installedChunkData = installedChunks[chunkId];
+/******/ if(installedChunkData !== 0) { // 0 means "already installed".
+/******/
+/******/ // a Promise means "currently loading".
+/******/ if(installedChunkData) {
+/******/ promises.push(installedChunkData[2]);
+/******/ } else {
+/******/ // setup Promise in chunk cache
+/******/ var promise = new Promise(function(resolve, reject) {
+/******/ installedChunkData = installedChunks[chunkId] = [resolve, reject];
+/******/ });
+/******/ promises.push(installedChunkData[2] = promise);
+/******/
+/******/ // start chunk loading
+/******/ var head = document.getElementsByTagName('head')[0];
+/******/ var script = document.createElement('script');
+/******/
+/******/ script.charset = 'utf-8';
+/******/ script.timeout = 120000;
+/******/
+/******/ if (__webpack_require__.nc) {
+/******/ script.setAttribute("nonce", __webpack_require__.nc);
+/******/ }
+/******/ script.src = __webpack_require__.p + "" + ({}[chunkId]||chunkId) + ".[chunkhash].js";
+/******/ var timeout = setTimeout(function(){
+/******/ onScriptComplete({ type: 'timeout', target: script });
+/******/ }, 120000);
+/******/ script.onerror = script.onload = onScriptComplete;
+/******/ function onScriptComplete(event) {
+/******/ // avoid mem leaks in IE.
+/******/ script.onerror = script.onload = null;
+/******/ clearTimeout(timeout);
+/******/ var chunk = installedChunks[chunkId];
+/******/ if(chunk !== 0) {
+/******/ if(chunk) {
+/******/ var errorType = event && (event.type === 'load' ? 'missing' : event.type);
+/******/ var realSrc = event && event.target && event.target.src;
+/******/ var error = new Error('Loading chunk ' + chunkId + ' failed.\n(' + errorType + ': ' + realSrc + ')');
+/******/ error.type = errorType;
+/******/ error.request = realSrc;
+/******/ chunk[1](error);
+/******/ }
+/******/ installedChunks[chunkId] = undefined;
+/******/ }
+/******/ };
+/******/ head.appendChild(script);
+/******/ }
+/******/ }
+/******/ return Promise.all(promises);
+/******/ };
+/******/
+/******/ // expose the modules object (__webpack_modules__)
+/******/ __webpack_require__.m = modules;
+/******/
+/******/ // expose the module cache
+/******/ __webpack_require__.c = installedModules;
+/******/
+/******/ // define getter function for harmony exports
+/******/ __webpack_require__.d = function(exports, name, getter) {
+/******/ if(!__webpack_require__.o(exports, name)) {
+/******/ Object.defineProperty(exports, name, {
+/******/ configurable: false,
+/******/ enumerable: true,
+/******/ get: getter
+/******/ });
+/******/ }
+/******/ };
+/******/
+/******/ // define __esModule on exports
+/******/ __webpack_require__.r = function(exports) {
+/******/ Object.defineProperty(exports, '__esModule', { value: true });
+/******/ };
+/******/
+/******/ // getDefaultExport function for compatibility with non-harmony modules
+/******/ __webpack_require__.n = function(module) {
+/******/ var getter = module && module.__esModule ?
+/******/ function getDefault() { return module['default']; } :
+/******/ function getModuleExports() { return module; };
+/******/ __webpack_require__.d(getter, 'a', getter);
+/******/ return getter;
+/******/ };
+/******/
+/******/ // Object.prototype.hasOwnProperty.call
+/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
+/******/
+/******/ // __webpack_public_path__
+/******/ __webpack_require__.p = "dist/";
+/******/
+/******/ // on error function for async loading
+/******/ __webpack_require__.oe = function(err) { console.error(err); throw err; };
+/******/
+/******/ var jsonpArray = window["webpackJsonp"] = window["webpackJsonp"] || [];
+/******/ var oldJsonpFunction = jsonpArray.push.bind(jsonpArray);
+/******/ jsonpArray.push = webpackJsonpCallback;
+/******/ jsonpArray = jsonpArray.slice();
+/******/ for(var i = 0; i < jsonpArray.length; i++) webpackJsonpCallback(jsonpArray[i]);
+/******/ var parentJsonpFunction = oldJsonpFunction;
+/******/
+/******/
+/******/ // run deferred modules from other chunks
+/******/ checkDeferredModules();
+/******/ })
+/************************************************************************/
+```
+</details>
-/***/ })
-],[2]);
+``` javascript
+/******/ ([]);
```
-# js/main.[chunkhash].js
+# dist/main.[chunkhash].js
``` javascript
-webpackJsonp([3],[
-/* 0 */,
-/* 1 */
+(window["webpackJsonp"] = window["webpackJsonp"] || []).push([[0],[
+/* 0 */
/*!********************!*\
!*** ./example.js ***!
\********************/
-/*! exports provided: */
-/*! all exports used */
-/***/ (function(module, __webpack_exports__, __webpack_require__) {
-
-"use strict";
-Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
-/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__vendor__ = __webpack_require__(/*! ./vendor */ 0);
+/*! no static exports found */
+/***/ (function(module, exports, __webpack_require__) {
// some module
-__webpack_require__.e/* import() */(1).then(__webpack_require__.bind(null, /*! ./async1 */ 3));
-__webpack_require__.e/* import() */(0).then(__webpack_require__.bind(null, /*! ./async2 */ 4));
+__webpack_require__.e(/*! import() */ 1).then(function() { var module = __webpack_require__(/*! ./async1 */ 1); return typeof module === "object" && module && module.__esModule ? module : { /* fake namespace object */ "default": module }; });
+__webpack_require__.e(/*! import() */ 2).then(function() { var module = __webpack_require__(/*! ./async2 */ 2); return typeof module === "object" && module && module.__esModule ? module : { /* fake namespace object */ "default": module }; });
/***/ })
-],[1]);
+],[[0,3]]]);
```
# Info
-## Uncompressed
+## Unoptimized
```
-Hash: 49023fec553882c3285c
-Version: webpack 3.5.1
- Asset Size Chunks Chunk Names
-3db3fdaf96bbdadce99a.js 238 bytes 0 [emitted]
-7c1138cf80dd374c367e.js 238 bytes 1 [emitted]
- common.[chunkhash].js 732 bytes 2 [emitted] common
- main.[chunkhash].js 656 bytes 3 [emitted] main
- manifest.[chunkhash].js 5.89 kB 4 [emitted] manifest
-Entrypoint main = manifest.[chunkhash].js common.[chunkhash].js main.[chunkhash].js
-Entrypoint common = manifest.[chunkhash].js common.[chunkhash].js
-chunk {0} 3db3fdaf96bbdadce99a.js 29 bytes {3} [rendered]
- > [1] ./example.js 4:0-18
- [4] ./async2.js 29 bytes {0} [built]
- import() ./async2 [1] ./example.js 4:0-18
-chunk {1} 7c1138cf80dd374c367e.js 29 bytes {3} [rendered]
- > [1] ./example.js 3:0-18
- [3] ./async1.js 29 bytes {1} [built]
- import() ./async1 [1] ./example.js 3:0-18
-chunk {2} common.[chunkhash].js (common) 97 bytes {4} [initial] [rendered]
- > common [2] multi ./vendor
- [0] ./vendor.js 69 bytes {2} [built]
- [exports: default]
- harmony import ./vendor [1] ./example.js 1:0-30
- single entry ./vendor [2] multi ./vendor common:100000
- [2] multi ./vendor 28 bytes {2} [built]
-chunk {3} main.[chunkhash].js (main) 90 bytes {2} [initial] [rendered]
- > main [1] ./example.js
- [1] ./example.js 90 bytes {3} [built]
- [no exports]
-chunk {4} manifest.[chunkhash].js (manifest) 0 bytes [entry] [rendered]
+Hash: 0a1b2c3d4e5f6a7b8c9d
+Version: webpack 4.0.0-beta.2
+ Asset Size Chunks Chunk Names
+ main.[chunkhash].js 768 bytes 0 [emitted] main
+ 1.[chunkhash].js 270 bytes 1 [emitted]
+ 2.[chunkhash].js 264 bytes 2 [emitted]
+runtime~main.[chunkhash].js 7.49 KiB 3 [emitted] runtime~main
+Entrypoint main = runtime~main.[chunkhash].js main.[chunkhash].js
+chunk {0} main.[chunkhash].js (main) 58 bytes ={3}= >{1}< >{2}< [initial] [rendered]
+ > ./example main
+ [0] ./example.js 58 bytes {0} [built]
+ single entry ./example main
+chunk {1} 1.[chunkhash].js 29 bytes <{0}> <{3}> [rendered]
+ > ./async1 [0] ./example.js 2:0-18
+ [1] ./async1.js 29 bytes {1} [built]
+ import() ./async1 [0] ./example.js 2:0-18
+chunk {2} 2.[chunkhash].js 29 bytes <{0}> <{3}> [rendered]
+ > ./async2 [0] ./example.js 3:0-18
+ [2] ./async2.js 29 bytes {2} [built]
+ import() ./async2 [0] ./example.js 3:0-18
+chunk {3} runtime~main.[chunkhash].js (runtime~main) 0 bytes ={0}= >{1}< >{2}< [entry] [rendered]
+ > ./example main
```
-## Minimized (uglify-js, no zip)
+## Production mode
```
-Hash: 49023fec553882c3285c
-Version: webpack 3.5.1
- Asset Size Chunks Chunk Names
-3db3fdaf96bbdadce99a.js 38 bytes 0 [emitted]
-7c1138cf80dd374c367e.js 38 bytes 1 [emitted]
- common.[chunkhash].js 150 bytes 2 [emitted] common
- main.[chunkhash].js 165 bytes 3 [emitted] main
- manifest.[chunkhash].js 1.46 kB 4 [emitted] manifest
-Entrypoint main = manifest.[chunkhash].js common.[chunkhash].js main.[chunkhash].js
-Entrypoint common = manifest.[chunkhash].js common.[chunkhash].js
-chunk {0} 3db3fdaf96bbdadce99a.js 29 bytes {3} [rendered]
- > [1] ./example.js 4:0-18
- [4] ./async2.js 29 bytes {0} [built]
- import() ./async2 [1] ./example.js 4:0-18
-chunk {1} 7c1138cf80dd374c367e.js 29 bytes {3} [rendered]
- > [1] ./example.js 3:0-18
- [3] ./async1.js 29 bytes {1} [built]
- import() ./async1 [1] ./example.js 3:0-18
-chunk {2} common.[chunkhash].js (common) 97 bytes {4} [initial] [rendered]
- > common [2] multi ./vendor
- [0] ./vendor.js 69 bytes {2} [built]
- [exports: default]
- harmony import ./vendor [1] ./example.js 1:0-30
- single entry ./vendor [2] multi ./vendor common:100000
- [2] multi ./vendor 28 bytes {2} [built]
-chunk {3} main.[chunkhash].js (main) 90 bytes {2} [initial] [rendered]
- > main [1] ./example.js
- [1] ./example.js 90 bytes {3} [built]
- [no exports]
-chunk {4} manifest.[chunkhash].js (manifest) 0 bytes [entry] [rendered]
-```
\ No newline at end of file
+Hash: 0a1b2c3d4e5f6a7b8c9d
+Version: webpack 4.0.0-beta.2
+ Asset Size Chunks Chunk Names
+ 0.[chunkhash].js 77 bytes 0 [emitted]
+ 1.[chunkhash].js 78 bytes 1 [emitted]
+runtime~main.[chunkhash].js 1.76 KiB 2 [emitted] runtime~main
+ main.[chunkhash].js 269 bytes 3 [emitted] main
+Entrypoint main = runtime~main.[chunkhash].js main.[chunkhash].js
+chunk {0} 0.[chunkhash].js 29 bytes <{2}> <{3}> [rendered]
+ > ./async2 [0] ./example.js 3:0-18
+ [1] ./async2.js 29 bytes {0} [built]
+ import() ./async2 [0] ./example.js 3:0-18
+chunk {1} 1.[chunkhash].js 29 bytes <{2}> <{3}> [rendered]
+ > ./async1 [0] ./example.js 2:0-18
+ [2] ./async1.js 29 bytes {1} [built]
+ import() ./async1 [0] ./example.js 2:0-18
+chunk {2} runtime~main.[chunkhash].js (runtime~main) 0 bytes ={3}= >{0}< >{1}< [entry] [rendered]
+ > ./example main
+chunk {3} main.[chunkhash].js (main) 58 bytes ={2}= >{0}< >{1}< [initial] [rendered]
+ > ./example main
+ [0] ./example.js 58 bytes {3} [built]
+ single entry ./example main
+```
diff --git a/examples/chunkhash/example.js b/examples/chunkhash/example.js
index 5588ac50..284869d0 100644
--- a/examples/chunkhash/example.js
+++ b/examples/chunkhash/example.js
@@ -1,4 +1,3 @@
-import vendor from "./vendor";
// some module
import("./async1");
import("./async2");
diff --git a/examples/chunkhash/template.md b/examples/chunkhash/template.md
index c6d4e1cf..b7df1a72 100644
--- a/examples/chunkhash/template.md
+++ b/examples/chunkhash/template.md
@@ -1,12 +1,11 @@
A common challenge with combining `[chunkhash]` and Code Splitting is that the entry chunk includes the webpack runtime and with it the chunkhash mappings. This means it's always updated and the `[chunkhash]` is pretty useless, because this chunk won't be cached.
-A very simple solution to this problem is to create another chunk which contains only the webpack runtime (including chunkhash map). This can be achieved by the CommonsChunkPlugin (or if the CommonsChunkPlugin is already used by passing multiple names to the CommonChunkPlugin). To avoid the additional request for another chunk, this pretty small chunk can be inlined into the HTML page.
+A very simple solution to this problem is to create another chunk which contains only the webpack runtime (including chunkhash map). This can be achieved with the `optimization.runtimeChunk` options. To avoid the additional request for another chunk, this pretty small chunk can be inlined into the HTML page.
The configuration required for this is:
* use `[chunkhash]` in `output.filename` (Note that this example doesn't do this because of the example generator infrastructure, but you should)
-* use `[chunkhash]` in `output.chunkFilename`
-* `CommonsChunkPlugin`
+* use `[chunkhash]` in `output.chunkFilename` (Note that this example doesn't do this because of the example generator infrastructure, but you should)
# example.js
@@ -14,12 +13,6 @@ The configuration required for this is:
{{example.js}}
```
-# vendor.js
-
-``` javascript
-{{vendor.js}}
-```
-
# webpack.config.js
``` javascript
@@ -34,42 +27,39 @@ The configuration required for this is:
</head>
<body>
-<!-- inlined minimized file "manifest.[chunkhash].js" -->
+<!-- inlined minimized file "runtime~main.[chunkhash].js" -->
<script>
-{{min:js/manifest.chunkhash.js}}
+{{production:dist/runtime~main.chunkhash.js}}
</script>
-<!-- optional when using the CommonChunkPlugin for vendor modules -->
-<script src="js/common.[chunkhash].js"></script>
-
-<script src="js/main.[chunkhash].js"></script>
+<script src="dist/main.[chunkhash].js"></script>
</body>
</html>
```
-# js/common.[chunkhash].js
+# dist/runtime~main.[chunkhash].js
``` javascript
-{{js/common.chunkhash.js}}
+{{dist/runtime~main.chunkhash.js}}
```
-# js/main.[chunkhash].js
+# dist/main.[chunkhash].js
``` javascript
-{{js/main.chunkhash.js}}
+{{dist/main.chunkhash.js}}
```
# Info
-## Uncompressed
+## Unoptimized
```
{{stdout}}
```
-## Minimized (uglify-js, no zip)
+## Production mode
```
-{{min:stdout}}
-```
\ No newline at end of file
+{{production:stdout}}
+```
diff --git a/examples/chunkhash/vendor.js b/examples/chunkhash/vendor.js
deleted file mode 100644
index ac0104f5..00000000
--- a/examples/chunkhash/vendor.js
+++ /dev/null
@@ -1,2 +0,0 @@
-// some vendor lib (should be in common chunk)
-export default 123;
diff --git a/examples/chunkhash/webpack.config.js b/examples/chunkhash/webpack.config.js
index 817f492b..cc34d559 100644
--- a/examples/chunkhash/webpack.config.js
+++ b/examples/chunkhash/webpack.config.js
@@ -1,23 +1,15 @@
var path = require("path");
-var webpack = require("../../");
module.exports = {
+ // mode: "development || "production",
entry: {
- main: "./example",
- common: ["./vendor"] // optional
+ main: "./example"
+ },
+ optimization: {
+ runtimeChunk: true
},
output: {
- path: path.join(__dirname, "js"),
+ path: path.join(__dirname, "dist"),
filename: "[name].chunkhash.js",
- chunkFilename: "[chunkhash].js"
- },
- plugins: [
- new webpack.optimize.CommonsChunkPlugin({
- names: ["common", "manifest"]
- })
- /* without the "common" chunk:
- new webpack.optimize.CommonsChunkPlugin({
- name: "manifest"
- })
- */
- ]
+ chunkFilename: "[name].chunkhash.js"
+ }
};
diff --git a/examples/code-splitted-css-bundle/README.md b/examples/code-splitted-css-bundle/README.md
index 50f01bb7..1552a655 100644
--- a/examples/code-splitted-css-bundle/README.md
+++ b/examples/code-splitted-css-bundle/README.md
@@ -67,10 +67,10 @@ body {
```
Hash: 5be34b0d3c624e61c616
-Version: webpack 3.5.1
+Version: webpack 3.11.0
Asset Size Chunks Chunk Names
ce21cbdd9b894e6af794813eb3fdaf60.png 119 bytes [emitted]
- 0.output.js 2.43 kB 0 [emitted]
+ 0.output.js 2.44 kB 0 [emitted]
output.js 21.2 kB 1 [emitted] main
style.css 71 bytes 1 [emitted] main
Entrypoint main = output.js style.css
@@ -105,7 +105,7 @@ Child extract-text-webpack-plugin ../../node_modules/extract-text-webpack-plugin
```
Hash: edbe0e91ba86d814d855
-Version: webpack 3.5.1
+Version: webpack 3.11.0
Asset Size Chunks Chunk Names
ce21cbdd9b894e6af794813eb3fdaf60.png 119 bytes [emitted]
0.output.js 343 bytes 0 [emitted]
diff --git a/examples/code-splitted-css-bundle/chunk.js b/examples/code-splitted-css-bundle/chunk.js
deleted file mode 100644
index be8d3dbb..00000000
--- a/examples/code-splitted-css-bundle/chunk.js
+++ /dev/null
@@ -1 +0,0 @@
-require("./style2.css");
diff --git a/examples/code-splitted-css-bundle/example.js b/examples/code-splitted-css-bundle/example.js
deleted file mode 100644
index d48ee310..00000000
--- a/examples/code-splitted-css-bundle/example.js
+++ /dev/null
@@ -1,2 +0,0 @@
-require("./style.css");
-require(["./chunk"]);
diff --git a/examples/code-splitted-css-bundle/image.png b/examples/code-splitted-css-bundle/image.png
deleted file mode 100644
index 818c71d0..00000000
Binary files a/examples/code-splitted-css-bundle/image.png and /dev/null differ
diff --git a/examples/code-splitted-css-bundle/image2.png b/examples/code-splitted-css-bundle/image2.png
deleted file mode 100644
index 818c71d0..00000000
Binary files a/examples/code-splitted-css-bundle/image2.png and /dev/null differ
diff --git a/examples/code-splitted-css-bundle/style.css b/examples/code-splitted-css-bundle/style.css
deleted file mode 100644
index cb7e20ae..00000000
--- a/examples/code-splitted-css-bundle/style.css
+++ /dev/null
@@ -1,3 +0,0 @@
-body {
- background: url(image.png);
-}
diff --git a/examples/code-splitted-css-bundle/style2.css b/examples/code-splitted-css-bundle/style2.css
deleted file mode 100644
index f48470fe..00000000
--- a/examples/code-splitted-css-bundle/style2.css
+++ /dev/null
@@ -1,3 +0,0 @@
-.xyz {
- background: url(image2.png);
-}
diff --git a/examples/code-splitted-css-bundle/template.md b/examples/code-splitted-css-bundle/template.md
deleted file mode 100644
index 42f03053..00000000
--- a/examples/code-splitted-css-bundle/template.md
+++ /dev/null
@@ -1,50 +0,0 @@
-
-# example.js
-
-``` javascript
-{{example.js}}
-```
-
-# style.css
-
-``` css
-{{style.css}}
-```
-
-# chunk.js
-
-``` javascript
-{{chunk.js}}
-```
-
-# style2.css
-
-``` css
-{{style2.css}}
-```
-
-# webpack.config.js
-
-``` javascript
-{{webpack.config.js}}
-```
-
-# js/style.css
-
-``` javascript
-{{js/style.css}}
-```
-
-# Info
-
-## Uncompressed
-
-```
-{{stdout}}
-```
-
-## Minimized (uglify-js, no zip)
-
-```
-{{min:stdout}}
-```
diff --git a/examples/code-splitted-css-bundle/webpack.config.js b/examples/code-splitted-css-bundle/webpack.config.js
deleted file mode 100644
index 53932340..00000000
--- a/examples/code-splitted-css-bundle/webpack.config.js
+++ /dev/null
@@ -1,20 +0,0 @@
-var ExtractTextPlugin = require("extract-text-webpack-plugin");
-module.exports = {
- module: {
- loaders: [
- {
- test: /\.css$/,
- use: ExtractTextPlugin.extract({
- fallback: "style-loader",
- use: "css-loader"
- })
- },
- { test: /\.png$/, loader: "file-loader" }
- ]
- },
- plugins: [
- new ExtractTextPlugin({
- filename: "style.css"
- })
- ]
-};
diff --git a/examples/code-splitted-require.context-amd/README.md b/examples/code-splitted-require.context-amd/README.md
index 918be881..17878049 100644
--- a/examples/code-splitted-require.context-amd/README.md
+++ b/examples/code-splitted-require.context-amd/README.md
@@ -14,18 +14,20 @@ getTemplate("b", function(b) {
});
```
-# js/output.js
+# dist/output.js
<details><summary><code>/******/ (function(modules) { /* webpackBootstrap */ })</code></summary>
``` javascript
/******/ (function(modules) { // webpackBootstrap
/******/ // install a JSONP callback for chunk loading
-/******/ var parentJsonpFunction = window["webpackJsonp"];
-/******/ window["webpackJsonp"] = function webpackJsonpCallback(chunkIds, moreModules, executeModules) {
+/******/ function webpackJsonpCallback(data) {
+/******/ var chunkIds = data[0];
+/******/ var moreModules = data[1]
+/******/
/******/ // add "moreModules" to the modules object,
/******/ // then flag all "chunkIds" as loaded and fire callback
-/******/ var moduleId, chunkId, i = 0, resolves = [], result;
+/******/ var moduleId, chunkId, i = 0, resolves = [];
/******/ for(;i < chunkIds.length; i++) {
/******/ chunkId = chunkIds[i];
/******/ if(installedChunks[chunkId]) {
@@ -38,21 +40,24 @@ getTemplate("b", function(b) {
/******/ modules[moduleId] = moreModules[moduleId];
/******/ }
/******/ }
-/******/ if(parentJsonpFunction) parentJsonpFunction(chunkIds, moreModules, executeModules);
+/******/ if(parentJsonpFunction) parentJsonpFunction(data);
/******/ while(resolves.length) {
/******/ resolves.shift()();
/******/ }
/******/
/******/ };
/******/
+/******/
/******/ // The module cache
/******/ var installedModules = {};
/******/
-/******/ // objects to store loaded and loading chunks
+/******/ // object to store loaded and loading chunks
/******/ var installedChunks = {
/******/ 1: 0
/******/ };
/******/
+/******/
+/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
@@ -80,51 +85,60 @@ getTemplate("b", function(b) {
/******/ // This file contains only the entry chunk.
/******/ // The chunk loading function for additional chunks
/******/ __webpack_require__.e = function requireEnsure(chunkId) {
+/******/ var promises = [];
+/******/
+/******/
+/******/ // JSONP chunk loading for javascript
+/******/
/******/ var installedChunkData = installedChunks[chunkId];
-/******/ if(installedChunkData === 0) {
-/******/ return new Promise(function(resolve) { resolve(); });
-/******/ }
+/******/ if(installedChunkData !== 0) { // 0 means "already installed".
/******/
-/******/ // a Promise means "currently loading".
-/******/ if(installedChunkData) {
-/******/ return installedChunkData[2];
-/******/ }
+/******/ // a Promise means "currently loading".
+/******/ if(installedChunkData) {
+/******/ promises.push(installedChunkData[2]);
+/******/ } else {
+/******/ // setup Promise in chunk cache
+/******/ var promise = new Promise(function(resolve, reject) {
+/******/ installedChunkData = installedChunks[chunkId] = [resolve, reject];
+/******/ });
+/******/ promises.push(installedChunkData[2] = promise);
/******/
-/******/ // setup Promise in chunk cache
-/******/ var promise = new Promise(function(resolve, reject) {
-/******/ installedChunkData = installedChunks[chunkId] = [resolve, reject];
-/******/ });
-/******/ installedChunkData[2] = promise;
+/******/ // start chunk loading
+/******/ var head = document.getElementsByTagName('head')[0];
+/******/ var script = document.createElement('script');
/******/
-/******/ // start chunk loading
-/******/ var head = document.getElementsByTagName('head')[0];
-/******/ var script = document.createElement('script');
-/******/ script.type = 'text/javascript';
-/******/ script.charset = 'utf-8';
-/******/ script.async = true;
-/******/ script.timeout = 120000;
+/******/ script.charset = 'utf-8';
+/******/ script.timeout = 120000;
/******/
-/******/ if (__webpack_require__.nc) {
-/******/ script.setAttribute("nonce", __webpack_require__.nc);
-/******/ }
-/******/ script.src = __webpack_require__.p + "" + chunkId + ".output.js";
-/******/ var timeout = setTimeout(onScriptComplete, 120000);
-/******/ script.onerror = script.onload = onScriptComplete;
-/******/ function onScriptComplete() {
-/******/ // avoid mem leaks in IE.
-/******/ script.onerror = script.onload = null;
-/******/ clearTimeout(timeout);
-/******/ var chunk = installedChunks[chunkId];
-/******/ if(chunk !== 0) {
-/******/ if(chunk) {
-/******/ chunk[1](new Error('Loading chunk ' + chunkId + ' failed.'));
+/******/ if (__webpack_require__.nc) {
+/******/ script.setAttribute("nonce", __webpack_require__.nc);
/******/ }
-/******/ installedChunks[chunkId] = undefined;
+/******/ script.src = __webpack_require__.p + "" + chunkId + ".output.js";
+/******/ var timeout = setTimeout(function(){
+/******/ onScriptComplete({ type: 'timeout', target: script });
+/******/ }, 120000);
+/******/ script.onerror = script.onload = onScriptComplete;
+/******/ function onScriptComplete(event) {
+/******/ // avoid mem leaks in IE.
+/******/ script.onerror = script.onload = null;
+/******/ clearTimeout(timeout);
+/******/ var chunk = installedChunks[chunkId];
+/******/ if(chunk !== 0) {
+/******/ if(chunk) {
+/******/ var errorType = event && (event.type === 'load' ? 'missing' : event.type);
+/******/ var realSrc = event && event.target && event.target.src;
+/******/ var error = new Error('Loading chunk ' + chunkId + ' failed.\n(' + errorType + ': ' + realSrc + ')');
+/******/ error.type = errorType;
+/******/ error.request = realSrc;
+/******/ chunk[1](error);
+/******/ }
+/******/ installedChunks[chunkId] = undefined;
+/******/ }
+/******/ };
+/******/ head.appendChild(script);
/******/ }
-/******/ };
-/******/ head.appendChild(script);
-/******/
-/******/ return promise;
+/******/ }
+/******/ return Promise.all(promises);
/******/ };
/******/
/******/ // expose the modules object (__webpack_modules__)
@@ -144,6 +158,11 @@ getTemplate("b", function(b) {
/******/ }
/******/ };
/******/
+/******/ // define __esModule on exports
+/******/ __webpack_require__.r = function(exports) {
+/******/ Object.defineProperty(exports, '__esModule', { value: true });
+/******/ };
+/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
@@ -157,11 +176,19 @@ getTemplate("b", function(b) {
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
-/******/ __webpack_require__.p = "js/";
+/******/ __webpack_require__.p = "dist/";
/******/
/******/ // on error function for async loading
/******/ __webpack_require__.oe = function(err) { console.error(err); throw err; };
/******/
+/******/ var jsonpArray = window["webpackJsonp"] = window["webpackJsonp"] || [];
+/******/ var oldJsonpFunction = jsonpArray.push.bind(jsonpArray);
+/******/ jsonpArray.push = webpackJsonpCallback;
+/******/ jsonpArray = jsonpArray.slice();
+/******/ for(var i = 0; i < jsonpArray.length; i++) webpackJsonpCallback(jsonpArray[i]);
+/******/ var parentJsonpFunction = oldJsonpFunction;
+/******/
+/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 0);
/******/ })
@@ -177,13 +204,12 @@ getTemplate("b", function(b) {
!*** ./example.js ***!
\********************/
/*! no static exports found */
-/*! all exports used */
/***/ (function(module, exports, __webpack_require__) {
function getTemplate(templateName, callback) {
- __webpack_require__.e/* require */(0).then(function() { var __WEBPACK_AMD_REQUIRE_ARRAY__ = [__webpack_require__(/*! ../require.context/templates */ 1)("./"+templateName)]; (function(tmpl) {
+ __webpack_require__.e(/*! AMD require */ 0).then(function() { var __WEBPACK_AMD_REQUIRE_ARRAY__ = [__webpack_require__(1)("./"+templateName)]; (function(tmpl) {
callback(tmpl());
- }.apply(null, __WEBPACK_AMD_REQUIRE_ARRAY__));}).catch(__webpack_require__.oe);
+ }).apply(null, __WEBPACK_AMD_REQUIRE_ARRAY__);}).catch(__webpack_require__.oe);
}
getTemplate("a", function(a) {
console.log(a);
@@ -196,36 +222,42 @@ getTemplate("b", function(b) {
/******/ ]);
```
-# js/0.output.js
+# dist/0.output.js
``` javascript
-webpackJsonp([0],[
+(window["webpackJsonp"] = window["webpackJsonp"] || []).push([[0],[
/* 0 */,
/* 1 */
-/*!*********************************************!*\
- !*** ../require.context/templates ^\.\/.*$ ***!
- \*********************************************/
+/*!**************************************************!*\
+ !*** ../require.context/templates sync ^\.\/.*$ ***!
+ \**************************************************/
/*! no static exports found */
-/*! all exports used */
/***/ (function(module, exports, __webpack_require__) {
var map = {
- "./a": 2,
- "./a.js": 2,
+ "./a": 4,
+ "./a.js": 4,
"./b": 3,
"./b.js": 3,
- "./c": 4,
- "./c.js": 4
+ "./c": 2,
+ "./c.js": 2
};
+
+
function webpackContext(req) {
- return __webpack_require__(webpackContextResolve(req));
-};
+ var id = webpackContextResolve(req);
+ var module = __webpack_require__(id);
+ return module;
+}
function webpackContextResolve(req) {
var id = map[req];
- if(!(id + 1)) // check for number or string
- throw new Error("Cannot find module '" + req + "'.");
+ if(!(id + 1)) { // check for number or string
+ var e = new Error('Cannot find module "' + req + '".');
+ e.code = 'MODULE_NOT_FOUND';
+ throw e;
+ }
return id;
-};
+}
webpackContext.keys = function webpackContextKeys() {
return Object.keys(map);
};
@@ -236,14 +268,13 @@ webpackContext.id = 1;
/***/ }),
/* 2 */
/*!*****************************************!*\
- !*** ../require.context/templates/a.js ***!
+ !*** ../require.context/templates/c.js ***!
\*****************************************/
/*! no static exports found */
-/*! all exports used */
/***/ (function(module, exports) {
module.exports = function() {
- return "This text was generated by template A";
+ return "This text was generated by template C";
}
/***/ }),
@@ -252,7 +283,6 @@ module.exports = function() {
!*** ../require.context/templates/b.js ***!
\*****************************************/
/*! no static exports found */
-/*! all exports used */
/***/ (function(module, exports) {
module.exports = function() {
@@ -262,72 +292,73 @@ module.exports = function() {
/***/ }),
/* 4 */
/*!*****************************************!*\
- !*** ../require.context/templates/c.js ***!
+ !*** ../require.context/templates/a.js ***!
\*****************************************/
/*! no static exports found */
-/*! all exports used */
/***/ (function(module, exports) {
module.exports = function() {
- return "This text was generated by template C";
+ return "This text was generated by template A";
}
/***/ })
-]);
+]]);
```
# Info
-## Uncompressed
+## Unoptimized
```
-Hash: 1c46bbe47e8b8a0ee8e2
-Version: webpack 3.5.1
- Asset Size Chunks Chunk Names
-0.output.js 1.85 kB 0 [emitted]
- output.js 6.37 kB 1 [emitted] main
+Hash: 0a1b2c3d4e5f6a7b8c9d
+Version: webpack 4.0.0-beta.2
+ Asset Size Chunks Chunk Names
+0.output.js 1.86 KiB 0 [emitted]
+ output.js 7.19 KiB 1 [emitted] main
Entrypoint main = output.js
-chunk {0} 0.output.js 463 bytes {1} [rendered]
+chunk {0} 0.output.js 463 bytes <{1}> [rendered]
> [0] ./example.js 2:1-4:3
- [1] ../require.context/templates ^\.\/.*$ 217 bytes {0} [built]
+ [1] ../require.context/templates sync ^\.\/.*$ 217 bytes {0} [built]
amd require context ../require.context/templates [0] ./example.js 2:1-4:3
- [2] ../require.context/templates/a.js 82 bytes {0} [optional] [built]
- context element ./a.js [1] ../require.context/templates ^\.\/.*$ ./a.js
- context element ./a [1] ../require.context/templates ^\.\/.*$ ./a
+ [2] ../require.context/templates/c.js 82 bytes {0} [optional] [built]
+ context element ./c.js [1] ../require.context/templates sync ^\.\/.*$ ./c.js
+ context element ./c [1] ../require.context/templates sync ^\.\/.*$ ./c
[3] ../require.context/templates/b.js 82 bytes {0} [optional] [built]
- context element ./b.js [1] ../require.context/templates ^\.\/.*$ ./b.js
- context element ./b [1] ../require.context/templates ^\.\/.*$ ./b
- [4] ../require.context/templates/c.js 82 bytes {0} [optional] [built]
- context element ./c.js [1] ../require.context/templates ^\.\/.*$ ./c.js
- context element ./c [1] ../require.context/templates ^\.\/.*$ ./c
-chunk {1} output.js (main) 261 bytes [entry] [rendered]
- > main [0] ./example.js
+ context element ./b.js [1] ../require.context/templates sync ^\.\/.*$ ./b.js
+ context element ./b [1] ../require.context/templates sync ^\.\/.*$ ./b
+ [4] ../require.context/templates/a.js 82 bytes {0} [optional] [built]
+ context element ./a.js [1] ../require.context/templates sync ^\.\/.*$ ./a.js
+ context element ./a [1] ../require.context/templates sync ^\.\/.*$ ./a
+chunk {1} output.js (main) 261 bytes >{0}< [entry] [rendered]
+ > .\example.js main
[0] ./example.js 261 bytes {1} [built]
+ single entry .\example.js main
```
-## Minimized (uglify-js, no zip)
+## Production mode
```
-Hash: 1c46bbe47e8b8a0ee8e2
-Version: webpack 3.5.1
+Hash: 0a1b2c3d4e5f6a7b8c9d
+Version: webpack 4.0.0-beta.2
Asset Size Chunks Chunk Names
-0.output.js 544 bytes 0 [emitted]
- output.js 1.52 kB 1 [emitted] main
+0.output.js 627 bytes 0 [emitted]
+ output.js 1.75 KiB 1 [emitted] main
Entrypoint main = output.js
-chunk {0} 0.output.js 463 bytes {1} [rendered]
+chunk {0} 0.output.js 463 bytes <{1}> [rendered]
> [0] ./example.js 2:1-4:3
- [1] ../require.context/templates ^\.\/.*$ 217 bytes {0} [built]
+ [1] ../require.context/templates sync ^\.\/.*$ 217 bytes {0} [built]
amd require context ../require.context/templates [0] ./example.js 2:1-4:3
- [2] ../require.context/templates/a.js 82 bytes {0} [optional] [built]
- context element ./a.js [1] ../require.context/templates ^\.\/.*$ ./a.js
- context element ./a [1] ../require.context/templates ^\.\/.*$ ./a
+ [2] ../require.context/templates/c.js 82 bytes {0} [optional] [built]
+ context element ./c.js [1] ../require.context/templates sync ^\.\/.*$ ./c.js
+ context element ./c [1] ../require.context/templates sync ^\.\/.*$ ./c
[3] ../require.context/templates/b.js 82 bytes {0} [optional] [built]
- context element ./b.js [1] ../require.context/templates ^\.\/.*$ ./b.js
- context element ./b [1] ../require.context/templates ^\.\/.*$ ./b
- [4] ../require.context/templates/c.js 82 bytes {0} [optional] [built]
- context element ./c.js [1] ../require.context/templates ^\.\/.*$ ./c.js
- context element ./c [1] ../require.context/templates ^\.\/.*$ ./c
-chunk {1} output.js (main) 261 bytes [entry] [rendered]
- > main [0] ./example.js
+ context element ./b.js [1] ../require.context/templates sync ^\.\/.*$ ./b.js
+ context element ./b [1] ../require.context/templates sync ^\.\/.*$ ./b
+ [4] ../require.context/templates/a.js 82 bytes {0} [optional] [built]
+ context element ./a.js [1] ../require.context/templates sync ^\.\/.*$ ./a.js
+ context element ./a [1] ../require.context/templates sync ^\.\/.*$ ./a
+chunk {1} output.js (main) 261 bytes >{0}< [entry] [rendered]
+ > .\example.js main
[0] ./example.js 261 bytes {1} [built]
+ single entry .\example.js main
```
diff --git a/examples/code-splitted-require.context-amd/template.md b/examples/code-splitted-require.context-amd/template.md
index 16654024..0b7b60cf 100644
--- a/examples/code-splitted-require.context-amd/template.md
+++ b/examples/code-splitted-require.context-amd/template.md
@@ -4,28 +4,28 @@
{{example.js}}
```
-# js/output.js
+# dist/output.js
``` javascript
-{{js/output.js}}
+{{dist/output.js}}
```
-# js/0.output.js
+# dist/0.output.js
``` javascript
-{{js/0.output.js}}
+{{dist/0.output.js}}
```
# Info
-## Uncompressed
+## Unoptimized
```
{{stdout}}
```
-## Minimized (uglify-js, no zip)
+## Production mode
```
-{{min:stdout}}
+{{production:stdout}}
```
diff --git a/examples/code-splitted-require.context-amd/webpack.config.js b/examples/code-splitted-require.context-amd/webpack.config.js
new file mode 100644
index 00000000..0d554bf6
--- /dev/null
+++ b/examples/code-splitted-require.context-amd/webpack.config.js
@@ -0,0 +1,5 @@
+module.exports = {
+ optimization: {
+ occurrenceOrder: true // To keep filename consistent between different modes (for example building only)
+ }
+};
diff --git a/examples/code-splitted-require.context/README.md b/examples/code-splitted-require.context/README.md
index 3c431704..515968bb 100644
--- a/examples/code-splitted-require.context/README.md
+++ b/examples/code-splitted-require.context/README.md
@@ -14,18 +14,20 @@ getTemplate("b", function(b) {
});
```
-# js/output.js
+# dist/output.js
<details><summary><code>/******/ (function(modules) { /* webpackBootstrap */ })</code></summary>
``` javascript
/******/ (function(modules) { // webpackBootstrap
/******/ // install a JSONP callback for chunk loading
-/******/ var parentJsonpFunction = window["webpackJsonp"];
-/******/ window["webpackJsonp"] = function webpackJsonpCallback(chunkIds, moreModules, executeModules) {
+/******/ function webpackJsonpCallback(data) {
+/******/ var chunkIds = data[0];
+/******/ var moreModules = data[1]
+/******/
/******/ // add "moreModules" to the modules object,
/******/ // then flag all "chunkIds" as loaded and fire callback
-/******/ var moduleId, chunkId, i = 0, resolves = [], result;
+/******/ var moduleId, chunkId, i = 0, resolves = [];
/******/ for(;i < chunkIds.length; i++) {
/******/ chunkId = chunkIds[i];
/******/ if(installedChunks[chunkId]) {
@@ -38,21 +40,24 @@ getTemplate("b", function(b) {
/******/ modules[moduleId] = moreModules[moduleId];
/******/ }
/******/ }
-/******/ if(parentJsonpFunction) parentJsonpFunction(chunkIds, moreModules, executeModules);
+/******/ if(parentJsonpFunction) parentJsonpFunction(data);
/******/ while(resolves.length) {
/******/ resolves.shift()();
/******/ }
/******/
/******/ };
/******/
+/******/
/******/ // The module cache
/******/ var installedModules = {};
/******/
-/******/ // objects to store loaded and loading chunks
+/******/ // object to store loaded and loading chunks
/******/ var installedChunks = {
/******/ 1: 0
/******/ };
/******/
+/******/
+/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
@@ -80,51 +85,60 @@ getTemplate("b", function(b) {
/******/ // This file contains only the entry chunk.
/******/ // The chunk loading function for additional chunks
/******/ __webpack_require__.e = function requireEnsure(chunkId) {
+/******/ var promises = [];
+/******/
+/******/
+/******/ // JSONP chunk loading for javascript
+/******/
/******/ var installedChunkData = installedChunks[chunkId];
-/******/ if(installedChunkData === 0) {
-/******/ return new Promise(function(resolve) { resolve(); });
-/******/ }
+/******/ if(installedChunkData !== 0) { // 0 means "already installed".
/******/
-/******/ // a Promise means "currently loading".
-/******/ if(installedChunkData) {
-/******/ return installedChunkData[2];
-/******/ }
+/******/ // a Promise means "currently loading".
+/******/ if(installedChunkData) {
+/******/ promises.push(installedChunkData[2]);
+/******/ } else {
+/******/ // setup Promise in chunk cache
+/******/ var promise = new Promise(function(resolve, reject) {
+/******/ installedChunkData = installedChunks[chunkId] = [resolve, reject];
+/******/ });
+/******/ promises.push(installedChunkData[2] = promise);
/******/
-/******/ // setup Promise in chunk cache
-/******/ var promise = new Promise(function(resolve, reject) {
-/******/ installedChunkData = installedChunks[chunkId] = [resolve, reject];
-/******/ });
-/******/ installedChunkData[2] = promise;
+/******/ // start chunk loading
+/******/ var head = document.getElementsByTagName('head')[0];
+/******/ var script = document.createElement('script');
/******/
-/******/ // start chunk loading
-/******/ var head = document.getElementsByTagName('head')[0];
-/******/ var script = document.createElement('script');
-/******/ script.type = 'text/javascript';
-/******/ script.charset = 'utf-8';
-/******/ script.async = true;
-/******/ script.timeout = 120000;
+/******/ script.charset = 'utf-8';
+/******/ script.timeout = 120000;
/******/
-/******/ if (__webpack_require__.nc) {
-/******/ script.setAttribute("nonce", __webpack_require__.nc);
-/******/ }
-/******/ script.src = __webpack_require__.p + "" + chunkId + ".output.js";
-/******/ var timeout = setTimeout(onScriptComplete, 120000);
-/******/ script.onerror = script.onload = onScriptComplete;
-/******/ function onScriptComplete() {
-/******/ // avoid mem leaks in IE.
-/******/ script.onerror = script.onload = null;
-/******/ clearTimeout(timeout);
-/******/ var chunk = installedChunks[chunkId];
-/******/ if(chunk !== 0) {
-/******/ if(chunk) {
-/******/ chunk[1](new Error('Loading chunk ' + chunkId + ' failed.'));
+/******/ if (__webpack_require__.nc) {
+/******/ script.setAttribute("nonce", __webpack_require__.nc);
/******/ }
-/******/ installedChunks[chunkId] = undefined;
+/******/ script.src = __webpack_require__.p + "" + chunkId + ".output.js";
+/******/ var timeout = setTimeout(function(){
+/******/ onScriptComplete({ type: 'timeout', target: script });
+/******/ }, 120000);
+/******/ script.onerror = script.onload = onScriptComplete;
+/******/ function onScriptComplete(event) {
+/******/ // avoid mem leaks in IE.
+/******/ script.onerror = script.onload = null;
+/******/ clearTimeout(timeout);
+/******/ var chunk = installedChunks[chunkId];
+/******/ if(chunk !== 0) {
+/******/ if(chunk) {
+/******/ var errorType = event && (event.type === 'load' ? 'missing' : event.type);
+/******/ var realSrc = event && event.target && event.target.src;
+/******/ var error = new Error('Loading chunk ' + chunkId + ' failed.\n(' + errorType + ': ' + realSrc + ')');
+/******/ error.type = errorType;
+/******/ error.request = realSrc;
+/******/ chunk[1](error);
+/******/ }
+/******/ installedChunks[chunkId] = undefined;
+/******/ }
+/******/ };
+/******/ head.appendChild(script);
/******/ }
-/******/ };
-/******/ head.appendChild(script);
-/******/
-/******/ return promise;
+/******/ }
+/******/ return Promise.all(promises);
/******/ };
/******/
/******/ // expose the modules object (__webpack_modules__)
@@ -144,6 +158,11 @@ getTemplate("b", function(b) {
/******/ }
/******/ };
/******/
+/******/ // define __esModule on exports
+/******/ __webpack_require__.r = function(exports) {
+/******/ Object.defineProperty(exports, '__esModule', { value: true });
+/******/ };
+/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
@@ -157,11 +176,19 @@ getTemplate("b", function(b) {
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
-/******/ __webpack_require__.p = "js/";
+/******/ __webpack_require__.p = "dist/";
/******/
/******/ // on error function for async loading
/******/ __webpack_require__.oe = function(err) { console.error(err); throw err; };
/******/
+/******/ var jsonpArray = window["webpackJsonp"] = window["webpackJsonp"] || [];
+/******/ var oldJsonpFunction = jsonpArray.push.bind(jsonpArray);
+/******/ jsonpArray.push = webpackJsonpCallback;
+/******/ jsonpArray = jsonpArray.slice();
+/******/ for(var i = 0; i < jsonpArray.length; i++) webpackJsonpCallback(jsonpArray[i]);
+/******/ var parentJsonpFunction = oldJsonpFunction;
+/******/
+/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 0);
/******/ })
@@ -177,12 +204,11 @@ getTemplate("b", function(b) {
!*** ./example.js ***!
\********************/
/*! no static exports found */
-/*! all exports used */
/***/ (function(module, exports, __webpack_require__) {
function getTemplate(templateName, callback) {
- __webpack_require__.e/* require.ensure */(0).then((function(require) {
- callback(__webpack_require__(/*! ../require.context/templates */ 1)("./"+templateName)());
+ __webpack_require__.e(/*! require.ensure */ 0).then((function(require) {
+ callback(__webpack_require__(1)("./"+templateName)());
}).bind(null, __webpack_require__)).catch(__webpack_require__.oe);
}
getTemplate("a", function(a) {
@@ -196,36 +222,42 @@ getTemplate("b", function(b) {
/******/ ]);
```
-# js/0.output.js
+# dist/0.output.js
``` javascript
-webpackJsonp([0],[
+(window["webpackJsonp"] = window["webpackJsonp"] || []).push([[0],[
/* 0 */,
/* 1 */
-/*!*********************************************!*\
- !*** ../require.context/templates ^\.\/.*$ ***!
- \*********************************************/
+/*!**************************************************!*\
+ !*** ../require.context/templates sync ^\.\/.*$ ***!
+ \**************************************************/
/*! no static exports found */
-/*! all exports used */
/***/ (function(module, exports, __webpack_require__) {
var map = {
- "./a": 2,
- "./a.js": 2,
+ "./a": 4,
+ "./a.js": 4,
"./b": 3,
"./b.js": 3,
- "./c": 4,
- "./c.js": 4
+ "./c": 2,
+ "./c.js": 2
};
+
+
function webpackContext(req) {
- return __webpack_require__(webpackContextResolve(req));
-};
+ var id = webpackContextResolve(req);
+ var module = __webpack_require__(id);
+ return module;
+}
function webpackContextResolve(req) {
var id = map[req];
- if(!(id + 1)) // check for number or string
- throw new Error("Cannot find module '" + req + "'.");
+ if(!(id + 1)) { // check for number or string
+ var e = new Error('Cannot find module "' + req + '".');
+ e.code = 'MODULE_NOT_FOUND';
+ throw e;
+ }
return id;
-};
+}
webpackContext.keys = function webpackContextKeys() {
return Object.keys(map);
};
@@ -236,14 +268,13 @@ webpackContext.id = 1;
/***/ }),
/* 2 */
/*!*****************************************!*\
- !*** ../require.context/templates/a.js ***!
+ !*** ../require.context/templates/c.js ***!
\*****************************************/
/*! no static exports found */
-/*! all exports used */
/***/ (function(module, exports) {
module.exports = function() {
- return "This text was generated by template A";
+ return "This text was generated by template C";
}
/***/ }),
@@ -252,7 +283,6 @@ module.exports = function() {
!*** ../require.context/templates/b.js ***!
\*****************************************/
/*! no static exports found */
-/*! all exports used */
/***/ (function(module, exports) {
module.exports = function() {
@@ -262,72 +292,73 @@ module.exports = function() {
/***/ }),
/* 4 */
/*!*****************************************!*\
- !*** ../require.context/templates/c.js ***!
+ !*** ../require.context/templates/a.js ***!
\*****************************************/
/*! no static exports found */
-/*! all exports used */
/***/ (function(module, exports) {
module.exports = function() {
- return "This text was generated by template C";
+ return "This text was generated by template A";
}
/***/ })
-]);
+]]);
```
# Info
-## Uncompressed
+## Unoptimized
```
-Hash: f67ab883501eec17d2fb
-Version: webpack 3.5.1
- Asset Size Chunks Chunk Names
-0.output.js 1.85 kB 0 [emitted]
- output.js 6.3 kB 1 [emitted] main
+Hash: 0a1b2c3d4e5f6a7b8c9d
+Version: webpack 4.0.0-beta.2
+ Asset Size Chunks Chunk Names
+0.output.js 1.86 KiB 0 [emitted]
+ output.js 7.13 KiB 1 [emitted] main
Entrypoint main = output.js
-chunk {0} 0.output.js 463 bytes {1} [rendered]
+chunk {0} 0.output.js 463 bytes <{1}> [rendered]
> [0] ./example.js 2:1-4:3
- [1] ../require.context/templates ^\.\/.*$ 217 bytes {0} [built]
+ [1] ../require.context/templates sync ^\.\/.*$ 217 bytes {0} [built]
cjs require context ../require.context/templates [0] ./example.js 3:11-64
- [2] ../require.context/templates/a.js 82 bytes {0} [optional] [built]
- context element ./a.js [1] ../require.context/templates ^\.\/.*$ ./a.js
- context element ./a [1] ../require.context/templates ^\.\/.*$ ./a
+ [2] ../require.context/templates/c.js 82 bytes {0} [optional] [built]
+ context element ./c.js [1] ../require.context/templates sync ^\.\/.*$ ./c.js
+ context element ./c [1] ../require.context/templates sync ^\.\/.*$ ./c
[3] ../require.context/templates/b.js 82 bytes {0} [optional] [built]
- context element ./b.js [1] ../require.context/templates ^\.\/.*$ ./b.js
- context element ./b [1] ../require.context/templates ^\.\/.*$ ./b
- [4] ../require.context/templates/c.js 82 bytes {0} [optional] [built]
- context element ./c.js [1] ../require.context/templates ^\.\/.*$ ./c.js
- context element ./c [1] ../require.context/templates ^\.\/.*$ ./c
-chunk {1} output.js (main) 276 bytes [entry] [rendered]
- > main [0] ./example.js
+ context element ./b.js [1] ../require.context/templates sync ^\.\/.*$ ./b.js
+ context element ./b [1] ../require.context/templates sync ^\.\/.*$ ./b
+ [4] ../require.context/templates/a.js 82 bytes {0} [optional] [built]
+ context element ./a.js [1] ../require.context/templates sync ^\.\/.*$ ./a.js
+ context element ./a [1] ../require.context/templates sync ^\.\/.*$ ./a
+chunk {1} output.js (main) 276 bytes >{0}< [entry] [rendered]
+ > .\example.js main
[0] ./example.js 276 bytes {1} [built]
+ single entry .\example.js main
```
-## Minimized (uglify-js, no zip)
+## Production mode
```
-Hash: f67ab883501eec17d2fb
-Version: webpack 3.5.1
+Hash: 0a1b2c3d4e5f6a7b8c9d
+Version: webpack 4.0.0-beta.2
Asset Size Chunks Chunk Names
-0.output.js 544 bytes 0 [emitted]
- output.js 1.49 kB 1 [emitted] main
+0.output.js 627 bytes 0 [emitted]
+ output.js 1.73 KiB 1 [emitted] main
Entrypoint main = output.js
-chunk {0} 0.output.js 463 bytes {1} [rendered]
+chunk {0} 0.output.js 463 bytes <{1}> [rendered]
> [0] ./example.js 2:1-4:3
- [1] ../require.context/templates ^\.\/.*$ 217 bytes {0} [built]
+ [1] ../require.context/templates sync ^\.\/.*$ 217 bytes {0} [built]
cjs require context ../require.context/templates [0] ./example.js 3:11-64
- [2] ../require.context/templates/a.js 82 bytes {0} [optional] [built]
- context element ./a.js [1] ../require.context/templates ^\.\/.*$ ./a.js
- context element ./a [1] ../require.context/templates ^\.\/.*$ ./a
+ [2] ../require.context/templates/c.js 82 bytes {0} [optional] [built]
+ context element ./c.js [1] ../require.context/templates sync ^\.\/.*$ ./c.js
+ context element ./c [1] ../require.context/templates sync ^\.\/.*$ ./c
[3] ../require.context/templates/b.js 82 bytes {0} [optional] [built]
- context element ./b.js [1] ../require.context/templates ^\.\/.*$ ./b.js
- context element ./b [1] ../require.context/templates ^\.\/.*$ ./b
- [4] ../require.context/templates/c.js 82 bytes {0} [optional] [built]
- context element ./c.js [1] ../require.context/templates ^\.\/.*$ ./c.js
- context element ./c [1] ../require.context/templates ^\.\/.*$ ./c
-chunk {1} output.js (main) 276 bytes [entry] [rendered]
- > main [0] ./example.js
+ context element ./b.js [1] ../require.context/templates sync ^\.\/.*$ ./b.js
+ context element ./b [1] ../require.context/templates sync ^\.\/.*$ ./b
+ [4] ../require.context/templates/a.js 82 bytes {0} [optional] [built]
+ context element ./a.js [1] ../require.context/templates sync ^\.\/.*$ ./a.js
+ context element ./a [1] ../require.context/templates sync ^\.\/.*$ ./a
+chunk {1} output.js (main) 276 bytes >{0}< [entry] [rendered]
+ > .\example.js main
[0] ./example.js 276 bytes {1} [built]
+ single entry .\example.js main
```
diff --git a/examples/code-splitted-require.context/template.md b/examples/code-splitted-require.context/template.md
index 16654024..0b7b60cf 100644
--- a/examples/code-splitted-require.context/template.md
+++ b/examples/code-splitted-require.context/template.md
@@ -4,28 +4,28 @@
{{example.js}}
```
-# js/output.js
+# dist/output.js
``` javascript
-{{js/output.js}}
+{{dist/output.js}}
```
-# js/0.output.js
+# dist/0.output.js
``` javascript
-{{js/0.output.js}}
+{{dist/0.output.js}}
```
# Info
-## Uncompressed
+## Unoptimized
```
{{stdout}}
```
-## Minimized (uglify-js, no zip)
+## Production mode
```
-{{min:stdout}}
+{{production:stdout}}
```
diff --git a/examples/code-splitted-require.context/webpack.config.js b/examples/code-splitted-require.context/webpack.config.js
new file mode 100644
index 00000000..0d554bf6
--- /dev/null
+++ b/examples/code-splitted-require.context/webpack.config.js
@@ -0,0 +1,5 @@
+module.exports = {
+ optimization: {
+ occurrenceOrder: true // To keep filename consistent between different modes (for example building only)
+ }
+};
diff --git a/examples/code-splitting-bundle-loader/README.md b/examples/code-splitting-bundle-loader/README.md
index 8d19cbc4..0888ab50 100644
--- a/examples/code-splitting-bundle-loader/README.md
+++ b/examples/code-splitting-bundle-loader/README.md
@@ -17,18 +17,20 @@ module.exports = "It works";
```
-# js/output.js
+# dist/output.js
<details><summary><code>/******/ (function(modules) { /* webpackBootstrap */ })</code></summary>
``` javascript
/******/ (function(modules) { // webpackBootstrap
/******/ // install a JSONP callback for chunk loading
-/******/ var parentJsonpFunction = window["webpackJsonp"];
-/******/ window["webpackJsonp"] = function webpackJsonpCallback(chunkIds, moreModules, executeModules) {
+/******/ function webpackJsonpCallback(data) {
+/******/ var chunkIds = data[0];
+/******/ var moreModules = data[1]
+/******/
/******/ // add "moreModules" to the modules object,
/******/ // then flag all "chunkIds" as loaded and fire callback
-/******/ var moduleId, chunkId, i = 0, resolves = [], result;
+/******/ var moduleId, chunkId, i = 0, resolves = [];
/******/ for(;i < chunkIds.length; i++) {
/******/ chunkId = chunkIds[i];
/******/ if(installedChunks[chunkId]) {
@@ -41,21 +43,24 @@ module.exports = "It works";
/******/ modules[moduleId] = moreModules[moduleId];
/******/ }
/******/ }
-/******/ if(parentJsonpFunction) parentJsonpFunction(chunkIds, moreModules, executeModules);
+/******/ if(parentJsonpFunction) parentJsonpFunction(data);
/******/ while(resolves.length) {
/******/ resolves.shift()();
/******/ }
/******/
/******/ };
/******/
+/******/
/******/ // The module cache
/******/ var installedModules = {};
/******/
-/******/ // objects to store loaded and loading chunks
+/******/ // object to store loaded and loading chunks
/******/ var installedChunks = {
/******/ 1: 0
/******/ };
/******/
+/******/
+/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
@@ -83,51 +88,60 @@ module.exports = "It works";
/******/ // This file contains only the entry chunk.
/******/ // The chunk loading function for additional chunks
/******/ __webpack_require__.e = function requireEnsure(chunkId) {
+/******/ var promises = [];
+/******/
+/******/
+/******/ // JSONP chunk loading for javascript
+/******/
/******/ var installedChunkData = installedChunks[chunkId];
-/******/ if(installedChunkData === 0) {
-/******/ return new Promise(function(resolve) { resolve(); });
-/******/ }
+/******/ if(installedChunkData !== 0) { // 0 means "already installed".
/******/
-/******/ // a Promise means "currently loading".
-/******/ if(installedChunkData) {
-/******/ return installedChunkData[2];
-/******/ }
+/******/ // a Promise means "currently loading".
+/******/ if(installedChunkData) {
+/******/ promises.push(installedChunkData[2]);
+/******/ } else {
+/******/ // setup Promise in chunk cache
+/******/ var promise = new Promise(function(resolve, reject) {
+/******/ installedChunkData = installedChunks[chunkId] = [resolve, reject];
+/******/ });
+/******/ promises.push(installedChunkData[2] = promise);
/******/
-/******/ // setup Promise in chunk cache
-/******/ var promise = new Promise(function(resolve, reject) {
-/******/ installedChunkData = installedChunks[chunkId] = [resolve, reject];
-/******/ });
-/******/ installedChunkData[2] = promise;
+/******/ // start chunk loading
+/******/ var head = document.getElementsByTagName('head')[0];
+/******/ var script = document.createElement('script');
/******/
-/******/ // start chunk loading
-/******/ var head = document.getElementsByTagName('head')[0];
-/******/ var script = document.createElement('script');
-/******/ script.type = 'text/javascript';
-/******/ script.charset = 'utf-8';
-/******/ script.async = true;
-/******/ script.timeout = 120000;
+/******/ script.charset = 'utf-8';
+/******/ script.timeout = 120000;
/******/
-/******/ if (__webpack_require__.nc) {
-/******/ script.setAttribute("nonce", __webpack_require__.nc);
-/******/ }
-/******/ script.src = __webpack_require__.p + "" + chunkId + ".output.js";
-/******/ var timeout = setTimeout(onScriptComplete, 120000);
-/******/ script.onerror = script.onload = onScriptComplete;
-/******/ function onScriptComplete() {
-/******/ // avoid mem leaks in IE.
-/******/ script.onerror = script.onload = null;
-/******/ clearTimeout(timeout);
-/******/ var chunk = installedChunks[chunkId];
-/******/ if(chunk !== 0) {
-/******/ if(chunk) {
-/******/ chunk[1](new Error('Loading chunk ' + chunkId + ' failed.'));
+/******/ if (__webpack_require__.nc) {
+/******/ script.setAttribute("nonce", __webpack_require__.nc);
/******/ }
-/******/ installedChunks[chunkId] = undefined;
+/******/ script.src = __webpack_require__.p + "" + chunkId + ".output.js";
+/******/ var timeout = setTimeout(function(){
+/******/ onScriptComplete({ type: 'timeout', target: script });
+/******/ }, 120000);
+/******/ script.onerror = script.onload = onScriptComplete;
+/******/ function onScriptComplete(event) {
+/******/ // avoid mem leaks in IE.
+/******/ script.onerror = script.onload = null;
+/******/ clearTimeout(timeout);
+/******/ var chunk = installedChunks[chunkId];
+/******/ if(chunk !== 0) {
+/******/ if(chunk) {
+/******/ var errorType = event && (event.type === 'load' ? 'missing' : event.type);
+/******/ var realSrc = event && event.target && event.target.src;
+/******/ var error = new Error('Loading chunk ' + chunkId + ' failed.\n(' + errorType + ': ' + realSrc + ')');
+/******/ error.type = errorType;
+/******/ error.request = realSrc;
+/******/ chunk[1](error);
+/******/ }
+/******/ installedChunks[chunkId] = undefined;
+/******/ }
+/******/ };
+/******/ head.appendChild(script);
/******/ }
-/******/ };
-/******/ head.appendChild(script);
-/******/
-/******/ return promise;
+/******/ }
+/******/ return Promise.all(promises);
/******/ };
/******/
/******/ // expose the modules object (__webpack_modules__)
@@ -147,6 +161,11 @@ module.exports = "It works";
/******/ }
/******/ };
/******/
+/******/ // define __esModule on exports
+/******/ __webpack_require__.r = function(exports) {
+/******/ Object.defineProperty(exports, '__esModule', { value: true });
+/******/ };
+/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
@@ -160,13 +179,21 @@ module.exports = "It works";
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
-/******/ __webpack_require__.p = "js/";
+/******/ __webpack_require__.p = "dist/";
/******/
/******/ // on error function for async loading
/******/ __webpack_require__.oe = function(err) { console.error(err); throw err; };
/******/
+/******/ var jsonpArray = window["webpackJsonp"] = window["webpackJsonp"] || [];
+/******/ var oldJsonpFunction = jsonpArray.push.bind(jsonpArray);
+/******/ jsonpArray.push = webpackJsonpCallback;
+/******/ jsonpArray = jsonpArray.slice();
+/******/ for(var i = 0; i < jsonpArray.length; i++) webpackJsonpCallback(jsonpArray[i]);
+/******/ var parentJsonpFunction = oldJsonpFunction;
+/******/
+/******/
/******/ // Load entry module and return exports
-/******/ return __webpack_require__(__webpack_require__.s = 0);
+/******/ return __webpack_require__(__webpack_require__.s = 1);
/******/ })
/************************************************************************/
```
@@ -176,25 +203,10 @@ module.exports = "It works";
``` javascript
/******/ ([
/* 0 */
-/*!********************!*\
- !*** ./example.js ***!
- \********************/
-/*! no static exports found */
-/*! all exports used */
-/***/ (function(module, exports, __webpack_require__) {
-
-__webpack_require__(/*! bundle-loader!./file.js */ 1)(function(fileJsExports) {
- console.log(fileJsExports);
-});
-
-
-/***/ }),
-/* 1 */
/*!******************************************************!*\
!*** (webpack)/node_modules/bundle-loader!./file.js ***!
\******************************************************/
/*! no static exports found */
-/*! all exports used */
/***/ (function(module, exports, __webpack_require__) {
var cbs = [],
@@ -203,7 +215,7 @@ module.exports = function(cb) {
if(cbs) cbs.push(cb);
else cb(data);
}
-__webpack_require__.e/* require.ensure */(0).then((function(require) {
+__webpack_require__.e(/*! require.ensure */ 0).then((function(require) {
data = __webpack_require__(/*! !./file.js */ 2);
var callbacks = cbs;
cbs = null;
@@ -212,68 +224,82 @@ __webpack_require__.e/* require.ensure */(0).then((function(require) {
}
}).bind(null, __webpack_require__)).catch(__webpack_require__.oe);
+/***/ }),
+/* 1 */
+/*!********************!*\
+ !*** ./example.js ***!
+ \********************/
+/*! no static exports found */
+/***/ (function(module, exports, __webpack_require__) {
+
+__webpack_require__(/*! bundle-loader!./file.js */ 0)(function(fileJsExports) {
+ console.log(fileJsExports);
+});
+
+
/***/ })
/******/ ]);
```
-# js/0.output.js
+# dist/0.output.js
``` javascript
-webpackJsonp([0],{
+(window["webpackJsonp"] = window["webpackJsonp"] || []).push([[0],{
/***/ 2:
/*!*****************!*\
!*** ./file.js ***!
\*****************/
/*! no static exports found */
-/*! all exports used */
/***/ (function(module, exports) {
module.exports = "It works";
/***/ })
-});
+}]);
```
# Info
-## Uncompressed
+## Unoptimized
```
-Hash: 0f292e2adbe6929efd48
-Version: webpack 3.5.1
+Hash: 0a1b2c3d4e5f6a7b8c9d
+Version: webpack 4.0.0-beta.2
Asset Size Chunks Chunk Names
-0.output.js 231 bytes 0 [emitted]
- output.js 6.73 kB 1 [emitted] main
+0.output.js 257 bytes 0 [emitted]
+ output.js 7.56 KiB 1 [emitted] main
Entrypoint main = output.js
-chunk {0} 0.output.js 28 bytes {1} [rendered]
- > [1] (webpack)/node_modules/bundle-loader!./file.js 7:0-14:2
+chunk {0} 0.output.js 28 bytes <{1}> [rendered]
+ > [0] (webpack)/node_modules/bundle-loader!./file.js 7:0-14:2
[2] ./file.js 28 bytes {0} [built]
- cjs require !!./file.js [1] (webpack)/node_modules/bundle-loader!./file.js 8:8-30
-chunk {1} output.js (main) 378 bytes [entry] [rendered]
- > main [0] ./example.js
- [0] ./example.js 97 bytes {1} [built]
- [1] (webpack)/node_modules/bundle-loader!./file.js 281 bytes {1} [built]
- cjs require bundle-loader!./file.js [0] ./example.js 1:0-34
+ cjs require !!./file.js [0] (webpack)/node_modules/bundle-loader!./file.js 8:8-30
+chunk {1} output.js (main) 378 bytes >{0}< [entry] [rendered]
+ > .\example.js main
+ [0] (webpack)/node_modules/bundle-loader!./file.js 281 bytes {1} [built]
+ cjs require bundle-loader!./file.js [1] ./example.js 1:0-34
+ [1] ./example.js 97 bytes {1} [built]
+ single entry .\example.js main
```
-## Minimized (uglify-js, no zip)
+## Production mode
```
-Hash: 0f292e2adbe6929efd48
-Version: webpack 3.5.1
+Hash: 0a1b2c3d4e5f6a7b8c9d
+Version: webpack 4.0.0-beta.2
Asset Size Chunks Chunk Names
-0.output.js 58 bytes 0 [emitted]
- output.js 1.55 kB 1 [emitted] main
+0.output.js 98 bytes 0 [emitted]
+ output.js 1.79 KiB 1 [emitted] main
Entrypoint main = output.js
-chunk {0} 0.output.js 28 bytes {1} [rendered]
- > [1] (webpack)/node_modules/bundle-loader!./file.js 7:0-14:2
+chunk {0} 0.output.js 28 bytes <{1}> [rendered]
+ > [0] (webpack)/node_modules/bundle-loader!./file.js 7:0-14:2
[2] ./file.js 28 bytes {0} [built]
- cjs require !!./file.js [1] (webpack)/node_modules/bundle-loader!./file.js 8:8-30
-chunk {1} output.js (main) 378 bytes [entry] [rendered]
- > main [0] ./example.js
- [0] ./example.js 97 bytes {1} [built]
- [1] (webpack)/node_modules/bundle-loader!./file.js 281 bytes {1} [built]
- cjs require bundle-loader!./file.js [0] ./example.js 1:0-34
+ cjs require !!./file.js [0] (webpack)/node_modules/bundle-loader!./file.js 8:8-30
+chunk {1} output.js (main) 378 bytes >{0}< [entry] [rendered]
+ > .\example.js main
+ [0] (webpack)/node_modules/bundle-loader!./file.js 281 bytes {1} [built]
+ cjs require bundle-loader!./file.js [1] ./example.js 1:0-34
+ [1] ./example.js 97 bytes {1} [built]
+ single entry .\example.js main
```
diff --git a/examples/code-splitting-bundle-loader/template.md b/examples/code-splitting-bundle-loader/template.md
index dbe8cfe5..f7c26e8b 100644
--- a/examples/code-splitting-bundle-loader/template.md
+++ b/examples/code-splitting-bundle-loader/template.md
@@ -15,28 +15,28 @@ The bundle loader is used to create a wrapper module for `file.js` that loads th
```
-# js/output.js
+# dist/output.js
``` javascript
-{{js/output.js}}
+{{dist/output.js}}
```
-# js/0.output.js
+# dist/0.output.js
``` javascript
-{{js/0.output.js}}
+{{dist/0.output.js}}
```
# Info
-## Uncompressed
+## Unoptimized
```
{{stdout}}
```
-## Minimized (uglify-js, no zip)
+## Production mode
```
-{{min:stdout}}
+{{production:stdout}}
```
diff --git a/examples/code-splitting-bundle-loader/webpack.config.js b/examples/code-splitting-bundle-loader/webpack.config.js
new file mode 100644
index 00000000..0d554bf6
--- /dev/null
+++ b/examples/code-splitting-bundle-loader/webpack.config.js
@@ -0,0 +1,5 @@
+module.exports = {
+ optimization: {
+ occurrenceOrder: true // To keep filename consistent between different modes (for example building only)
+ }
+};
diff --git a/examples/code-splitting-harmony/README.md b/examples/code-splitting-harmony/README.md
index 4c03bc9e..d762f33d 100644
--- a/examples/code-splitting-harmony/README.md
+++ b/examples/code-splitting-harmony/README.md
@@ -25,18 +25,20 @@ Promise.all([loadC("1"), loadC("2")]).then(function(arr) {
```
-# js/output.js
+# dist/output.js
<details><summary><code>/******/ (function(modules) { /* webpackBootstrap */ })</code></summary>
``` javascript
/******/ (function(modules) { // webpackBootstrap
/******/ // install a JSONP callback for chunk loading
-/******/ var parentJsonpFunction = window["webpackJsonp"];
-/******/ window["webpackJsonp"] = function webpackJsonpCallback(chunkIds, moreModules, executeModules) {
+/******/ function webpackJsonpCallback(data) {
+/******/ var chunkIds = data[0];
+/******/ var moreModules = data[1]
+/******/
/******/ // add "moreModules" to the modules object,
/******/ // then flag all "chunkIds" as loaded and fire callback
-/******/ var moduleId, chunkId, i = 0, resolves = [], result;
+/******/ var moduleId, chunkId, i = 0, resolves = [];
/******/ for(;i < chunkIds.length; i++) {
/******/ chunkId = chunkIds[i];
/******/ if(installedChunks[chunkId]) {
@@ -49,21 +51,24 @@ Promise.all([loadC("1"), loadC("2")]).then(function(arr) {
/******/ modules[moduleId] = moreModules[moduleId];
/******/ }
/******/ }
-/******/ if(parentJsonpFunction) parentJsonpFunction(chunkIds, moreModules, executeModules);
+/******/ if(parentJsonpFunction) parentJsonpFunction(data);
/******/ while(resolves.length) {
/******/ resolves.shift()();
/******/ }
/******/
/******/ };
/******/
+/******/
/******/ // The module cache
/******/ var installedModules = {};
/******/
-/******/ // objects to store loaded and loading chunks
+/******/ // object to store loaded and loading chunks
/******/ var installedChunks = {
/******/ 3: 0
/******/ };
/******/
+/******/
+/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
@@ -91,51 +96,60 @@ Promise.all([loadC("1"), loadC("2")]).then(function(arr) {
/******/ // This file contains only the entry chunk.
/******/ // The chunk loading function for additional chunks
/******/ __webpack_require__.e = function requireEnsure(chunkId) {
+/******/ var promises = [];
+/******/
+/******/
+/******/ // JSONP chunk loading for javascript
+/******/
/******/ var installedChunkData = installedChunks[chunkId];
-/******/ if(installedChunkData === 0) {
-/******/ return new Promise(function(resolve) { resolve(); });
-/******/ }
+/******/ if(installedChunkData !== 0) { // 0 means "already installed".
/******/
-/******/ // a Promise means "currently loading".
-/******/ if(installedChunkData) {
-/******/ return installedChunkData[2];
-/******/ }
+/******/ // a Promise means "currently loading".
+/******/ if(installedChunkData) {
+/******/ promises.push(installedChunkData[2]);
+/******/ } else {
+/******/ // setup Promise in chunk cache
+/******/ var promise = new Promise(function(resolve, reject) {
+/******/ installedChunkData = installedChunks[chunkId] = [resolve, reject];
+/******/ });
+/******/ promises.push(installedChunkData[2] = promise);
/******/
-/******/ // setup Promise in chunk cache
-/******/ var promise = new Promise(function(resolve, reject) {
-/******/ installedChunkData = installedChunks[chunkId] = [resolve, reject];
-/******/ });
-/******/ installedChunkData[2] = promise;
+/******/ // start chunk loading
+/******/ var head = document.getElementsByTagName('head')[0];
+/******/ var script = document.createElement('script');
/******/
-/******/ // start chunk loading
-/******/ var head = document.getElementsByTagName('head')[0];
-/******/ var script = document.createElement('script');
-/******/ script.type = 'text/javascript';
-/******/ script.charset = 'utf-8';
-/******/ script.async = true;
-/******/ script.timeout = 120000;
+/******/ script.charset = 'utf-8';
+/******/ script.timeout = 120000;
/******/
-/******/ if (__webpack_require__.nc) {
-/******/ script.setAttribute("nonce", __webpack_require__.nc);
-/******/ }
-/******/ script.src = __webpack_require__.p + "" + chunkId + ".output.js";
-/******/ var timeout = setTimeout(onScriptComplete, 120000);
-/******/ script.onerror = script.onload = onScriptComplete;
-/******/ function onScriptComplete() {
-/******/ // avoid mem leaks in IE.
-/******/ script.onerror = script.onload = null;
-/******/ clearTimeout(timeout);
-/******/ var chunk = installedChunks[chunkId];
-/******/ if(chunk !== 0) {
-/******/ if(chunk) {
-/******/ chunk[1](new Error('Loading chunk ' + chunkId + ' failed.'));
+/******/ if (__webpack_require__.nc) {
+/******/ script.setAttribute("nonce", __webpack_require__.nc);
/******/ }
-/******/ installedChunks[chunkId] = undefined;
+/******/ script.src = __webpack_require__.p + "" + chunkId + ".output.js";
+/******/ var timeout = setTimeout(function(){
+/******/ onScriptComplete({ type: 'timeout', target: script });
+/******/ }, 120000);
+/******/ script.onerror = script.onload = onScriptComplete;
+/******/ function onScriptComplete(event) {
+/******/ // avoid mem leaks in IE.
+/******/ script.onerror = script.onload = null;
+/******/ clearTimeout(timeout);
+/******/ var chunk = installedChunks[chunkId];
+/******/ if(chunk !== 0) {
+/******/ if(chunk) {
+/******/ var errorType = event && (event.type === 'load' ? 'missing' : event.type);
+/******/ var realSrc = event && event.target && event.target.src;
+/******/ var error = new Error('Loading chunk ' + chunkId + ' failed.\n(' + errorType + ': ' + realSrc + ')');
+/******/ error.type = errorType;
+/******/ error.request = realSrc;
+/******/ chunk[1](error);
+/******/ }
+/******/ installedChunks[chunkId] = undefined;
+/******/ }
+/******/ };
+/******/ head.appendChild(script);
/******/ }
-/******/ };
-/******/ head.appendChild(script);
-/******/
-/******/ return promise;
+/******/ }
+/******/ return Promise.all(promises);
/******/ };
/******/
/******/ // expose the modules object (__webpack_modules__)
@@ -155,6 +169,11 @@ Promise.all([loadC("1"), loadC("2")]).then(function(arr) {
/******/ }
/******/ };
/******/
+/******/ // define __esModule on exports
+/******/ __webpack_require__.r = function(exports) {
+/******/ Object.defineProperty(exports, '__esModule', { value: true });
+/******/ };
+/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
@@ -168,13 +187,21 @@ Promise.all([loadC("1"), loadC("2")]).then(function(arr) {
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
-/******/ __webpack_require__.p = "js/";
+/******/ __webpack_require__.p = "dist/";
/******/
/******/ // on error function for async loading
/******/ __webpack_require__.oe = function(err) { console.error(err); throw err; };
/******/
+/******/ var jsonpArray = window["webpackJsonp"] = window["webpackJsonp"] || [];
+/******/ var oldJsonpFunction = jsonpArray.push.bind(jsonpArray);
+/******/ jsonpArray.push = webpackJsonpCallback;
+/******/ jsonpArray = jsonpArray.slice();
+/******/ for(var i = 0; i < jsonpArray.length; i++) webpackJsonpCallback(jsonpArray[i]);
+/******/ var parentJsonpFunction = oldJsonpFunction;
+/******/
+/******/
/******/ // Load entry module and return exports
-/******/ return __webpack_require__(__webpack_require__.s = 2);
+/******/ return __webpack_require__(__webpack_require__.s = 4);
/******/ })
/************************************************************************/
```
@@ -186,83 +213,87 @@ Promise.all([loadC("1"), loadC("2")]).then(function(arr) {
/* 0 */,
/* 1 */,
/* 2 */
-/*!********************!*\
- !*** ./example.js ***!
- \********************/
-/*! exports provided: */
-/*! all exports used */
-/***/ (function(module, __webpack_exports__, __webpack_require__) {
-
-"use strict";
-Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
-/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_a__ = __webpack_require__(/*! a */ 3);
-/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_a___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_a__);
-
-
-__webpack_require__.e/* import() */(2).then(__webpack_require__.bind(null, /*! b */ 5)).then(function(b) {
- console.log("b loaded", b);
-})
-
-function loadC(name) {
- return __webpack_require__(/*! c */ 4)("./" + name);
-}
-
-Promise.all([loadC("1"), loadC("2")]).then(function(arr) {
- console.log("c/1 and c/2 loaded", arr);
-});
-
-
-/***/ }),
-/* 3 */
-/*!***************************!*\
- !*** ./node_modules/a.js ***!
- \***************************/
+/*!*******************************************************!*\
+ !*** ./node_modules/c lazy ^\.\/.*$ namespace object ***!
+ \*******************************************************/
/*! no static exports found */
-/***/ (function(module, exports) {
-
-// module a
-
-/***/ }),
-/* 4 */
-/*!**************************************!*\
- !*** ./node_modules/c lazy ^\.\/.*$ ***!
- \**************************************/
-/*! no static exports found */
-/*! all exports used */
/***/ (function(module, exports, __webpack_require__) {
var map = {
"./1": [
- 0,
+ 1,
1
],
"./1.js": [
- 0,
+ 1,
1
],
"./2": [
- 1,
+ 0,
0
],
"./2.js": [
- 1,
+ 0,
0
]
};
function webpackAsyncContext(req) {
var ids = map[req];
- if(!ids)
- return Promise.reject(new Error("Cannot find module '" + req + "'."));
+ if(!ids) {
+ return Promise.resolve().then(function() {
+ var e = new Error('Cannot find module "' + req + '".');
+ e.code = 'MODULE_NOT_FOUND';
+ throw e;
+ });
+ }
return __webpack_require__.e(ids[1]).then(function() {
- return __webpack_require__(ids[0]);
+ var module = __webpack_require__(ids[0]);
+ return (typeof module === "object" && module && module.__esModule ? module : /* fake namespace object */ { "default": module });
});
-};
+}
webpackAsyncContext.keys = function webpackAsyncContextKeys() {
return Object.keys(map);
};
-webpackAsyncContext.id = 4;
+webpackAsyncContext.id = 2;
module.exports = webpackAsyncContext;
+/***/ }),
+/* 3 */
+/*!***************************!*\
+ !*** ./node_modules/a.js ***!
+ \***************************/
+/*! no static exports found */
+/***/ (function(module, exports) {
+
+// module a
+
+/***/ }),
+/* 4 */
+/*!********************!*\
+ !*** ./example.js ***!
+ \********************/
+/*! no exports provided */
+/***/ (function(module, __webpack_exports__, __webpack_require__) {
+
+"use strict";
+__webpack_require__.r(__webpack_exports__);
+/* harmony import */ var a__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! a */ 3);
+/* harmony import */ var a__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(a__WEBPACK_IMPORTED_MODULE_0__);
+
+
+__webpack_require__.e(/*! import() */ 2).then(function() { var module = __webpack_require__(/*! b */ 5); return typeof module === "object" && module && module.__esModule ? module : { /* fake namespace object */ "default": module }; }).then(function(b) {
+ console.log("b loaded", b);
+})
+
+function loadC(name) {
+ return __webpack_require__(2)("./" + name);
+}
+
+Promise.all([loadC("1"), loadC("2")]).then(function(arr) {
+ console.log("c/1 and c/2 loaded", arr);
+});
+
+
/***/ })
/******/ ]);
```
@@ -270,56 +301,66 @@ module.exports = webpackAsyncContext;
# Info
-## Uncompressed
+## Unoptimized
```
-Hash: f2701c90a6d1597932b5
-Version: webpack 3.5.1
+Hash: 0a1b2c3d4e5f6a7b8c9d
+Version: webpack 4.0.0-beta.2
Asset Size Chunks Chunk Names
-0.output.js 258 bytes 0 [emitted]
-1.output.js 249 bytes 1 [emitted]
-2.output.js 244 bytes 2 [emitted]
- output.js 7.55 kB 3 [emitted] main
+0.output.js 275 bytes 0 [emitted]
+1.output.js 284 bytes 1 [emitted]
+2.output.js 270 bytes 2 [emitted]
+ output.js 8.74 KiB 3 [emitted] main
Entrypoint main = output.js
-chunk {0} 0.output.js 13 bytes {3} [rendered]
+chunk {0} 0.output.js 13 bytes <{3}> [rendered]
+ > ./2 [2] ./node_modules/c lazy ^\.\/.*$ namespace object ./2
+ > ./2.js [2] ./node_modules/c lazy ^\.\/.*$ namespace object ./2.js
1 module
-chunk {1} 1.output.js 13 bytes {3} [rendered]
+chunk {1} 1.output.js 13 bytes <{3}> [rendered]
+ > ./1 [2] ./node_modules/c lazy ^\.\/.*$ namespace object ./1
+ > ./1.js [2] ./node_modules/c lazy ^\.\/.*$ namespace object ./1.js
1 module
-chunk {2} 2.output.js 11 bytes {3} [rendered]
- > [2] ./example.js 3:0-11
+chunk {2} 2.output.js 11 bytes <{3}> [rendered]
+ > b [4] ./example.js 3:0-11
1 module
-chunk {3} output.js (main) 427 bytes [entry] [rendered]
- > main [2] ./example.js
- [2] ./example.js 256 bytes {3} [built]
+chunk {3} output.js (main) 427 bytes >{0}< >{1}< >{2}< [entry] [rendered]
+ > .\example.js main
+ [2] ./node_modules/c lazy ^\.\/.*$ namespace object 160 bytes {3} [built]
+ import() context lazy c [4] ./example.js 8:8-27
+ [4] ./example.js 256 bytes {3} [built]
[no exports]
- [4] ./node_modules/c lazy ^\.\/.*$ 160 bytes {3} [built]
- import() context lazy c [2] ./example.js 8:8-27
+ single entry .\example.js main
+ 1 hidden module
```
-## Minimized (uglify-js, no zip)
+## Production mode
```
-Hash: f2701c90a6d1597932b5
-Version: webpack 3.5.1
+Hash: 0a1b2c3d4e5f6a7b8c9d
+Version: webpack 4.0.0-beta.2
Asset Size Chunks Chunk Names
-0.output.js 37 bytes 0 [emitted]
-1.output.js 36 bytes 1 [emitted]
-2.output.js 38 bytes 2 [emitted]
- output.js 1.9 kB 3 [emitted] main
+0.output.js 76 bytes 0 [emitted]
+1.output.js 77 bytes 1 [emitted]
+2.output.js 78 bytes 2 [emitted]
+ output.js 2.25 KiB 3 [emitted] main
Entrypoint main = output.js
-chunk {0} 0.output.js 13 bytes {3} [rendered]
+chunk {0} 0.output.js 13 bytes <{3}> [rendered]
+ > ./2 [2] ./node_modules/c lazy ^\.\/.*$ namespace object ./2
+ > ./2.js [2] ./node_modules/c lazy ^\.\/.*$ namespace object ./2.js
1 module
-chunk {1} 1.output.js 13 bytes {3} [rendered]
+chunk {1} 1.output.js 13 bytes <{3}> [rendered]
+ > ./1 [2] ./node_modules/c lazy ^\.\/.*$ namespace object ./1
+ > ./1.js [2] ./node_modules/c lazy ^\.\/.*$ namespace object ./1.js
1 module
-chunk {2} 2.output.js 11 bytes {3} [rendered]
- > [2] ./example.js 3:0-11
+chunk {2} 2.output.js 11 bytes <{3}> [rendered]
+ > b [4] ./example.js 3:0-11
1 module
-chunk {3} output.js (main) 427 bytes [entry] [rendered]
- > main [2] ./example.js
- [2] ./example.js 256 bytes {3} [built]
+chunk {3} output.js (main) 427 bytes >{0}< >{1}< >{2}< [entry] [rendered]
+ > .\example.js main
+ [2] ./node_modules/c lazy ^\.\/.*$ namespace object 160 bytes {3} [built]
+ import() context lazy c [4] ./example.js 8:8-27
+ [4] ./example.js 256 bytes {3} [built]
[no exports]
- [4] ./node_modules/c lazy ^\.\/.*$ 160 bytes {3} [built]
- import() context lazy c [2] ./example.js 8:8-27
+ single entry .\example.js main
+ 1 hidden module
```
diff --git a/examples/code-splitting-harmony/template.md b/examples/code-splitting-harmony/template.md
index 33c94859..5f6a68cd 100644
--- a/examples/code-splitting-harmony/template.md
+++ b/examples/code-splitting-harmony/template.md
@@ -13,23 +13,23 @@ Providing dynamic expressions to `import` is possible. The same limits as with d
```
-# js/output.js
+# dist/output.js
``` javascript
-{{js/output.js}}
+{{dist/output.js}}
```
# Info
-## Uncompressed
+## Unoptimized
```
{{stdout}}
```
-## Minimized (uglify-js, no zip)
+## Production mode
```
-{{min:stdout}}
+{{production:stdout}}
```
diff --git a/examples/code-splitting-harmony/webpack.config.js b/examples/code-splitting-harmony/webpack.config.js
new file mode 100644
index 00000000..0d554bf6
--- /dev/null
+++ b/examples/code-splitting-harmony/webpack.config.js
@@ -0,0 +1,5 @@
+module.exports = {
+ optimization: {
+ occurrenceOrder: true // To keep filename consistent between different modes (for example building only)
+ }
+};
diff --git a/examples/code-splitting-native-import-context-filter/README.md b/examples/code-splitting-native-import-context-filter/README.md
new file mode 100644
index 00000000..25595e12
--- /dev/null
+++ b/examples/code-splitting-native-import-context-filter/README.md
@@ -0,0 +1,398 @@
+# example.js
+
+This example illustrates how to filter the ContextModule results of `import()` statements. only `.js` files that don't
+end in `.noimport.js` within the `templates` folder will be bundled.
+
+``` javascript
+async function getTemplate(templateName) {
+ try {
+ let template = await import(
+ /* webpackInclude: /\.js$/ */
+ /* webpackExclude: /\.noimport\.js$/ */
+ `./templates/${templateName}`
+ );
+ console.log(template);
+ } catch(err) {
+ console.error(err);
+ return new Error(err);
+ }
+}
+
+getTemplate("foo");
+getTemplate("bar");
+getTemplate("baz");
+getTemplate("foo.noimport");
+getTemplate("bar.noimport");
+getTemplate("baz.noimport");
+```
+
+# templates/
+
+* foo.js
+* foo.noimport.js
+* baz.js
+* foo.noimport.js
+* bar.js
+* foo.noimport.js
+
+All templates are of this pattern:
+
+``` javascript
+var foo = "foo";
+
+export default foo;
+```
+
+# dist/output.js
+
+<details><summary><code>/******/ (function(modules) { /* webpackBootstrap */ })</code></summary>
+
+``` javascript
+/******/ (function(modules) { // webpackBootstrap
+/******/ // install a JSONP callback for chunk loading
+/******/ function webpackJsonpCallback(data) {
+/******/ var chunkIds = data[0];
+/******/ var moreModules = data[1]
+/******/
+/******/ // add "moreModules" to the modules object,
+/******/ // then flag all "chunkIds" as loaded and fire callback
+/******/ var moduleId, chunkId, i = 0, resolves = [];
+/******/ for(;i < chunkIds.length; i++) {
+/******/ chunkId = chunkIds[i];
+/******/ if(installedChunks[chunkId]) {
+/******/ resolves.push(installedChunks[chunkId][0]);
+/******/ }
+/******/ installedChunks[chunkId] = 0;
+/******/ }
+/******/ for(moduleId in moreModules) {
+/******/ if(Object.prototype.hasOwnProperty.call(moreModules, moduleId)) {
+/******/ modules[moduleId] = moreModules[moduleId];
+/******/ }
+/******/ }
+/******/ if(parentJsonpFunction) parentJsonpFunction(data);
+/******/ while(resolves.length) {
+/******/ resolves.shift()();
+/******/ }
+/******/
+/******/ };
+/******/
+/******/
+/******/ // The module cache
+/******/ var installedModules = {};
+/******/
+/******/ // object to store loaded and loading chunks
+/******/ var installedChunks = {
+/******/ 3: 0
+/******/ };
+/******/
+/******/
+/******/
+/******/ // The require function
+/******/ function __webpack_require__(moduleId) {
+/******/
+/******/ // Check if module is in cache
+/******/ if(installedModules[moduleId]) {
+/******/ return installedModules[moduleId].exports;
+/******/ }
+/******/ // Create a new module (and put it into the cache)
+/******/ var module = installedModules[moduleId] = {
+/******/ i: moduleId,
+/******/ l: false,
+/******/ exports: {}
+/******/ };
+/******/
+/******/ // Execute the module function
+/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
+/******/
+/******/ // Flag the module as loaded
+/******/ module.l = true;
+/******/
+/******/ // Return the exports of the module
+/******/ return module.exports;
+/******/ }
+/******/
+/******/ // This file contains only the entry chunk.
+/******/ // The chunk loading function for additional chunks
+/******/ __webpack_require__.e = function requireEnsure(chunkId) {
+/******/ var promises = [];
+/******/
+/******/
+/******/ // JSONP chunk loading for javascript
+/******/
+/******/ var installedChunkData = installedChunks[chunkId];
+/******/ if(installedChunkData !== 0) { // 0 means "already installed".
+/******/
+/******/ // a Promise means "currently loading".
+/******/ if(installedChunkData) {
+/******/ promises.push(installedChunkData[2]);
+/******/ } else {
+/******/ // setup Promise in chunk cache
+/******/ var promise = new Promise(function(resolve, reject) {
+/******/ installedChunkData = installedChunks[chunkId] = [resolve, reject];
+/******/ });
+/******/ promises.push(installedChunkData[2] = promise);
+/******/
+/******/ // start chunk loading
+/******/ var head = document.getElementsByTagName('head')[0];
+/******/ var script = document.createElement('script');
+/******/
+/******/ script.charset = 'utf-8';
+/******/ script.timeout = 120000;
+/******/
+/******/ if (__webpack_require__.nc) {
+/******/ script.setAttribute("nonce", __webpack_require__.nc);
+/******/ }
+/******/ script.src = __webpack_require__.p + "" + chunkId + ".output.js";
+/******/ var timeout = setTimeout(function(){
+/******/ onScriptComplete({ type: 'timeout', target: script });
+/******/ }, 120000);
+/******/ script.onerror = script.onload = onScriptComplete;
+/******/ function onScriptComplete(event) {
+/******/ // avoid mem leaks in IE.
+/******/ script.onerror = script.onload = null;
+/******/ clearTimeout(timeout);
+/******/ var chunk = installedChunks[chunkId];
+/******/ if(chunk !== 0) {
+/******/ if(chunk) {
+/******/ var errorType = event && (event.type === 'load' ? 'missing' : event.type);
+/******/ var realSrc = event && event.target && event.target.src;
+/******/ var error = new Error('Loading chunk ' + chunkId + ' failed.\n(' + errorType + ': ' + realSrc + ')');
+/******/ error.type = errorType;
+/******/ error.request = realSrc;
+/******/ chunk[1](error);
+/******/ }
+/******/ installedChunks[chunkId] = undefined;
+/******/ }
+/******/ };
+/******/ head.appendChild(script);
+/******/ }
+/******/ }
+/******/ return Promise.all(promises);
+/******/ };
+/******/
+/******/ // expose the modules object (__webpack_modules__)
+/******/ __webpack_require__.m = modules;
+/******/
+/******/ // expose the module cache
+/******/ __webpack_require__.c = installedModules;
+/******/
+/******/ // define getter function for harmony exports
+/******/ __webpack_require__.d = function(exports, name, getter) {
+/******/ if(!__webpack_require__.o(exports, name)) {
+/******/ Object.defineProperty(exports, name, {
+/******/ configurable: false,
+/******/ enumerable: true,
+/******/ get: getter
+/******/ });
+/******/ }
+/******/ };
+/******/
+/******/ // define __esModule on exports
+/******/ __webpack_require__.r = function(exports) {
+/******/ Object.defineProperty(exports, '__esModule', { value: true });
+/******/ };
+/******/
+/******/ // getDefaultExport function for compatibility with non-harmony modules
+/******/ __webpack_require__.n = function(module) {
+/******/ var getter = module && module.__esModule ?
+/******/ function getDefault() { return module['default']; } :
+/******/ function getModuleExports() { return module; };
+/******/ __webpack_require__.d(getter, 'a', getter);
+/******/ return getter;
+/******/ };
+/******/
+/******/ // Object.prototype.hasOwnProperty.call
+/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
+/******/
+/******/ // __webpack_public_path__
+/******/ __webpack_require__.p = "dist/";
+/******/
+/******/ // on error function for async loading
+/******/ __webpack_require__.oe = function(err) { console.error(err); throw err; };
+/******/
+/******/ var jsonpArray = window["webpackJsonp"] = window["webpackJsonp"] || [];
+/******/ var oldJsonpFunction = jsonpArray.push.bind(jsonpArray);
+/******/ jsonpArray.push = webpackJsonpCallback;
+/******/ jsonpArray = jsonpArray.slice();
+/******/ for(var i = 0; i < jsonpArray.length; i++) webpackJsonpCallback(jsonpArray[i]);
+/******/ var parentJsonpFunction = oldJsonpFunction;
+/******/
+/******/
+/******/ // Load entry module and return exports
+/******/ return __webpack_require__(__webpack_require__.s = 4);
+/******/ })
+/************************************************************************/
+```
+
+</details>
+
+``` javascript
+/******/ ([
+/* 0 */,
+/* 1 */,
+/* 2 */,
+/* 3 */
+/*!******************************************************************************************!*\
+ !*** ./templates lazy ^\.\/.*$ include: \.js$ exclude: \.noimport\.js$ namespace object ***!
+ \******************************************************************************************/
+/*! no static exports found */
+/***/ (function(module, exports, __webpack_require__) {
+
+var map = {
+ "./bar": [
+ 2,
+ 2
+ ],
+ "./bar.js": [
+ 2,
+ 2
+ ],
+ "./baz": [
+ 1,
+ 1
+ ],
+ "./baz.js": [
+ 1,
+ 1
+ ],
+ "./foo": [
+ 0,
+ 0
+ ],
+ "./foo.js": [
+ 0,
+ 0
+ ]
+};
+function webpackAsyncContext(req) {
+ var ids = map[req];
+ if(!ids) {
+ return Promise.resolve().then(function() {
+ var e = new Error('Cannot find module "' + req + '".');
+ e.code = 'MODULE_NOT_FOUND';
+ throw e;
+ });
+ }
+ return __webpack_require__.e(ids[1]).then(function() {
+ var module = __webpack_require__(ids[0]);
+ return module;
+ });
+}
+webpackAsyncContext.keys = function webpackAsyncContextKeys() {
+ return Object.keys(map);
+};
+webpackAsyncContext.id = 3;
+module.exports = webpackAsyncContext;
+
+/***/ }),
+/* 4 */
+/*!********************!*\
+ !*** ./example.js ***!
+ \********************/
+/*! no static exports found */
+/***/ (function(module, exports, __webpack_require__) {
+
+async function getTemplate(templateName) {
+ try {
+ let template = await __webpack_require__(3)(`./${templateName}`);
+ console.log(template);
+ } catch(err) {
+ console.error(err);
+ return new Error(err);
+ }
+}
+
+getTemplate("foo");
+getTemplate("bar");
+getTemplate("baz");
+getTemplate("foo.noimport");
+getTemplate("bar.noimport");
+getTemplate("baz.noimport");
+
+
+
+/***/ })
+/******/ ]);
+```
+
+# Info
+
+## Unoptimized
+
+```
+Hash: 0a1b2c3d4e5f6a7b8c9d
+Version: webpack 4.0.0-beta.2
+ Asset Size Chunks Chunk Names
+0.output.js 436 bytes 0 [emitted]
+1.output.js 445 bytes 1 [emitted]
+2.output.js 439 bytes 2 [emitted]
+ output.js 8.22 KiB 3 [emitted] main
+Entrypoint main = output.js
+chunk {0} 0.output.js 41 bytes <{3}> [rendered]
+ > ./foo [3] ./templates lazy ^\.\/.*$ include: \.js$ exclude: \.noimport\.js$ namespace object ./foo
+ > ./foo.js [3] ./templates lazy ^\.\/.*$ include: \.js$ exclude: \.noimport\.js$ namespace object ./foo.js
+ [0] ./templates/foo.js 41 bytes {0} [optional] [built]
+ [exports: default]
+ context element ./foo.js [3] ./templates lazy ^\.\/.*$ include: \.js$ exclude: \.noimport\.js$ namespace object ./foo.js
+ context element ./foo [3] ./templates lazy ^\.\/.*$ include: \.js$ exclude: \.noimport\.js$ namespace object ./foo
+chunk {1} 1.output.js 41 bytes <{3}> [rendered]
+ > ./baz [3] ./templates lazy ^\.\/.*$ include: \.js$ exclude: \.noimport\.js$ namespace object ./baz
+ > ./baz.js [3] ./templates lazy ^\.\/.*$ include: \.js$ exclude: \.noimport\.js$ namespace object ./baz.js
+ [1] ./templates/baz.js 41 bytes {1} [optional] [built]
+ [exports: default]
+ context element ./baz.js [3] ./templates lazy ^\.\/.*$ include: \.js$ exclude: \.noimport\.js$ namespace object ./baz.js
+ context element ./baz [3] ./templates lazy ^\.\/.*$ include: \.js$ exclude: \.noimport\.js$ namespace object ./baz
+chunk {2} 2.output.js 41 bytes <{3}> [rendered]
+ > ./bar [3] ./templates lazy ^\.\/.*$ include: \.js$ exclude: \.noimport\.js$ namespace object ./bar
+ > ./bar.js [3] ./templates lazy ^\.\/.*$ include: \.js$ exclude: \.noimport\.js$ namespace object ./bar.js
+ [2] ./templates/bar.js 41 bytes {2} [optional] [built]
+ [exports: default]
+ context element ./bar.js [3] ./templates lazy ^\.\/.*$ include: \.js$ exclude: \.noimport\.js$ namespace object ./bar.js
+ context element ./bar [3] ./templates lazy ^\.\/.*$ include: \.js$ exclude: \.noimport\.js$ namespace object ./bar
+chunk {3} output.js (main) 618 bytes >{0}< >{1}< >{2}< [entry] [rendered]
+ > .\example.js main
+ [3] ./templates lazy ^\.\/.*$ include: \.js$ exclude: \.noimport\.js$ namespace object 160 bytes {3} [optional] [built]
+ import() context lazy ./templates [4] ./example.js 3:23-7:3
+ [4] ./example.js 458 bytes {3} [built]
+ single entry .\example.js main
+```
+
+## Production mode
+
+```
+Hash: 0a1b2c3d4e5f6a7b8c9d
+Version: webpack 4.0.0-beta.2
+ Asset Size Chunks Chunk Names
+0.output.js 113 bytes 0 [emitted]
+1.output.js 114 bytes 1 [emitted]
+2.output.js 115 bytes 2 [emitted]
+ output.js 2.13 KiB 3 [emitted] main
+Entrypoint main = output.js
+chunk {0} 0.output.js 41 bytes <{3}> [rendered]
+ > ./foo [3] ./templates lazy ^\.\/.*$ include: \.js$ exclude: \.noimport\.js$ namespace object ./foo
+ > ./foo.js [3] ./templates lazy ^\.\/.*$ include: \.js$ exclude: \.noimport\.js$ namespace object ./foo.js
+ [0] ./templates/foo.js 41 bytes {0} [optional] [built]
+ [exports: default]
+ context element ./foo.js [3] ./templates lazy ^\.\/.*$ include: \.js$ exclude: \.noimport\.js$ namespace object ./foo.js
+ context element ./foo [3] ./templates lazy ^\.\/.*$ include: \.js$ exclude: \.noimport\.js$ namespace object ./foo
+chunk {1} 1.output.js 41 bytes <{3}> [rendered]
+ > ./baz [3] ./templates lazy ^\.\/.*$ include: \.js$ exclude: \.noimport\.js$ namespace object ./baz
+ > ./baz.js [3] ./templates lazy ^\.\/.*$ include: \.js$ exclude: \.noimport\.js$ namespace object ./baz.js
+ [1] ./templates/baz.js 41 bytes {1} [optional] [built]
+ [exports: default]
+ context element ./baz.js [3] ./templates lazy ^\.\/.*$ include: \.js$ exclude: \.noimport\.js$ namespace object ./baz.js
+ context element ./baz [3] ./templates lazy ^\.\/.*$ include: \.js$ exclude: \.noimport\.js$ namespace object ./baz
+chunk {2} 2.output.js 41 bytes <{3}> [rendered]
+ > ./bar [3] ./templates lazy ^\.\/.*$ include: \.js$ exclude: \.noimport\.js$ namespace object ./bar
+ > ./bar.js [3] ./templates lazy ^\.\/.*$ include: \.js$ exclude: \.noimport\.js$ namespace object ./bar.js
+ [2] ./templates/bar.js 41 bytes {2} [optional] [built]
+ [exports: default]
+ context element ./bar.js [3] ./templates lazy ^\.\/.*$ include: \.js$ exclude: \.noimport\.js$ namespace object ./bar.js
+ context element ./bar [3] ./templates lazy ^\.\/.*$ include: \.js$ exclude: \.noimport\.js$ namespace object ./bar
+chunk {3} output.js (main) 618 bytes >{0}< >{1}< >{2}< [entry] [rendered]
+ > .\example.js main
+ [3] ./templates lazy ^\.\/.*$ include: \.js$ exclude: \.noimport\.js$ namespace object 160 bytes {3} [optional] [built]
+ import() context lazy ./templates [4] ./example.js 3:23-7:3
+ [4] ./example.js 458 bytes {3} [built]
+ single entry .\example.js main
+```
diff --git a/examples/code-splitted-css-bundle/build.js b/examples/code-splitting-native-import-context-filter/build.js
similarity index 100%
rename from examples/code-splitted-css-bundle/build.js
rename to examples/code-splitting-native-import-context-filter/build.js
diff --git a/examples/code-splitting-native-import-context-filter/example.js b/examples/code-splitting-native-import-context-filter/example.js
new file mode 100644
index 00000000..417603a5
--- /dev/null
+++ b/examples/code-splitting-native-import-context-filter/example.js
@@ -0,0 +1,21 @@
+async function getTemplate(templateName) {
+ try {
+ let template = await import(
+ /* webpackInclude: /\.js$/ */
+ /* webpackExclude: /\.noimport\.js$/ */
+ `./templates/${templateName}`
+ );
+ console.log(template);
+ } catch(err) {
+ console.error(err);
+ return new Error(err);
+ }
+}
+
+getTemplate("foo");
+getTemplate("bar");
+getTemplate("baz");
+getTemplate("foo.noimport");
+getTemplate("bar.noimport");
+getTemplate("baz.noimport");
+
diff --git a/examples/code-splitting-native-import-context-filter/template.md b/examples/code-splitting-native-import-context-filter/template.md
new file mode 100644
index 00000000..31fa2aeb
--- /dev/null
+++ b/examples/code-splitting-native-import-context-filter/template.md
@@ -0,0 +1,43 @@
+# example.js
+
+This example illustrates how to filter the ContextModule results of `import()` statements. only `.js` files that don't
+end in `.noimport.js` within the `templates` folder will be bundled.
+
+``` javascript
+{{example.js}}
+```
+
+# templates/
+
+* foo.js
+* foo.noimport.js
+* baz.js
+* foo.noimport.js
+* bar.js
+* foo.noimport.js
+
+All templates are of this pattern:
+
+``` javascript
+{{templates/foo.js}}
+```
+
+# dist/output.js
+
+``` javascript
+{{dist/output.js}}
+```
+
+# Info
+
+## Unoptimized
+
+```
+{{stdout}}
+```
+
+## Production mode
+
+```
+{{production:stdout}}
+```
diff --git a/examples/code-splitting-native-import-context-filter/templates/bar.js b/examples/code-splitting-native-import-context-filter/templates/bar.js
new file mode 100644
index 00000000..3b34c4d7
--- /dev/null
+++ b/examples/code-splitting-native-import-context-filter/templates/bar.js
@@ -0,0 +1,3 @@
+var bar = "bar";
+
+export default bar;
diff --git a/examples/code-splitting-native-import-context-filter/templates/bar.noimport.js b/examples/code-splitting-native-import-context-filter/templates/bar.noimport.js
new file mode 100644
index 00000000..3b34c4d7
--- /dev/null
+++ b/examples/code-splitting-native-import-context-filter/templates/bar.noimport.js
@@ -0,0 +1,3 @@
+var bar = "bar";
+
+export default bar;
diff --git a/examples/code-splitting-native-import-context-filter/templates/baz.js b/examples/code-splitting-native-import-context-filter/templates/baz.js
new file mode 100644
index 00000000..7f7547c8
--- /dev/null
+++ b/examples/code-splitting-native-import-context-filter/templates/baz.js
@@ -0,0 +1,3 @@
+var baz = "baz";
+
+export default baz;
diff --git a/examples/code-splitting-native-import-context-filter/templates/baz.noimport.js b/examples/code-splitting-native-import-context-filter/templates/baz.noimport.js
new file mode 100644
index 00000000..7f7547c8
--- /dev/null
+++ b/examples/code-splitting-native-import-context-filter/templates/baz.noimport.js
@@ -0,0 +1,3 @@
+var baz = "baz";
+
+export default baz;
diff --git a/examples/code-splitting-native-import-context-filter/templates/foo.js b/examples/code-splitting-native-import-context-filter/templates/foo.js
new file mode 100644
index 00000000..92b67b2c
--- /dev/null
+++ b/examples/code-splitting-native-import-context-filter/templates/foo.js
@@ -0,0 +1,3 @@
+var foo = "foo";
+
+export default foo;
diff --git a/examples/code-splitting-native-import-context-filter/templates/foo.noimport.js b/examples/code-splitting-native-import-context-filter/templates/foo.noimport.js
new file mode 100644
index 00000000..92b67b2c
--- /dev/null
+++ b/examples/code-splitting-native-import-context-filter/templates/foo.noimport.js
@@ -0,0 +1,3 @@
+var foo = "foo";
+
+export default foo;
diff --git a/examples/code-splitting-native-import-context-filter/webpack.config.js b/examples/code-splitting-native-import-context-filter/webpack.config.js
new file mode 100644
index 00000000..0d554bf6
--- /dev/null
+++ b/examples/code-splitting-native-import-context-filter/webpack.config.js
@@ -0,0 +1,5 @@
+module.exports = {
+ optimization: {
+ occurrenceOrder: true // To keep filename consistent between different modes (for example building only)
+ }
+};
diff --git a/examples/code-splitting-native-import-context/README.md b/examples/code-splitting-native-import-context/README.md
index e7786bcf..14a0d709 100644
--- a/examples/code-splitting-native-import-context/README.md
+++ b/examples/code-splitting-native-import-context/README.md
@@ -32,18 +32,20 @@ var foo = "foo";
export default foo;
```
-# js/output.js
+# dist/output.js
<details><summary><code>/******/ (function(modules) { /* webpackBootstrap */ })</code></summary>
``` javascript
/******/ (function(modules) { // webpackBootstrap
/******/ // install a JSONP callback for chunk loading
-/******/ var parentJsonpFunction = window["webpackJsonp"];
-/******/ window["webpackJsonp"] = function webpackJsonpCallback(chunkIds, moreModules, executeModules) {
+/******/ function webpackJsonpCallback(data) {
+/******/ var chunkIds = data[0];
+/******/ var moreModules = data[1]
+/******/
/******/ // add "moreModules" to the modules object,
/******/ // then flag all "chunkIds" as loaded and fire callback
-/******/ var moduleId, chunkId, i = 0, resolves = [], result;
+/******/ var moduleId, chunkId, i = 0, resolves = [];
/******/ for(;i < chunkIds.length; i++) {
/******/ chunkId = chunkIds[i];
/******/ if(installedChunks[chunkId]) {
@@ -56,21 +58,24 @@ export default foo;
/******/ modules[moduleId] = moreModules[moduleId];
/******/ }
/******/ }
-/******/ if(parentJsonpFunction) parentJsonpFunction(chunkIds, moreModules, executeModules);
+/******/ if(parentJsonpFunction) parentJsonpFunction(data);
/******/ while(resolves.length) {
/******/ resolves.shift()();
/******/ }
/******/
/******/ };
/******/
+/******/
/******/ // The module cache
/******/ var installedModules = {};
/******/
-/******/ // objects to store loaded and loading chunks
+/******/ // object to store loaded and loading chunks
/******/ var installedChunks = {
/******/ 3: 0
/******/ };
/******/
+/******/
+/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
@@ -98,51 +103,60 @@ export default foo;
/******/ // This file contains only the entry chunk.
/******/ // The chunk loading function for additional chunks
/******/ __webpack_require__.e = function requireEnsure(chunkId) {
+/******/ var promises = [];
+/******/
+/******/
+/******/ // JSONP chunk loading for javascript
+/******/
/******/ var installedChunkData = installedChunks[chunkId];
-/******/ if(installedChunkData === 0) {
-/******/ return new Promise(function(resolve) { resolve(); });
-/******/ }
+/******/ if(installedChunkData !== 0) { // 0 means "already installed".
/******/
-/******/ // a Promise means "currently loading".
-/******/ if(installedChunkData) {
-/******/ return installedChunkData[2];
-/******/ }
+/******/ // a Promise means "currently loading".
+/******/ if(installedChunkData) {
+/******/ promises.push(installedChunkData[2]);
+/******/ } else {
+/******/ // setup Promise in chunk cache
+/******/ var promise = new Promise(function(resolve, reject) {
+/******/ installedChunkData = installedChunks[chunkId] = [resolve, reject];
+/******/ });
+/******/ promises.push(installedChunkData[2] = promise);
/******/
-/******/ // setup Promise in chunk cache
-/******/ var promise = new Promise(function(resolve, reject) {
-/******/ installedChunkData = installedChunks[chunkId] = [resolve, reject];
-/******/ });
-/******/ installedChunkData[2] = promise;
+/******/ // start chunk loading
+/******/ var head = document.getElementsByTagName('head')[0];
+/******/ var script = document.createElement('script');
/******/
-/******/ // start chunk loading
-/******/ var head = document.getElementsByTagName('head')[0];
-/******/ var script = document.createElement('script');
-/******/ script.type = 'text/javascript';
-/******/ script.charset = 'utf-8';
-/******/ script.async = true;
-/******/ script.timeout = 120000;
+/******/ script.charset = 'utf-8';
+/******/ script.timeout = 120000;
/******/
-/******/ if (__webpack_require__.nc) {
-/******/ script.setAttribute("nonce", __webpack_require__.nc);
-/******/ }
-/******/ script.src = __webpack_require__.p + "" + chunkId + ".output.js";
-/******/ var timeout = setTimeout(onScriptComplete, 120000);
-/******/ script.onerror = script.onload = onScriptComplete;
-/******/ function onScriptComplete() {
-/******/ // avoid mem leaks in IE.
-/******/ script.onerror = script.onload = null;
-/******/ clearTimeout(timeout);
-/******/ var chunk = installedChunks[chunkId];
-/******/ if(chunk !== 0) {
-/******/ if(chunk) {
-/******/ chunk[1](new Error('Loading chunk ' + chunkId + ' failed.'));
+/******/ if (__webpack_require__.nc) {
+/******/ script.setAttribute("nonce", __webpack_require__.nc);
/******/ }
-/******/ installedChunks[chunkId] = undefined;
+/******/ script.src = __webpack_require__.p + "" + chunkId + ".output.js";
+/******/ var timeout = setTimeout(function(){
+/******/ onScriptComplete({ type: 'timeout', target: script });
+/******/ }, 120000);
+/******/ script.onerror = script.onload = onScriptComplete;
+/******/ function onScriptComplete(event) {
+/******/ // avoid mem leaks in IE.
+/******/ script.onerror = script.onload = null;
+/******/ clearTimeout(timeout);
+/******/ var chunk = installedChunks[chunkId];
+/******/ if(chunk !== 0) {
+/******/ if(chunk) {
+/******/ var errorType = event && (event.type === 'load' ? 'missing' : event.type);
+/******/ var realSrc = event && event.target && event.target.src;
+/******/ var error = new Error('Loading chunk ' + chunkId + ' failed.\n(' + errorType + ': ' + realSrc + ')');
+/******/ error.type = errorType;
+/******/ error.request = realSrc;
+/******/ chunk[1](error);
+/******/ }
+/******/ installedChunks[chunkId] = undefined;
+/******/ }
+/******/ };
+/******/ head.appendChild(script);
/******/ }
-/******/ };
-/******/ head.appendChild(script);
-/******/
-/******/ return promise;
+/******/ }
+/******/ return Promise.all(promises);
/******/ };
/******/
/******/ // expose the modules object (__webpack_modules__)
@@ -162,6 +176,11 @@ export default foo;
/******/ }
/******/ };
/******/
+/******/ // define __esModule on exports
+/******/ __webpack_require__.r = function(exports) {
+/******/ Object.defineProperty(exports, '__esModule', { value: true });
+/******/ };
+/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
@@ -175,13 +194,21 @@ export default foo;
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
-/******/ __webpack_require__.p = "js/";
+/******/ __webpack_require__.p = "dist/";
/******/
/******/ // on error function for async loading
/******/ __webpack_require__.oe = function(err) { console.error(err); throw err; };
/******/
+/******/ var jsonpArray = window["webpackJsonp"] = window["webpackJsonp"] || [];
+/******/ var oldJsonpFunction = jsonpArray.push.bind(jsonpArray);
+/******/ jsonpArray.push = webpackJsonpCallback;
+/******/ jsonpArray = jsonpArray.slice();
+/******/ for(var i = 0; i < jsonpArray.length; i++) webpackJsonpCallback(jsonpArray[i]);
+/******/ var parentJsonpFunction = oldJsonpFunction;
+/******/
+/******/
/******/ // Load entry module and return exports
-/******/ return __webpack_require__(__webpack_require__.s = 3);
+/******/ return __webpack_require__(__webpack_require__.s = 4);
/******/ })
/************************************************************************/
```
@@ -194,46 +221,19 @@ export default foo;
/* 1 */,
/* 2 */,
/* 3 */
-/*!********************!*\
- !*** ./example.js ***!
- \********************/
+/*!**************************************************!*\
+ !*** ./templates lazy ^\.\/.*$ namespace object ***!
+ \**************************************************/
/*! no static exports found */
-/*! all exports used */
-/***/ (function(module, exports, __webpack_require__) {
-
-async function getTemplate(templateName) {
- try {
- let template = await __webpack_require__(/*! ./templates */ 4)(`./${templateName}`);
- console.log(template);
- } catch(err) {
- console.error("template error");
- return new Error(err);
- }
-}
-
-getTemplate("foo");
-getTemplate("bar");
-getTemplate("baz");
-
-
-
-
-/***/ }),
-/* 4 */
-/*!*********************************!*\
- !*** ./templates lazy ^\.\/.*$ ***!
- \*********************************/
-/*! no static exports found */
-/*! all exports used */
/***/ (function(module, exports, __webpack_require__) {
var map = {
"./bar": [
- 0,
+ 2,
2
],
"./bar.js": [
- 0,
+ 2,
2
],
"./baz": [
@@ -245,99 +245,141 @@ var map = {
1
],
"./foo": [
- 2,
+ 0,
0
],
"./foo.js": [
- 2,
+ 0,
0
]
};
function webpackAsyncContext(req) {
var ids = map[req];
- if(!ids)
- return Promise.reject(new Error("Cannot find module '" + req + "'."));
+ if(!ids) {
+ return Promise.resolve().then(function() {
+ var e = new Error('Cannot find module "' + req + '".');
+ e.code = 'MODULE_NOT_FOUND';
+ throw e;
+ });
+ }
return __webpack_require__.e(ids[1]).then(function() {
- return __webpack_require__(ids[0]);
+ var module = __webpack_require__(ids[0]);
+ return module;
});
-};
+}
webpackAsyncContext.keys = function webpackAsyncContextKeys() {
return Object.keys(map);
};
-webpackAsyncContext.id = 4;
+webpackAsyncContext.id = 3;
module.exports = webpackAsyncContext;
+/***/ }),
+/* 4 */
+/*!********************!*\
+ !*** ./example.js ***!
+ \********************/
+/*! no static exports found */
+/***/ (function(module, exports, __webpack_require__) {
+
+async function getTemplate(templateName) {
+ try {
+ let template = await __webpack_require__(3)(`./${templateName}`);
+ console.log(template);
+ } catch(err) {
+ console.error("template error");
+ return new Error(err);
+ }
+}
+
+getTemplate("foo");
+getTemplate("bar");
+getTemplate("baz");
+
+
+
+
/***/ })
/******/ ]);
```
# Info
-## Uncompressed
+## Unoptimized
```
-Hash: 6f07710827408f86ab81
-Version: webpack 3.5.1
+Hash: 0a1b2c3d4e5f6a7b8c9d
+Version: webpack 4.0.0-beta.2
Asset Size Chunks Chunk Names
-0.output.js 444 bytes 0 [emitted]
-1.output.js 450 bytes 1 [emitted]
-2.output.js 441 bytes 2 [emitted]
- output.js 7.08 kB 3 [emitted] main
+0.output.js 436 bytes 0 [emitted]
+1.output.js 445 bytes 1 [emitted]
+2.output.js 439 bytes 2 [emitted]
+ output.js 8.03 KiB 3 [emitted] main
Entrypoint main = output.js
-chunk {0} 0.output.js 41 bytes {3} [rendered]
- [2] ./templates/foo.js 41 bytes {0} [optional] [built]
+chunk {0} 0.output.js 41 bytes <{3}> [rendered]
+ > ./foo [3] ./templates lazy ^\.\/.*$ namespace object ./foo
+ > ./foo.js [3] ./templates lazy ^\.\/.*$ namespace object ./foo.js
+ [0] ./templates/foo.js 41 bytes {0} [optional] [built]
[exports: default]
- context element ./foo.js [4] ./templates lazy ^\.\/.*$ ./foo.js
- context element ./foo [4] ./templates lazy ^\.\/.*$ ./foo
-chunk {1} 1.output.js 41 bytes {3} [rendered]
+ context element ./foo.js [3] ./templates lazy ^\.\/.*$ namespace object ./foo.js
+ context element ./foo [3] ./templates lazy ^\.\/.*$ namespace object ./foo
+chunk {1} 1.output.js 41 bytes <{3}> [rendered]
+ > ./baz [3] ./templates lazy ^\.\/.*$ namespace object ./baz
+ > ./baz.js [3] ./templates lazy ^\.\/.*$ namespace object ./baz.js
[1] ./templates/baz.js 41 bytes {1} [optional] [built]
[exports: default]
- context element ./baz.js [4] ./templates lazy ^\.\/.*$ ./baz.js
- context element ./baz [4] ./templates lazy ^\.\/.*$ ./baz
-chunk {2} 2.output.js 41 bytes {3} [rendered]
- [0] ./templates/bar.js 41 bytes {2} [optional] [built]
+ context element ./baz.js [3] ./templates lazy ^\.\/.*$ namespace object ./baz.js
+ context element ./baz [3] ./templates lazy ^\.\/.*$ namespace object ./baz
+chunk {2} 2.output.js 41 bytes <{3}> [rendered]
+ > ./bar [3] ./templates lazy ^\.\/.*$ namespace object ./bar
+ > ./bar.js [3] ./templates lazy ^\.\/.*$ namespace object ./bar.js
+ [2] ./templates/bar.js 41 bytes {2} [optional] [built]
[exports: default]
- context element ./bar.js [4] ./templates lazy ^\.\/.*$ ./bar.js
- context element ./bar [4] ./templates lazy ^\.\/.*$ ./bar
-chunk {3} output.js (main) 456 bytes [entry] [rendered]
- > main [3] ./example.js
- [3] ./example.js 296 bytes {3} [built]
- [4] ./templates lazy ^\.\/.*$ 160 bytes {3} [optional] [built]
- import() context lazy ./templates [3] ./example.js 3:23-60
+ context element ./bar.js [3] ./templates lazy ^\.\/.*$ namespace object ./bar.js
+ context element ./bar [3] ./templates lazy ^\.\/.*$ namespace object ./bar
+chunk {3} output.js (main) 456 bytes >{0}< >{1}< >{2}< [entry] [rendered]
+ > .\example.js main
+ [3] ./templates lazy ^\.\/.*$ namespace object 160 bytes {3} [optional] [built]
+ import() context lazy ./templates [4] ./example.js 3:23-60
+ [4] ./example.js 296 bytes {3} [built]
+ single entry .\example.js main
```
-## Minimized (uglify-js, no zip)
+## Production mode
```
-Hash: 6f07710827408f86ab81
-Version: webpack 3.5.1
+Hash: 0a1b2c3d4e5f6a7b8c9d
+Version: webpack 4.0.0-beta.2
Asset Size Chunks Chunk Names
-0.output.js 117 bytes 0 [emitted]
-1.output.js 116 bytes 1 [emitted]
+0.output.js 113 bytes 0 [emitted]
+1.output.js 114 bytes 1 [emitted]
2.output.js 115 bytes 2 [emitted]
- output.js 6.76 kB 3 [emitted] main
+ output.js 2.1 KiB 3 [emitted] main
Entrypoint main = output.js
-chunk {0} 0.output.js 41 bytes {3} [rendered]
- [2] ./templates/foo.js 41 bytes {0} [optional] [built]
+chunk {0} 0.output.js 41 bytes <{3}> [rendered]
+ > ./foo [3] ./templates lazy ^\.\/.*$ namespace object ./foo
+ > ./foo.js [3] ./templates lazy ^\.\/.*$ namespace object ./foo.js
+ [0] ./templates/foo.js 41 bytes {0} [optional] [built]
[exports: default]
- context element ./foo.js [4] ./templates lazy ^\.\/.*$ ./foo.js
- context element ./foo [4] ./templates lazy ^\.\/.*$ ./foo
-chunk {1} 1.output.js 41 bytes {3} [rendered]
+ context element ./foo.js [3] ./templates lazy ^\.\/.*$ namespace object ./foo.js
+ context element ./foo [3] ./templates lazy ^\.\/.*$ namespace object ./foo
+chunk {1} 1.output.js 41 bytes <{3}> [rendered]
+ > ./baz [3] ./templates lazy ^\.\/.*$ namespace object ./baz
+ > ./baz.js [3] ./templates lazy ^\.\/.*$ namespace object ./baz.js
[1] ./templates/baz.js 41 bytes {1} [optional] [built]
[exports: default]
- context element ./baz.js [4] ./templates lazy ^\.\/.*$ ./baz.js
- context element ./baz [4] ./templates lazy ^\.\/.*$ ./baz
-chunk {2} 2.output.js 41 bytes {3} [rendered]
- [0] ./templates/bar.js 41 bytes {2} [optional] [built]
+ context element ./baz.js [3] ./templates lazy ^\.\/.*$ namespace object ./baz.js
+ context element ./baz [3] ./templates lazy ^\.\/.*$ namespace object ./baz
+chunk {2} 2.output.js 41 bytes <{3}> [rendered]
+ > ./bar [3] ./templates lazy ^\.\/.*$ namespace object ./bar
+ > ./bar.js [3] ./templates lazy ^\.\/.*$ namespace object ./bar.js
+ [2] ./templates/bar.js 41 bytes {2} [optional] [built]
[exports: default]
- context element ./bar.js [4] ./templates lazy ^\.\/.*$ ./bar.js
- context element ./bar [4] ./templates lazy ^\.\/.*$ ./bar
-chunk {3} output.js (main) 456 bytes [entry] [rendered]
- > main [3] ./example.js
- [3] ./example.js 296 bytes {3} [built]
- [4] ./templates lazy ^\.\/.*$ 160 bytes {3} [optional] [built]
- import() context lazy ./templates [3] ./example.js 3:23-60
-
-ERROR in output.js from UglifyJs
-Unexpected token: keyword (function) [output.js:155,6]
+ context element ./bar.js [3] ./templates lazy ^\.\/.*$ namespace object ./bar.js
+ context element ./bar [3] ./templates lazy ^\.\/.*$ namespace object ./bar
+chunk {3} output.js (main) 456 bytes >{0}< >{1}< >{2}< [entry] [rendered]
+ > .\example.js main
+ [3] ./templates lazy ^\.\/.*$ namespace object 160 bytes {3} [optional] [built]
+ import() context lazy ./templates [4] ./example.js 3:23-60
+ [4] ./example.js 296 bytes {3} [built]
+ single entry .\example.js main
```
diff --git a/examples/code-splitting-native-import-context/template.md b/examples/code-splitting-native-import-context/template.md
index c37b1476..f26cba07 100644
--- a/examples/code-splitting-native-import-context/template.md
+++ b/examples/code-splitting-native-import-context/template.md
@@ -18,22 +18,22 @@ All templates are of this pattern:
{{templates/foo.js}}
```
-# js/output.js
+# dist/output.js
``` javascript
-{{js/output.js}}
+{{dist/output.js}}
```
# Info
-## Uncompressed
+## Unoptimized
```
{{stdout}}
```
-## Minimized (uglify-js, no zip)
+## Production mode
```
-{{min:stdout}}
+{{production:stdout}}
```
diff --git a/examples/code-splitting-native-import-context/webpack.config.js b/examples/code-splitting-native-import-context/webpack.config.js
new file mode 100644
index 00000000..0d554bf6
--- /dev/null
+++ b/examples/code-splitting-native-import-context/webpack.config.js
@@ -0,0 +1,5 @@
+module.exports = {
+ optimization: {
+ occurrenceOrder: true // To keep filename consistent between different modes (for example building only)
+ }
+};
diff --git a/examples/code-splitting-specify-chunk-name/README.md b/examples/code-splitting-specify-chunk-name/README.md
index 8b2fc93c..774856e6 100644
--- a/examples/code-splitting-specify-chunk-name/README.md
+++ b/examples/code-splitting-specify-chunk-name/README.md
@@ -32,18 +32,20 @@ var foo = "foo";
export default foo;
```
-# js/output.js
+# dist/output.js
<details><summary><code>/******/ (function(modules) { /* webpackBootstrap */ })</code></summary>
``` javascript
/******/ (function(modules) { // webpackBootstrap
/******/ // install a JSONP callback for chunk loading
-/******/ var parentJsonpFunction = window["webpackJsonp"];
-/******/ window["webpackJsonp"] = function webpackJsonpCallback(chunkIds, moreModules, executeModules) {
+/******/ function webpackJsonpCallback(data) {
+/******/ var chunkIds = data[0];
+/******/ var moreModules = data[1]
+/******/
/******/ // add "moreModules" to the modules object,
/******/ // then flag all "chunkIds" as loaded and fire callback
-/******/ var moduleId, chunkId, i = 0, resolves = [], result;
+/******/ var moduleId, chunkId, i = 0, resolves = [];
/******/ for(;i < chunkIds.length; i++) {
/******/ chunkId = chunkIds[i];
/******/ if(installedChunks[chunkId]) {
@@ -56,21 +58,24 @@ export default foo;
/******/ modules[moduleId] = moreModules[moduleId];
/******/ }
/******/ }
-/******/ if(parentJsonpFunction) parentJsonpFunction(chunkIds, moreModules, executeModules);
+/******/ if(parentJsonpFunction) parentJsonpFunction(data);
/******/ while(resolves.length) {
/******/ resolves.shift()();
/******/ }
/******/
/******/ };
/******/
+/******/
/******/ // The module cache
/******/ var installedModules = {};
/******/
-/******/ // objects to store loaded and loading chunks
+/******/ // object to store loaded and loading chunks
/******/ var installedChunks = {
/******/ 3: 0
/******/ };
/******/
+/******/
+/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
@@ -98,51 +103,60 @@ export default foo;
/******/ // This file contains only the entry chunk.
/******/ // The chunk loading function for additional chunks
/******/ __webpack_require__.e = function requireEnsure(chunkId) {
+/******/ var promises = [];
+/******/
+/******/
+/******/ // JSONP chunk loading for javascript
+/******/
/******/ var installedChunkData = installedChunks[chunkId];
-/******/ if(installedChunkData === 0) {
-/******/ return new Promise(function(resolve) { resolve(); });
-/******/ }
+/******/ if(installedChunkData !== 0) { // 0 means "already installed".
/******/
-/******/ // a Promise means "currently loading".
-/******/ if(installedChunkData) {
-/******/ return installedChunkData[2];
-/******/ }
+/******/ // a Promise means "currently loading".
+/******/ if(installedChunkData) {
+/******/ promises.push(installedChunkData[2]);
+/******/ } else {
+/******/ // setup Promise in chunk cache
+/******/ var promise = new Promise(function(resolve, reject) {
+/******/ installedChunkData = installedChunks[chunkId] = [resolve, reject];
+/******/ });
+/******/ promises.push(installedChunkData[2] = promise);
/******/
-/******/ // setup Promise in chunk cache
-/******/ var promise = new Promise(function(resolve, reject) {
-/******/ installedChunkData = installedChunks[chunkId] = [resolve, reject];
-/******/ });
-/******/ installedChunkData[2] = promise;
+/******/ // start chunk loading
+/******/ var head = document.getElementsByTagName('head')[0];
+/******/ var script = document.createElement('script');
/******/
-/******/ // start chunk loading
-/******/ var head = document.getElementsByTagName('head')[0];
-/******/ var script = document.createElement('script');
-/******/ script.type = 'text/javascript';
-/******/ script.charset = 'utf-8';
-/******/ script.async = true;
-/******/ script.timeout = 120000;
+/******/ script.charset = 'utf-8';
+/******/ script.timeout = 120000;
/******/
-/******/ if (__webpack_require__.nc) {
-/******/ script.setAttribute("nonce", __webpack_require__.nc);
-/******/ }
-/******/ script.src = __webpack_require__.p + "" + chunkId + ".output.js";
-/******/ var timeout = setTimeout(onScriptComplete, 120000);
-/******/ script.onerror = script.onload = onScriptComplete;
-/******/ function onScriptComplete() {
-/******/ // avoid mem leaks in IE.
-/******/ script.onerror = script.onload = null;
-/******/ clearTimeout(timeout);
-/******/ var chunk = installedChunks[chunkId];
-/******/ if(chunk !== 0) {
-/******/ if(chunk) {
-/******/ chunk[1](new Error('Loading chunk ' + chunkId + ' failed.'));
+/******/ if (__webpack_require__.nc) {
+/******/ script.setAttribute("nonce", __webpack_require__.nc);
/******/ }
-/******/ installedChunks[chunkId] = undefined;
+/******/ script.src = __webpack_require__.p + "" + chunkId + ".output.js";
+/******/ var timeout = setTimeout(function(){
+/******/ onScriptComplete({ type: 'timeout', target: script });
+/******/ }, 120000);
+/******/ script.onerror = script.onload = onScriptComplete;
+/******/ function onScriptComplete(event) {
+/******/ // avoid mem leaks in IE.
+/******/ script.onerror = script.onload = null;
+/******/ clearTimeout(timeout);
+/******/ var chunk = installedChunks[chunkId];
+/******/ if(chunk !== 0) {
+/******/ if(chunk) {
+/******/ var errorType = event && (event.type === 'load' ? 'missing' : event.type);
+/******/ var realSrc = event && event.target && event.target.src;
+/******/ var error = new Error('Loading chunk ' + chunkId + ' failed.\n(' + errorType + ': ' + realSrc + ')');
+/******/ error.type = errorType;
+/******/ error.request = realSrc;
+/******/ chunk[1](error);
+/******/ }
+/******/ installedChunks[chunkId] = undefined;
+/******/ }
+/******/ };
+/******/ head.appendChild(script);
/******/ }
-/******/ };
-/******/ head.appendChild(script);
-/******/
-/******/ return promise;
+/******/ }
+/******/ return Promise.all(promises);
/******/ };
/******/
/******/ // expose the modules object (__webpack_modules__)
@@ -162,6 +176,11 @@ export default foo;
/******/ }
/******/ };
/******/
+/******/ // define __esModule on exports
+/******/ __webpack_require__.r = function(exports) {
+/******/ Object.defineProperty(exports, '__esModule', { value: true });
+/******/ };
+/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
@@ -175,13 +194,21 @@ export default foo;
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
-/******/ __webpack_require__.p = "js/";
+/******/ __webpack_require__.p = "dist/";
/******/
/******/ // on error function for async loading
/******/ __webpack_require__.oe = function(err) { console.error(err); throw err; };
/******/
+/******/ var jsonpArray = window["webpackJsonp"] = window["webpackJsonp"] || [];
+/******/ var oldJsonpFunction = jsonpArray.push.bind(jsonpArray);
+/******/ jsonpArray.push = webpackJsonpCallback;
+/******/ jsonpArray = jsonpArray.slice();
+/******/ for(var i = 0; i < jsonpArray.length; i++) webpackJsonpCallback(jsonpArray[i]);
+/******/ var parentJsonpFunction = oldJsonpFunction;
+/******/
+/******/
/******/ // Load entry module and return exports
-/******/ return __webpack_require__(__webpack_require__.s = 3);
+/******/ return __webpack_require__(__webpack_require__.s = 4);
/******/ })
/************************************************************************/
```
@@ -194,143 +221,157 @@ export default foo;
/* 1 */,
/* 2 */,
/* 3 */
-/*!********************!*\
- !*** ./example.js ***!
- \********************/
-/*! no static exports found */
-/*! all exports used */
-/***/ (function(module, exports, __webpack_require__) {
-
-__webpack_require__.e/* import() */(0/*! chunk-foo */).then(__webpack_require__.bind(null, /*! ./templates/foo */ 2)).then(function(foo) {
- console.log('foo:', foo);
-})
-
-__webpack_require__.e/* require.ensure */(0/*! chunk-foo1 *//* duplicate */).then((function(require) {
- var foo = __webpack_require__(/*! ./templates/foo */ 2);
- console.log('foo:', foo);
-}).bind(null, __webpack_require__)).catch(__webpack_require__.oe);
-
-var createContextVar = "r";
-__webpack_require__(/*! ./templates */ 4)("./ba" + createContextVar).then(function(bar) {
- console.log('bar:', bar);
-})
-
-
-
-
-/***/ }),
-/* 4 */
-/*!***********************************!*\
- !*** ./templates lazy ^\.\/ba.*$ ***!
- \***********************************/
+/*!****************************************************!*\
+ !*** ./templates lazy ^\.\/ba.*$ namespace object ***!
+ \****************************************************/
/*! no static exports found */
-/*! all exports used */
/***/ (function(module, exports, __webpack_require__) {
var map = {
"./bar": [
- 0,
- 2
+ 2,
+ 1
],
"./bar.js": [
- 0,
- 2
+ 2,
+ 1
],
"./baz": [
1,
- 1
+ 0
],
"./baz.js": [
1,
- 1
+ 0
]
};
function webpackAsyncContext(req) {
var ids = map[req];
- if(!ids)
- return Promise.reject(new Error("Cannot find module '" + req + "'."));
+ if(!ids) {
+ return Promise.resolve().then(function() {
+ var e = new Error('Cannot find module "' + req + '".');
+ e.code = 'MODULE_NOT_FOUND';
+ throw e;
+ });
+ }
return __webpack_require__.e(ids[1]).then(function() {
- return __webpack_require__(ids[0]);
+ var module = __webpack_require__(ids[0]);
+ return module;
});
-};
+}
webpackAsyncContext.keys = function webpackAsyncContextKeys() {
return Object.keys(map);
};
-webpackAsyncContext.id = 4;
+webpackAsyncContext.id = 3;
module.exports = webpackAsyncContext;
+/***/ }),
+/* 4 */
+/*!********************!*\
+ !*** ./example.js ***!
+ \********************/
+/*! no static exports found */
+/***/ (function(module, exports, __webpack_require__) {
+
+__webpack_require__.e(/*! import() | chunk-foo */ 2).then(__webpack_require__.bind(null, /*! ./templates/foo */ 0)).then(function(foo) {
+ console.log('foo:', foo);
+})
+
+__webpack_require__.e(/*! require.ensure | chunk-foo1 */ 2).then((function(require) {
+ var foo = __webpack_require__(/*! ./templates/foo */ 0);
+ console.log('foo:', foo);
+}).bind(null, __webpack_require__)).catch(__webpack_require__.oe);
+
+var createContextVar = "r";
+__webpack_require__(3)("./ba" + createContextVar).then(function(bar) {
+ console.log('bar:', bar);
+})
+
+
+
+
/***/ })
/******/ ]);
```
# Info
-## Uncompressed
+## Unoptimized
```
-Hash: 9d034b3ada38a1291aa9
-Version: webpack 3.5.1
+Hash: 0a1b2c3d4e5f6a7b8c9d
+Version: webpack 4.0.0-beta.2
Asset Size Chunks Chunk Names
-0.output.js 444 bytes 0 [emitted] chunk-foo
-1.output.js 450 bytes 1 [emitted] chunk-bar-baz2
-2.output.js 441 bytes 2 [emitted] chunk-bar-baz0
- output.js 7.3 kB 3 [emitted] main
+0.output.js 445 bytes 0 [emitted] chunk-bar-baz2
+1.output.js 439 bytes 1 [emitted] chunk-bar-baz0
+2.output.js 436 bytes 2 [emitted] chunk-foo
+ output.js 8.23 KiB 3 [emitted] main
Entrypoint main = output.js
-chunk {0} 0.output.js (chunk-foo) 41 bytes {3} [rendered]
- > duplicate chunk-foo [3] ./example.js 1:0-62
- > duplicate chunk-foo1 [3] ./example.js 5:0-8:16
- [2] ./templates/foo.js 41 bytes {0} [built]
+chunk {0} 0.output.js (chunk-bar-baz2) 41 bytes <{3}> [rendered]
+ > ./baz [3] ./templates lazy ^\.\/ba.*$ namespace object ./baz
+ > ./baz.js [3] ./templates lazy ^\.\/ba.*$ namespace object ./baz.js
+ [1] ./templates/baz.js 41 bytes {0} [optional] [built]
[exports: default]
- import() ./templates/foo [3] ./example.js 1:0-62
- cjs require ./templates/foo [3] ./example.js 6:11-37
-chunk {1} 1.output.js (chunk-bar-baz2) 41 bytes {3} [rendered]
- [1] ./templates/baz.js 41 bytes {1} [optional] [built]
+ context element ./baz.js [3] ./templates lazy ^\.\/ba.*$ namespace object ./baz.js
+ context element ./baz [3] ./templates lazy ^\.\/ba.*$ namespace object ./baz
+chunk {1} 1.output.js (chunk-bar-baz0) 41 bytes <{3}> [rendered]
+ > ./bar [3] ./templates lazy ^\.\/ba.*$ namespace object ./bar
+ > ./bar.js [3] ./templates lazy ^\.\/ba.*$ namespace object ./bar.js
+ [2] ./templates/bar.js 41 bytes {1} [optional] [built]
[exports: default]
- context element ./baz.js [4] ./templates lazy ^\.\/ba.*$ ./baz.js
- context element ./baz [4] ./templates lazy ^\.\/ba.*$ ./baz
-chunk {2} 2.output.js (chunk-bar-baz0) 41 bytes {3} [rendered]
- [0] ./templates/bar.js 41 bytes {2} [optional] [built]
+ context element ./bar.js [3] ./templates lazy ^\.\/ba.*$ namespace object ./bar.js
+ context element ./bar [3] ./templates lazy ^\.\/ba.*$ namespace object ./bar
+chunk {2} 2.output.js (chunk-foo) 41 bytes <{3}> [rendered]
+ > ./templates/foo [4] ./example.js 1:0-62
+ > [4] ./example.js 5:0-8:16
+ [0] ./templates/foo.js 41 bytes {2} [built]
[exports: default]
- context element ./bar.js [4] ./templates lazy ^\.\/ba.*$ ./bar.js
- context element ./bar [4] ./templates lazy ^\.\/ba.*$ ./bar
-chunk {3} output.js (main) 580 bytes [entry] [rendered]
- > main [3] ./example.js
- [3] ./example.js 420 bytes {3} [built]
- [4] ./templates lazy ^\.\/ba.*$ 160 bytes {3} [built]
- import() context lazy ./templates [3] ./example.js 11:0-84
+ import() ./templates/foo [4] ./example.js 1:0-62
+ cjs require ./templates/foo [4] ./example.js 6:11-37
+chunk {3} output.js (main) 580 bytes >{0}< >{1}< >{2}< [entry] [rendered]
+ > .\example.js main
+ [3] ./templates lazy ^\.\/ba.*$ namespace object 160 bytes {3} [built]
+ import() context lazy ./templates [4] ./example.js 11:0-84
+ [4] ./example.js 420 bytes {3} [built]
+ single entry .\example.js main
```
-## Minimized (uglify-js, no zip)
+## Production mode
```
-Hash: 9d034b3ada38a1291aa9
-Version: webpack 3.5.1
+Hash: 0a1b2c3d4e5f6a7b8c9d
+Version: webpack 4.0.0-beta.2
Asset Size Chunks Chunk Names
-0.output.js 117 bytes 0 [emitted] chunk-foo
-1.output.js 116 bytes 1 [emitted] chunk-bar-baz2
-2.output.js 115 bytes 2 [emitted] chunk-bar-baz0
- output.js 1.83 kB 3 [emitted] main
+0.output.js 114 bytes 0 [emitted] chunk-bar-baz2
+1.output.js 115 bytes 1 [emitted] chunk-bar-baz0
+2.output.js 113 bytes 2 [emitted] chunk-foo
+ output.js 2.12 KiB 3 [emitted] main
Entrypoint main = output.js
-chunk {0} 0.output.js (chunk-foo) 41 bytes {3} [rendered]
- > duplicate chunk-foo [3] ./example.js 1:0-62
- > duplicate chunk-foo1 [3] ./example.js 5:0-8:16
- [2] ./templates/foo.js 41 bytes {0} [built]
+chunk {0} 0.output.js (chunk-bar-baz2) 41 bytes <{3}> [rendered]
+ > ./baz [3] ./templates lazy ^\.\/ba.*$ namespace object ./baz
+ > ./baz.js [3] ./templates lazy ^\.\/ba.*$ namespace object ./baz.js
+ [1] ./templates/baz.js 41 bytes {0} [optional] [built]
[exports: default]
- import() ./templates/foo [3] ./example.js 1:0-62
- cjs require ./templates/foo [3] ./example.js 6:11-37
-chunk {1} 1.output.js (chunk-bar-baz2) 41 bytes {3} [rendered]
- [1] ./templates/baz.js 41 bytes {1} [optional] [built]
+ context element ./baz.js [3] ./templates lazy ^\.\/ba.*$ namespace object ./baz.js
+ context element ./baz [3] ./templates lazy ^\.\/ba.*$ namespace object ./baz
+chunk {1} 1.output.js (chunk-bar-baz0) 41 bytes <{3}> [rendered]
+ > ./bar [3] ./templates lazy ^\.\/ba.*$ namespace object ./bar
+ > ./bar.js [3] ./templates lazy ^\.\/ba.*$ namespace object ./bar.js
+ [2] ./templates/bar.js 41 bytes {1} [optional] [built]
[exports: default]
- context element ./baz.js [4] ./templates lazy ^\.\/ba.*$ ./baz.js
- context element ./baz [4] ./templates lazy ^\.\/ba.*$ ./baz
-chunk {2} 2.output.js (chunk-bar-baz0) 41 bytes {3} [rendered]
- [0] ./templates/bar.js 41 bytes {2} [optional] [built]
+ context element ./bar.js [3] ./templates lazy ^\.\/ba.*$ namespace object ./bar.js
+ context element ./bar [3] ./templates lazy ^\.\/ba.*$ namespace object ./bar
+chunk {2} 2.output.js (chunk-foo) 41 bytes <{3}> [rendered]
+ > ./templates/foo [4] ./example.js 1:0-62
+ > [4] ./example.js 5:0-8:16
+ [0] ./templates/foo.js 41 bytes {2} [built]
[exports: default]
- context element ./bar.js [4] ./templates lazy ^\.\/ba.*$ ./bar.js
- context element ./bar [4] ./templates lazy ^\.\/ba.*$ ./bar
-chunk {3} output.js (main) 580 bytes [entry] [rendered]
- > main [3] ./example.js
- [3] ./example.js 420 bytes {3} [built]
- [4] ./templates lazy ^\.\/ba.*$ 160 bytes {3} [built]
- import() context lazy ./templates [3] ./example.js 11:0-84
+ import() ./templates/foo [4] ./example.js 1:0-62
+ cjs require ./templates/foo [4] ./example.js 6:11-37
+chunk {3} output.js (main) 580 bytes >{0}< >{1}< >{2}< [entry] [rendered]
+ > .\example.js main
+ [3] ./templates lazy ^\.\/ba.*$ namespace object 160 bytes {3} [built]
+ import() context lazy ./templates [4] ./example.js 11:0-84
+ [4] ./example.js 420 bytes {3} [built]
+ single entry .\example.js main
```
diff --git a/examples/code-splitting-specify-chunk-name/template.md b/examples/code-splitting-specify-chunk-name/template.md
index 79c4626d..b85d38e9 100644
--- a/examples/code-splitting-specify-chunk-name/template.md
+++ b/examples/code-splitting-specify-chunk-name/template.md
@@ -18,22 +18,22 @@ All templates are of this pattern:
{{templates/foo.js}}
```
-# js/output.js
+# dist/output.js
``` javascript
-{{js/output.js}}
+{{dist/output.js}}
```
# Info
-## Uncompressed
+## Unoptimized
```
{{stdout}}
```
-## Minimized (uglify-js, no zip)
+## Production mode
```
-{{min:stdout}}
+{{production:stdout}}
```
diff --git a/examples/code-splitting-specify-chunk-name/webpack.config.js b/examples/code-splitting-specify-chunk-name/webpack.config.js
new file mode 100644
index 00000000..0d554bf6
--- /dev/null
+++ b/examples/code-splitting-specify-chunk-name/webpack.config.js
@@ -0,0 +1,5 @@
+module.exports = {
+ optimization: {
+ occurrenceOrder: true // To keep filename consistent between different modes (for example building only)
+ }
+};
diff --git a/examples/code-splitting/README.md b/examples/code-splitting/README.md
index ea56da7d..f1a7f60b 100644
--- a/examples/code-splitting/README.md
+++ b/examples/code-splitting/README.md
@@ -36,18 +36,20 @@ require.ensure(["c"], function(require) {
```
-# js/output.js
+# dist/output.js
<details><summary><code>/******/ (function(modules) { /* webpackBootstrap */ })</code></summary>
``` javascript
/******/ (function(modules) { // webpackBootstrap
/******/ // install a JSONP callback for chunk loading
-/******/ var parentJsonpFunction = window["webpackJsonp"];
-/******/ window["webpackJsonp"] = function webpackJsonpCallback(chunkIds, moreModules, executeModules) {
+/******/ function webpackJsonpCallback(data) {
+/******/ var chunkIds = data[0];
+/******/ var moreModules = data[1]
+/******/
/******/ // add "moreModules" to the modules object,
/******/ // then flag all "chunkIds" as loaded and fire callback
-/******/ var moduleId, chunkId, i = 0, resolves = [], result;
+/******/ var moduleId, chunkId, i = 0, resolves = [];
/******/ for(;i < chunkIds.length; i++) {
/******/ chunkId = chunkIds[i];
/******/ if(installedChunks[chunkId]) {
@@ -60,21 +62,24 @@ require.ensure(["c"], function(require) {
/******/ modules[moduleId] = moreModules[moduleId];
/******/ }
/******/ }
-/******/ if(parentJsonpFunction) parentJsonpFunction(chunkIds, moreModules, executeModules);
+/******/ if(parentJsonpFunction) parentJsonpFunction(data);
/******/ while(resolves.length) {
/******/ resolves.shift()();
/******/ }
/******/
/******/ };
/******/
+/******/
/******/ // The module cache
/******/ var installedModules = {};
/******/
-/******/ // objects to store loaded and loading chunks
+/******/ // object to store loaded and loading chunks
/******/ var installedChunks = {
/******/ 1: 0
/******/ };
/******/
+/******/
+/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
@@ -102,51 +107,60 @@ require.ensure(["c"], function(require) {
/******/ // This file contains only the entry chunk.
/******/ // The chunk loading function for additional chunks
/******/ __webpack_require__.e = function requireEnsure(chunkId) {
+/******/ var promises = [];
+/******/
+/******/
+/******/ // JSONP chunk loading for javascript
+/******/
/******/ var installedChunkData = installedChunks[chunkId];
-/******/ if(installedChunkData === 0) {
-/******/ return new Promise(function(resolve) { resolve(); });
-/******/ }
+/******/ if(installedChunkData !== 0) { // 0 means "already installed".
/******/
-/******/ // a Promise means "currently loading".
-/******/ if(installedChunkData) {
-/******/ return installedChunkData[2];
-/******/ }
+/******/ // a Promise means "currently loading".
+/******/ if(installedChunkData) {
+/******/ promises.push(installedChunkData[2]);
+/******/ } else {
+/******/ // setup Promise in chunk cache
+/******/ var promise = new Promise(function(resolve, reject) {
+/******/ installedChunkData = installedChunks[chunkId] = [resolve, reject];
+/******/ });
+/******/ promises.push(installedChunkData[2] = promise);
/******/
-/******/ // setup Promise in chunk cache
-/******/ var promise = new Promise(function(resolve, reject) {
-/******/ installedChunkData = installedChunks[chunkId] = [resolve, reject];
-/******/ });
-/******/ installedChunkData[2] = promise;
+/******/ // start chunk loading
+/******/ var head = document.getElementsByTagName('head')[0];
+/******/ var script = document.createElement('script');
/******/
-/******/ // start chunk loading
-/******/ var head = document.getElementsByTagName('head')[0];
-/******/ var script = document.createElement('script');
-/******/ script.type = 'text/javascript';
-/******/ script.charset = 'utf-8';
-/******/ script.async = true;
-/******/ script.timeout = 120000;
+/******/ script.charset = 'utf-8';
+/******/ script.timeout = 120000;
/******/
-/******/ if (__webpack_require__.nc) {
-/******/ script.setAttribute("nonce", __webpack_require__.nc);
-/******/ }
-/******/ script.src = __webpack_require__.p + "" + chunkId + ".output.js";
-/******/ var timeout = setTimeout(onScriptComplete, 120000);
-/******/ script.onerror = script.onload = onScriptComplete;
-/******/ function onScriptComplete() {
-/******/ // avoid mem leaks in IE.
-/******/ script.onerror = script.onload = null;
-/******/ clearTimeout(timeout);
-/******/ var chunk = installedChunks[chunkId];
-/******/ if(chunk !== 0) {
-/******/ if(chunk) {
-/******/ chunk[1](new Error('Loading chunk ' + chunkId + ' failed.'));
+/******/ if (__webpack_require__.nc) {
+/******/ script.setAttribute("nonce", __webpack_require__.nc);
/******/ }
-/******/ installedChunks[chunkId] = undefined;
+/******/ script.src = __webpack_require__.p + "" + chunkId + ".output.js";
+/******/ var timeout = setTimeout(function(){
+/******/ onScriptComplete({ type: 'timeout', target: script });
+/******/ }, 120000);
+/******/ script.onerror = script.onload = onScriptComplete;
+/******/ function onScriptComplete(event) {
+/******/ // avoid mem leaks in IE.
+/******/ script.onerror = script.onload = null;
+/******/ clearTimeout(timeout);
+/******/ var chunk = installedChunks[chunkId];
+/******/ if(chunk !== 0) {
+/******/ if(chunk) {
+/******/ var errorType = event && (event.type === 'load' ? 'missing' : event.type);
+/******/ var realSrc = event && event.target && event.target.src;
+/******/ var error = new Error('Loading chunk ' + chunkId + ' failed.\n(' + errorType + ': ' + realSrc + ')');
+/******/ error.type = errorType;
+/******/ error.request = realSrc;
+/******/ chunk[1](error);
+/******/ }
+/******/ installedChunks[chunkId] = undefined;
+/******/ }
+/******/ };
+/******/ head.appendChild(script);
/******/ }
-/******/ };
-/******/ head.appendChild(script);
-/******/
-/******/ return promise;
+/******/ }
+/******/ return Promise.all(promises);
/******/ };
/******/
/******/ // expose the modules object (__webpack_modules__)
@@ -166,6 +180,11 @@ require.ensure(["c"], function(require) {
/******/ }
/******/ };
/******/
+/******/ // define __esModule on exports
+/******/ __webpack_require__.r = function(exports) {
+/******/ Object.defineProperty(exports, '__esModule', { value: true });
+/******/ };
+/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
@@ -179,13 +198,21 @@ require.ensure(["c"], function(require) {
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
-/******/ __webpack_require__.p = "js/";
+/******/ __webpack_require__.p = "dist/";
/******/
/******/ // on error function for async loading
/******/ __webpack_require__.oe = function(err) { console.error(err); throw err; };
/******/
+/******/ var jsonpArray = window["webpackJsonp"] = window["webpackJsonp"] || [];
+/******/ var oldJsonpFunction = jsonpArray.push.bind(jsonpArray);
+/******/ jsonpArray.push = webpackJsonpCallback;
+/******/ jsonpArray = jsonpArray.slice();
+/******/ for(var i = 0; i < jsonpArray.length; i++) webpackJsonpCallback(jsonpArray[i]);
+/******/ var parentJsonpFunction = oldJsonpFunction;
+/******/
+/******/
/******/ // Load entry module and return exports
-/******/ return __webpack_require__(__webpack_require__.s = 1);
+/******/ return __webpack_require__(__webpack_require__.s = 2);
/******/ })
/************************************************************************/
```
@@ -199,114 +226,111 @@ require.ensure(["c"], function(require) {
!*** ./node_modules/b.js ***!
\***************************/
/*! no static exports found */
-/*! all exports used */
/***/ (function(module, exports) {
// module b
/***/ }),
/* 1 */
+/*!***************************!*\
+ !*** ./node_modules/a.js ***!
+ \***************************/
+/*! no static exports found */
+/***/ (function(module, exports) {
+
+// module a
+
+/***/ }),
+/* 2 */
/*!********************!*\
!*** ./example.js ***!
\********************/
/*! no static exports found */
-/*! all exports used */
/***/ (function(module, exports, __webpack_require__) {
-var a = __webpack_require__(/*! a */ 2);
+var a = __webpack_require__(/*! a */ 1);
var b = __webpack_require__(/*! b */ 0);
-__webpack_require__.e/* require.ensure */(0).then((function(require) {
+__webpack_require__.e(/*! require.ensure */ 0).then((function(require) {
__webpack_require__(/*! b */ 0).xyz();
- var d = __webpack_require__(/*! d */ 4);
+ var d = __webpack_require__(/*! d */ 3);
}).bind(null, __webpack_require__)).catch(__webpack_require__.oe);
-/***/ }),
-/* 2 */
-/*!***************************!*\
- !*** ./node_modules/a.js ***!
- \***************************/
-/*! no static exports found */
-/*! all exports used */
-/***/ (function(module, exports) {
-
-// module a
-
/***/ })
/******/ ]);
```
-# js/0.output.js
+# dist/0.output.js
``` javascript
-webpackJsonp([0],[
+(window["webpackJsonp"] = window["webpackJsonp"] || []).push([[0],[
/* 0 */,
/* 1 */,
/* 2 */,
/* 3 */
/*!***************************!*\
- !*** ./node_modules/c.js ***!
+ !*** ./node_modules/d.js ***!
\***************************/
/*! no static exports found */
-/*! all exports used */
/***/ (function(module, exports) {
-// module c
+// module d
/***/ }),
/* 4 */
/*!***************************!*\
- !*** ./node_modules/d.js ***!
+ !*** ./node_modules/c.js ***!
\***************************/
/*! no static exports found */
-/*! all exports used */
/***/ (function(module, exports) {
-// module d
+// module c
/***/ })
-]);
+]]);
```
Minimized
``` javascript
-webpackJsonp([0],[,,,function(n,c){},function(n,c){}]);
+(window.webpackJsonp=window.webpackJsonp||[]).push([[0],[,,,function(n,o){},function(n,o){}]]);
```
# Info
-## Uncompressed
+## Unoptimized
```
-Hash: 6a2e963878a958fd1aca
-Version: webpack 3.5.1
+Hash: 0a1b2c3d4e5f6a7b8c9d
+Version: webpack 4.0.0-beta.2
Asset Size Chunks Chunk Names
-0.output.js 488 bytes 0 [emitted]
- output.js 6.66 kB 1 [emitted] main
+0.output.js 490 bytes 0 [emitted]
+ output.js 7.47 KiB 1 [emitted] main
Entrypoint main = output.js
-chunk {0} 0.output.js 22 bytes {1} [rendered]
- > [1] ./example.js 3:0-6:2
+chunk {0} 0.output.js 22 bytes <{1}> [rendered]
+ > [2] ./example.js 3:0-6:2
2 modules
-chunk {1} output.js (main) 166 bytes [entry] [rendered]
- > main [1] ./example.js
- [1] ./example.js 144 bytes {1} [built]
+chunk {1} output.js (main) 166 bytes >{0}< [entry] [rendered]
+ > .\example.js main
+ [2] ./example.js 144 bytes {1} [built]
+ single entry .\example.js main
+ 2 hidden modules
```
-## Minimized (uglify-js, no zip)
+## Production mode
```
-Hash: 6a2e963878a958fd1aca
-Version: webpack 3.5.1
+Hash: 0a1b2c3d4e5f6a7b8c9d
+Version: webpack 4.0.0-beta.2
Asset Size Chunks Chunk Names
-0.output.js 55 bytes 0 [emitted]
- output.js 1.45 kB 1 [emitted] main
+0.output.js 95 bytes 0 [emitted]
+ output.js 1.68 KiB 1 [emitted] main
Entrypoint main = output.js
-chunk {0} 0.output.js 22 bytes {1} [rendered]
- > [1] ./example.js 3:0-6:2
+chunk {0} 0.output.js 22 bytes <{1}> [rendered]
+ > [2] ./example.js 3:0-6:2
2 modules
-chunk {1} output.js (main) 166 bytes [entry] [rendered]
- > main [1] ./example.js
- [1] ./example.js 144 bytes {1} [built]
+chunk {1} output.js (main) 166 bytes >{0}< [entry] [rendered]
+ > .\example.js main
+ [2] ./example.js 144 bytes {1} [built]
+ single entry .\example.js main
+ 2 hidden modules
```
diff --git a/examples/code-splitting/template.md b/examples/code-splitting/template.md
index 8cd898a1..7c21f7ae 100644
--- a/examples/code-splitting/template.md
+++ b/examples/code-splitting/template.md
@@ -31,34 +31,34 @@ You can see that chunks are loaded via JSONP. The additional chunks are pretty s
```
-# js/output.js
+# dist/output.js
``` javascript
-{{js/output.js}}
+{{dist/output.js}}
```
-# js/0.output.js
+# dist/0.output.js
``` javascript
-{{js/0.output.js}}
+{{dist/0.output.js}}
```
Minimized
``` javascript
-{{min:js/0.output.js}}
+{{production:dist/0.output.js}}
```
# Info
-## Uncompressed
+## Unoptimized
```
{{stdout}}
```
-## Minimized (uglify-js, no zip)
+## Production mode
```
-{{min:stdout}}
+{{production:stdout}}
```
diff --git a/examples/code-splitting/webpack.config.js b/examples/code-splitting/webpack.config.js
new file mode 100644
index 00000000..0d554bf6
--- /dev/null
+++ b/examples/code-splitting/webpack.config.js
@@ -0,0 +1,5 @@
+module.exports = {
+ optimization: {
+ occurrenceOrder: true // To keep filename consistent between different modes (for example building only)
+ }
+};
diff --git a/examples/coffee-script/README.md b/examples/coffee-script/README.md
index be118ac7..113b9ad8 100644
--- a/examples/coffee-script/README.md
+++ b/examples/coffee-script/README.md
@@ -23,7 +23,7 @@ console.log "yeah coffee-script"
module.exports = 42
```
-# js/output.js
+# dist/output.js
<details><summary><code>/******/ (function(modules) { /* webpackBootstrap */ })</code></summary>
@@ -74,6 +74,11 @@ module.exports = 42
/******/ }
/******/ };
/******/
+/******/ // define __esModule on exports
+/******/ __webpack_require__.r = function(exports) {
+/******/ Object.defineProperty(exports, '__esModule', { value: true });
+/******/ };
+/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
@@ -87,10 +92,11 @@ module.exports = 42
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
-/******/ __webpack_require__.p = "js/";
+/******/ __webpack_require__.p = "dist/";
+/******/
/******/
/******/ // Load entry module and return exports
-/******/ return __webpack_require__(__webpack_require__.s = 1);
+/******/ return __webpack_require__(__webpack_require__.s = 0);
/******/ })
/************************************************************************/
```
@@ -100,84 +106,83 @@ module.exports = 42
``` javascript
/******/ ([
/* 0 */
-/*!*********************!*\
- !*** ./cup2.coffee ***!
- \*********************/
-/*! no static exports found */
-/*! all exports used */
-/***/ (function(module, exports) {
-
-console.log("yeah coffee-script");
-
-module.exports = 42;
-
-
-/***/ }),
-/* 1 */
/*!********************!*\
!*** ./example.js ***!
\********************/
/*! no static exports found */
-/*! all exports used */
/***/ (function(module, exports, __webpack_require__) {
-console.log(__webpack_require__(/*! ./cup1 */ 2));
+console.log(__webpack_require__(/*! ./cup1 */ 1));
/***/ }),
-/* 2 */
+/* 1 */
/*!*********************!*\
!*** ./cup1.coffee ***!
\*********************/
/*! no static exports found */
-/*! all exports used */
/***/ (function(module, exports, __webpack_require__) {
module.exports = {
cool: "stuff",
answer: 42,
- external: __webpack_require__(/*! ./cup2.coffee */ 0),
- again: __webpack_require__(/*! ./cup2 */ 0)
+ external: __webpack_require__(/*! ./cup2.coffee */ 2),
+ again: __webpack_require__(/*! ./cup2 */ 2)
};
+/***/ }),
+/* 2 */
+/*!*********************!*\
+ !*** ./cup2.coffee ***!
+ \*********************/
+/*! no static exports found */
+/***/ (function(module, exports) {
+
+console.log("yeah coffee-script");
+
+module.exports = 42;
+
+
/***/ })
/******/ ]);
```
# Info
-## Uncompressed
+## Unoptimized
```
-Hash: 22e68923dcce75e38966
-Version: webpack 3.5.1
- Asset Size Chunks Chunk Names
-output.js 3.29 kB 0 [emitted] main
+Hash: 0a1b2c3d4e5f6a7b8c9d
+Version: webpack 4.0.0-beta.2
+ Asset Size Chunks Chunk Names
+output.js 3.35 KiB 0 [emitted] main
Entrypoint main = output.js
chunk {0} output.js (main) 206 bytes [entry] [rendered]
- > main [1] ./example.js
- [0] ./cup2.coffee 57 bytes {0} [built]
- cjs require ./cup2.coffee [2] ./cup1.coffee 4:12-36
- cjs require ./cup2 [2] ./cup1.coffee 5:9-26
- [1] ./example.js 31 bytes {0} [built]
- [2] ./cup1.coffee 118 bytes {0} [built]
- cjs require ./cup1 [1] ./example.js 1:12-29
+ > .\example.js main
+ [0] ./example.js 31 bytes {0} [built]
+ single entry .\example.js main
+ [1] ./cup1.coffee 118 bytes {0} [built]
+ cjs require ./cup1 [0] ./example.js 1:12-29
+ [2] ./cup2.coffee 57 bytes {0} [built]
+ cjs require ./cup2.coffee [1] ./cup1.coffee 4:12-36
+ cjs require ./cup2 [1] ./cup1.coffee 5:9-26
```
-## Minimized (uglify-js, no zip)
+## Production mode
```
-Hash: 22e68923dcce75e38966
-Version: webpack 3.5.1
+Hash: 0a1b2c3d4e5f6a7b8c9d
+Version: webpack 4.0.0-beta.2
Asset Size Chunks Chunk Names
-output.js 640 bytes 0 [emitted] main
+output.js 708 bytes 0 [emitted] main
Entrypoint main = output.js
chunk {0} output.js (main) 206 bytes [entry] [rendered]
- > main [1] ./example.js
+ > .\example.js main
[0] ./cup2.coffee 57 bytes {0} [built]
- cjs require ./cup2.coffee [2] ./cup1.coffee 4:12-36
- cjs require ./cup2 [2] ./cup1.coffee 5:9-26
- [1] ./example.js 31 bytes {0} [built]
- [2] ./cup1.coffee 118 bytes {0} [built]
- cjs require ./cup1 [1] ./example.js 1:12-29
+ cjs require ./cup2.coffee [1] ./cup1.coffee 4:12-36
+ cjs require ./cup2 [1] ./cup1.coffee 5:9-26
+ [1] ./cup1.coffee 118 bytes {0} [built]
+ cjs require ./cup1 [2] ./example.js 1:12-29
+ [2] ./example.js 31 bytes {0} [built]
+ single entry .\example.js main
```
\ No newline at end of file
diff --git a/examples/coffee-script/template.md b/examples/coffee-script/template.md
index 2f398ea9..bef6e314 100644
--- a/examples/coffee-script/template.md
+++ b/examples/coffee-script/template.md
@@ -17,22 +17,22 @@
{{cup2.coffee}}
```
-# js/output.js
+# dist/output.js
``` javascript
-{{js/output.js}}
+{{dist/output.js}}
```
# Info
-## Uncompressed
+## Unoptimized
```
{{stdout}}
```
-## Minimized (uglify-js, no zip)
+## Production mode
```
-{{min:stdout}}
+{{production:stdout}}
```
\ No newline at end of file
diff --git a/examples/coffee-script/webpack.config.js b/examples/coffee-script/webpack.config.js
index 5c3ba952..845f9f4c 100644
--- a/examples/coffee-script/webpack.config.js
+++ b/examples/coffee-script/webpack.config.js
@@ -1,7 +1,11 @@
module.exports = {
+ // mode: "development || "production",
module: {
- loaders: [
- { test: /\.coffee$/, loader: "coffee-loader" }
+ rules: [
+ {
+ test: /\.coffee$/,
+ loader: "coffee-loader"
+ }
]
},
resolve: {
diff --git a/examples/common-chunk-and-vendor-chunk/README.md b/examples/common-chunk-and-vendor-chunk/README.md
index 5166915d..78a646a9 100644
--- a/examples/common-chunk-and-vendor-chunk/README.md
+++ b/examples/common-chunk-and-vendor-chunk/README.md
@@ -35,43 +35,122 @@ With this bundle configuration, you would load your third party libraries, then
``` javascript
var path = require("path");
-var CommonsChunkPlugin = require("../../lib/optimize/CommonsChunkPlugin");
module.exports = {
+ // mode: "development" || "production",
entry: {
- vendor: ["./vendor1", "./vendor2"],
pageA: "./pageA",
pageB: "./pageB",
pageC: "./pageC"
- // older versions of webpack may require an empty entry point declaration here
- // common: []
+ },
+ optimization: {
+ splitChunks: {
+ cacheGroups: {
+ commons: {
+ chunks: "initial",
+ minChunks: 2,
+ maxInitialRequests: 5, // The default limit is too small to showcase the effect
+ minSize: 0 // This is example is too small to create commons chunks
+ },
+ vendor: {
+ test: /node_modules/,
+ chunks: "initial",
+ name: "vendor",
+ priority: 10,
+ enforce: true
+ }
+ }
+ }
},
output: {
- path: path.join(__dirname, "js"),
+ path: path.join(__dirname, "dist"),
filename: "[name].js"
- },
- plugins: [
- new CommonsChunkPlugin({
- // The order of this array matters
- names: ["common", "vendor"],
- minChunks: 2
- })
- ]
+ }
};
```
-# js/vendor.js
+# dist/vendor.js
+
+``` javascript
+(window["webpackJsonp"] = window["webpackJsonp"] || []).push([[3],{
+
+/***/ 1:
+/*!*********************************!*\
+ !*** ./node_modules/vendor1.js ***!
+ \*********************************/
+/*! no static exports found */
+/***/ (function(module, exports) {
+
+module.exports = "vendor1";
+
+/***/ }),
+
+/***/ 5:
+/*!*********************************!*\
+ !*** ./node_modules/vendor2.js ***!
+ \*********************************/
+/*! no static exports found */
+/***/ (function(module, exports) {
+
+module.exports = "vendor2";
+
+/***/ })
+
+}]);
+```
+
+# dist/commons~pageA~pageB~pageC.js
+
+``` javascript
+(window["webpackJsonp"] = window["webpackJsonp"] || []).push([[4],{
+
+/***/ 3:
+/*!*********************!*\
+ !*** ./utility2.js ***!
+ \*********************/
+/*! no static exports found */
+/***/ (function(module, exports) {
+
+module.exports = "utility2";
+
+/***/ })
+
+}]);
+```
+
+# dist/commons~pageB~pageC.js
+
+``` javascript
+(window["webpackJsonp"] = window["webpackJsonp"] || []).push([[5],{
+
+/***/ 6:
+/*!*********************!*\
+ !*** ./utility3.js ***!
+ \*********************/
+/*! no static exports found */
+/***/ (function(module, exports) {
+
+module.exports = "utility3";
+
+/***/ })
+
+}]);
+```
+
+# dist/pageA.js
<details><summary><code>/******/ (function(modules) { /* webpackBootstrap */ })</code></summary>
``` javascript
/******/ (function(modules) { // webpackBootstrap
/******/ // install a JSONP callback for chunk loading
-/******/ var parentJsonpFunction = window["webpackJsonp"];
-/******/ window["webpackJsonp"] = function webpackJsonpCallback(chunkIds, moreModules, executeModules) {
+/******/ function webpackJsonpCallback(data) {
+/******/ var chunkIds = data[0];
+/******/ var moreModules = data[1]
+/******/ var executeModules = data[2];
/******/ // add "moreModules" to the modules object,
/******/ // then flag all "chunkIds" as loaded and fire callback
-/******/ var moduleId, chunkId, i = 0, resolves = [], result;
+/******/ var moduleId, chunkId, i = 0, resolves = [];
/******/ for(;i < chunkIds.length; i++) {
/******/ chunkId = chunkIds[i];
/******/ if(installedChunks[chunkId]) {
@@ -84,26 +163,44 @@ module.exports = {
/******/ modules[moduleId] = moreModules[moduleId];
/******/ }
/******/ }
-/******/ if(parentJsonpFunction) parentJsonpFunction(chunkIds, moreModules, executeModules);
+/******/ if(parentJsonpFunction) parentJsonpFunction(data);
/******/ while(resolves.length) {
/******/ resolves.shift()();
/******/ }
-/******/ if(executeModules) {
-/******/ for(i=0; i < executeModules.length; i++) {
-/******/ result = __webpack_require__(__webpack_require__.s = executeModules[i]);
+/******/
+/******/ // add entry modules from loaded chunk to deferred list
+/******/ deferredModules.push.apply(deferredModules, executeModules || []);
+/******/
+/******/ // run deferred modules when all chunks ready
+/******/ return checkDeferredModules();
+/******/ };
+/******/ function checkDeferredModules() {
+/******/ var result;
+/******/ for(var i = 0; i < deferredModules.length; i++) {
+/******/ var deferredModule = deferredModules[i];
+/******/ var fullfilled = true;
+/******/ for(var j = 1; j < deferredModule.length; j++) {
+/******/ var depId = deferredModule[j];
+/******/ if(installedChunks[depId] !== 0) fullfilled = false;
+/******/ }
+/******/ if(fullfilled) {
+/******/ deferredModules.splice(i--, 1);
+/******/ result = __webpack_require__(__webpack_require__.s = deferredModule[0]);
/******/ }
/******/ }
/******/ return result;
-/******/ };
+/******/ }
/******/
/******/ // The module cache
/******/ var installedModules = {};
/******/
-/******/ // objects to store loaded and loading chunks
+/******/ // object to store loaded and loading chunks
/******/ var installedChunks = {
-/******/ 4: 0
+/******/ 0: 0
/******/ };
/******/
+/******/ var deferredModules = [];
+/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
@@ -128,55 +225,6 @@ module.exports = {
/******/ return module.exports;
/******/ }
/******/
-/******/ // This file contains only the entry chunk.
-/******/ // The chunk loading function for additional chunks
-/******/ __webpack_require__.e = function requireEnsure(chunkId) {
-/******/ var installedChunkData = installedChunks[chunkId];
-/******/ if(installedChunkData === 0) {
-/******/ return new Promise(function(resolve) { resolve(); });
-/******/ }
-/******/
-/******/ // a Promise means "currently loading".
-/******/ if(installedChunkData) {
-/******/ return installedChunkData[2];
-/******/ }
-/******/
-/******/ // setup Promise in chunk cache
-/******/ var promise = new Promise(function(resolve, reject) {
-/******/ installedChunkData = installedChunks[chunkId] = [resolve, reject];
-/******/ });
-/******/ installedChunkData[2] = promise;
-/******/
-/******/ // start chunk loading
-/******/ var head = document.getElementsByTagName('head')[0];
-/******/ var script = document.createElement('script');
-/******/ script.type = 'text/javascript';
-/******/ script.charset = 'utf-8';
-/******/ script.async = true;
-/******/ script.timeout = 120000;
-/******/
-/******/ if (__webpack_require__.nc) {
-/******/ script.setAttribute("nonce", __webpack_require__.nc);
-/******/ }
-/******/ script.src = __webpack_require__.p + "" + chunkId + ".js";
-/******/ var timeout = setTimeout(onScriptComplete, 120000);
-/******/ script.onerror = script.onload = onScriptComplete;
-/******/ function onScriptComplete() {
-/******/ // avoid mem leaks in IE.
-/******/ script.onerror = script.onload = null;
-/******/ clearTimeout(timeout);
-/******/ var chunk = installedChunks[chunkId];
-/******/ if(chunk !== 0) {
-/******/ if(chunk) {
-/******/ chunk[1](new Error('Loading chunk ' + chunkId + ' failed.'));
-/******/ }
-/******/ installedChunks[chunkId] = undefined;
-/******/ }
-/******/ };
-/******/ head.appendChild(script);
-/******/
-/******/ return promise;
-/******/ };
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
@@ -195,6 +243,11 @@ module.exports = {
/******/ }
/******/ };
/******/
+/******/ // define __esModule on exports
+/******/ __webpack_require__.r = function(exports) {
+/******/ Object.defineProperty(exports, '__esModule', { value: true });
+/******/ };
+/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
@@ -208,13 +261,20 @@ module.exports = {
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
-/******/ __webpack_require__.p = "js/";
+/******/ __webpack_require__.p = "dist/";
+/******/
+/******/ var jsonpArray = window["webpackJsonp"] = window["webpackJsonp"] || [];
+/******/ var oldJsonpFunction = jsonpArray.push.bind(jsonpArray);
+/******/ jsonpArray.push = webpackJsonpCallback;
+/******/ jsonpArray = jsonpArray.slice();
+/******/ for(var i = 0; i < jsonpArray.length; i++) webpackJsonpCallback(jsonpArray[i]);
+/******/ var parentJsonpFunction = oldJsonpFunction;
/******/
-/******/ // on error function for async loading
-/******/ __webpack_require__.oe = function(err) { console.error(err); throw err; };
/******/
-/******/ // Load entry module and return exports
-/******/ return __webpack_require__(__webpack_require__.s = 2);
+/******/ // add entry module to deferred list
+/******/ deferredModules.push([0,3,4]);
+/******/ // run deferred modules when ready
+/******/ return checkDeferredModules();
/******/ })
/************************************************************************/
```
@@ -223,240 +283,447 @@ module.exports = {
``` javascript
/******/ ([
-/* 0 */,
-/* 1 */,
-/* 2 */
-/*!*********************************!*\
- !*** multi ./vendor1 ./vendor2 ***!
- \*********************************/
-/*! no static exports found */
-/*! all exports used */
-/***/ (function(module, exports, __webpack_require__) {
-
-__webpack_require__(/*! ./vendor1 */3);
-module.exports = __webpack_require__(/*! ./vendor2 */4);
-
-
-/***/ }),
-/* 3 */
-/*!********************!*\
- !*** ./vendor1.js ***!
- \********************/
-/*! no static exports found */
-/*! all exports used */
-/***/ (function(module, exports) {
-
-module.exports = "vendor1";
-
-/***/ }),
-/* 4 */
-/*!********************!*\
- !*** ./vendor2.js ***!
- \********************/
-/*! no static exports found */
-/*! all exports used */
-/***/ (function(module, exports) {
-
-module.exports = "vendor2";
-
-/***/ })
-/******/ ]);
-```
-
-# js/common.js
-
-``` javascript
-webpackJsonp([0],[
/* 0 */
-/*!*********************!*\
- !*** ./utility2.js ***!
- \*********************/
-/*! no static exports found */
-/*! all exports used */
-/***/ (function(module, exports) {
-
-module.exports = "utility2";
-
-/***/ }),
-/* 1 */
-/*!*********************!*\
- !*** ./utility3.js ***!
- \*********************/
-/*! no static exports found */
-/*! all exports used */
-/***/ (function(module, exports) {
-
-module.exports = "utility3";
-
-/***/ })
-]);
-```
-
-# js/pageA.js
-
-``` javascript
-webpackJsonp([1],{
-
-/***/ 5:
/*!******************!*\
!*** ./pageA.js ***!
\******************/
/*! no static exports found */
-/*! all exports used */
/***/ (function(module, exports, __webpack_require__) {
-var utility1 = __webpack_require__(/*! ./utility1 */ 6);
-var utility2 = __webpack_require__(/*! ./utility2 */ 0);
+var vendor1 = __webpack_require__(/*! vendor1 */ 1);
+var utility1 = __webpack_require__(/*! ./utility1 */ 2);
+var utility2 = __webpack_require__(/*! ./utility2 */ 3);
module.exports = "pageA";
-/***/ }),
-/***/ 6:
+/***/ }),
+/* 1 */,
+/* 2 */
/*!*********************!*\
!*** ./utility1.js ***!
\*********************/
/*! no static exports found */
-/*! all exports used */
/***/ (function(module, exports) {
module.exports = "utility1";
/***/ })
-
-},[5]);
+/******/ ]);
```
-# js/pageB.js
+# dist/pageB.js
``` javascript
-webpackJsonp([3],{
+/******/ (function(modules) { // webpackBootstrap
+/******/ // install a JSONP callback for chunk loading
+/******/ function webpackJsonpCallback(data) {
+/******/ var chunkIds = data[0];
+/******/ var moreModules = data[1]
+/******/ var executeModules = data[2];
+/******/ // add "moreModules" to the modules object,
+/******/ // then flag all "chunkIds" as loaded and fire callback
+/******/ var moduleId, chunkId, i = 0, resolves = [];
+/******/ for(;i < chunkIds.length; i++) {
+/******/ chunkId = chunkIds[i];
+/******/ if(installedChunks[chunkId]) {
+/******/ resolves.push(installedChunks[chunkId][0]);
+/******/ }
+/******/ installedChunks[chunkId] = 0;
+/******/ }
+/******/ for(moduleId in moreModules) {
+/******/ if(Object.prototype.hasOwnProperty.call(moreModules, moduleId)) {
+/******/ modules[moduleId] = moreModules[moduleId];
+/******/ }
+/******/ }
+/******/ if(parentJsonpFunction) parentJsonpFunction(data);
+/******/ while(resolves.length) {
+/******/ resolves.shift()();
+/******/ }
+/******/
+/******/ // add entry modules from loaded chunk to deferred list
+/******/ deferredModules.push.apply(deferredModules, executeModules || []);
+/******/
+/******/ // run deferred modules when all chunks ready
+/******/ return checkDeferredModules();
+/******/ };
+/******/ function checkDeferredModules() {
+/******/ var result;
+/******/ for(var i = 0; i < deferredModules.length; i++) {
+/******/ var deferredModule = deferredModules[i];
+/******/ var fullfilled = true;
+/******/ for(var j = 1; j < deferredModule.length; j++) {
+/******/ var depId = deferredModule[j];
+/******/ if(installedChunks[depId] !== 0) fullfilled = false;
+/******/ }
+/******/ if(fullfilled) {
+/******/ deferredModules.splice(i--, 1);
+/******/ result = __webpack_require__(__webpack_require__.s = deferredModule[0]);
+/******/ }
+/******/ }
+/******/ return result;
+/******/ }
+/******/
+/******/ // The module cache
+/******/ var installedModules = {};
+/******/
+/******/ // object to store loaded and loading chunks
+/******/ var installedChunks = {
+/******/ 1: 0
+/******/ };
+/******/
+/******/ var deferredModules = [];
+/******/
+/******/ // The require function
+/******/ function __webpack_require__(moduleId) {
+/******/
+/******/ // Check if module is in cache
+/******/ if(installedModules[moduleId]) {
+/******/ return installedModules[moduleId].exports;
+/******/ }
+/******/ // Create a new module (and put it into the cache)
+/******/ var module = installedModules[moduleId] = {
+/******/ i: moduleId,
+/******/ l: false,
+/******/ exports: {}
+/******/ };
+/******/
+/******/ // Execute the module function
+/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
+/******/
+/******/ // Flag the module as loaded
+/******/ module.l = true;
+/******/
+/******/ // Return the exports of the module
+/******/ return module.exports;
+/******/ }
+/******/
+/******/
+/******/ // expose the modules object (__webpack_modules__)
+/******/ __webpack_require__.m = modules;
+/******/
+/******/ // expose the module cache
+/******/ __webpack_require__.c = installedModules;
+/******/
+/******/ // define getter function for harmony exports
+/******/ __webpack_require__.d = function(exports, name, getter) {
+/******/ if(!__webpack_require__.o(exports, name)) {
+/******/ Object.defineProperty(exports, name, {
+/******/ configurable: false,
+/******/ enumerable: true,
+/******/ get: getter
+/******/ });
+/******/ }
+/******/ };
+/******/
+/******/ // define __esModule on exports
+/******/ __webpack_require__.r = function(exports) {
+/******/ Object.defineProperty(exports, '__esModule', { value: true });
+/******/ };
+/******/
+/******/ // getDefaultExport function for compatibility with non-harmony modules
+/******/ __webpack_require__.n = function(module) {
+/******/ var getter = module && module.__esModule ?
+/******/ function getDefault() { return module['default']; } :
+/******/ function getModuleExports() { return module; };
+/******/ __webpack_require__.d(getter, 'a', getter);
+/******/ return getter;
+/******/ };
+/******/
+/******/ // Object.prototype.hasOwnProperty.call
+/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
+/******/
+/******/ // __webpack_public_path__
+/******/ __webpack_require__.p = "dist/";
+/******/
+/******/ var jsonpArray = window["webpackJsonp"] = window["webpackJsonp"] || [];
+/******/ var oldJsonpFunction = jsonpArray.push.bind(jsonpArray);
+/******/ jsonpArray.push = webpackJsonpCallback;
+/******/ jsonpArray = jsonpArray.slice();
+/******/ for(var i = 0; i < jsonpArray.length; i++) webpackJsonpCallback(jsonpArray[i]);
+/******/ var parentJsonpFunction = oldJsonpFunction;
+/******/
+/******/
+/******/ // add entry module to deferred list
+/******/ deferredModules.push([4,3,4,5]);
+/******/ // run deferred modules when ready
+/******/ return checkDeferredModules();
+/******/ })
+/************************************************************************/
+/******/ ({
-/***/ 7:
+/***/ 4:
/*!******************!*\
!*** ./pageB.js ***!
\******************/
/*! no static exports found */
-/*! all exports used */
/***/ (function(module, exports, __webpack_require__) {
-var utility2 = __webpack_require__(/*! ./utility2 */ 0);
-var utility3 = __webpack_require__(/*! ./utility3 */ 1);
+var vendor2 = __webpack_require__(/*! vendor2 */ 5);
+var utility2 = __webpack_require__(/*! ./utility2 */ 3);
+var utility3 = __webpack_require__(/*! ./utility3 */ 6);
module.exports = "pageB";
+
/***/ })
-},[7]);
+/******/ });
```
-# js/pageC.js
+# dist/pageC.js
``` javascript
-webpackJsonp([2],{
+/******/ (function(modules) { // webpackBootstrap
+/******/ // install a JSONP callback for chunk loading
+/******/ function webpackJsonpCallback(data) {
+/******/ var chunkIds = data[0];
+/******/ var moreModules = data[1]
+/******/ var executeModules = data[2];
+/******/ // add "moreModules" to the modules object,
+/******/ // then flag all "chunkIds" as loaded and fire callback
+/******/ var moduleId, chunkId, i = 0, resolves = [];
+/******/ for(;i < chunkIds.length; i++) {
+/******/ chunkId = chunkIds[i];
+/******/ if(installedChunks[chunkId]) {
+/******/ resolves.push(installedChunks[chunkId][0]);
+/******/ }
+/******/ installedChunks[chunkId] = 0;
+/******/ }
+/******/ for(moduleId in moreModules) {
+/******/ if(Object.prototype.hasOwnProperty.call(moreModules, moduleId)) {
+/******/ modules[moduleId] = moreModules[moduleId];
+/******/ }
+/******/ }
+/******/ if(parentJsonpFunction) parentJsonpFunction(data);
+/******/ while(resolves.length) {
+/******/ resolves.shift()();
+/******/ }
+/******/
+/******/ // add entry modules from loaded chunk to deferred list
+/******/ deferredModules.push.apply(deferredModules, executeModules || []);
+/******/
+/******/ // run deferred modules when all chunks ready
+/******/ return checkDeferredModules();
+/******/ };
+/******/ function checkDeferredModules() {
+/******/ var result;
+/******/ for(var i = 0; i < deferredModules.length; i++) {
+/******/ var deferredModule = deferredModules[i];
+/******/ var fullfilled = true;
+/******/ for(var j = 1; j < deferredModule.length; j++) {
+/******/ var depId = deferredModule[j];
+/******/ if(installedChunks[depId] !== 0) fullfilled = false;
+/******/ }
+/******/ if(fullfilled) {
+/******/ deferredModules.splice(i--, 1);
+/******/ result = __webpack_require__(__webpack_require__.s = deferredModule[0]);
+/******/ }
+/******/ }
+/******/ return result;
+/******/ }
+/******/
+/******/ // The module cache
+/******/ var installedModules = {};
+/******/
+/******/ // object to store loaded and loading chunks
+/******/ var installedChunks = {
+/******/ 2: 0
+/******/ };
+/******/
+/******/ var deferredModules = [];
+/******/
+/******/ // The require function
+/******/ function __webpack_require__(moduleId) {
+/******/
+/******/ // Check if module is in cache
+/******/ if(installedModules[moduleId]) {
+/******/ return installedModules[moduleId].exports;
+/******/ }
+/******/ // Create a new module (and put it into the cache)
+/******/ var module = installedModules[moduleId] = {
+/******/ i: moduleId,
+/******/ l: false,
+/******/ exports: {}
+/******/ };
+/******/
+/******/ // Execute the module function
+/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
+/******/
+/******/ // Flag the module as loaded
+/******/ module.l = true;
+/******/
+/******/ // Return the exports of the module
+/******/ return module.exports;
+/******/ }
+/******/
+/******/
+/******/ // expose the modules object (__webpack_modules__)
+/******/ __webpack_require__.m = modules;
+/******/
+/******/ // expose the module cache
+/******/ __webpack_require__.c = installedModules;
+/******/
+/******/ // define getter function for harmony exports
+/******/ __webpack_require__.d = function(exports, name, getter) {
+/******/ if(!__webpack_require__.o(exports, name)) {
+/******/ Object.defineProperty(exports, name, {
+/******/ configurable: false,
+/******/ enumerable: true,
+/******/ get: getter
+/******/ });
+/******/ }
+/******/ };
+/******/
+/******/ // define __esModule on exports
+/******/ __webpack_require__.r = function(exports) {
+/******/ Object.defineProperty(exports, '__esModule', { value: true });
+/******/ };
+/******/
+/******/ // getDefaultExport function for compatibility with non-harmony modules
+/******/ __webpack_require__.n = function(module) {
+/******/ var getter = module && module.__esModule ?
+/******/ function getDefault() { return module['default']; } :
+/******/ function getModuleExports() { return module; };
+/******/ __webpack_require__.d(getter, 'a', getter);
+/******/ return getter;
+/******/ };
+/******/
+/******/ // Object.prototype.hasOwnProperty.call
+/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
+/******/
+/******/ // __webpack_public_path__
+/******/ __webpack_require__.p = "dist/";
+/******/
+/******/ var jsonpArray = window["webpackJsonp"] = window["webpackJsonp"] || [];
+/******/ var oldJsonpFunction = jsonpArray.push.bind(jsonpArray);
+/******/ jsonpArray.push = webpackJsonpCallback;
+/******/ jsonpArray = jsonpArray.slice();
+/******/ for(var i = 0; i < jsonpArray.length; i++) webpackJsonpCallback(jsonpArray[i]);
+/******/ var parentJsonpFunction = oldJsonpFunction;
+/******/
+/******/
+/******/ // add entry module to deferred list
+/******/ deferredModules.push([7,4,5]);
+/******/ // run deferred modules when ready
+/******/ return checkDeferredModules();
+/******/ })
+/************************************************************************/
+/******/ ({
-/***/ 8:
+/***/ 7:
/*!******************!*\
!*** ./pageC.js ***!
\******************/
/*! no static exports found */
-/*! all exports used */
/***/ (function(module, exports, __webpack_require__) {
-var utility2 = __webpack_require__(/*! ./utility2 */ 0);
-var utility3 = __webpack_require__(/*! ./utility3 */ 1);
+var utility2 = __webpack_require__(/*! ./utility2 */ 3);
+var utility3 = __webpack_require__(/*! ./utility3 */ 6);
module.exports = "pageC";
/***/ })
-},[8]);
+/******/ });
```
# Info
-## Uncompressed
+## Unoptimized
```
-Hash: 3b80b7c17398c31e4705
-Version: webpack 3.5.1
- Asset Size Chunks Chunk Names
-common.js 459 bytes 0 [emitted] common
- pageA.js 595 bytes 1 [emitted] pageA
- pageC.js 374 bytes 2 [emitted] pageC
- pageB.js 374 bytes 3 [emitted] pageB
-vendor.js 6.7 kB 4 [emitted] vendor
-Entrypoint vendor = vendor.js
-Entrypoint pageA = vendor.js common.js pageA.js
-Entrypoint pageB = vendor.js common.js pageB.js
-Entrypoint pageC = vendor.js common.js pageC.js
-chunk {0} common.js (common) 56 bytes {4} [initial] [rendered]
- [0] ./utility2.js 28 bytes {0} [built]
- cjs require ./utility2 [5] ./pageA.js 2:15-36
- cjs require ./utility2 [7] ./pageB.js 1:15-36
- cjs require ./utility2 [8] ./pageC.js 1:15-36
- [1] ./utility3.js 28 bytes {0} [built]
- cjs require ./utility3 [7] ./pageB.js 2:15-36
- cjs require ./utility3 [8] ./pageC.js 2:15-36
-chunk {1} pageA.js (pageA) 133 bytes {0} [initial] [rendered]
- > pageA [5] ./pageA.js
- [5] ./pageA.js 105 bytes {1} [built]
- [6] ./utility1.js 28 bytes {1} [built]
- cjs require ./utility1 [5] ./pageA.js 1:15-36
-chunk {2} pageC.js (pageC) 105 bytes {0} [initial] [rendered]
- > pageC [8] ./pageC.js
- [8] ./pageC.js 105 bytes {2} [built]
-chunk {3} pageB.js (pageB) 105 bytes {0} [initial] [rendered]
- > pageB [7] ./pageB.js
- [7] ./pageB.js 105 bytes {3} [built]
-chunk {4} vendor.js (vendor) 94 bytes [entry] [rendered]
- > vendor [2] multi ./vendor1 ./vendor2
- [2] multi ./vendor1 ./vendor2 40 bytes {4} [built]
- [3] ./vendor1.js 27 bytes {4} [built]
- single entry ./vendor1 [2] multi ./vendor1 ./vendor2 vendor:100000
- [4] ./vendor2.js 27 bytes {4} [built]
- single entry ./vendor2 [2] multi ./vendor1 ./vendor2 vendor:100001
+Hash: 0a1b2c3d4e5f6a7b8c9d
+Version: webpack 4.0.0-beta.2
+ Asset Size Chunks Chunk Names
+ pageA.js 5.6 KiB 0 [emitted] pageA
+ pageB.js 5.4 KiB 1 [emitted] pageB
+ pageC.js 5.34 KiB 2 [emitted] pageC
+ vendor.js 536 bytes 3 [emitted] vendor
+commons~pageA~pageB~pageC.js 269 bytes 4 [emitted] commons~pageA~pageB~pageC
+ commons~pageB~pageC.js 269 bytes 5 [emitted] commons~pageB~pageC
+Entrypoint pageA = vendor.js commons~pageA~pageB~pageC.js pageA.js
+Entrypoint pageB = vendor.js commons~pageA~pageB~pageC.js commons~pageB~pageC.js pageB.js
+Entrypoint pageC = commons~pageA~pageB~pageC.js commons~pageB~pageC.js pageC.js
+chunk {0} pageA.js (pageA) 170 bytes ={3}= ={4}= [entry] [rendered]
+ > ./pageA pageA
+ [0] ./pageA.js 142 bytes {0} [built]
+ single entry ./pageA pageA
+ [2] ./utility1.js 28 bytes {0} [built]
+ cjs require ./utility1 [0] ./pageA.js 2:15-36
+chunk {1} pageB.js (pageB) 142 bytes ={3}= ={4}= ={5}= [entry] [rendered]
+ > ./pageB pageB
+ [4] ./pageB.js 142 bytes {1} [built]
+ single entry ./pageB pageB
+chunk {2} pageC.js (pageC) 105 bytes ={4}= ={5}= [entry] [rendered]
+ > ./pageC pageC
+ [7] ./pageC.js 105 bytes {2} [built]
+ single entry ./pageC pageC
+chunk {3} vendor.js (vendor) 54 bytes ={0}= ={1}= ={4}= ={5}= [initial] [rendered] split chunk (cache group: vendor) (name: vendor)
+ > ./pageA pageA
+ > ./pageB pageB
+ 2 modules
+chunk {4} commons~pageA~pageB~pageC.js (commons~pageA~pageB~pageC) 28 bytes ={0}= ={1}= ={2}= ={3}= ={5}= [initial] [rendered] split chunk (cache group: commons) (name: commons~pageA~pageB~pageC)
+ > ./pageA pageA
+ > ./pageB pageB
+ > ./pageC pageC
+ [3] ./utility2.js 28 bytes {4} [built]
+ cjs require ./utility2 [0] ./pageA.js 3:15-36
+ cjs require ./utility2 [4] ./pageB.js 2:15-36
+ cjs require ./utility2 [7] ./pageC.js 1:15-36
+chunk {5} commons~pageB~pageC.js (commons~pageB~pageC) 28 bytes ={1}= ={2}= ={3}= ={4}= [initial] [rendered] split chunk (cache group: commons) (name: commons~pageB~pageC)
+ > ./pageB pageB
+ > ./pageC pageC
+ [6] ./utility3.js 28 bytes {5} [built]
+ cjs require ./utility3 [4] ./pageB.js 3:15-36
+ cjs require ./utility3 [7] ./pageC.js 2:15-36
```
-## Minimized (uglify-js, no zip)
+## Production mode
```
-Hash: 3b80b7c17398c31e4705
-Version: webpack 3.5.1
- Asset Size Chunks Chunk Names
-common.js 92 bytes 0 [emitted] common
- pageA.js 109 bytes 1 [emitted] pageA
- pageC.js 71 bytes 2 [emitted] pageC
- pageB.js 71 bytes 3 [emitted] pageB
-vendor.js 1.48 kB 4 [emitted] vendor
-Entrypoint vendor = vendor.js
-Entrypoint pageA = vendor.js common.js pageA.js
-Entrypoint pageB = vendor.js common.js pageB.js
-Entrypoint pageC = vendor.js common.js pageC.js
-chunk {0} common.js (common) 56 bytes {4} [initial] [rendered]
+Hash: 0a1b2c3d4e5f6a7b8c9d
+Version: webpack 4.0.0-beta.2
+ Asset Size Chunks Chunk Names
+commons~pageA~pageB~pageC.js 96 bytes 0 [emitted] commons~pageA~pageB~pageC
+ commons~pageB~pageC.js 97 bytes 1 [emitted] commons~pageB~pageC
+ vendor.js 134 bytes 2 [emitted] vendor
+ pageC.js 1.1 KiB 3 [emitted] pageC
+ pageB.js 1.11 KiB 4 [emitted] pageB
+ pageA.js 1.15 KiB 5 [emitted] pageA
+Entrypoint pageA = vendor.js commons~pageA~pageB~pageC.js pageA.js
+Entrypoint pageB = vendor.js commons~pageA~pageB~pageC.js commons~pageB~pageC.js pageB.js
+Entrypoint pageC = commons~pageA~pageB~pageC.js commons~pageB~pageC.js pageC.js
+chunk {0} commons~pageA~pageB~pageC.js (commons~pageA~pageB~pageC) 28 bytes ={1}= ={2}= ={3}= ={4}= ={5}= [initial] [rendered] split chunk (cache group: commons) (name: commons~pageA~pageB~pageC)
+ > ./pageA pageA
+ > ./pageB pageB
+ > ./pageC pageC
[0] ./utility2.js 28 bytes {0} [built]
- cjs require ./utility2 [5] ./pageA.js 2:15-36
- cjs require ./utility2 [7] ./pageB.js 1:15-36
- cjs require ./utility2 [8] ./pageC.js 1:15-36
- [1] ./utility3.js 28 bytes {0} [built]
- cjs require ./utility3 [7] ./pageB.js 2:15-36
- cjs require ./utility3 [8] ./pageC.js 2:15-36
-chunk {1} pageA.js (pageA) 133 bytes {0} [initial] [rendered]
- > pageA [5] ./pageA.js
- [5] ./pageA.js 105 bytes {1} [built]
- [6] ./utility1.js 28 bytes {1} [built]
- cjs require ./utility1 [5] ./pageA.js 1:15-36
-chunk {2} pageC.js (pageC) 105 bytes {0} [initial] [rendered]
- > pageC [8] ./pageC.js
- [8] ./pageC.js 105 bytes {2} [built]
-chunk {3} pageB.js (pageB) 105 bytes {0} [initial] [rendered]
- > pageB [7] ./pageB.js
- [7] ./pageB.js 105 bytes {3} [built]
-chunk {4} vendor.js (vendor) 94 bytes [entry] [rendered]
- > vendor [2] multi ./vendor1 ./vendor2
- [2] multi ./vendor1 ./vendor2 40 bytes {4} [built]
- [3] ./vendor1.js 27 bytes {4} [built]
- single entry ./vendor1 [2] multi ./vendor1 ./vendor2 vendor:100000
- [4] ./vendor2.js 27 bytes {4} [built]
- single entry ./vendor2 [2] multi ./vendor1 ./vendor2 vendor:100001
+ cjs require ./utility2 [2] ./pageC.js 1:15-36
+ cjs require ./utility2 [4] ./pageB.js 2:15-36
+ cjs require ./utility2 [7] ./pageA.js 3:15-36
+chunk {1} commons~pageB~pageC.js (commons~pageB~pageC) 28 bytes ={0}= ={2}= ={3}= ={4}= [initial] [rendered] split chunk (cache group: commons) (name: commons~pageB~pageC)
+ > ./pageB pageB
+ > ./pageC pageC
+ [1] ./utility3.js 28 bytes {1} [built]
+ cjs require ./utility3 [2] ./pageC.js 2:15-36
+ cjs require ./utility3 [4] ./pageB.js 3:15-36
+chunk {2} vendor.js (vendor) 54 bytes ={0}= ={1}= ={4}= ={5}= [initial] [rendered] split chunk (cache group: vendor) (name: vendor)
+ > ./pageA pageA
+ > ./pageB pageB
+ 2 modules
+chunk {3} pageC.js (pageC) 105 bytes ={0}= ={1}= [entry] [rendered]
+ > ./pageC pageC
+ [2] ./pageC.js 105 bytes {3} [built]
+ single entry ./pageC pageC
+chunk {4} pageB.js (pageB) 142 bytes ={0}= ={1}= ={2}= [entry] [rendered]
+ > ./pageB pageB
+ [4] ./pageB.js 142 bytes {4} [built]
+ single entry ./pageB pageB
+chunk {5} pageA.js (pageA) 170 bytes ={0}= ={2}= [entry] [rendered]
+ > ./pageA pageA
+ [5] ./utility1.js 28 bytes {5} [built]
+ cjs require ./utility1 [7] ./pageA.js 2:15-36
+ [7] ./pageA.js 142 bytes {5} [built]
+ single entry ./pageA pageA
```
diff --git a/examples/common-chunk-and-vendor-chunk/vendor1.js b/examples/common-chunk-and-vendor-chunk/node_modules/vendor1.js
similarity index 100%
rename from examples/common-chunk-and-vendor-chunk/vendor1.js
rename to examples/common-chunk-and-vendor-chunk/node_modules/vendor1.js
diff --git a/examples/common-chunk-and-vendor-chunk/vendor2.js b/examples/common-chunk-and-vendor-chunk/node_modules/vendor2.js
similarity index 100%
rename from examples/common-chunk-and-vendor-chunk/vendor2.js
rename to examples/common-chunk-and-vendor-chunk/node_modules/vendor2.js
diff --git a/examples/common-chunk-and-vendor-chunk/pageA.js b/examples/common-chunk-and-vendor-chunk/pageA.js
index c709deda..d74b62eb 100644
--- a/examples/common-chunk-and-vendor-chunk/pageA.js
+++ b/examples/common-chunk-and-vendor-chunk/pageA.js
@@ -1,4 +1,5 @@
+var vendor1 = require('vendor1');
var utility1 = require('./utility1');
var utility2 = require('./utility2');
-module.exports = "pageA";
\ No newline at end of file
+module.exports = "pageA";
diff --git a/examples/common-chunk-and-vendor-chunk/pageB.js b/examples/common-chunk-and-vendor-chunk/pageB.js
index c343eb53..8be56b6d 100644
--- a/examples/common-chunk-and-vendor-chunk/pageB.js
+++ b/examples/common-chunk-and-vendor-chunk/pageB.js
@@ -1,4 +1,5 @@
+var vendor2 = require('vendor2');
var utility2 = require('./utility2');
var utility3 = require('./utility3');
-module.exports = "pageB";
\ No newline at end of file
+module.exports = "pageB";
diff --git a/examples/common-chunk-and-vendor-chunk/template.md b/examples/common-chunk-and-vendor-chunk/template.md
index 89b5cb7a..bc7f590c 100644
--- a/examples/common-chunk-and-vendor-chunk/template.md
+++ b/examples/common-chunk-and-vendor-chunk/template.md
@@ -37,46 +37,52 @@ With this bundle configuration, you would load your third party libraries, then
{{webpack.config.js}}
```
-# js/vendor.js
+# dist/vendor.js
``` javascript
-{{js/vendor.js}}
+{{dist/vendor.js}}
```
-# js/common.js
+# dist/commons~pageA~pageB~pageC.js
``` javascript
-{{js/common.js}}
+{{dist/commons~pageA~pageB~pageC.js}}
```
-# js/pageA.js
+# dist/commons~pageB~pageC.js
``` javascript
-{{js/pageA.js}}
+{{dist/commons~pageB~pageC.js}}
```
-# js/pageB.js
+# dist/pageA.js
``` javascript
-{{js/pageB.js}}
+{{dist/pageA.js}}
```
-# js/pageC.js
+# dist/pageB.js
``` javascript
-{{js/pageC.js}}
+{{dist/pageB.js}}
+```
+
+# dist/pageC.js
+
+``` javascript
+{{dist/pageC.js}}
```
# Info
-## Uncompressed
+## Unoptimized
```
{{stdout}}
```
-## Minimized (uglify-js, no zip)
+## Production mode
```
-{{min:stdout}}
+{{production:stdout}}
```
diff --git a/examples/common-chunk-and-vendor-chunk/webpack.config.js b/examples/common-chunk-and-vendor-chunk/webpack.config.js
index a85c3e4e..2cdc9599 100644
--- a/examples/common-chunk-and-vendor-chunk/webpack.config.js
+++ b/examples/common-chunk-and-vendor-chunk/webpack.config.js
@@ -1,24 +1,33 @@
var path = require("path");
-var CommonsChunkPlugin = require("../../lib/optimize/CommonsChunkPlugin");
module.exports = {
+ // mode: "development" || "production",
entry: {
- vendor: ["./vendor1", "./vendor2"],
pageA: "./pageA",
pageB: "./pageB",
pageC: "./pageC"
- // older versions of webpack may require an empty entry point declaration here
- // common: []
+ },
+ optimization: {
+ splitChunks: {
+ cacheGroups: {
+ commons: {
+ chunks: "initial",
+ minChunks: 2,
+ maxInitialRequests: 5, // The default limit is too small to showcase the effect
+ minSize: 0 // This is example is too small to create commons chunks
+ },
+ vendor: {
+ test: /node_modules/,
+ chunks: "initial",
+ name: "vendor",
+ priority: 10,
+ enforce: true
+ }
+ }
+ }
},
output: {
- path: path.join(__dirname, "js"),
+ path: path.join(__dirname, "dist"),
filename: "[name].js"
- },
- plugins: [
- new CommonsChunkPlugin({
- // The order of this array matters
- names: ["common", "vendor"],
- minChunks: 2
- })
- ]
+ }
};
diff --git a/examples/common-chunk-grandchildren/README.md b/examples/common-chunk-grandchildren/README.md
index 3ee56bfb..2477bfe1 100644
--- a/examples/common-chunk-grandchildren/README.md
+++ b/examples/common-chunk-grandchildren/README.md
@@ -4,19 +4,20 @@ This example illustrates how common modules from deep ancestors of an entry poin
* `pageC` and `pageA` both require the `reusableComponent`
* `pageB` dynamically requires `PageC`
-You can see that webpack outputs four files/chunks:
+You can see that webpack outputs five files/chunks:
* `output.js` is the entry chunk and contains
* the module system
* chunk loading logic
* the entry point `example.js`
- * module `reusableComponent`
* `0.output.js` is an additional chunk
- * module `pageC`
+ * module `reusableComponent`
* `1.output.js` is an additional chunk
* module `pageB`
* `2.output.js` is an additional chunk
* module `pageA`
+* `3.output.js` is an additional chunk
+ * module `pageC`
# example.js
@@ -83,60 +84,40 @@ module.exports = function() {
``` javascript
"use strict";
-const webpack = require("../../");
const path = require("path");
-module.exports = [
- {
- entry: {
- main: ["./example.js"]
- },
- output: {
- path: path.resolve(__dirname, "js"),
- filename: "output.js"
- },
- plugins: [
- new webpack.optimize.CommonsChunkPlugin({
- name: "main",
- minChunks: 2,
- children: true,
- deepChildren: true,
- })
- ]
+module.exports = {
+ // mode: "development || "production",
+ entry: {
+ main: ["./example.js"]
},
- {
- entry: {
- main: ["./example.js"]
+ optimization: {
+ splitChunks: {
+ minSize: 0 // This example is too small, in pratice you can use the defaults
},
- output: {
- path: path.resolve(__dirname, "js"),
- filename: "asyncoutput.js"
- },
- plugins: [
- new webpack.optimize.CommonsChunkPlugin({
- name: "main",
- minChunks: 2,
- async: true,
- children: true,
- deepChildren: true,
- })
- ]
+ occurrenceOrder: true // To keep filename consistent between different modes (for example building only)
+ },
+ output: {
+ path: path.resolve(__dirname, "dist"),
+ filename: "output.js"
}
-];
+};
```
-# js/output.js
+# dist/output.js
<details><summary><code>/******/ (function(modules) { /* webpackBootstrap */ })</code></summary>
``` javascript
/******/ (function(modules) { // webpackBootstrap
/******/ // install a JSONP callback for chunk loading
-/******/ var parentJsonpFunction = window["webpackJsonp"];
-/******/ window["webpackJsonp"] = function webpackJsonpCallback(chunkIds, moreModules, executeModules) {
+/******/ function webpackJsonpCallback(data) {
+/******/ var chunkIds = data[0];
+/******/ var moreModules = data[1]
+/******/
/******/ // add "moreModules" to the modules object,
/******/ // then flag all "chunkIds" as loaded and fire callback
-/******/ var moduleId, chunkId, i = 0, resolves = [], result;
+/******/ var moduleId, chunkId, i = 0, resolves = [];
/******/ for(;i < chunkIds.length; i++) {
/******/ chunkId = chunkIds[i];
/******/ if(installedChunks[chunkId]) {
@@ -149,21 +130,24 @@ module.exports = [
/******/ modules[moduleId] = moreModules[moduleId];
/******/ }
/******/ }
-/******/ if(parentJsonpFunction) parentJsonpFunction(chunkIds, moreModules, executeModules);
+/******/ if(parentJsonpFunction) parentJsonpFunction(data);
/******/ while(resolves.length) {
/******/ resolves.shift()();
/******/ }
/******/
/******/ };
/******/
+/******/
/******/ // The module cache
/******/ var installedModules = {};
/******/
-/******/ // objects to store loaded and loading chunks
+/******/ // object to store loaded and loading chunks
/******/ var installedChunks = {
-/******/ 3: 0
+/******/ 4: 0
/******/ };
/******/
+/******/
+/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
@@ -191,51 +175,60 @@ module.exports = [
/******/ // This file contains only the entry chunk.
/******/ // The chunk loading function for additional chunks
/******/ __webpack_require__.e = function requireEnsure(chunkId) {
-/******/ var installedChunkData = installedChunks[chunkId];
-/******/ if(installedChunkData === 0) {
-/******/ return new Promise(function(resolve) { resolve(); });
-/******/ }
+/******/ var promises = [];
/******/
-/******/ // a Promise means "currently loading".
-/******/ if(installedChunkData) {
-/******/ return installedChunkData[2];
-/******/ }
-/******/
-/******/ // setup Promise in chunk cache
-/******/ var promise = new Promise(function(resolve, reject) {
-/******/ installedChunkData = installedChunks[chunkId] = [resolve, reject];
-/******/ });
-/******/ installedChunkData[2] = promise;
/******/
-/******/ // start chunk loading
-/******/ var head = document.getElementsByTagName('head')[0];
-/******/ var script = document.createElement('script');
-/******/ script.type = 'text/javascript';
-/******/ script.charset = 'utf-8';
-/******/ script.async = true;
-/******/ script.timeout = 120000;
+/******/ // JSONP chunk loading for javascript
/******/
-/******/ if (__webpack_require__.nc) {
-/******/ script.setAttribute("nonce", __webpack_require__.nc);
-/******/ }
-/******/ script.src = __webpack_require__.p + "" + chunkId + ".output.js";
-/******/ var timeout = setTimeout(onScriptComplete, 120000);
-/******/ script.onerror = script.onload = onScriptComplete;
-/******/ function onScriptComplete() {
-/******/ // avoid mem leaks in IE.
-/******/ script.onerror = script.onload = null;
-/******/ clearTimeout(timeout);
-/******/ var chunk = installedChunks[chunkId];
-/******/ if(chunk !== 0) {
-/******/ if(chunk) {
-/******/ chunk[1](new Error('Loading chunk ' + chunkId + ' failed.'));
+/******/ var installedChunkData = installedChunks[chunkId];
+/******/ if(installedChunkData !== 0) { // 0 means "already installed".
+/******/
+/******/ // a Promise means "currently loading".
+/******/ if(installedChunkData) {
+/******/ promises.push(installedChunkData[2]);
+/******/ } else {
+/******/ // setup Promise in chunk cache
+/******/ var promise = new Promise(function(resolve, reject) {
+/******/ installedChunkData = installedChunks[chunkId] = [resolve, reject];
+/******/ });
+/******/ promises.push(installedChunkData[2] = promise);
+/******/
+/******/ // start chunk loading
+/******/ var head = document.getElementsByTagName('head')[0];
+/******/ var script = document.createElement('script');
+/******/
+/******/ script.charset = 'utf-8';
+/******/ script.timeout = 120000;
+/******/
+/******/ if (__webpack_require__.nc) {
+/******/ script.setAttribute("nonce", __webpack_require__.nc);
/******/ }
-/******/ installedChunks[chunkId] = undefined;
+/******/ script.src = __webpack_require__.p + "" + chunkId + ".output.js";
+/******/ var timeout = setTimeout(function(){
+/******/ onScriptComplete({ type: 'timeout', target: script });
+/******/ }, 120000);
+/******/ script.onerror = script.onload = onScriptComplete;
+/******/ function onScriptComplete(event) {
+/******/ // avoid mem leaks in IE.
+/******/ script.onerror = script.onload = null;
+/******/ clearTimeout(timeout);
+/******/ var chunk = installedChunks[chunkId];
+/******/ if(chunk !== 0) {
+/******/ if(chunk) {
+/******/ var errorType = event && (event.type === 'load' ? 'missing' : event.type);
+/******/ var realSrc = event && event.target && event.target.src;
+/******/ var error = new Error('Loading chunk ' + chunkId + ' failed.\n(' + errorType + ': ' + realSrc + ')');
+/******/ error.type = errorType;
+/******/ error.request = realSrc;
+/******/ chunk[1](error);
+/******/ }
+/******/ installedChunks[chunkId] = undefined;
+/******/ }
+/******/ };
+/******/ head.appendChild(script);
/******/ }
-/******/ };
-/******/ head.appendChild(script);
-/******/
-/******/ return promise;
+/******/ }
+/******/ return Promise.all(promises);
/******/ };
/******/
/******/ // expose the modules object (__webpack_modules__)
@@ -255,6 +248,11 @@ module.exports = [
/******/ }
/******/ };
/******/
+/******/ // define __esModule on exports
+/******/ __webpack_require__.r = function(exports) {
+/******/ Object.defineProperty(exports, '__esModule', { value: true });
+/******/ };
+/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
@@ -268,13 +266,21 @@ module.exports = [
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
-/******/ __webpack_require__.p = "js/";
+/******/ __webpack_require__.p = "dist/";
/******/
/******/ // on error function for async loading
/******/ __webpack_require__.oe = function(err) { console.error(err); throw err; };
/******/
+/******/ var jsonpArray = window["webpackJsonp"] = window["webpackJsonp"] || [];
+/******/ var oldJsonpFunction = jsonpArray.push.bind(jsonpArray);
+/******/ jsonpArray.push = webpackJsonpCallback;
+/******/ jsonpArray = jsonpArray.slice();
+/******/ for(var i = 0; i < jsonpArray.length; i++) webpackJsonpCallback(jsonpArray[i]);
+/******/ var parentJsonpFunction = oldJsonpFunction;
+/******/
+/******/
/******/ // Load entry module and return exports
-/******/ return __webpack_require__(__webpack_require__.s = 0);
+/******/ return __webpack_require__(__webpack_require__.s = 1);
/******/ })
/************************************************************************/
```
@@ -284,33 +290,20 @@ module.exports = [
``` javascript
/******/ ([
/* 0 */
-/*!**************************!*\
- !*** multi ./example.js ***!
- \**************************/
-/*! no static exports found */
-/*! all exports used */
-/***/ (function(module, exports, __webpack_require__) {
-
-module.exports = __webpack_require__(/*! ./example.js */1);
-
-
-/***/ }),
-/* 1 */
/*!********************!*\
!*** ./example.js ***!
\********************/
/*! no static exports found */
-/*! all exports used */
/***/ (function(module, exports, __webpack_require__) {
var main = function() {
console.log("Main class");
- __webpack_require__.e/* require.ensure */(2).then((() => {
+ Promise.all(/*! require.ensure */[__webpack_require__.e(0), __webpack_require__.e(2)]).then((() => {
const page = __webpack_require__(/*! ./pageA */ 3);
page();
}).bind(null, __webpack_require__)).catch(__webpack_require__.oe);
- __webpack_require__.e/* require.ensure */(1).then((() => {
- const page = __webpack_require__(/*! ./pageB */ 4);
+ __webpack_require__.e(/*! require.ensure */ 1).then((() => {
+ const page = __webpack_require__(/*! ./pageB */ 2);
page();
}).bind(null, __webpack_require__)).catch(__webpack_require__.oe);
};
@@ -319,303 +312,30 @@ main();
/***/ }),
-/* 2 */
-/*!******************************!*\
- !*** ./reusableComponent.js ***!
- \******************************/
-/*! no static exports found */
-/*! all exports used */
-/***/ (function(module, exports) {
-
-module.exports = function() {
- console.log("reusable Component");
-};
-
-
-/***/ })
-/******/ ]);
-```
-
-# js/0.output.js
-
-``` javascript
-webpackJsonp([0],{
-
-/***/ 5:
-/*!******************!*\
- !*** ./pageC.js ***!
- \******************/
-/*! no static exports found */
-/*! all exports used */
-/***/ (function(module, exports, __webpack_require__) {
-
-var reusableComponent = __webpack_require__(/*! ./reusableComponent */ 2);
-
-module.exports = function() {
- console.log("Page C");
- reusableComponent();
-};
-
-
-/***/ })
-
-});
-```
-
-# js/1.output.js
-
-``` javascript
-webpackJsonp([1],{
-
-/***/ 4:
-/*!******************!*\
- !*** ./pageB.js ***!
- \******************/
-/*! no static exports found */
-/*! all exports used */
-/***/ (function(module, exports, __webpack_require__) {
-
-module.exports = function() {
- console.log("Page B");
- __webpack_require__.e/* require.ensure */(0).then((()=>{
- const page = __webpack_require__(/*! ./pageC */ 5);
- page();
- }).bind(null, __webpack_require__)).catch(__webpack_require__.oe);
-};
-
-
-/***/ })
-
-});
-```
-
-# js/2.output.js
-
-``` javascript
-webpackJsonp([2],{
-
-/***/ 3:
-/*!******************!*\
- !*** ./pageA.js ***!
- \******************/
-/*! no static exports found */
-/*! all exports used */
-/***/ (function(module, exports, __webpack_require__) {
-
-var reusableComponent = __webpack_require__(/*! ./reusableComponent */ 2);
-
-module.exports = function() {
- console.log("Page A");
- reusableComponent();
-};
-
-
-/***/ })
-
-});
-```
-
-# js/asyncoutput.js
-
-``` javascript
-/******/ (function(modules) { // webpackBootstrap
-/******/ // install a JSONP callback for chunk loading
-/******/ var parentJsonpFunction = window["webpackJsonp"];
-/******/ window["webpackJsonp"] = function webpackJsonpCallback(chunkIds, moreModules, executeModules) {
-/******/ // add "moreModules" to the modules object,
-/******/ // then flag all "chunkIds" as loaded and fire callback
-/******/ var moduleId, chunkId, i = 0, resolves = [], result;
-/******/ for(;i < chunkIds.length; i++) {
-/******/ chunkId = chunkIds[i];
-/******/ if(installedChunks[chunkId]) {
-/******/ resolves.push(installedChunks[chunkId][0]);
-/******/ }
-/******/ installedChunks[chunkId] = 0;
-/******/ }
-/******/ for(moduleId in moreModules) {
-/******/ if(Object.prototype.hasOwnProperty.call(moreModules, moduleId)) {
-/******/ modules[moduleId] = moreModules[moduleId];
-/******/ }
-/******/ }
-/******/ if(parentJsonpFunction) parentJsonpFunction(chunkIds, moreModules, executeModules);
-/******/ while(resolves.length) {
-/******/ resolves.shift()();
-/******/ }
-/******/
-/******/ };
-/******/
-/******/ // The module cache
-/******/ var installedModules = {};
-/******/
-/******/ // objects to store loaded and loading chunks
-/******/ var installedChunks = {
-/******/ 4: 0
-/******/ };
-/******/
-/******/ // The require function
-/******/ function __webpack_require__(moduleId) {
-/******/
-/******/ // Check if module is in cache
-/******/ if(installedModules[moduleId]) {
-/******/ return installedModules[moduleId].exports;
-/******/ }
-/******/ // Create a new module (and put it into the cache)
-/******/ var module = installedModules[moduleId] = {
-/******/ i: moduleId,
-/******/ l: false,
-/******/ exports: {}
-/******/ };
-/******/
-/******/ // Execute the module function
-/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
-/******/
-/******/ // Flag the module as loaded
-/******/ module.l = true;
-/******/
-/******/ // Return the exports of the module
-/******/ return module.exports;
-/******/ }
-/******/
-/******/ // This file contains only the entry chunk.
-/******/ // The chunk loading function for additional chunks
-/******/ __webpack_require__.e = function requireEnsure(chunkId) {
-/******/ var installedChunkData = installedChunks[chunkId];
-/******/ if(installedChunkData === 0) {
-/******/ return new Promise(function(resolve) { resolve(); });
-/******/ }
-/******/
-/******/ // a Promise means "currently loading".
-/******/ if(installedChunkData) {
-/******/ return installedChunkData[2];
-/******/ }
-/******/
-/******/ // setup Promise in chunk cache
-/******/ var promise = new Promise(function(resolve, reject) {
-/******/ installedChunkData = installedChunks[chunkId] = [resolve, reject];
-/******/ });
-/******/ installedChunkData[2] = promise;
-/******/
-/******/ // start chunk loading
-/******/ var head = document.getElementsByTagName('head')[0];
-/******/ var script = document.createElement('script');
-/******/ script.type = 'text/javascript';
-/******/ script.charset = 'utf-8';
-/******/ script.async = true;
-/******/ script.timeout = 120000;
-/******/
-/******/ if (__webpack_require__.nc) {
-/******/ script.setAttribute("nonce", __webpack_require__.nc);
-/******/ }
-/******/ script.src = __webpack_require__.p + "" + chunkId + ".asyncoutput.js";
-/******/ var timeout = setTimeout(onScriptComplete, 120000);
-/******/ script.onerror = script.onload = onScriptComplete;
-/******/ function onScriptComplete() {
-/******/ // avoid mem leaks in IE.
-/******/ script.onerror = script.onload = null;
-/******/ clearTimeout(timeout);
-/******/ var chunk = installedChunks[chunkId];
-/******/ if(chunk !== 0) {
-/******/ if(chunk) {
-/******/ chunk[1](new Error('Loading chunk ' + chunkId + ' failed.'));
-/******/ }
-/******/ installedChunks[chunkId] = undefined;
-/******/ }
-/******/ };
-/******/ head.appendChild(script);
-/******/
-/******/ return promise;
-/******/ };
-/******/
-/******/ // expose the modules object (__webpack_modules__)
-/******/ __webpack_require__.m = modules;
-/******/
-/******/ // expose the module cache
-/******/ __webpack_require__.c = installedModules;
-/******/
-/******/ // define getter function for harmony exports
-/******/ __webpack_require__.d = function(exports, name, getter) {
-/******/ if(!__webpack_require__.o(exports, name)) {
-/******/ Object.defineProperty(exports, name, {
-/******/ configurable: false,
-/******/ enumerable: true,
-/******/ get: getter
-/******/ });
-/******/ }
-/******/ };
-/******/
-/******/ // getDefaultExport function for compatibility with non-harmony modules
-/******/ __webpack_require__.n = function(module) {
-/******/ var getter = module && module.__esModule ?
-/******/ function getDefault() { return module['default']; } :
-/******/ function getModuleExports() { return module; };
-/******/ __webpack_require__.d(getter, 'a', getter);
-/******/ return getter;
-/******/ };
-/******/
-/******/ // Object.prototype.hasOwnProperty.call
-/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
-/******/
-/******/ // __webpack_public_path__
-/******/ __webpack_require__.p = "js/";
-/******/
-/******/ // on error function for async loading
-/******/ __webpack_require__.oe = function(err) { console.error(err); throw err; };
-/******/
-/******/ // Load entry module and return exports
-/******/ return __webpack_require__(__webpack_require__.s = 0);
-/******/ })
-/************************************************************************/
-/******/ ([
-/* 0 */
+/* 1 */
/*!**************************!*\
!*** multi ./example.js ***!
\**************************/
/*! no static exports found */
-/*! all exports used */
/***/ (function(module, exports, __webpack_require__) {
-module.exports = __webpack_require__(/*! ./example.js */1);
-
-
-/***/ }),
-/* 1 */
-/*!********************!*\
- !*** ./example.js ***!
- \********************/
-/*! no static exports found */
-/*! all exports used */
-/***/ (function(module, exports, __webpack_require__) {
-
-var main = function() {
- console.log("Main class");
- Promise.all/* require.ensure */([__webpack_require__.e(0), __webpack_require__.e(2)]).then((() => {
- const page = __webpack_require__(/*! ./pageA */ 2);
- page();
- }).bind(null, __webpack_require__)).catch(__webpack_require__.oe);
- __webpack_require__.e/* require.ensure */(1).then((() => {
- const page = __webpack_require__(/*! ./pageB */ 3);
- page();
- }).bind(null, __webpack_require__)).catch(__webpack_require__.oe);
-};
-
-main();
+module.exports = __webpack_require__(/*! ./example.js */0);
/***/ })
/******/ ]);
```
-# js/0.asyncoutput.js
+# dist/0.output.js
``` javascript
-webpackJsonp([0],{
+(window["webpackJsonp"] = window["webpackJsonp"] || []).push([[0],{
/***/ 4:
/*!******************************!*\
!*** ./reusableComponent.js ***!
\******************************/
/*! no static exports found */
-/*! all exports used */
/***/ (function(module, exports) {
module.exports = function() {
@@ -625,25 +345,24 @@ module.exports = function() {
/***/ })
-});
+}]);
```
-# js/1.asyncoutput.js
+# dist/1.output.js
``` javascript
-webpackJsonp([1],{
+(window["webpackJsonp"] = window["webpackJsonp"] || []).push([[1],{
-/***/ 3:
+/***/ 2:
/*!******************!*\
!*** ./pageB.js ***!
\******************/
/*! no static exports found */
-/*! all exports used */
/***/ (function(module, exports, __webpack_require__) {
module.exports = function() {
console.log("Page B");
- Promise.all/* require.ensure */([__webpack_require__.e(0), __webpack_require__.e(3)]).then((()=>{
+ Promise.all(/*! require.ensure */[__webpack_require__.e(0), __webpack_require__.e(3)]).then((()=>{
const page = __webpack_require__(/*! ./pageC */ 5);
page();
}).bind(null, __webpack_require__)).catch(__webpack_require__.oe);
@@ -652,20 +371,19 @@ module.exports = function() {
/***/ })
-});
+}]);
```
-# js/2.asyncoutput.js
+# dist/2.output.js
``` javascript
-webpackJsonp([2],{
+(window["webpackJsonp"] = window["webpackJsonp"] || []).push([[2],{
-/***/ 2:
+/***/ 3:
/*!******************!*\
!*** ./pageA.js ***!
\******************/
/*! no static exports found */
-/*! all exports used */
/***/ (function(module, exports, __webpack_require__) {
var reusableComponent = __webpack_require__(/*! ./reusableComponent */ 4);
@@ -678,20 +396,19 @@ module.exports = function() {
/***/ })
-});
+}]);
```
-# js/3.asyncoutput.js
+# dist/3.output.js
``` javascript
-webpackJsonp([3],{
+(window["webpackJsonp"] = window["webpackJsonp"] || []).push([[3],{
/***/ 5:
/*!******************!*\
!*** ./pageC.js ***!
\******************/
/*! no static exports found */
-/*! all exports used */
/***/ (function(module, exports, __webpack_require__) {
var reusableComponent = __webpack_require__(/*! ./reusableComponent */ 4);
@@ -704,153 +421,83 @@ module.exports = function() {
/***/ })
-});
+}]);
```
# Info
-## Uncompressed
+## Unoptimized
```
-Hash: 777f989f517d7831d56f1d268f47bc8703ad9f73
-Version: webpack 3.6.0
-Child
- Hash: 777f989f517d7831d56f
- Asset Size Chunks Chunk Names
- 0.output.js 388 bytes 0 [emitted]
- 1.output.js 481 bytes 1 [emitted]
- 2.output.js 388 bytes 2 [emitted]
- output.js 6.95 kB 3 [emitted] main
- Entrypoint main = output.js
- chunk {0} 0.output.js 142 bytes {3} [rendered]
- > [4] ./pageB.js 3:1-6:3
- [5] ./pageC.js 142 bytes {0} [built]
- cjs require ./pageC [4] ./pageB.js 4:15-33
- chunk {1} 1.output.js 140 bytes {3} [rendered]
- > [1] ./example.js 7:1-10:3
- [4] ./pageB.js 140 bytes {1} [built]
- cjs require ./pageB [1] ./example.js 8:15-33
- chunk {2} 2.output.js 142 bytes {3} [rendered]
- > [1] ./example.js 3:1-6:3
- [3] ./pageA.js 142 bytes {2} [built]
- cjs require ./pageA [1] ./example.js 4:15-33
- chunk {3} output.js (main) 333 bytes [entry] [rendered]
- > main [0] multi ./example.js
- [0] multi ./example.js 28 bytes {3} [built]
- [1] ./example.js 233 bytes {3} [built]
- single entry ./example.js [0] multi ./example.js main:100000
- [2] ./reusableComponent.js 72 bytes {3} [built]
- cjs require ./reusableComponent [3] ./pageA.js 1:24-54
- cjs require ./reusableComponent [5] ./pageC.js 1:24-54
-Child
- Hash: 1d268f47bc8703ad9f73
- Asset Size Chunks Chunk Names
- 0.asyncoutput.js 314 bytes 0 [emitted]
- 1.asyncoutput.js 522 bytes 1 [emitted]
- 2.asyncoutput.js 388 bytes 2 [emitted]
- 3.asyncoutput.js 388 bytes 3 [emitted]
- asyncoutput.js 6.7 kB 4 [emitted] main
- Entrypoint main = asyncoutput.js
- chunk {0} 0.asyncoutput.js 72 bytes {4} [rendered]
- > async commons [1] ./example.js 3:1-6:3
- > async commons [3] ./pageB.js 3:1-6:3
- [4] ./reusableComponent.js 72 bytes {0} [built]
- cjs require ./reusableComponent [2] ./pageA.js 1:24-54
- cjs require ./reusableComponent [5] ./pageC.js 1:24-54
- chunk {1} 1.asyncoutput.js 140 bytes {4} [rendered]
- > [1] ./example.js 7:1-10:3
- [3] ./pageB.js 140 bytes {1} [built]
- cjs require ./pageB [1] ./example.js 8:15-33
- chunk {2} 2.asyncoutput.js 142 bytes {4} [rendered]
- > [1] ./example.js 3:1-6:3
- [2] ./pageA.js 142 bytes {2} [built]
- cjs require ./pageA [1] ./example.js 4:15-33
- chunk {3} 3.asyncoutput.js 142 bytes {1} [rendered]
- > [3] ./pageB.js 3:1-6:3
- [5] ./pageC.js 142 bytes {3} [built]
- cjs require ./pageC [3] ./pageB.js 4:15-33
- chunk {4} asyncoutput.js (main) 261 bytes [entry] [rendered]
- > main [0] multi ./example.js
- [0] multi ./example.js 28 bytes {4} [built]
- [1] ./example.js 233 bytes {4} [built]
- single entry ./example.js [0] multi ./example.js main:100000
+Hash: 0a1b2c3d4e5f6a7b8c9d
+Version: webpack 4.0.0-beta.2
+ Asset Size Chunks Chunk Names
+0.output.js 340 bytes 0 [emitted]
+1.output.js 549 bytes 1 [emitted]
+2.output.js 414 bytes 2 [emitted]
+3.output.js 414 bytes 3 [emitted]
+ output.js 7.53 KiB 4 [emitted] main
+Entrypoint main = output.js
+chunk {0} 0.output.js 72 bytes <{1}> <{4}> ={2}= ={3}= [rendered] split chunk (cache group: default)
+ > [0] ./example.js 3:1-6:3
+ > [2] ./pageB.js 3:1-6:3
+ [4] ./reusableComponent.js 72 bytes {0} [built]
+ cjs require ./reusableComponent [3] ./pageA.js 1:24-54
+ cjs require ./reusableComponent [5] ./pageC.js 1:24-54
+chunk {1} 1.output.js 140 bytes <{4}> >{0}< >{3}< [rendered]
+ > [0] ./example.js 7:1-10:3
+ [2] ./pageB.js 140 bytes {1} [built]
+ cjs require ./pageB [0] ./example.js 8:15-33
+chunk {2} 2.output.js 142 bytes <{4}> ={0}= [rendered]
+ > [0] ./example.js 3:1-6:3
+ [3] ./pageA.js 142 bytes {2} [built]
+ cjs require ./pageA [0] ./example.js 4:15-33
+chunk {3} 3.output.js 142 bytes <{1}> ={0}= [rendered]
+ > [2] ./pageB.js 3:1-6:3
+ [5] ./pageC.js 142 bytes {3} [built]
+ cjs require ./pageC [2] ./pageB.js 4:15-33
+chunk {4} output.js (main) 261 bytes >{0}< >{1}< >{2}< [entry] [rendered]
+ > main
+ [0] ./example.js 233 bytes {4} [built]
+ single entry ./example.js [1] multi ./example.js main:100000
+ [1] multi ./example.js 28 bytes {4} [built]
+ multi entry
```
-## Minimized (uglify-js, no zip)
+## Production mode
```
-Hash: 777f989f517d7831d56f1d268f47bc8703ad9f73
-Version: webpack 3.6.0
-Child
- Hash: 777f989f517d7831d56f
- Asset Size Chunks Chunk Names
- 0.output.js 98 bytes 0 [emitted]
- 1.output.js 340 bytes 1 [emitted]
- 2.output.js 98 bytes 2 [emitted]
- output.js 6.46 kB 3 [emitted] main
- Entrypoint main = output.js
- chunk {0} 0.output.js 142 bytes {3} [rendered]
- > [4] ./pageB.js 3:1-6:3
- [5] ./pageC.js 142 bytes {0} [built]
- cjs require ./pageC [4] ./pageB.js 4:15-33
- chunk {1} 1.output.js 140 bytes {3} [rendered]
- > [1] ./example.js 7:1-10:3
- [4] ./pageB.js 140 bytes {1} [built]
- cjs require ./pageB [1] ./example.js 8:15-33
- chunk {2} 2.output.js 142 bytes {3} [rendered]
- > [1] ./example.js 3:1-6:3
- [3] ./pageA.js 142 bytes {2} [built]
- cjs require ./pageA [1] ./example.js 4:15-33
- chunk {3} output.js (main) 333 bytes [entry] [rendered]
- > main [0] multi ./example.js
- [0] multi ./example.js 28 bytes {3} [built]
- [1] ./example.js 233 bytes {3} [built]
- single entry ./example.js [0] multi ./example.js main:100000
- [2] ./reusableComponent.js 72 bytes {3} [built]
- cjs require ./reusableComponent [3] ./pageA.js 1:24-54
- cjs require ./reusableComponent [5] ./pageC.js 1:24-54
-
- ERROR in 1.output.js from UglifyJs
- Unexpected token: punc ()) [1.output.js:8,53]
-
- ERROR in output.js from UglifyJs
- Unexpected token: punc ()) [output.js:161,53]
-Child
- Hash: 1d268f47bc8703ad9f73
- Asset Size Chunks Chunk Names
- 0.asyncoutput.js 93 bytes 0 [emitted]
- 1.asyncoutput.js 381 bytes 1 [emitted]
- 2.asyncoutput.js 98 bytes 2 [emitted]
- 3.asyncoutput.js 98 bytes 3 [emitted]
- asyncoutput.js 6.37 kB 4 [emitted] main
- Entrypoint main = asyncoutput.js
- chunk {0} 0.asyncoutput.js 72 bytes {4} [rendered]
- > async commons [1] ./example.js 3:1-6:3
- > async commons [3] ./pageB.js 3:1-6:3
- [4] ./reusableComponent.js 72 bytes {0} [built]
- cjs require ./reusableComponent [2] ./pageA.js 1:24-54
- cjs require ./reusableComponent [5] ./pageC.js 1:24-54
- chunk {1} 1.asyncoutput.js 140 bytes {4} [rendered]
- > [1] ./example.js 7:1-10:3
- [3] ./pageB.js 140 bytes {1} [built]
- cjs require ./pageB [1] ./example.js 8:15-33
- chunk {2} 2.asyncoutput.js 142 bytes {4} [rendered]
- > [1] ./example.js 3:1-6:3
- [2] ./pageA.js 142 bytes {2} [built]
- cjs require ./pageA [1] ./example.js 4:15-33
- chunk {3} 3.asyncoutput.js 142 bytes {1} [rendered]
- > [3] ./pageB.js 3:1-6:3
- [5] ./pageC.js 142 bytes {3} [built]
- cjs require ./pageC [3] ./pageB.js 4:15-33
- chunk {4} asyncoutput.js (main) 261 bytes [entry] [rendered]
- > main [0] multi ./example.js
- [0] multi ./example.js 28 bytes {4} [built]
- [1] ./example.js 233 bytes {4} [built]
- single entry ./example.js [0] multi ./example.js main:100000
-
- ERROR in 1.asyncoutput.js from UglifyJs
- Unexpected token: punc ()) [1.asyncoutput.js:8,94]
-
- ERROR in asyncoutput.js from UglifyJs
- Unexpected token: punc ()) [asyncoutput.js:161,94]
+Hash: 0a1b2c3d4e5f6a7b8c9d
+Version: webpack 4.0.0-beta.2
+ Asset Size Chunks Chunk Names
+0.output.js 133 bytes 0 [emitted]
+1.output.js 198 bytes 1 [emitted]
+2.output.js 138 bytes 2 [emitted]
+3.output.js 138 bytes 3 [emitted]
+ output.js 1.76 KiB 4 [emitted] main
+Entrypoint main = output.js
+chunk {0} 0.output.js 72 bytes <{1}> <{4}> ={2}= ={3}= [rendered] split chunk (cache group: default)
+ > [0] ./example.js 3:1-6:3
+ > [2] ./pageB.js 3:1-6:3
+ [4] ./reusableComponent.js 72 bytes {0} [built]
+ cjs require ./reusableComponent [3] ./pageA.js 1:24-54
+ cjs require ./reusableComponent [5] ./pageC.js 1:24-54
+chunk {1} 1.output.js 140 bytes <{4}> >{0}< >{3}< [rendered]
+ > [0] ./example.js 7:1-10:3
+ [2] ./pageB.js 140 bytes {1} [built]
+ cjs require ./pageB [0] ./example.js 8:15-33
+chunk {2} 2.output.js 142 bytes <{4}> ={0}= [rendered]
+ > [0] ./example.js 3:1-6:3
+ [3] ./pageA.js 142 bytes {2} [built]
+ cjs require ./pageA [0] ./example.js 4:15-33
+chunk {3} 3.output.js 142 bytes <{1}> ={0}= [rendered]
+ > [2] ./pageB.js 3:1-6:3
+ [5] ./pageC.js 142 bytes {3} [built]
+ cjs require ./pageC [2] ./pageB.js 4:15-33
+chunk {4} output.js (main) 261 bytes >{0}< >{1}< >{2}< [entry] [rendered]
+ > main
+ [0] ./example.js 233 bytes {4} [built]
+ single entry ./example.js [1] multi ./example.js main:100000
+ [1] multi ./example.js 28 bytes {4} [built]
+ multi entry
```
diff --git a/examples/common-chunk-grandchildren/template.md b/examples/common-chunk-grandchildren/template.md
index 3516598b..edf7a426 100644
--- a/examples/common-chunk-grandchildren/template.md
+++ b/examples/common-chunk-grandchildren/template.md
@@ -4,19 +4,20 @@ This example illustrates how common modules from deep ancestors of an entry poin
* `pageC` and `pageA` both require the `reusableComponent`
* `pageB` dynamically requires `PageC`
-You can see that webpack outputs four files/chunks:
+You can see that webpack outputs five files/chunks:
* `output.js` is the entry chunk and contains
* the module system
* chunk loading logic
* the entry point `example.js`
- * module `reusableComponent`
* `0.output.js` is an additional chunk
- * module `pageC`
+ * module `reusableComponent`
* `1.output.js` is an additional chunk
* module `pageB`
* `2.output.js` is an additional chunk
* module `pageA`
+* `3.output.js` is an additional chunk
+ * module `pageC`
# example.js
@@ -55,70 +56,46 @@ You can see that webpack outputs four files/chunks:
{{webpack.config.js}}
```
-# js/output.js
-
-``` javascript
-{{js/output.js}}
-```
-
-# js/0.output.js
-
-``` javascript
-{{js/0.output.js}}
-```
-
-# js/1.output.js
-
-``` javascript
-{{js/1.output.js}}
-```
-
-# js/2.output.js
-
-``` javascript
-{{js/2.output.js}}
-```
-
-# js/asyncoutput.js
+# dist/output.js
``` javascript
-{{js/asyncoutput.js}}
+{{dist/output.js}}
```
-# js/0.asyncoutput.js
+# dist/0.output.js
``` javascript
-{{js/0.asyncoutput.js}}
+{{dist/0.output.js}}
```
-# js/1.asyncoutput.js
+# dist/1.output.js
``` javascript
-{{js/1.asyncoutput.js}}
+{{dist/1.output.js}}
```
-# js/2.asyncoutput.js
+# dist/2.output.js
``` javascript
-{{js/2.asyncoutput.js}}
+{{dist/2.output.js}}
```
-# js/3.asyncoutput.js
+# dist/3.output.js
``` javascript
-{{js/3.asyncoutput.js}}
+{{dist/3.output.js}}
```
# Info
-## Uncompressed
+## Unoptimized
```
{{stdout}}
```
-## Minimized (uglify-js, no zip)
+## Production mode
```
-{{min:stdout}}
+{{production:stdout}}
```
diff --git a/examples/common-chunk-grandchildren/webpack.config.js b/examples/common-chunk-grandchildren/webpack.config.js
index 7b2696d7..5b5da3e5 100644
--- a/examples/common-chunk-grandchildren/webpack.config.js
+++ b/examples/common-chunk-grandchildren/webpack.config.js
@@ -1,41 +1,19 @@
"use strict";
-const webpack = require("../../");
const path = require("path");
-module.exports = [
- {
- entry: {
- main: ["./example.js"]
- },
- output: {
- path: path.resolve(__dirname, "js"),
- filename: "output.js"
- },
- plugins: [
- new webpack.optimize.CommonsChunkPlugin({
- name: "main",
- minChunks: 2,
- children: true,
- deepChildren: true,
- })
- ]
+module.exports = {
+ // mode: "development || "production",
+ entry: {
+ main: ["./example.js"]
},
- {
- entry: {
- main: ["./example.js"]
+ optimization: {
+ splitChunks: {
+ minSize: 0 // This example is too small, in pratice you can use the defaults
},
- output: {
- path: path.resolve(__dirname, "js"),
- filename: "asyncoutput.js"
- },
- plugins: [
- new webpack.optimize.CommonsChunkPlugin({
- name: "main",
- minChunks: 2,
- async: true,
- children: true,
- deepChildren: true,
- })
- ]
+ occurrenceOrder: true // To keep filename consistent between different modes (for example building only)
+ },
+ output: {
+ path: path.resolve(__dirname, "dist"),
+ filename: "output.js"
}
-];
+};
diff --git a/examples/commonjs/README.md b/examples/commonjs/README.md
index 46766fcd..6cc2b4e5 100644
--- a/examples/commonjs/README.md
+++ b/examples/commonjs/README.md
@@ -35,7 +35,7 @@ exports.add = function() {
};
```
-# js/output.js
+# dist/output.js
<details><summary><code>/******/ (function(modules) { /* webpackBootstrap */ })</code></summary>
@@ -86,6 +86,11 @@ exports.add = function() {
/******/ }
/******/ };
/******/
+/******/ // define __esModule on exports
+/******/ __webpack_require__.r = function(exports) {
+/******/ Object.defineProperty(exports, '__esModule', { value: true });
+/******/ };
+/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
@@ -99,7 +104,8 @@ exports.add = function() {
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
-/******/ __webpack_require__.p = "js/";
+/******/ __webpack_require__.p = "dist/";
+/******/
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 0);
@@ -116,7 +122,6 @@ exports.add = function() {
!*** ./example.js ***!
\********************/
/*! no static exports found */
-/*! all exports used */
/***/ (function(module, exports, __webpack_require__) {
var inc = __webpack_require__(/*! ./increment */ 1).increment;
@@ -129,7 +134,6 @@ inc(a); // 2
!*** ./increment.js ***!
\**********************/
/*! no static exports found */
-/*! all exports used */
/***/ (function(module, exports, __webpack_require__) {
var add = __webpack_require__(/*! ./math */ 2).add;
@@ -143,7 +147,6 @@ exports.increment = function(val) {
!*** ./math.js ***!
\*****************/
/*! no static exports found */
-/*! all exports used */
/***/ (function(module, exports) {
exports.add = function() {
@@ -160,36 +163,38 @@ exports.add = function() {
# Info
-## Uncompressed
+## Unoptimized
```
-Hash: 9407d8cd068b1845b368
-Version: webpack 3.5.1
- Asset Size Chunks Chunk Names
-output.js 3.39 kB 0 [emitted] main
+Hash: 0a1b2c3d4e5f6a7b8c9d
+Version: webpack 4.0.0-beta.2
+ Asset Size Chunks Chunk Names
+output.js 3.44 KiB 0 [emitted] main
Entrypoint main = output.js
chunk {0} output.js (main) 329 bytes [entry] [rendered]
- > main [0] ./example.js
+ > .\example.js main
[0] ./example.js 69 bytes {0} [built]
+ single entry .\example.js main
[1] ./increment.js 98 bytes {0} [built]
cjs require ./increment [0] ./example.js 1:10-32
[2] ./math.js 162 bytes {0} [built]
cjs require ./math [1] ./increment.js 1:10-27
```
-## Minimized (uglify-js, no zip)
+## Production mode
```
-Hash: 9407d8cd068b1845b368
-Version: webpack 3.5.1
+Hash: 0a1b2c3d4e5f6a7b8c9d
+Version: webpack 4.0.0-beta.2
Asset Size Chunks Chunk Names
-output.js 672 bytes 0 [emitted] main
+output.js 740 bytes 0 [emitted] main
Entrypoint main = output.js
chunk {0} output.js (main) 329 bytes [entry] [rendered]
- > main [0] ./example.js
- [0] ./example.js 69 bytes {0} [built]
- [1] ./increment.js 98 bytes {0} [built]
- cjs require ./increment [0] ./example.js 1:10-32
- [2] ./math.js 162 bytes {0} [built]
+ > .\example.js main
+ [0] ./math.js 162 bytes {0} [built]
cjs require ./math [1] ./increment.js 1:10-27
+ [1] ./increment.js 98 bytes {0} [built]
+ cjs require ./increment [2] ./example.js 1:10-32
+ [2] ./example.js 69 bytes {0} [built]
+ single entry .\example.js main
```
\ No newline at end of file
diff --git a/examples/commonjs/template.md b/examples/commonjs/template.md
index 40d8c1f3..5ed0539f 100644
--- a/examples/commonjs/template.md
+++ b/examples/commonjs/template.md
@@ -24,22 +24,22 @@ You can also see the info messages webpack prints to console (for both normal an
{{math.js}}
```
-# js/output.js
+# dist/output.js
``` javascript
-{{js/output.js}}
+{{dist/output.js}}
```
# Info
-## Uncompressed
+## Unoptimized
```
{{stdout}}
```
-## Minimized (uglify-js, no zip)
+## Production mode
```
-{{min:stdout}}
+{{production:stdout}}
```
\ No newline at end of file
diff --git a/examples/css-bundle/README.md b/examples/css-bundle/README.md
deleted file mode 100644
index 565abb02..00000000
--- a/examples/css-bundle/README.md
+++ /dev/null
@@ -1,204 +0,0 @@
-
-# example.js
-
-``` javascript
-require("./style.css");
-```
-
-# style.css
-
-``` css
-body {
- background: url(image.png);
-}
-```
-
-# webpack.config.js
-
-``` javascript
-var ExtractTextPlugin = require("extract-text-webpack-plugin");
-module.exports = {
- module: {
- loaders: [
- {
- test: /\.css$/,
- use: ExtractTextPlugin.extract({
- use: "css-loader"
- })
- },
- { test: /\.png$/, loader: "file-loader" }
- ]
- },
- plugins: [
- new ExtractTextPlugin({
- filename: "style.css",
- allChunks: true
- })
- ]
-};
-```
-
-# js/output.js
-
-<details><summary><code>/******/ (function(modules) { /* webpackBootstrap */ })</code></summary>
-
-``` javascript
-/******/ (function(modules) { // webpackBootstrap
-/******/ // The module cache
-/******/ var installedModules = {};
-/******/
-/******/ // The require function
-/******/ function __webpack_require__(moduleId) {
-/******/
-/******/ // Check if module is in cache
-/******/ if(installedModules[moduleId]) {
-/******/ return installedModules[moduleId].exports;
-/******/ }
-/******/ // Create a new module (and put it into the cache)
-/******/ var module = installedModules[moduleId] = {
-/******/ i: moduleId,
-/******/ l: false,
-/******/ exports: {}
-/******/ };
-/******/
-/******/ // Execute the module function
-/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
-/******/
-/******/ // Flag the module as loaded
-/******/ module.l = true;
-/******/
-/******/ // Return the exports of the module
-/******/ return module.exports;
-/******/ }
-/******/
-/******/
-/******/ // expose the modules object (__webpack_modules__)
-/******/ __webpack_require__.m = modules;
-/******/
-/******/ // expose the module cache
-/******/ __webpack_require__.c = installedModules;
-/******/
-/******/ // define getter function for harmony exports
-/******/ __webpack_require__.d = function(exports, name, getter) {
-/******/ if(!__webpack_require__.o(exports, name)) {
-/******/ Object.defineProperty(exports, name, {
-/******/ configurable: false,
-/******/ enumerable: true,
-/******/ get: getter
-/******/ });
-/******/ }
-/******/ };
-/******/
-/******/ // getDefaultExport function for compatibility with non-harmony modules
-/******/ __webpack_require__.n = function(module) {
-/******/ var getter = module && module.__esModule ?
-/******/ function getDefault() { return module['default']; } :
-/******/ function getModuleExports() { return module; };
-/******/ __webpack_require__.d(getter, 'a', getter);
-/******/ return getter;
-/******/ };
-/******/
-/******/ // Object.prototype.hasOwnProperty.call
-/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
-/******/
-/******/ // __webpack_public_path__
-/******/ __webpack_require__.p = "js/";
-/******/
-/******/ // Load entry module and return exports
-/******/ return __webpack_require__(__webpack_require__.s = 0);
-/******/ })
-/************************************************************************/
-```
-
-</details>
-
-``` javascript
-/******/ ([
-/* 0 */
-/*!********************!*\
- !*** ./example.js ***!
- \********************/
-/*! no static exports found */
-/*! all exports used */
-/***/ (function(module, exports, __webpack_require__) {
-
-__webpack_require__(/*! ./style.css */ 1);
-
-/***/ }),
-/* 1 */
-/*!*******************!*\
- !*** ./style.css ***!
- \*******************/
-/*! no static exports found */
-/*! all exports used */
-/***/ (function(module, exports) {
-
-// removed by extract-text-webpack-plugin
-
-/***/ })
-/******/ ]);
-```
-
-# js/style.css
-
-``` css
-body {
- background: url(js/ce21cbdd9b894e6af794813eb3fdaf60.png);
-}
-```
-
-# Info
-
-## Uncompressed
-
-```
-Hash: d3955970c7b0655c299a
-Version: webpack 3.5.1
- Asset Size Chunks Chunk Names
-ce21cbdd9b894e6af794813eb3fdaf60.png 119 bytes [emitted]
- output.js 2.9 kB 0 [emitted] main
- style.css 69 bytes 0 [emitted] main
-Entrypoint main = output.js style.css
-chunk {0} output.js, style.css (main) 64 bytes [entry] [rendered]
- > main [0] ./example.js
- [0] ./example.js 23 bytes {0} [built]
- [1] ./style.css 41 bytes {0} [built]
- cjs require ./style.css [0] ./example.js 1:0-22
-Child extract-text-webpack-plugin ../../node_modules/extract-text-webpack-plugin/dist ../../node_modules/css-loader/index.js!style.css:
- Asset Size Chunks Chunk Names
- ce21cbdd9b894e6af794813eb3fdaf60.png 119 bytes [emitted]
- Entrypoint undefined = extract-text-webpack-plugin-output-filename
- chunk {0} extract-text-webpack-plugin-output-filename 2.57 kB [entry] [rendered]
- > [0] (webpack)/node_modules/css-loader!./style.css
- [0] (webpack)/node_modules/css-loader!./style.css 231 bytes {0} [built]
- [2] ./image.png 82 bytes {0} [built]
- cjs require ./image.png [0] (webpack)/node_modules/css-loader!./style.css 6:58-80
- + 1 hidden module
-```
-
-## Minimized (uglify-js, no zip)
-
-```
-Hash: 7e35402b768b90e83df1
-Version: webpack 3.5.1
- Asset Size Chunks Chunk Names
-ce21cbdd9b894e6af794813eb3fdaf60.png 119 bytes [emitted]
- output.js 504 bytes 0 [emitted] main
- style.css 61 bytes 0 [emitted] main
-Entrypoint main = output.js style.css
-chunk {0} output.js, style.css (main) 64 bytes [entry] [rendered]
- > main [0] ./example.js
- [0] ./example.js 23 bytes {0} [built]
- [1] ./style.css 41 bytes {0} [built]
- cjs require ./style.css [0] ./example.js 1:0-22
-Child extract-text-webpack-plugin ../../node_modules/extract-text-webpack-plugin/dist ../../node_modules/css-loader/index.js!style.css:
- Asset Size Chunks Chunk Names
- ce21cbdd9b894e6af794813eb3fdaf60.png 119 bytes [emitted]
- Entrypoint undefined = extract-text-webpack-plugin-output-filename
- chunk {0} extract-text-webpack-plugin-output-filename 2.56 kB [entry] [rendered]
- > [0] (webpack)/node_modules/css-loader!./style.css
- [0] (webpack)/node_modules/css-loader!./style.css 218 bytes {0} [built]
- [2] ./image.png 82 bytes {0} [built]
- cjs require ./image.png [0] (webpack)/node_modules/css-loader!./style.css 6:50-72
- + 1 hidden module
-```
\ No newline at end of file
diff --git a/examples/css-bundle/example.js b/examples/css-bundle/example.js
deleted file mode 100644
index 7160bf5e..00000000
--- a/examples/css-bundle/example.js
+++ /dev/null
@@ -1 +0,0 @@
-require("./style.css");
\ No newline at end of file
diff --git a/examples/css-bundle/image.png b/examples/css-bundle/image.png
deleted file mode 100644
index 818c71d0..00000000
Binary files a/examples/css-bundle/image.png and /dev/null differ
diff --git a/examples/css-bundle/style.css b/examples/css-bundle/style.css
deleted file mode 100644
index 6249df12..00000000
--- a/examples/css-bundle/style.css
+++ /dev/null
@@ -1,3 +0,0 @@
-body {
- background: url(image.png);
-}
\ No newline at end of file
diff --git a/examples/css-bundle/template.md b/examples/css-bundle/template.md
deleted file mode 100644
index 97f54ff9..00000000
--- a/examples/css-bundle/template.md
+++ /dev/null
@@ -1,44 +0,0 @@
-
-# example.js
-
-``` javascript
-{{example.js}}
-```
-
-# style.css
-
-``` css
-{{style.css}}
-```
-
-# webpack.config.js
-
-``` javascript
-{{webpack.config.js}}
-```
-
-# js/output.js
-
-``` javascript
-{{js/output.js}}
-```
-
-# js/style.css
-
-``` css
-{{js/style.css}}
-```
-
-# Info
-
-## Uncompressed
-
-```
-{{stdout}}
-```
-
-## Minimized (uglify-js, no zip)
-
-```
-{{min:stdout}}
-```
\ No newline at end of file
diff --git a/examples/css-bundle/webpack.config.js b/examples/css-bundle/webpack.config.js
deleted file mode 100644
index 1025c304..00000000
--- a/examples/css-bundle/webpack.config.js
+++ /dev/null
@@ -1,20 +0,0 @@
-var ExtractTextPlugin = require("extract-text-webpack-plugin");
-module.exports = {
- module: {
- loaders: [
- {
- test: /\.css$/,
- use: ExtractTextPlugin.extract({
- use: "css-loader"
- })
- },
- { test: /\.png$/, loader: "file-loader" }
- ]
- },
- plugins: [
- new ExtractTextPlugin({
- filename: "style.css",
- allChunks: true
- })
- ]
-};
diff --git a/examples/dll-app-and-vendor/0-vendor/README.md b/examples/dll-app-and-vendor/0-vendor/README.md
index 1331b6b1..f85646a0 100644
--- a/examples/dll-app-and-vendor/0-vendor/README.md
+++ b/examples/dll-app-and-vendor/0-vendor/README.md
@@ -2,7 +2,7 @@ This is the vendor build part.
It's built separatly from the app part. The vendors dll is only built when vendors has changed and not while the normal development cycle.
-The DllPlugin in combination with the `output.library` option exposes the internal require function as global variable in the target enviroment.
+The DllPlugin in combination with the `output.library` option exposes the internal require function as global variable in the target environment.
A manifest is creates which includes mappings from module names to internal ids.
@@ -13,17 +13,18 @@ var path = require("path");
var webpack = require("../../../");
module.exports = {
+ // mode: "development || "production",
context: __dirname,
entry: ["example-vendor"],
output: {
filename: "vendor.js", // best use [hash] here too
- path: path.resolve(__dirname, "js"),
+ path: path.resolve(__dirname, "dist"),
library: "vendor_lib_[hash]",
},
plugins: [
new webpack.DllPlugin({
name: "vendor_lib_[hash]",
- path: path.resolve(__dirname, "js/vendor-manifest.json"),
+ path: path.resolve(__dirname, "dist/vendor-manifest.json"),
}),
],
};
@@ -37,10 +38,10 @@ export function square(n) {
}
```
-# js/vendor.js
+# dist/vendor.js
``` javascript
-var vendor_lib_6b1edee0549eb5092709 =
+var vendor_lib_9ee2f174307b7ef21301 =
```
<details><summary><code>/******/ (function(modules) { /* webpackBootstrap */ })</code></summary>
@@ -91,6 +92,11 @@ var vendor_lib_6b1edee0549eb5092709 =
/******/ }
/******/ };
/******/
+/******/ // define __esModule on exports
+/******/ __webpack_require__.r = function(exports) {
+/******/ Object.defineProperty(exports, '__esModule', { value: true });
+/******/ };
+/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
@@ -104,7 +110,8 @@ var vendor_lib_6b1edee0549eb5092709 =
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
-/******/ __webpack_require__.p = "js/";
+/******/ __webpack_require__.p = "dist/";
+/******/
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 0);
@@ -136,8 +143,8 @@ module.exports = __webpack_require__;
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
-Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
-/* harmony export (immutable) */ __webpack_exports__["square"] = square;
+__webpack_require__.r(__webpack_exports__);
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "square", function() { return square; });
function square(n) {
return n * n;
}
@@ -147,39 +154,43 @@ function square(n) {
/******/ ]);
```
-# js/vendor-manifest.json
+# dist/vendor-manifest.json
``` javascript
-{"name":"vendor_lib_6b1edee0549eb5092709","content":{"../node_modules/example-vendor.js":{"id":1,"meta":{"harmonyModule":true},"exports":["square"]}}}
+{"name":"vendor_lib_9ee2f174307b7ef21301","content":{"../node_modules/example-vendor.js":{"id":1,"buildMeta":{"exportsType":"namespace","providedExports":["square"]}}}}
```
# Info
-## Uncompressed
+## Unoptimized
```
-Hash: 6b1edee0549eb5092709
-Version: webpack 3.5.1
- Asset Size Chunks Chunk Names
-vendor.js 3.18 kB 0 [emitted] main
+Hash: 0a1b2c3d4e5f6a7b8c9d
+Version: webpack 4.0.0-beta.2
+ Asset Size Chunks Chunk Names
+vendor.js 3.32 KiB 0 [emitted] main
Entrypoint main = vendor.js
chunk {0} vendor.js (main) 60 bytes [entry] [rendered]
- > main [0] dll main
+ > main
[0] dll main 12 bytes {0} [built]
+ dll entry
+
+ 1 hidden module
```
-## Minimized (uglify-js, no zip)
+## Production mode
```
-Hash: 6b1edee0549eb5092709
-Version: webpack 3.5.1
+Hash: 0a1b2c3d4e5f6a7b8c9d
+Version: webpack 4.0.0-beta.2
Asset Size Chunks Chunk Names
-vendor.js 652 bytes 0 [emitted] main
+vendor.js 704 bytes 0 [emitted] main
Entrypoint main = vendor.js
chunk {0} vendor.js (main) 60 bytes [entry] [rendered]
- > main [0] dll main
- [0] dll main 12 bytes {0} [built]
+ > main
+ [1] dll main 12 bytes {0} [built]
+ dll entry
+
+ 1 hidden module
```
diff --git a/examples/dll-app-and-vendor/0-vendor/template.md b/examples/dll-app-and-vendor/0-vendor/template.md
index 140b1fbe..99bf5549 100644
--- a/examples/dll-app-and-vendor/0-vendor/template.md
+++ b/examples/dll-app-and-vendor/0-vendor/template.md
@@ -2,7 +2,7 @@ This is the vendor build part.
It's built separatly from the app part. The vendors dll is only built when vendors has changed and not while the normal development cycle.
-The DllPlugin in combination with the `output.library` option exposes the internal require function as global variable in the target enviroment.
+The DllPlugin in combination with the `output.library` option exposes the internal require function as global variable in the target environment.
A manifest is creates which includes mappings from module names to internal ids.
@@ -18,29 +18,29 @@ A manifest is creates which includes mappings from module names to internal ids.
{{../node_modules/example-vendor.js}}
```
-# js/vendor.js
+# dist/vendor.js
``` javascript
-{{js/vendor.js}}
+{{dist/vendor.js}}
```
-# js/vendor-manifest.json
+# dist/vendor-manifest.json
``` javascript
-{{js/vendor-manifest.json}}
+{{dist/vendor-manifest.json}}
```
# Info
-## Uncompressed
+## Unoptimized
```
{{stdout}}
```
-## Minimized (uglify-js, no zip)
+## Production mode
```
-{{min:stdout}}
+{{production:stdout}}
```
diff --git a/examples/dll-app-and-vendor/0-vendor/webpack.config.js b/examples/dll-app-and-vendor/0-vendor/webpack.config.js
index 89b48fa5..ec5f19b1 100644
--- a/examples/dll-app-and-vendor/0-vendor/webpack.config.js
+++ b/examples/dll-app-and-vendor/0-vendor/webpack.config.js
@@ -2,17 +2,18 @@ var path = require("path");
var webpack = require("../../../");
module.exports = {
+ // mode: "development || "production",
context: __dirname,
entry: ["example-vendor"],
output: {
filename: "vendor.js", // best use [hash] here too
- path: path.resolve(__dirname, "js"),
- library: "vendor_lib_[hash]",
+ path: path.resolve(__dirname, "dist"),
+ library: "vendor_lib_[hash]"
},
plugins: [
new webpack.DllPlugin({
name: "vendor_lib_[hash]",
- path: path.resolve(__dirname, "js/vendor-manifest.json"),
- }),
- ],
+ path: path.resolve(__dirname, "dist/vendor-manifest.json")
+ })
+ ]
};
diff --git a/examples/dll-app-and-vendor/1-app/README.md b/examples/dll-app-and-vendor/1-app/README.md
index 3a77b1ae..39033fe9 100644
--- a/examples/dll-app-and-vendor/1-app/README.md
+++ b/examples/dll-app-and-vendor/1-app/README.md
@@ -9,16 +9,17 @@ var path = require("path");
var webpack = require("../../../");
module.exports = {
+ // mode: "development" || "production",
context: __dirname,
entry: "./example-app",
output: {
filename: "app.js",
- path: path.resolve(__dirname, "js"),
+ path: path.resolve(__dirname, "dist"),
},
plugins: [
new webpack.DllReferencePlugin({
context: ".",
- manifest: require("../0-vendor/js/vendor-manifest.json"), // eslint-disable-line
+ manifest: require("../0-vendor/dist/vendor-manifest.json"), // eslint-disable-line
}),
],
};
@@ -39,13 +40,13 @@ console.log(new square(7));
<html>
<head></head>
<body>
- <script src="js/vendor.bundle.js" charset="utf-8"></script>
- <script src="js/app.bundle.js" charset="utf-8"></script>
+ <script src="../0-vendor/js/vendor.js" charset="utf-8"></script>
+ <script src="js/app.js" charset="utf-8"></script>
</body>
</html>
```
-# js/app.js
+# dist/app.js
<details><summary><code>/******/ (function(modules) { /* webpackBootstrap */ })</code></summary>
@@ -96,6 +97,11 @@ console.log(new square(7));
/******/ }
/******/ };
/******/
+/******/ // define __esModule on exports
+/******/ __webpack_require__.r = function(exports) {
+/******/ Object.defineProperty(exports, '__esModule', { value: true });
+/******/ };
+/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
@@ -109,7 +115,8 @@ console.log(new square(7));
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
-/******/ __webpack_require__.p = "js/";
+/******/ __webpack_require__.p = "dist/";
+/******/
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 0);
@@ -125,40 +132,37 @@ console.log(new square(7));
/*!************************!*\
!*** ./example-app.js ***!
\************************/
-/*! exports provided: */
-/*! all exports used */
+/*! no exports provided */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
-Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
-/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_example_vendor__ = __webpack_require__(/*! example-vendor */ 1);
+__webpack_require__.r(__webpack_exports__);
+/* harmony import */ var example_vendor__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! example-vendor */ 1);
-console.log(Object(__WEBPACK_IMPORTED_MODULE_0_example_vendor__["square"])(7));
-console.log(new __WEBPACK_IMPORTED_MODULE_0_example_vendor__["square"](7));
+console.log(Object(example_vendor__WEBPACK_IMPORTED_MODULE_0__["square"])(7));
+console.log(new example_vendor__WEBPACK_IMPORTED_MODULE_0__["square"](7));
/***/ }),
/* 1 */
/*!******************************************************************************************************!*\
- !*** delegated ../node_modules/example-vendor.js from dll-reference vendor_lib_6b1edee0549eb5092709 ***!
+ !*** delegated ../node_modules/example-vendor.js from dll-reference vendor_lib_9ee2f174307b7ef21301 ***!
\******************************************************************************************************/
/*! exports provided: square */
-/*! all exports used */
/***/ (function(module, exports, __webpack_require__) {
-module.exports = (__webpack_require__(2))(1);
+module.exports = (__webpack_require__(/*! dll-reference vendor_lib_9ee2f174307b7ef21301 */ 2))(1);
/***/ }),
/* 2 */
/*!**************************************************!*\
- !*** external "vendor_lib_6b1edee0549eb5092709" ***!
+ !*** external "vendor_lib_9ee2f174307b7ef21301" ***!
\**************************************************/
/*! no static exports found */
-/*! all exports used */
/***/ (function(module, exports) {
-module.exports = vendor_lib_6b1edee0549eb5092709;
+module.exports = vendor_lib_9ee2f174307b7ef21301;
/***/ })
/******/ ]);
@@ -166,40 +170,48 @@ module.exports = vendor_lib_6b1edee0549eb5092709;
# Info
-## Uncompressed
+## Unoptimized
```
-Hash: 26778169dabaf1f3965d
-Version: webpack 3.5.1
+Hash: 0a1b2c3d4e5f6a7b8c9d
+Version: webpack 4.0.0-beta.2
Asset Size Chunks Chunk Names
-app.js 3.85 kB 0 [emitted] main
+app.js 3.9 KiB 0 [emitted] main
Entrypoint main = app.js
chunk {0} app.js (main) 182 bytes [entry] [rendered]
- > main [0] ./example-app.js
+ > ./example-app main
[0] ./example-app.js 98 bytes {0} [built]
[no exports]
- [1] delegated ../node_modules/example-vendor.js from dll-reference vendor_lib_6b1edee0549eb5092709 42 bytes {0} [built]
+ single entry ./example-app main
+ [1] delegated ../node_modules/example-vendor.js from dll-reference vendor_lib_9ee2f174307b7ef21301 42 bytes {0} [built]
[exports: square]
- harmony import example-vendor [0] ./example-app.js 1:0-40
- + 1 hidden module
+ harmony side effect evaluation example-vendor [0] ./example-app.js 1:0-40
+ harmony import specifier example-vendor [0] ./example-app.js 3:12-18
+ harmony import specifier example-vendor [0] ./example-app.js 4:16-22
+ [2] external "vendor_lib_9ee2f174307b7ef21301" 42 bytes {0} [built]
+ delegated source dll-reference vendor_lib_9ee2f174307b7ef21301 [1] delegated ../node_modules/example-vendor.js from dll-reference vendor_lib_9ee2f174307b7ef21301
```
-## Minimized (uglify-js, no zip)
+## Production mode
```
-Hash: 26778169dabaf1f3965d
-Version: webpack 3.5.1
+Hash: 0a1b2c3d4e5f6a7b8c9d
+Version: webpack 4.0.0-beta.2
Asset Size Chunks Chunk Names
-app.js 710 bytes 0 [emitted] main
+app.js 736 bytes 0 [emitted] main
Entrypoint main = app.js
chunk {0} app.js (main) 182 bytes [entry] [rendered]
- > main [0] ./example-app.js
- [0] ./example-app.js 98 bytes {0} [built]
- [no exports]
- [1] delegated ../node_modules/example-vendor.js from dll-reference vendor_lib_6b1edee0549eb5092709 42 bytes {0} [built]
+ > ./example-app main
+ [0] delegated ../node_modules/example-vendor.js from dll-reference vendor_lib_9ee2f174307b7ef21301 42 bytes {0} [built]
[exports: square]
- harmony import example-vendor [0] ./example-app.js 1:0-40
- + 1 hidden module
+ harmony side effect evaluation example-vendor [2] ./example-app.js 1:0-40
+ harmony import specifier example-vendor [2] ./example-app.js 3:12-18
+ harmony import specifier example-vendor [2] ./example-app.js 4:16-22
+ [1] external "vendor_lib_9ee2f174307b7ef21301" 42 bytes {0} [built]
+ delegated source dll-reference vendor_lib_9ee2f174307b7ef21301 [0] delegated ../node_modules/example-vendor.js from dll-reference vendor_lib_9ee2f174307b7ef21301
+ [2] ./example-app.js 98 bytes {0} [built]
+ [no exports]
+ single entry ./example-app main
```
<!-- @TODO:
diff --git a/examples/dll-app-and-vendor/1-app/example.html b/examples/dll-app-and-vendor/1-app/example.html
index 84c2fe2f..bcc7ea50 100644
--- a/examples/dll-app-and-vendor/1-app/example.html
+++ b/examples/dll-app-and-vendor/1-app/example.html
@@ -1,7 +1,7 @@
<html>
<head></head>
<body>
- <script src="js/vendor.bundle.js" charset="utf-8"></script>
- <script src="js/app.bundle.js" charset="utf-8"></script>
+ <script src="../0-vendor/js/vendor.js" charset="utf-8"></script>
+ <script src="js/app.js" charset="utf-8"></script>
</body>
</html>
diff --git a/examples/dll-app-and-vendor/1-app/template.md b/examples/dll-app-and-vendor/1-app/template.md
index 48e47293..288f1206 100644
--- a/examples/dll-app-and-vendor/1-app/template.md
+++ b/examples/dll-app-and-vendor/1-app/template.md
@@ -20,24 +20,24 @@ The previously built vendor dll is used. The DllReferencePlugin reads the conten
{{example.html}}
```
-# js/app.js
+# dist/app.js
``` javascript
-{{js/app.js}}
+{{dist/app.js}}
```
# Info
-## Uncompressed
+## Unoptimized
```
{{stdout}}
```
-## Minimized (uglify-js, no zip)
+## Production mode
```
-{{min:stdout}}
+{{production:stdout}}
```
<!-- @TODO:
diff --git a/examples/dll-app-and-vendor/1-app/webpack.config.js b/examples/dll-app-and-vendor/1-app/webpack.config.js
index 2a02109d..2f43dace 100644
--- a/examples/dll-app-and-vendor/1-app/webpack.config.js
+++ b/examples/dll-app-and-vendor/1-app/webpack.config.js
@@ -2,16 +2,17 @@ var path = require("path");
var webpack = require("../../../");
module.exports = {
+ // mode: "development" || "production",
context: __dirname,
entry: "./example-app",
output: {
filename: "app.js",
- path: path.resolve(__dirname, "js"),
+ path: path.resolve(__dirname, "dist")
},
plugins: [
new webpack.DllReferencePlugin({
context: ".",
- manifest: require("../0-vendor/js/vendor-manifest.json"), // eslint-disable-line
- }),
- ],
+ manifest: require("../0-vendor/dist/vendor-manifest.json") // eslint-disable-line
+ })
+ ]
};
diff --git a/examples/dll-user/README.md b/examples/dll-user/README.md
index 44d8db00..d4ce06d0 100644
--- a/examples/dll-user/README.md
+++ b/examples/dll-user/README.md
@@ -10,14 +10,15 @@ This is the _user_ bundle, which uses the manifest from [dll-reference example](
var path = require("path");
var webpack = require("../../");
module.exports = {
+ // mode: "development || "production",
plugins: [
new webpack.DllReferencePlugin({
context: path.join(__dirname, "..", "dll"),
- manifest: require("../dll/js/alpha-manifest.json") // eslint-disable-line
+ manifest: require("../dll/dist/alpha-manifest.json") // eslint-disable-line
}),
new webpack.DllReferencePlugin({
scope: "beta",
- manifest: require("../dll/js/beta-manifest.json"), // eslint-disable-line
+ manifest: require("../dll/dist/beta-manifest.json"), // eslint-disable-line
extensions: [".js", ".jsx"]
})
]
@@ -37,7 +38,7 @@ console.log(require("beta/c"));
console.log(require("module"));
```
-# js/output.js
+# dist/output.js
<details><summary><code>/******/ (function(modules) { /* webpackBootstrap */ })</code></summary>
@@ -88,6 +89,11 @@ console.log(require("module"));
/******/ }
/******/ };
/******/
+/******/ // define __esModule on exports
+/******/ __webpack_require__.r = function(exports) {
+/******/ Object.defineProperty(exports, '__esModule', { value: true });
+/******/ };
+/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
@@ -101,10 +107,11 @@ console.log(require("module"));
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
-/******/ __webpack_require__.p = "js/";
+/******/ __webpack_require__.p = "dist/";
+/******/
/******/
/******/ // Load entry module and return exports
-/******/ return __webpack_require__(__webpack_require__.s = 2);
+/******/ return __webpack_require__(__webpack_require__.s = 0);
/******/ })
/************************************************************************/
```
@@ -114,39 +121,16 @@ console.log(require("module"));
``` javascript
/******/ ([
/* 0 */
-/*!*********************************************!*\
- !*** external "alpha_457b6718a3ff9f8c2d77" ***!
- \*********************************************/
-/*! no static exports found */
-/*! all exports used */
-/***/ (function(module, exports) {
-
-module.exports = alpha_457b6718a3ff9f8c2d77;
-
-/***/ }),
-/* 1 */
-/*!********************************************!*\
- !*** external "beta_457b6718a3ff9f8c2d77" ***!
- \********************************************/
-/*! no static exports found */
-/*! all exports used */
-/***/ (function(module, exports) {
-
-module.exports = beta_457b6718a3ff9f8c2d77;
-
-/***/ }),
-/* 2 */
/*!********************!*\
!*** ./example.js ***!
\********************/
/*! no static exports found */
-/*! all exports used */
/***/ (function(module, exports, __webpack_require__) {
-console.log(__webpack_require__(/*! ../dll/alpha */ 3));
-console.log(__webpack_require__(/*! ../dll/a */ 4));
+console.log(__webpack_require__(/*! ../dll/alpha */ 1));
+console.log(__webpack_require__(/*! ../dll/a */ 3));
-console.log(__webpack_require__(/*! beta/beta */ 5));
+console.log(__webpack_require__(/*! beta/beta */ 4));
console.log(__webpack_require__(/*! beta/b */ 6));
console.log(__webpack_require__(/*! beta/c */ 7));
@@ -154,70 +138,84 @@ console.log(__webpack_require__(/*! module */ 8));
/***/ }),
-/* 3 */
+/* 1 */
/*!**************************************************************************!*\
- !*** delegated ./alpha.js from dll-reference alpha_457b6718a3ff9f8c2d77 ***!
+ !*** delegated ./alpha.js from dll-reference alpha_ae937b5d3e880b635a69 ***!
\**************************************************************************/
/*! no static exports found */
-/*! all exports used */
/***/ (function(module, exports, __webpack_require__) {
-module.exports = (__webpack_require__(0))(1);
+module.exports = (__webpack_require__(/*! dll-reference alpha_ae937b5d3e880b635a69 */ 2))(1);
/***/ }),
-/* 4 */
+/* 2 */
+/*!*********************************************!*\
+ !*** external "alpha_ae937b5d3e880b635a69" ***!
+ \*********************************************/
+/*! no static exports found */
+/***/ (function(module, exports) {
+
+module.exports = alpha_ae937b5d3e880b635a69;
+
+/***/ }),
+/* 3 */
/*!**********************************************************************!*\
- !*** delegated ./a.js from dll-reference alpha_457b6718a3ff9f8c2d77 ***!
+ !*** delegated ./a.js from dll-reference alpha_ae937b5d3e880b635a69 ***!
\**********************************************************************/
/*! no static exports found */
-/*! all exports used */
/***/ (function(module, exports, __webpack_require__) {
-module.exports = (__webpack_require__(0))(2);
+module.exports = (__webpack_require__(/*! dll-reference alpha_ae937b5d3e880b635a69 */ 2))(2);
/***/ }),
-/* 5 */
+/* 4 */
/*!************************************************************************!*\
- !*** delegated ./beta.js from dll-reference beta_457b6718a3ff9f8c2d77 ***!
+ !*** delegated ./beta.js from dll-reference beta_ae937b5d3e880b635a69 ***!
\************************************************************************/
/*! no static exports found */
-/*! all exports used */
/***/ (function(module, exports, __webpack_require__) {
-module.exports = (__webpack_require__(1))(5);
+module.exports = (__webpack_require__(/*! dll-reference beta_ae937b5d3e880b635a69 */ 5))(5);
+
+/***/ }),
+/* 5 */
+/*!********************************************!*\
+ !*** external "beta_ae937b5d3e880b635a69" ***!
+ \********************************************/
+/*! no static exports found */
+/***/ (function(module, exports) {
+
+module.exports = beta_ae937b5d3e880b635a69;
/***/ }),
/* 6 */
/*!*********************************************************************!*\
- !*** delegated ./b.js from dll-reference beta_457b6718a3ff9f8c2d77 ***!
+ !*** delegated ./b.js from dll-reference beta_ae937b5d3e880b635a69 ***!
\*********************************************************************/
/*! no static exports found */
-/*! all exports used */
/***/ (function(module, exports, __webpack_require__) {
-module.exports = (__webpack_require__(1))(6);
+module.exports = (__webpack_require__(/*! dll-reference beta_ae937b5d3e880b635a69 */ 5))(6);
/***/ }),
/* 7 */
/*!**********************************************************************!*\
- !*** delegated ./c.jsx from dll-reference beta_457b6718a3ff9f8c2d77 ***!
+ !*** delegated ./c.jsx from dll-reference beta_ae937b5d3e880b635a69 ***!
\**********************************************************************/
/*! no static exports found */
-/*! all exports used */
/***/ (function(module, exports, __webpack_require__) {
-module.exports = (__webpack_require__(1))(7);
+module.exports = (__webpack_require__(/*! dll-reference beta_ae937b5d3e880b635a69 */ 5))(7);
/***/ }),
/* 8 */
/*!*****************************************************************************************!*\
- !*** delegated ../node_modules/module.js from dll-reference alpha_457b6718a3ff9f8c2d77 ***!
+ !*** delegated ../node_modules/module.js from dll-reference alpha_ae937b5d3e880b635a69 ***!
\*****************************************************************************************/
/*! no static exports found */
-/*! all exports used */
/***/ (function(module, exports, __webpack_require__) {
-module.exports = (__webpack_require__(0))(3);
+module.exports = (__webpack_require__(/*! dll-reference alpha_ae937b5d3e880b635a69 */ 2))(3);
/***/ })
/******/ ]);
@@ -225,54 +223,70 @@ module.exports = (__webpack_require__(0))(3);
# Info
-## Uncompressed
+## Unoptimized
```
-Hash: 60ca229a9df08630fded
-Version: webpack 3.5.1
- Asset Size Chunks Chunk Names
-output.js 6.06 kB 0 [emitted] main
+Hash: 0a1b2c3d4e5f6a7b8c9d
+Version: webpack 4.0.0-beta.2
+ Asset Size Chunks Chunk Names
+output.js 6.19 KiB 0 [emitted] main
Entrypoint main = output.js
chunk {0} output.js (main) 549 bytes [entry] [rendered]
- > main [2] ./example.js
- [2] ./example.js 213 bytes {0} [built]
- [3] delegated ./alpha.js from dll-reference alpha_457b6718a3ff9f8c2d77 42 bytes {0} [built]
- cjs require ../dll/alpha [2] ./example.js 1:12-35
- [4] delegated ./a.js from dll-reference alpha_457b6718a3ff9f8c2d77 42 bytes {0} [built]
- cjs require ../dll/a [2] ./example.js 2:12-31
- [5] delegated ./beta.js from dll-reference beta_457b6718a3ff9f8c2d77 42 bytes {0} [built]
- cjs require beta/beta [2] ./example.js 4:12-32
- [6] delegated ./b.js from dll-reference beta_457b6718a3ff9f8c2d77 42 bytes {0} [built]
- cjs require beta/b [2] ./example.js 5:12-29
- [7] delegated ./c.jsx from dll-reference beta_457b6718a3ff9f8c2d77 42 bytes {0} [built]
- cjs require beta/c [2] ./example.js 6:12-29
- [8] delegated ../node_modules/module.js from dll-reference alpha_457b6718a3ff9f8c2d77 42 bytes {0} [built]
- cjs require module [2] ./example.js 8:12-29
- + 2 hidden modules
+ > .\example.js main
+ [0] ./example.js 213 bytes {0} [built]
+ single entry .\example.js main
+ [1] delegated ./alpha.js from dll-reference alpha_ae937b5d3e880b635a69 42 bytes {0} [built]
+ cjs require ../dll/alpha [0] ./example.js 1:12-35
+ [2] external "alpha_ae937b5d3e880b635a69" 42 bytes {0} [built]
+ delegated source dll-reference alpha_ae937b5d3e880b635a69 [1] delegated ./alpha.js from dll-reference alpha_ae937b5d3e880b635a69
+ delegated source dll-reference alpha_ae937b5d3e880b635a69 [3] delegated ./a.js from dll-reference alpha_ae937b5d3e880b635a69
+ delegated source dll-reference alpha_ae937b5d3e880b635a69 [8] delegated ../node_modules/module.js from dll-reference alpha_ae937b5d3e880b635a69
+ [3] delegated ./a.js from dll-reference alpha_ae937b5d3e880b635a69 42 bytes {0} [built]
+ cjs require ../dll/a [0] ./example.js 2:12-31
+ [4] delegated ./beta.js from dll-reference beta_ae937b5d3e880b635a69 42 bytes {0} [built]
+ cjs require beta/beta [0] ./example.js 4:12-32
+ [5] external "beta_ae937b5d3e880b635a69" 42 bytes {0} [built]
+ delegated source dll-reference beta_ae937b5d3e880b635a69 [4] delegated ./beta.js from dll-reference beta_ae937b5d3e880b635a69
+ delegated source dll-reference beta_ae937b5d3e880b635a69 [6] delegated ./b.js from dll-reference beta_ae937b5d3e880b635a69
+ delegated source dll-reference beta_ae937b5d3e880b635a69 [7] delegated ./c.jsx from dll-reference beta_ae937b5d3e880b635a69
+ [6] delegated ./b.js from dll-reference beta_ae937b5d3e880b635a69 42 bytes {0} [built]
+ cjs require beta/b [0] ./example.js 5:12-29
+ [7] delegated ./c.jsx from dll-reference beta_ae937b5d3e880b635a69 42 bytes {0} [built]
+ cjs require beta/c [0] ./example.js 6:12-29
+ [8] delegated ../node_modules/module.js from dll-reference alpha_ae937b5d3e880b635a69 42 bytes {0} [built]
+ cjs require module [0] ./example.js 8:12-29
```
-## Minimized (uglify-js, no zip)
+## Production mode
```
-Hash: 60ca229a9df08630fded
-Version: webpack 3.5.1
+Hash: 0a1b2c3d4e5f6a7b8c9d
+Version: webpack 4.0.0-beta.2
Asset Size Chunks Chunk Names
-output.js 904 bytes 0 [emitted] main
+output.js 972 bytes 0 [emitted] main
Entrypoint main = output.js
chunk {0} output.js (main) 549 bytes [entry] [rendered]
- > main [2] ./example.js
- [2] ./example.js 213 bytes {0} [built]
- [3] delegated ./alpha.js from dll-reference alpha_457b6718a3ff9f8c2d77 42 bytes {0} [built]
- cjs require ../dll/alpha [2] ./example.js 1:12-35
- [4] delegated ./a.js from dll-reference alpha_457b6718a3ff9f8c2d77 42 bytes {0} [built]
- cjs require ../dll/a [2] ./example.js 2:12-31
- [5] delegated ./beta.js from dll-reference beta_457b6718a3ff9f8c2d77 42 bytes {0} [built]
- cjs require beta/beta [2] ./example.js 4:12-32
- [6] delegated ./b.js from dll-reference beta_457b6718a3ff9f8c2d77 42 bytes {0} [built]
- cjs require beta/b [2] ./example.js 5:12-29
- [7] delegated ./c.jsx from dll-reference beta_457b6718a3ff9f8c2d77 42 bytes {0} [built]
- cjs require beta/c [2] ./example.js 6:12-29
- [8] delegated ../node_modules/module.js from dll-reference alpha_457b6718a3ff9f8c2d77 42 bytes {0} [built]
- cjs require module [2] ./example.js 8:12-29
- + 2 hidden modules
+ > .\example.js main
+ [0] external "beta_ae937b5d3e880b635a69" 42 bytes {0} [built]
+ delegated source dll-reference beta_ae937b5d3e880b635a69 [3] delegated ./c.jsx from dll-reference beta_ae937b5d3e880b635a69
+ delegated source dll-reference beta_ae937b5d3e880b635a69 [4] delegated ./b.js from dll-reference beta_ae937b5d3e880b635a69
+ delegated source dll-reference beta_ae937b5d3e880b635a69 [5] delegated ./beta.js from dll-reference beta_ae937b5d3e880b635a69
+ [1] external "alpha_ae937b5d3e880b635a69" 42 bytes {0} [built]
+ delegated source dll-reference alpha_ae937b5d3e880b635a69 [2] delegated ../node_modules/module.js from dll-reference alpha_ae937b5d3e880b635a69
+ delegated source dll-reference alpha_ae937b5d3e880b635a69 [6] delegated ./a.js from dll-reference alpha_ae937b5d3e880b635a69
+ delegated source dll-reference alpha_ae937b5d3e880b635a69 [7] delegated ./alpha.js from dll-reference alpha_ae937b5d3e880b635a69
+ [2] delegated ../node_modules/module.js from dll-reference alpha_ae937b5d3e880b635a69 42 bytes {0} [built]
+ cjs require module [8] ./example.js 8:12-29
+ [3] delegated ./c.jsx from dll-reference beta_ae937b5d3e880b635a69 42 bytes {0} [built]
+ cjs require beta/c [8] ./example.js 6:12-29
+ [4] delegated ./b.js from dll-reference beta_ae937b5d3e880b635a69 42 bytes {0} [built]
+ cjs require beta/b [8] ./example.js 5:12-29
+ [5] delegated ./beta.js from dll-reference beta_ae937b5d3e880b635a69 42 bytes {0} [built]
+ cjs require beta/beta [8] ./example.js 4:12-32
+ [6] delegated ./a.js from dll-reference alpha_ae937b5d3e880b635a69 42 bytes {0} [built]
+ cjs require ../dll/a [8] ./example.js 2:12-31
+ [7] delegated ./alpha.js from dll-reference alpha_ae937b5d3e880b635a69 42 bytes {0} [built]
+ cjs require ../dll/alpha [8] ./example.js 1:12-35
+ [8] ./example.js 213 bytes {0} [built]
+ single entry .\example.js main
```
diff --git a/examples/dll-user/template.md b/examples/dll-user/template.md
index 1bef8d20..c6df8d2b 100644
--- a/examples/dll-user/template.md
+++ b/examples/dll-user/template.md
@@ -16,22 +16,22 @@ This is the _user_ bundle, which uses the manifest from [dll-reference example](
{{example.js}}
```
-# js/output.js
+# dist/output.js
``` javascript
-{{js/output.js}}
+{{dist/output.js}}
```
# Info
-## Uncompressed
+## Unoptimized
```
{{stdout}}
```
-## Minimized (uglify-js, no zip)
+## Production mode
```
-{{min:stdout}}
+{{production:stdout}}
```
diff --git a/examples/dll-user/webpack.config.js b/examples/dll-user/webpack.config.js
index 45aed8fd..7d058b6d 100644
--- a/examples/dll-user/webpack.config.js
+++ b/examples/dll-user/webpack.config.js
@@ -1,14 +1,15 @@
var path = require("path");
var webpack = require("../../");
module.exports = {
+ // mode: "development || "production",
plugins: [
new webpack.DllReferencePlugin({
context: path.join(__dirname, "..", "dll"),
- manifest: require("../dll/js/alpha-manifest.json") // eslint-disable-line
+ manifest: require("../dll/dist/alpha-manifest.json") // eslint-disable-line
}),
new webpack.DllReferencePlugin({
scope: "beta",
- manifest: require("../dll/js/beta-manifest.json"), // eslint-disable-line
+ manifest: require("../dll/dist/beta-manifest.json"), // eslint-disable-line
extensions: [".js", ".jsx"]
})
]
diff --git a/examples/dll/README.md b/examples/dll/README.md
index 4896769e..066bfb14 100644
--- a/examples/dll/README.md
+++ b/examples/dll/README.md
@@ -11,6 +11,7 @@ This is the _reference_ bundle (with the manifests) for [dll user example](https
var path = require("path");
var webpack = require("../../");
module.exports = {
+ // mode: "development || "production",
resolve: {
extensions: [".js", ".jsx"]
},
@@ -19,23 +20,23 @@ module.exports = {
beta: ["./beta", "./b", "./c"]
},
output: {
- path: path.join(__dirname, "js"),
+ path: path.join(__dirname, "dist"),
filename: "MyDll.[name].js",
library: "[name]_[hash]"
},
plugins: [
new webpack.DllPlugin({
- path: path.join(__dirname, "js", "[name]-manifest.json"),
+ path: path.join(__dirname, "dist", "[name]-manifest.json"),
name: "[name]_[hash]"
})
]
};
```
-# js/MyDll.alpha.js
+# dist/MyDll.alpha.js
``` javascript
-var alpha_457b6718a3ff9f8c2d77 =
+var alpha_ae937b5d3e880b635a69 =
```
<details><summary><code>/******/ (function(modules) { /* webpackBootstrap */ })</code></summary>
@@ -86,6 +87,11 @@ var alpha_457b6718a3ff9f8c2d77 =
/******/ }
/******/ };
/******/
+/******/ // define __esModule on exports
+/******/ __webpack_require__.r = function(exports) {
+/******/ Object.defineProperty(exports, '__esModule', { value: true });
+/******/ };
+/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
@@ -99,7 +105,8 @@ var alpha_457b6718a3ff9f8c2d77 =
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
-/******/ __webpack_require__.p = "js/";
+/******/ __webpack_require__.p = "dist/";
+/******/
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 0);
@@ -158,68 +165,86 @@ module.exports = "module";
/******/ ]);
```
-# js/alpha-manifest.json
+# dist/alpha-manifest.json
``` javascript
-{"name":"alpha_457b6718a3ff9f8c2d77","content":{"./alpha.js":{"id":1,"meta":{}},"./a.js":{"id":2,"meta":{}},"../node_modules/module.js":{"id":3,"meta":{}}}}
+{"name":"alpha_ae937b5d3e880b635a69","content":{"./alpha.js":{"id":1,"buildMeta":{"providedExports":true}},"./a.js":{"id":2,"buildMeta":{"providedExports":true}},"../node_modules/module.js":{"id":3,"buildMeta":{"providedExports":true}}}}
```
# Info
-## Uncompressed
+## Unoptimized
```
-Hash: 457b6718a3ff9f8c2d77
-Version: webpack 3.5.1
- Asset Size Chunks Chunk Names
- MyDll.beta.js 3.31 kB 0 [emitted] beta
-MyDll.alpha.js 3.34 kB 1 [emitted] alpha
+Hash: 0a1b2c3d4e5f6a7b8c9d
+Version: webpack 4.0.0-beta.2
+ Asset Size Chunks Chunk Names
+MyDll.alpha.js 3.46 KiB 0 [emitted] alpha
+ MyDll.beta.js 3.43 KiB 1 [emitted] beta
Entrypoint alpha = MyDll.alpha.js
Entrypoint beta = MyDll.beta.js
-chunk {0} MyDll.beta.js (beta) 80 bytes [entry] [rendered]
- > beta [4] dll beta
- [4] dll beta 12 bytes {0} [built]
- [5] ./beta.js 24 bytes {0} [built]
- single entry ./beta [4] dll beta beta:0
- [6] ./b.js 21 bytes {0} [built]
- single entry ./b [4] dll beta beta:1
- [7] ./c.jsx 23 bytes {0} [built]
- single entry ./c [4] dll beta beta:2
-chunk {1} MyDll.alpha.js (alpha) 84 bytes [entry] [rendered]
- > alpha [0] dll alpha
- [0] dll alpha 12 bytes {1} [built]
- [1] ./alpha.js 25 bytes {1} [built]
+chunk {0} MyDll.alpha.js (alpha) 84 bytes [entry] [rendered]
+ > alpha
+ [0] dll alpha 12 bytes {0} [built]
+ dll entry
+
+ [1] ./alpha.js 25 bytes {0} [built]
+
single entry ./alpha [0] dll alpha alpha:0
- [2] ./a.js 21 bytes {1} [built]
+ [2] ./a.js 21 bytes {0} [built]
+
single entry ./a [0] dll alpha alpha:1
+ 1 hidden module
+chunk {1} MyDll.beta.js (beta) 80 bytes [entry] [rendered]
+ > beta
+ [4] dll beta 12 bytes {1} [built]
+ dll entry
+
+ [5] ./beta.js 24 bytes {1} [built]
+
+ single entry ./beta [4] dll beta beta:0
+ [6] ./b.js 21 bytes {1} [built]
+
+ single entry ./b [4] dll beta beta:1
+ [7] ./c.jsx 23 bytes {1} [built]
+
+ single entry ./c [4] dll beta beta:2
```
-## Minimized (uglify-js, no zip)
+## Production mode
```
-Hash: 457b6718a3ff9f8c2d77
-Version: webpack 3.5.1
+Hash: 0a1b2c3d4e5f6a7b8c9d
+Version: webpack 4.0.0-beta.2
Asset Size Chunks Chunk Names
- MyDll.beta.js 627 bytes 0 [emitted] beta
-MyDll.alpha.js 628 bytes 1 [emitted] alpha
+ MyDll.beta.js 691 bytes 0 [emitted] beta
+MyDll.alpha.js 700 bytes 1 [emitted] alpha
Entrypoint alpha = MyDll.alpha.js
Entrypoint beta = MyDll.beta.js
chunk {0} MyDll.beta.js (beta) 80 bytes [entry] [rendered]
- > beta [4] dll beta
- [4] dll beta 12 bytes {0} [built]
- [5] ./beta.js 24 bytes {0} [built]
- single entry ./beta [4] dll beta beta:0
- [6] ./b.js 21 bytes {0} [built]
- single entry ./b [4] dll beta beta:1
- [7] ./c.jsx 23 bytes {0} [built]
- single entry ./c [4] dll beta beta:2
+ > beta
+ [0] ./c.jsx 23 bytes {0} [built]
+
+ single entry ./c [3] dll beta beta:2
+ [1] ./b.js 21 bytes {0} [built]
+
+ single entry ./b [3] dll beta beta:1
+ [2] ./beta.js 24 bytes {0} [built]
+
+ single entry ./beta [3] dll beta beta:0
+ [3] dll beta 12 bytes {0} [built]
+ dll entry
+
chunk {1} MyDll.alpha.js (alpha) 84 bytes [entry] [rendered]
- > alpha [0] dll alpha
- [0] dll alpha 12 bytes {1} [built]
- [1] ./alpha.js 25 bytes {1} [built]
- single entry ./alpha [0] dll alpha alpha:0
- [2] ./a.js 21 bytes {1} [built]
- single entry ./a [0] dll alpha alpha:1
+ > alpha
+ [5] ./a.js 21 bytes {1} [built]
+
+ single entry ./a [7] dll alpha alpha:1
+ [6] ./alpha.js 25 bytes {1} [built]
+
+ single entry ./alpha [7] dll alpha alpha:0
+ [7] dll alpha 12 bytes {1} [built]
+ dll entry
+
+ 1 hidden module
```
diff --git a/examples/dll/template.md b/examples/dll/template.md
index a34fab92..f51914ec 100644
--- a/examples/dll/template.md
+++ b/examples/dll/template.md
@@ -11,28 +11,28 @@ This is the _reference_ bundle (with the manifests) for [dll user example](https
{{webpack.config.js}}
```
-# js/MyDll.alpha.js
+# dist/MyDll.alpha.js
``` javascript
-{{js/MyDll.alpha.js}}
+{{dist/MyDll.alpha.js}}
```
-# js/alpha-manifest.json
+# dist/alpha-manifest.json
``` javascript
-{{js/alpha-manifest.json}}
+{{dist/alpha-manifest.json}}
```
# Info
-## Uncompressed
+## Unoptimized
```
{{stdout}}
```
-## Minimized (uglify-js, no zip)
+## Production mode
```
-{{min:stdout}}
+{{production:stdout}}
```
diff --git a/examples/dll/webpack.config.js b/examples/dll/webpack.config.js
index e907576b..7d96a139 100644
--- a/examples/dll/webpack.config.js
+++ b/examples/dll/webpack.config.js
@@ -1,6 +1,7 @@
var path = require("path");
var webpack = require("../../");
module.exports = {
+ // mode: "development || "production",
resolve: {
extensions: [".js", ".jsx"]
},
@@ -9,13 +10,13 @@ module.exports = {
beta: ["./beta", "./b", "./c"]
},
output: {
- path: path.join(__dirname, "js"),
+ path: path.join(__dirname, "dist"),
filename: "MyDll.[name].js",
library: "[name]_[hash]"
},
plugins: [
new webpack.DllPlugin({
- path: path.join(__dirname, "js", "[name]-manifest.json"),
+ path: path.join(__dirname, "dist", "[name]-manifest.json"),
name: "[name]_[hash]"
})
]
diff --git a/examples/explicit-vendor-chunk/README.md b/examples/explicit-vendor-chunk/README.md
index 05644175..5824f6f8 100644
--- a/examples/explicit-vendor-chunk/README.md
+++ b/examples/explicit-vendor-chunk/README.md
@@ -4,23 +4,27 @@
var path = require("path");
var webpack = require("../../");
module.exports = [
+
{
name: "vendor",
+ // mode: "development || "production",
entry: ["./vendor", "./vendor2"],
output: {
- path: path.resolve(__dirname, "js"),
+ path: path.resolve(__dirname, "dist"),
filename: "vendor.js",
library: "vendor_[hash]"
},
plugins: [
new webpack.DllPlugin({
name: "vendor_[hash]",
- path: path.resolve(__dirname, "js/manifest.json")
+ path: path.resolve(__dirname, "dist/manifest.json")
})
]
},
+
{
name: "app",
+ // mode: "development || "production",
dependencies: ["vendor"],
entry: {
pageA: "./pageA",
@@ -28,22 +32,23 @@ module.exports = [
pageC: "./pageC"
},
output: {
- path: path.join(__dirname, "js"),
+ path: path.join(__dirname, "dist"),
filename: "[name].js"
},
plugins: [
new webpack.DllReferencePlugin({
- manifest: path.resolve(__dirname, "js/manifest.json")
+ manifest: path.resolve(__dirname, "dist/manifest.json")
})
]
}
+
];
```
-# js/vendor.js
+# dist/vendor.js
``` javascript
-var vendor_3e23dee019354f6a37c0 =
+var vendor_36000db9190edee14765 =
```
<details><summary><code>/******/ (function(modules) { /* webpackBootstrap */ })</code></summary>
@@ -94,6 +99,11 @@ var vendor_3e23dee019354f6a37c0 =
/******/ }
/******/ };
/******/
+/******/ // define __esModule on exports
+/******/ __webpack_require__.r = function(exports) {
+/******/ Object.defineProperty(exports, '__esModule', { value: true });
+/******/ };
+/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
@@ -107,7 +117,8 @@ var vendor_3e23dee019354f6a37c0 =
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
-/******/ __webpack_require__.p = "js/";
+/******/ __webpack_require__.p = "dist/";
+/******/
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 0);
@@ -155,7 +166,7 @@ module.exports = "Vendor2";
/******/ ]);
```
-# js/pageA.js
+# dist/pageA.js
``` javascript
/******/ (function(modules) { // webpackBootstrap
@@ -204,6 +215,11 @@ module.exports = "Vendor2";
/******/ }
/******/ };
/******/
+/******/ // define __esModule on exports
+/******/ __webpack_require__.r = function(exports) {
+/******/ Object.defineProperty(exports, '__esModule', { value: true });
+/******/ };
+/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
@@ -217,45 +233,43 @@ module.exports = "Vendor2";
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
-/******/ __webpack_require__.p = "js/";
+/******/ __webpack_require__.p = "dist/";
+/******/
/******/
/******/ // Load entry module and return exports
-/******/ return __webpack_require__(__webpack_require__.s = 1);
+/******/ return __webpack_require__(__webpack_require__.s = 0);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
-/*!**********************************************!*\
- !*** external "vendor_3e23dee019354f6a37c0" ***!
- \**********************************************/
-/*! no static exports found */
-/*! all exports used */
-/***/ (function(module, exports) {
-
-module.exports = vendor_3e23dee019354f6a37c0;
-
-/***/ }),
-/* 1 */
/*!******************!*\
!*** ./pageA.js ***!
\******************/
/*! no static exports found */
-/*! all exports used */
/***/ (function(module, exports, __webpack_require__) {
-console.log(__webpack_require__(/*! ./vendor */ 2));
+console.log(__webpack_require__(/*! ./vendor */ 1));
module.exports = "pageA";
/***/ }),
-/* 2 */
+/* 1 */
/*!****************************************************************************!*\
- !*** delegated ./vendor.js from dll-reference vendor_3e23dee019354f6a37c0 ***!
+ !*** delegated ./vendor.js from dll-reference vendor_36000db9190edee14765 ***!
\****************************************************************************/
/*! no static exports found */
-/*! all exports used */
/***/ (function(module, exports, __webpack_require__) {
-module.exports = (__webpack_require__(0))(1);
+module.exports = (__webpack_require__(/*! dll-reference vendor_36000db9190edee14765 */ 2))(1);
+
+/***/ }),
+/* 2 */
+/*!**********************************************!*\
+ !*** external "vendor_36000db9190edee14765" ***!
+ \**********************************************/
+/*! no static exports found */
+/***/ (function(module, exports) {
+
+module.exports = vendor_36000db9190edee14765;
/***/ })
/******/ ]);
@@ -263,88 +277,110 @@ module.exports = (__webpack_require__(0))(1);
# Info
-## Uncompressed
+## Unoptimized
```
-Hash: 3e23dee019354f6a37c0873a025592bd40b1b4d6
-Version: webpack 3.5.1
+Hash: 0a1b2c3d4e5f6a7b8c9d
+Version: webpack 4.0.0-beta.2
Child vendor:
- Hash: 3e23dee019354f6a37c0
- Asset Size Chunks Chunk Names
- vendor.js 3.11 kB 0 [emitted] main
+ Hash: 0a1b2c3d4e5f6a7b8c9d
+ Asset Size Chunks Chunk Names
+ vendor.js 3.24 KiB 0 [emitted] main
Entrypoint main = vendor.js
chunk {0} vendor.js (main) 65 bytes [entry] [rendered]
- > main [0] dll main
+ > main
[0] dll main 12 bytes {0} [built]
+ dll entry
+
[1] ./vendor.js 26 bytes {0} [built]
+
single entry ./vendor [0] dll main main:0
[2] ./vendor2.js 27 bytes {0} [built]
+
single entry ./vendor2 [0] dll main main:1
Child app:
- Hash: 873a025592bd40b1b4d6
- Asset Size Chunks Chunk Names
- pageB.js 3.46 kB 0 [emitted] pageB
- pageA.js 3.44 kB 1 [emitted] pageA
- pageC.js 2.63 kB 2 [emitted] pageC
+ Hash: 0a1b2c3d4e5f6a7b8c9d
+ Asset Size Chunks Chunk Names
+ pageA.js 3.53 KiB 0 [emitted] pageA
+ pageB.js 3.55 KiB 1 [emitted] pageB
+ pageC.js 2.74 KiB 2 [emitted] pageC
Entrypoint pageA = pageA.js
Entrypoint pageB = pageB.js
Entrypoint pageC = pageC.js
- chunk {0} pageB.js (pageB) 145 bytes [entry] [rendered]
- > pageB [3] ./pageB.js
- [3] ./pageB.js 61 bytes {0} [built]
- [4] delegated ./vendor2.js from dll-reference vendor_3e23dee019354f6a37c0 42 bytes {0} [built]
+ chunk {0} pageA.js (pageA) 144 bytes [entry] [rendered]
+ > ./pageA pageA
+ [0] ./pageA.js 60 bytes {0} [built]
+ single entry ./pageA pageA
+ [1] delegated ./vendor.js from dll-reference vendor_36000db9190edee14765 42 bytes {0} [built]
+ cjs require ./vendor [0] ./pageA.js 1:12-31
+ [2] external "vendor_36000db9190edee14765" 42 bytes {0} {1} [built]
+ delegated source dll-reference vendor_36000db9190edee14765 [1] delegated ./vendor.js from dll-reference vendor_36000db9190edee14765
+ delegated source dll-reference vendor_36000db9190edee14765 [4] delegated ./vendor2.js from dll-reference vendor_36000db9190edee14765
+ chunk {1} pageB.js (pageB) 145 bytes [entry] [rendered]
+ > ./pageB pageB
+ [2] external "vendor_36000db9190edee14765" 42 bytes {0} {1} [built]
+ delegated source dll-reference vendor_36000db9190edee14765 [1] delegated ./vendor.js from dll-reference vendor_36000db9190edee14765
+ delegated source dll-reference vendor_36000db9190edee14765 [4] delegated ./vendor2.js from dll-reference vendor_36000db9190edee14765
+ [3] ./pageB.js 61 bytes {1} [built]
+ single entry ./pageB pageB
+ [4] delegated ./vendor2.js from dll-reference vendor_36000db9190edee14765 42 bytes {1} [built]
cjs require ./vendor2 [3] ./pageB.js 1:12-32
- + 1 hidden module
- chunk {1} pageA.js (pageA) 144 bytes [entry] [rendered]
- > pageA [1] ./pageA.js
- [1] ./pageA.js 60 bytes {1} [built]
- [2] delegated ./vendor.js from dll-reference vendor_3e23dee019354f6a37c0 42 bytes {1} [built]
- cjs require ./vendor [1] ./pageA.js 1:12-31
- + 1 hidden module
chunk {2} pageC.js (pageC) 25 bytes [entry] [rendered]
- > pageC [5] ./pageC.js
+ > ./pageC pageC
[5] ./pageC.js 25 bytes {2} [built]
+ single entry ./pageC pageC
```
-## Minimized (uglify-js, no zip)
+## Production mode
```
-Hash: 3e23dee019354f6a37c0873a025592bd40b1b4d6
-Version: webpack 3.5.1
+Hash: 0a1b2c3d4e5f6a7b8c9d
+Version: webpack 4.0.0-beta.2
Child vendor:
- Hash: 3e23dee019354f6a37c0
+ Hash: 0a1b2c3d4e5f6a7b8c9d
Asset Size Chunks Chunk Names
- vendor.js 602 bytes 0 [emitted] main
+ vendor.js 670 bytes 0 [emitted] main
Entrypoint main = vendor.js
chunk {0} vendor.js (main) 65 bytes [entry] [rendered]
- > main [0] dll main
- [0] dll main 12 bytes {0} [built]
+ > main
+ [0] ./vendor2.js 27 bytes {0} [built]
+
+ single entry ./vendor2 [2] dll main main:1
[1] ./vendor.js 26 bytes {0} [built]
- single entry ./vendor [0] dll main main:0
- [2] ./vendor2.js 27 bytes {0} [built]
- single entry ./vendor2 [0] dll main main:1
+
+ single entry ./vendor [2] dll main main:0
+ [2] dll main 12 bytes {0} [built]
+ dll entry
+
Child app:
- Hash: 873a025592bd40b1b4d6
+ Hash: 0a1b2c3d4e5f6a7b8c9d
Asset Size Chunks Chunk Names
- pageB.js 609 bytes 0 [emitted] pageB
- pageA.js 607 bytes 1 [emitted] pageA
- pageC.js 501 bytes 2 [emitted] pageC
+ pageC.js 568 bytes 0 [emitted] pageC
+ pageB.js 676 bytes 1 [emitted] pageB
+ pageA.js 678 bytes 2 [emitted] pageA
Entrypoint pageA = pageA.js
Entrypoint pageB = pageB.js
Entrypoint pageC = pageC.js
- chunk {0} pageB.js (pageB) 145 bytes [entry] [rendered]
- > pageB [3] ./pageB.js
- [3] ./pageB.js 61 bytes {0} [built]
- [4] delegated ./vendor2.js from dll-reference vendor_3e23dee019354f6a37c0 42 bytes {0} [built]
+ chunk {0} pageC.js (pageC) 25 bytes [entry] [rendered]
+ > ./pageC pageC
+ [1] ./pageC.js 25 bytes {0} [built]
+ single entry ./pageC pageC
+ chunk {1} pageB.js (pageB) 145 bytes [entry] [rendered]
+ > ./pageB pageB
+ [0] external "vendor_bca8264c25e79f49ad09" 42 bytes {1} {2} [built]
+ delegated source dll-reference vendor_bca8264c25e79f49ad09 [2] delegated ./vendor2.js from dll-reference vendor_bca8264c25e79f49ad09
+ delegated source dll-reference vendor_bca8264c25e79f49ad09 [4] delegated ./vendor.js from dll-reference vendor_bca8264c25e79f49ad09
+ [2] delegated ./vendor2.js from dll-reference vendor_bca8264c25e79f49ad09 42 bytes {1} [built]
cjs require ./vendor2 [3] ./pageB.js 1:12-32
- + 1 hidden module
- chunk {1} pageA.js (pageA) 144 bytes [entry] [rendered]
- > pageA [1] ./pageA.js
- [1] ./pageA.js 60 bytes {1} [built]
- [2] delegated ./vendor.js from dll-reference vendor_3e23dee019354f6a37c0 42 bytes {1} [built]
- cjs require ./vendor [1] ./pageA.js 1:12-31
- + 1 hidden module
- chunk {2} pageC.js (pageC) 25 bytes [entry] [rendered]
- > pageC [5] ./pageC.js
- [5] ./pageC.js 25 bytes {2} [built]
+ [3] ./pageB.js 61 bytes {1} [built]
+ single entry ./pageB pageB
+ chunk {2} pageA.js (pageA) 144 bytes [entry] [rendered]
+ > ./pageA pageA
+ [0] external "vendor_bca8264c25e79f49ad09" 42 bytes {1} {2} [built]
+ delegated source dll-reference vendor_bca8264c25e79f49ad09 [2] delegated ./vendor2.js from dll-reference vendor_bca8264c25e79f49ad09
+ delegated source dll-reference vendor_bca8264c25e79f49ad09 [4] delegated ./vendor.js from dll-reference vendor_bca8264c25e79f49ad09
+ [4] delegated ./vendor.js from dll-reference vendor_bca8264c25e79f49ad09 42 bytes {2} [built]
+ cjs require ./vendor [5] ./pageA.js 1:12-31
+ [5] ./pageA.js 60 bytes {2} [built]
+ single entry ./pageA pageA
```
diff --git a/examples/explicit-vendor-chunk/template.md b/examples/explicit-vendor-chunk/template.md
index a2310eff..e683b3da 100644
--- a/examples/explicit-vendor-chunk/template.md
+++ b/examples/explicit-vendor-chunk/template.md
@@ -4,28 +4,28 @@
{{webpack.config.js}}
```
-# js/vendor.js
+# dist/vendor.js
``` javascript
-{{js/vendor.js}}
+{{dist/vendor.js}}
```
-# js/pageA.js
+# dist/pageA.js
``` javascript
-{{js/pageA.js}}
+{{dist/pageA.js}}
```
# Info
-## Uncompressed
+## Unoptimized
```
{{stdout}}
```
-## Minimized (uglify-js, no zip)
+## Production mode
```
-{{min:stdout}}
+{{production:stdout}}
```
diff --git a/examples/explicit-vendor-chunk/webpack.config.js b/examples/explicit-vendor-chunk/webpack.config.js
index cf61f743..e924b3ac 100644
--- a/examples/explicit-vendor-chunk/webpack.config.js
+++ b/examples/explicit-vendor-chunk/webpack.config.js
@@ -3,21 +3,24 @@ var webpack = require("../../");
module.exports = [
{
name: "vendor",
+ // mode: "development || "production",
entry: ["./vendor", "./vendor2"],
output: {
- path: path.resolve(__dirname, "js"),
+ path: path.resolve(__dirname, "dist"),
filename: "vendor.js",
library: "vendor_[hash]"
},
plugins: [
new webpack.DllPlugin({
name: "vendor_[hash]",
- path: path.resolve(__dirname, "js/manifest.json")
+ path: path.resolve(__dirname, "dist/manifest.json")
})
]
},
+
{
name: "app",
+ // mode: "development || "production",
dependencies: ["vendor"],
entry: {
pageA: "./pageA",
@@ -25,12 +28,12 @@ module.exports = [
pageC: "./pageC"
},
output: {
- path: path.join(__dirname, "js"),
+ path: path.join(__dirname, "dist"),
filename: "[name].js"
},
plugins: [
new webpack.DllReferencePlugin({
- manifest: path.resolve(__dirname, "js/manifest.json")
+ manifest: path.resolve(__dirname, "dist/manifest.json")
})
]
}
diff --git a/examples/externals/README.md b/examples/externals/README.md
index 6e7649c7..c1fe360e 100644
--- a/examples/externals/README.md
+++ b/examples/externals/README.md
@@ -28,6 +28,7 @@ exports.exampleValue = subtract(add(42, 2), 2);
``` javascript
module.exports = {
+ // mode: "development || "production",
output: {
libraryTarget: "umd"
},
@@ -45,7 +46,7 @@ module.exports = {
};
```
-# js/output.js
+# dist/output.js
``` javascript
(function webpackUniversalModuleDefinition(root, factory) {
@@ -57,7 +58,7 @@ module.exports = {
var a = typeof exports === 'object' ? factory(require("add"), require("./math")["subtract"]) : factory(root["add"], root["subtract"]);
for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
}
-})(this, function(__WEBPACK_EXTERNAL_MODULE_1__, __WEBPACK_EXTERNAL_MODULE_2__) {
+})(window, function(__WEBPACK_EXTERNAL_MODULE__1__, __WEBPACK_EXTERNAL_MODULE__2__) {
```
<details><summary><code>return /******/ (function(modules) { /* webpackBootstrap */ })</code></summary>
@@ -108,6 +109,11 @@ return /******/ (function(modules) { // webpackBootstrap
/******/ }
/******/ };
/******/
+/******/ // define __esModule on exports
+/******/ __webpack_require__.r = function(exports) {
+/******/ Object.defineProperty(exports, '__esModule', { value: true });
+/******/ };
+/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
@@ -121,7 +127,8 @@ return /******/ (function(modules) { // webpackBootstrap
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
-/******/ __webpack_require__.p = "js/";
+/******/ __webpack_require__.p = "dist/";
+/******/
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 0);
@@ -138,7 +145,6 @@ return /******/ (function(modules) { // webpackBootstrap
!*** ./example.js ***!
\********************/
/*! no static exports found */
-/*! all exports used */
/***/ (function(module, exports, __webpack_require__) {
var add = __webpack_require__(/*! add */ 1);
@@ -152,10 +158,9 @@ exports.exampleValue = subtract(add(42, 2), 2);
!*** external "add" ***!
\**********************/
/*! no static exports found */
-/*! all exports used */
/***/ (function(module, exports) {
-module.exports = __WEBPACK_EXTERNAL_MODULE_1__;
+module.exports = __WEBPACK_EXTERNAL_MODULE__1__;
/***/ }),
/* 2 */
@@ -163,10 +168,9 @@ module.exports = __WEBPACK_EXTERNAL_MODULE_1__;
!*** external {"root":"subtract","commonjs2":"./subtract","commonjs":["./math","subtract"],"amd":"subtract"} ***!
\***************************************************************************************************************/
/*! no static exports found */
-/*! all exports used */
/***/ (function(module, exports) {
-module.exports = __WEBPACK_EXTERNAL_MODULE_2__;
+module.exports = __WEBPACK_EXTERNAL_MODULE__2__;
/***/ })
/******/ ]);
@@ -175,30 +179,38 @@ module.exports = __WEBPACK_EXTERNAL_MODULE_2__;
# Info
-## Uncompressed
+## Unoptimized
```
-Hash: b21d422ed5d9ade3ed36
-Version: webpack 3.5.1
- Asset Size Chunks Chunk Names
-output.js 4.13 kB 0 [emitted] main
+Hash: 0a1b2c3d4e5f6a7b8c9d
+Version: webpack 4.0.0-beta.2
+ Asset Size Chunks Chunk Names
+output.js 4.17 KiB 0 [emitted] main
Entrypoint main = output.js
chunk {0} output.js (main) 197 bytes [entry] [rendered]
- > main [0] ./example.js
+ > .\example.js main
[0] ./example.js 113 bytes {0} [built]
- + 2 hidden modules
+ single entry .\example.js main
+ [1] external "add" 42 bytes {0} [built]
+ cjs require add [0] ./example.js 1:10-24
+ [2] external {"root":"subtract","commonjs2":"./subtract","commonjs":["./math","subtract"],"amd":"subtract"} 42 bytes {0} [built]
+ cjs require subtract [0] ./example.js 2:15-34
```
-## Minimized (uglify-js, no zip)
+## Production mode
```
-Hash: b21d422ed5d9ade3ed36
-Version: webpack 3.5.1
- Asset Size Chunks Chunk Names
-output.js 978 bytes 0 [emitted] main
+Hash: 0a1b2c3d4e5f6a7b8c9d
+Version: webpack 4.0.0-beta.2
+ Asset Size Chunks Chunk Names
+output.js 1.02 KiB 0 [emitted] main
Entrypoint main = output.js
chunk {0} output.js (main) 197 bytes [entry] [rendered]
- > main [0] ./example.js
- [0] ./example.js 113 bytes {0} [built]
- + 2 hidden modules
+ > .\example.js main
+ [0] external {"root":"subtract","commonjs2":"./subtract","commonjs":["./math","subtract"],"amd":"subtract"} 42 bytes {0} [built]
+ cjs require subtract [2] ./example.js 2:15-34
+ [1] external "add" 42 bytes {0} [built]
+ cjs require add [2] ./example.js 1:10-24
+ [2] ./example.js 113 bytes {0} [built]
+ single entry .\example.js main
```
\ No newline at end of file
diff --git a/examples/externals/template.md b/examples/externals/template.md
index 64a87c23..d79321a9 100644
--- a/examples/externals/template.md
+++ b/examples/externals/template.md
@@ -27,22 +27,22 @@ In the complex case we specify different values for each environment:
{{webpack.config.js}}
```
-# js/output.js
+# dist/output.js
``` javascript
-{{js/output.js}}
+{{dist/output.js}}
```
# Info
-## Uncompressed
+## Unoptimized
```
{{stdout}}
```
-## Minimized (uglify-js, no zip)
+## Production mode
```
-{{min:stdout}}
+{{production:stdout}}
```
\ No newline at end of file
diff --git a/examples/externals/webpack.config.js b/examples/externals/webpack.config.js
index fa5cddbc..8210f662 100644
--- a/examples/externals/webpack.config.js
+++ b/examples/externals/webpack.config.js
@@ -1,11 +1,12 @@
module.exports = {
+ // mode: "development || "production",
output: {
libraryTarget: "umd"
},
externals: [
"add",
{
- "subtract": {
+ subtract: {
root: "subtract",
commonjs2: "./subtract",
commonjs: ["./math", "subtract"],
diff --git a/examples/extra-async-chunk-advanced/README.md b/examples/extra-async-chunk-advanced/README.md
index ca061d54..58def38a 100644
--- a/examples/extra-async-chunk-advanced/README.md
+++ b/examples/extra-async-chunk-advanced/README.md
@@ -24,38 +24,31 @@ require.ensure(["./a", "./e"], function(require) {
# webpack.config.js
``` javascript
-var CommonsChunkPlugin = require("../../lib/optimize/CommonsChunkPlugin");
-
module.exports = {
- plugins: [
- new CommonsChunkPlugin({
- name: "main",
- async: "async1"
- }),
- new CommonsChunkPlugin({
- name: "main",
- async: "async2",
- minChunks: 2
- }),
- new CommonsChunkPlugin({
- async: true
- }),
- ]
+ // mode: "development || "production",
+ optimization: {
+ splitChunks: {
+ minSize: 0 // This example is too small
+ },
+ occurrenceOrder: true // To keep filename consistent between different modes (for example building only)
+ }
};
```
-# js/output.js
+# dist/output.js
<details><summary><code>/******/ (function(modules) { /* webpackBootstrap */ })</code></summary>
``` javascript
/******/ (function(modules) { // webpackBootstrap
/******/ // install a JSONP callback for chunk loading
-/******/ var parentJsonpFunction = window["webpackJsonp"];
-/******/ window["webpackJsonp"] = function webpackJsonpCallback(chunkIds, moreModules, executeModules) {
+/******/ function webpackJsonpCallback(data) {
+/******/ var chunkIds = data[0];
+/******/ var moreModules = data[1]
+/******/
/******/ // add "moreModules" to the modules object,
/******/ // then flag all "chunkIds" as loaded and fire callback
-/******/ var moduleId, chunkId, i = 0, resolves = [], result;
+/******/ var moduleId, chunkId, i = 0, resolves = [];
/******/ for(;i < chunkIds.length; i++) {
/******/ chunkId = chunkIds[i];
/******/ if(installedChunks[chunkId]) {
@@ -68,21 +61,24 @@ module.exports = {
/******/ modules[moduleId] = moreModules[moduleId];
/******/ }
/******/ }
-/******/ if(parentJsonpFunction) parentJsonpFunction(chunkIds, moreModules, executeModules);
+/******/ if(parentJsonpFunction) parentJsonpFunction(data);
/******/ while(resolves.length) {
/******/ resolves.shift()();
/******/ }
/******/
/******/ };
/******/
+/******/
/******/ // The module cache
/******/ var installedModules = {};
/******/
-/******/ // objects to store loaded and loading chunks
+/******/ // object to store loaded and loading chunks
/******/ var installedChunks = {
/******/ 7: 0
/******/ };
/******/
+/******/
+/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
@@ -110,51 +106,60 @@ module.exports = {
/******/ // This file contains only the entry chunk.
/******/ // The chunk loading function for additional chunks
/******/ __webpack_require__.e = function requireEnsure(chunkId) {
+/******/ var promises = [];
+/******/
+/******/
+/******/ // JSONP chunk loading for javascript
+/******/
/******/ var installedChunkData = installedChunks[chunkId];
-/******/ if(installedChunkData === 0) {
-/******/ return new Promise(function(resolve) { resolve(); });
-/******/ }
+/******/ if(installedChunkData !== 0) { // 0 means "already installed".
/******/
-/******/ // a Promise means "currently loading".
-/******/ if(installedChunkData) {
-/******/ return installedChunkData[2];
-/******/ }
+/******/ // a Promise means "currently loading".
+/******/ if(installedChunkData) {
+/******/ promises.push(installedChunkData[2]);
+/******/ } else {
+/******/ // setup Promise in chunk cache
+/******/ var promise = new Promise(function(resolve, reject) {
+/******/ installedChunkData = installedChunks[chunkId] = [resolve, reject];
+/******/ });
+/******/ promises.push(installedChunkData[2] = promise);
/******/
-/******/ // setup Promise in chunk cache
-/******/ var promise = new Promise(function(resolve, reject) {
-/******/ installedChunkData = installedChunks[chunkId] = [resolve, reject];
-/******/ });
-/******/ installedChunkData[2] = promise;
+/******/ // start chunk loading
+/******/ var head = document.getElementsByTagName('head')[0];
+/******/ var script = document.createElement('script');
/******/
-/******/ // start chunk loading
-/******/ var head = document.getElementsByTagName('head')[0];
-/******/ var script = document.createElement('script');
-/******/ script.type = 'text/javascript';
-/******/ script.charset = 'utf-8';
-/******/ script.async = true;
-/******/ script.timeout = 120000;
+/******/ script.charset = 'utf-8';
+/******/ script.timeout = 120000;
/******/
-/******/ if (__webpack_require__.nc) {
-/******/ script.setAttribute("nonce", __webpack_require__.nc);
-/******/ }
-/******/ script.src = __webpack_require__.p + "" + chunkId + ".output.js";
-/******/ var timeout = setTimeout(onScriptComplete, 120000);
-/******/ script.onerror = script.onload = onScriptComplete;
-/******/ function onScriptComplete() {
-/******/ // avoid mem leaks in IE.
-/******/ script.onerror = script.onload = null;
-/******/ clearTimeout(timeout);
-/******/ var chunk = installedChunks[chunkId];
-/******/ if(chunk !== 0) {
-/******/ if(chunk) {
-/******/ chunk[1](new Error('Loading chunk ' + chunkId + ' failed.'));
+/******/ if (__webpack_require__.nc) {
+/******/ script.setAttribute("nonce", __webpack_require__.nc);
/******/ }
-/******/ installedChunks[chunkId] = undefined;
+/******/ script.src = __webpack_require__.p + "" + chunkId + ".output.js";
+/******/ var timeout = setTimeout(function(){
+/******/ onScriptComplete({ type: 'timeout', target: script });
+/******/ }, 120000);
+/******/ script.onerror = script.onload = onScriptComplete;
+/******/ function onScriptComplete(event) {
+/******/ // avoid mem leaks in IE.
+/******/ script.onerror = script.onload = null;
+/******/ clearTimeout(timeout);
+/******/ var chunk = installedChunks[chunkId];
+/******/ if(chunk !== 0) {
+/******/ if(chunk) {
+/******/ var errorType = event && (event.type === 'load' ? 'missing' : event.type);
+/******/ var realSrc = event && event.target && event.target.src;
+/******/ var error = new Error('Loading chunk ' + chunkId + ' failed.\n(' + errorType + ': ' + realSrc + ')');
+/******/ error.type = errorType;
+/******/ error.request = realSrc;
+/******/ chunk[1](error);
+/******/ }
+/******/ installedChunks[chunkId] = undefined;
+/******/ }
+/******/ };
+/******/ head.appendChild(script);
/******/ }
-/******/ };
-/******/ head.appendChild(script);
-/******/
-/******/ return promise;
+/******/ }
+/******/ return Promise.all(promises);
/******/ };
/******/
/******/ // expose the modules object (__webpack_modules__)
@@ -174,6 +179,11 @@ module.exports = {
/******/ }
/******/ };
/******/
+/******/ // define __esModule on exports
+/******/ __webpack_require__.r = function(exports) {
+/******/ Object.defineProperty(exports, '__esModule', { value: true });
+/******/ };
+/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
@@ -187,11 +197,19 @@ module.exports = {
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
-/******/ __webpack_require__.p = "js/";
+/******/ __webpack_require__.p = "dist/";
/******/
/******/ // on error function for async loading
/******/ __webpack_require__.oe = function(err) { console.error(err); throw err; };
/******/
+/******/ var jsonpArray = window["webpackJsonp"] = window["webpackJsonp"] || [];
+/******/ var oldJsonpFunction = jsonpArray.push.bind(jsonpArray);
+/******/ jsonpArray.push = webpackJsonpCallback;
+/******/ jsonpArray = jsonpArray.slice();
+/******/ for(var i = 0; i < jsonpArray.length; i++) webpackJsonpCallback(jsonpArray[i]);
+/******/ var parentJsonpFunction = oldJsonpFunction;
+/******/
+/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 2);
/******/ })
@@ -208,23 +226,22 @@ module.exports = {
!*** ./example.js ***!
\********************/
/*! no static exports found */
-/*! all exports used */
/***/ (function(module, exports, __webpack_require__) {
-Promise.all/* require */([__webpack_require__.e(4), __webpack_require__.e(0), __webpack_require__.e(1)]).then(function() { var __WEBPACK_AMD_REQUIRE_ARRAY__ = [__webpack_require__(/*! ./a */ 0), __webpack_require__(/*! ./b */ 1), __webpack_require__(/*! ./c */ 3)]; (function(a, b, c) {}.apply(null, __WEBPACK_AMD_REQUIRE_ARRAY__));}).catch(__webpack_require__.oe);
+Promise.all(/*! AMD require */[__webpack_require__.e(1), __webpack_require__.e(0), __webpack_require__.e(4)]).then(function() { var __WEBPACK_AMD_REQUIRE_ARRAY__ = [__webpack_require__(/*! ./a */ 1), __webpack_require__(/*! ./b */ 0), __webpack_require__(/*! ./c */ 7)]; (function(a, b, c) {}).apply(null, __WEBPACK_AMD_REQUIRE_ARRAY__);}).catch(__webpack_require__.oe);
-Promise.all/* require.ensure */([__webpack_require__.e(3), __webpack_require__.e(0), __webpack_require__.e(1)]).then((function(require) {
- __webpack_require__(/*! ./b */ 1);
- __webpack_require__(/*! ./d */ 4);
+Promise.all(/*! require.ensure */[__webpack_require__.e(1), __webpack_require__.e(0), __webpack_require__.e(3)]).then((function(require) {
+ __webpack_require__(/*! ./b */ 0);
+ __webpack_require__(/*! ./d */ 6);
}).bind(null, __webpack_require__)).catch(__webpack_require__.oe);
-Promise.all/* require.ensure */([__webpack_require__.e(2), __webpack_require__.e(1)]).then((function(require) {
- __webpack_require__(/*! ./a */ 0);
- Promise.all/* require.ensure */([__webpack_require__.e(6), __webpack_require__.e(0)]).then((function(require) {
- __webpack_require__(/*! ./f */ 6);
+Promise.all(/*! require.ensure */[__webpack_require__.e(0), __webpack_require__.e(2)]).then((function(require) {
+ __webpack_require__(/*! ./a */ 1);
+ Promise.all(/*! require.ensure */[__webpack_require__.e(1), __webpack_require__.e(6)]).then((function(require) {
+ __webpack_require__(/*! ./f */ 4);
}).bind(null, __webpack_require__)).catch(__webpack_require__.oe);
- Promise.all/* require.ensure */([__webpack_require__.e(5), __webpack_require__.e(0)]).then((function(require) {
- __webpack_require__(/*! ./g */ 7);
+ Promise.all(/*! require.ensure */[__webpack_require__.e(1), __webpack_require__.e(5)]).then((function(require) {
+ __webpack_require__(/*! ./g */ 3);
}).bind(null, __webpack_require__)).catch(__webpack_require__.oe);
}).bind(null, __webpack_require__)).catch(__webpack_require__.oe);
@@ -236,120 +253,122 @@ Promise.all/* require.ensure */([__webpack_require__.e(2), __webpack_require__.e
# Info
-## Uncompressed
+## Unoptimized
```
-Hash: 37a3748d37b36bc162d0
-Version: webpack 3.5.1
+Hash: 0a1b2c3d4e5f6a7b8c9d
+Version: webpack 4.0.0-beta.2
Asset Size Chunks Chunk Names
-0.output.js 221 bytes 0 [emitted] async2
-1.output.js 212 bytes 1 [emitted] async1
-2.output.js 215 bytes 2 [emitted]
-3.output.js 215 bytes 3 [emitted]
-4.output.js 215 bytes 4 [emitted]
-5.output.js 215 bytes 5 [emitted]
-6.output.js 215 bytes 6 [emitted]
- output.js 7.22 kB 7 [emitted] main
+0.output.js 247 bytes 0 [emitted]
+1.output.js 238 bytes 1 [emitted]
+2.output.js 241 bytes 2 [emitted]
+3.output.js 241 bytes 3 [emitted]
+4.output.js 241 bytes 4 [emitted]
+5.output.js 241 bytes 5 [emitted]
+6.output.js 241 bytes 6 [emitted]
+ output.js 8.07 KiB 7 [emitted] main
Entrypoint main = output.js
-chunk {0} 0.output.js (async2) 21 bytes {2} {7} [rendered]
- > async commons duplicate [2] ./example.js 1:0-52
- > async commons duplicate [2] ./example.js 3:0-6:2
- > async commons duplicate [2] ./example.js 10:1-12:3
- > async commons duplicate [2] ./example.js 13:1-15:3
- [1] ./b.js 21 bytes {0} [built]
- amd require ./b [2] ./example.js 1:0-52
- cjs require ./b [2] ./example.js 4:1-15
- require.ensure item ./b [2] ./example.js 10:1-12:3
- require.ensure item ./b [2] ./example.js 13:1-15:3
-chunk {1} 1.output.js (async1) 21 bytes {7} [rendered]
- > async commons [2] ./example.js 1:0-52
- > async commons [2] ./example.js 3:0-6:2
- > async commons [2] ./example.js 8:0-16:2
- [0] ./a.js 21 bytes {1} [built]
+chunk {0} 0.output.js 21 bytes <{7}> ={1}= ={2}= ={3}= ={4}= >{1}< >{5}< >{6}< [rendered] split chunk (cache group: default)
+ > ./a ./b ./c [2] ./example.js 1:0-52
+ > [2] ./example.js 3:0-6:2
+ > [2] ./example.js 8:0-16:2
+ [1] ./a.js 21 bytes {0} [built]
amd require ./a [2] ./example.js 1:0-52
require.ensure item ./a [2] ./example.js 3:0-6:2
require.ensure item ./a [2] ./example.js 8:0-16:2
cjs require ./a [2] ./example.js 9:1-15
-chunk {2} 2.output.js 21 bytes {7} [rendered]
+chunk {1} 1.output.js 21 bytes <{0}> <{2}> <{7}> ={0}= ={3}= ={4}= ={5}= ={6}= [rendered] split chunk (cache group: default)
+ > [2] ./example.js 10:1-12:3
+ > [2] ./example.js 13:1-15:3
+ > ./a ./b ./c [2] ./example.js 1:0-52
+ > [2] ./example.js 3:0-6:2
+ [0] ./b.js 21 bytes {1} [built]
+ amd require ./b [2] ./example.js 1:0-52
+ cjs require ./b [2] ./example.js 4:1-15
+ require.ensure item ./b [2] ./example.js 10:1-12:3
+ require.ensure item ./b [2] ./example.js 13:1-15:3
+chunk {2} 2.output.js 21 bytes <{7}> ={0}= >{1}< >{5}< >{6}< [rendered]
> [2] ./example.js 8:0-16:2
[5] ./e.js 21 bytes {2} [built]
require.ensure item ./e [2] ./example.js 8:0-16:2
-chunk {3} 3.output.js 21 bytes {7} [rendered]
+chunk {3} 3.output.js 21 bytes <{7}> ={0}= ={1}= [rendered]
> [2] ./example.js 3:0-6:2
- [4] ./d.js 21 bytes {3} [built]
+ [6] ./d.js 21 bytes {3} [built]
cjs require ./d [2] ./example.js 5:1-15
-chunk {4} 4.output.js 21 bytes {7} [rendered]
- > [2] ./example.js 1:0-52
- [3] ./c.js 21 bytes {4} [built]
+chunk {4} 4.output.js 21 bytes <{7}> ={0}= ={1}= [rendered]
+ > ./a ./b ./c [2] ./example.js 1:0-52
+ [7] ./c.js 21 bytes {4} [built]
amd require ./c [2] ./example.js 1:0-52
-chunk {5} 5.output.js 21 bytes {2} [rendered]
+chunk {5} 5.output.js 21 bytes <{0}> <{2}> ={1}= [rendered]
> [2] ./example.js 13:1-15:3
- [7] ./g.js 21 bytes {5} [built]
+ [3] ./g.js 21 bytes {5} [built]
cjs require ./g [2] ./example.js 14:2-16
-chunk {6} 6.output.js 21 bytes {2} [rendered]
+chunk {6} 6.output.js 21 bytes <{0}> <{2}> ={1}= [rendered]
> [2] ./example.js 10:1-12:3
- [6] ./f.js 21 bytes {6} [built]
+ [4] ./f.js 21 bytes {6} [built]
cjs require ./f [2] ./example.js 11:2-16
-chunk {7} output.js (main) 362 bytes [entry] [rendered]
- > main [2] ./example.js
+chunk {7} output.js (main) 362 bytes >{0}< >{1}< >{2}< >{3}< >{4}< [entry] [rendered]
+ > .\example.js main
[2] ./example.js 362 bytes {7} [built]
+ single entry .\example.js main
```
-## Minimized (uglify-js, no zip)
+## Production mode
```
-Hash: 37a3748d37b36bc162d0
-Version: webpack 3.5.1
+Hash: 0a1b2c3d4e5f6a7b8c9d
+Version: webpack 4.0.0-beta.2
Asset Size Chunks Chunk Names
-0.output.js 50 bytes 0 [emitted] async2
-1.output.js 49 bytes 1 [emitted] async1
-2.output.js 51 bytes 2 [emitted]
-3.output.js 51 bytes 3 [emitted]
-4.output.js 51 bytes 4 [emitted]
-5.output.js 51 bytes 5 [emitted]
-6.output.js 51 bytes 6 [emitted]
- output.js 1.79 kB 7 [emitted] main
+0.output.js 90 bytes 0 [emitted]
+1.output.js 89 bytes 1 [emitted]
+2.output.js 91 bytes 2 [emitted]
+3.output.js 91 bytes 3 [emitted]
+4.output.js 91 bytes 4 [emitted]
+5.output.js 91 bytes 5 [emitted]
+6.output.js 91 bytes 6 [emitted]
+ output.js 2.02 KiB 7 [emitted] main
Entrypoint main = output.js
-chunk {0} 0.output.js (async2) 21 bytes {2} {7} [rendered]
- > async commons duplicate [2] ./example.js 1:0-52
- > async commons duplicate [2] ./example.js 3:0-6:2
- > async commons duplicate [2] ./example.js 10:1-12:3
- > async commons duplicate [2] ./example.js 13:1-15:3
- [1] ./b.js 21 bytes {0} [built]
- amd require ./b [2] ./example.js 1:0-52
- cjs require ./b [2] ./example.js 4:1-15
- require.ensure item ./b [2] ./example.js 10:1-12:3
- require.ensure item ./b [2] ./example.js 13:1-15:3
-chunk {1} 1.output.js (async1) 21 bytes {7} [rendered]
- > async commons [2] ./example.js 1:0-52
- > async commons [2] ./example.js 3:0-6:2
- > async commons [2] ./example.js 8:0-16:2
- [0] ./a.js 21 bytes {1} [built]
+chunk {0} 0.output.js 21 bytes <{7}> ={1}= ={2}= ={3}= ={4}= >{1}< >{5}< >{6}< [rendered] split chunk (cache group: default)
+ > ./a ./b ./c [2] ./example.js 1:0-52
+ > [2] ./example.js 3:0-6:2
+ > [2] ./example.js 8:0-16:2
+ [1] ./a.js 21 bytes {0} [built]
amd require ./a [2] ./example.js 1:0-52
require.ensure item ./a [2] ./example.js 3:0-6:2
require.ensure item ./a [2] ./example.js 8:0-16:2
cjs require ./a [2] ./example.js 9:1-15
-chunk {2} 2.output.js 21 bytes {7} [rendered]
+chunk {1} 1.output.js 21 bytes <{0}> <{2}> <{7}> ={0}= ={3}= ={4}= ={5}= ={6}= [rendered] split chunk (cache group: default)
+ > [2] ./example.js 10:1-12:3
+ > [2] ./example.js 13:1-15:3
+ > ./a ./b ./c [2] ./example.js 1:0-52
+ > [2] ./example.js 3:0-6:2
+ [0] ./b.js 21 bytes {1} [built]
+ amd require ./b [2] ./example.js 1:0-52
+ cjs require ./b [2] ./example.js 4:1-15
+ require.ensure item ./b [2] ./example.js 10:1-12:3
+ require.ensure item ./b [2] ./example.js 13:1-15:3
+chunk {2} 2.output.js 21 bytes <{7}> ={0}= >{1}< >{5}< >{6}< [rendered]
> [2] ./example.js 8:0-16:2
[5] ./e.js 21 bytes {2} [built]
require.ensure item ./e [2] ./example.js 8:0-16:2
-chunk {3} 3.output.js 21 bytes {7} [rendered]
+chunk {3} 3.output.js 21 bytes <{7}> ={0}= ={1}= [rendered]
> [2] ./example.js 3:0-6:2
- [4] ./d.js 21 bytes {3} [built]
+ [6] ./d.js 21 bytes {3} [built]
cjs require ./d [2] ./example.js 5:1-15
-chunk {4} 4.output.js 21 bytes {7} [rendered]
- > [2] ./example.js 1:0-52
- [3] ./c.js 21 bytes {4} [built]
+chunk {4} 4.output.js 21 bytes <{7}> ={0}= ={1}= [rendered]
+ > ./a ./b ./c [2] ./example.js 1:0-52
+ [7] ./c.js 21 bytes {4} [built]
amd require ./c [2] ./example.js 1:0-52
-chunk {5} 5.output.js 21 bytes {2} [rendered]
+chunk {5} 5.output.js 21 bytes <{0}> <{2}> ={1}= [rendered]
> [2] ./example.js 13:1-15:3
- [7] ./g.js 21 bytes {5} [built]
+ [3] ./g.js 21 bytes {5} [built]
cjs require ./g [2] ./example.js 14:2-16
-chunk {6} 6.output.js 21 bytes {2} [rendered]
+chunk {6} 6.output.js 21 bytes <{0}> <{2}> ={1}= [rendered]
> [2] ./example.js 10:1-12:3
- [6] ./f.js 21 bytes {6} [built]
+ [4] ./f.js 21 bytes {6} [built]
cjs require ./f [2] ./example.js 11:2-16
-chunk {7} output.js (main) 362 bytes [entry] [rendered]
- > main [2] ./example.js
+chunk {7} output.js (main) 362 bytes >{0}< >{1}< >{2}< >{3}< >{4}< [entry] [rendered]
+ > .\example.js main
[2] ./example.js 362 bytes {7} [built]
+ single entry .\example.js main
```
diff --git a/examples/extra-async-chunk-advanced/template.md b/examples/extra-async-chunk-advanced/template.md
index ebdb9e3a..89d6b1b9 100644
--- a/examples/extra-async-chunk-advanced/template.md
+++ b/examples/extra-async-chunk-advanced/template.md
@@ -12,22 +12,22 @@
{{webpack.config.js}}
```
-# js/output.js
+# dist/output.js
``` javascript
-{{js/output.js}}
+{{dist/output.js}}
```
# Info
-## Uncompressed
+## Unoptimized
```
{{stdout}}
```
-## Minimized (uglify-js, no zip)
+## Production mode
```
-{{min:stdout}}
+{{production:stdout}}
```
diff --git a/examples/extra-async-chunk-advanced/webpack.config.js b/examples/extra-async-chunk-advanced/webpack.config.js
index 33a80ed0..1ea01151 100644
--- a/examples/extra-async-chunk-advanced/webpack.config.js
+++ b/examples/extra-async-chunk-advanced/webpack.config.js
@@ -1,18 +1,9 @@
-var CommonsChunkPlugin = require("../../lib/optimize/CommonsChunkPlugin");
-
module.exports = {
- plugins: [
- new CommonsChunkPlugin({
- name: "main",
- async: "async1"
- }),
- new CommonsChunkPlugin({
- name: "main",
- async: "async2",
- minChunks: 2
- }),
- new CommonsChunkPlugin({
- async: true
- }),
- ]
+ // mode: "development || "production",
+ optimization: {
+ splitChunks: {
+ minSize: 0 // This example is too small
+ },
+ occurrenceOrder: true // To keep filename consistent between different modes (for example building only)
+ }
};
diff --git a/examples/extra-async-chunk/README.md b/examples/extra-async-chunk/README.md
index 26fd79b6..db22c4dc 100644
--- a/examples/extra-async-chunk/README.md
+++ b/examples/extra-async-chunk/README.md
@@ -1,6 +1,4 @@
-This example shows how to create a async loaded commons chunk.
-
-When a chunk has many child chunks which share common modules the `CommonsChunkPlugin` can extract these common modules into a commons chunk which is loaded in parallel to the requested child chunk.
+This example shows automatically created async commons chunks.
The example entry references two chunks:
@@ -16,7 +14,9 @@ The example entry references two chunks:
* module `b`
* module `d`
-These chunks share modules `a` and `b`. The `CommonsChunkPlugin` extract these into chunk Z:
+These chunks share modules `a` and `b`. The optimization extract these into chunk Z:
+
+Note: Actually the optimization compare size of chunk Z to some minimum value, but this is disabled from this example. In pratice there is no configuration needed for this.
* entry chunk
* async require -> chunk X & Z
@@ -36,7 +36,7 @@ Pretty useful for a router in a SPA.
``` javascript
// a chunks with a, b, c
-require(["./a", "./b", "./c"], function(a, b, c) {});
+require(["./a", "./b", "./c"]);
// a chunk with a, b, d
require.ensure(["./a"], function(require) {
@@ -45,37 +45,20 @@ require.ensure(["./a"], function(require) {
});
```
-# webpack.config.js
-
-``` javascript
-var CommonsChunkPlugin = require("../../lib/optimize/CommonsChunkPlugin");
-
-module.exports = {
- plugins: [
- new CommonsChunkPlugin({
- // process all children of the main chunk
- // if omitted it would process all chunks
- name: "main",
- // create a additional async chunk for the common modules
- // which is loaded in parallel to the requested chunks
- async: true
- })
- ]
-};
-```
-
-# js/output.js
+# dist/output.js
<details><summary><code>/******/ (function(modules) { /* webpackBootstrap */ })</code></summary>
``` javascript
/******/ (function(modules) { // webpackBootstrap
/******/ // install a JSONP callback for chunk loading
-/******/ var parentJsonpFunction = window["webpackJsonp"];
-/******/ window["webpackJsonp"] = function webpackJsonpCallback(chunkIds, moreModules, executeModules) {
+/******/ function webpackJsonpCallback(data) {
+/******/ var chunkIds = data[0];
+/******/ var moreModules = data[1]
+/******/
/******/ // add "moreModules" to the modules object,
/******/ // then flag all "chunkIds" as loaded and fire callback
-/******/ var moduleId, chunkId, i = 0, resolves = [], result;
+/******/ var moduleId, chunkId, i = 0, resolves = [];
/******/ for(;i < chunkIds.length; i++) {
/******/ chunkId = chunkIds[i];
/******/ if(installedChunks[chunkId]) {
@@ -88,21 +71,24 @@ module.exports = {
/******/ modules[moduleId] = moreModules[moduleId];
/******/ }
/******/ }
-/******/ if(parentJsonpFunction) parentJsonpFunction(chunkIds, moreModules, executeModules);
+/******/ if(parentJsonpFunction) parentJsonpFunction(data);
/******/ while(resolves.length) {
/******/ resolves.shift()();
/******/ }
/******/
/******/ };
/******/
+/******/
/******/ // The module cache
/******/ var installedModules = {};
/******/
-/******/ // objects to store loaded and loading chunks
+/******/ // object to store loaded and loading chunks
/******/ var installedChunks = {
/******/ 3: 0
/******/ };
/******/
+/******/
+/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
@@ -130,51 +116,60 @@ module.exports = {
/******/ // This file contains only the entry chunk.
/******/ // The chunk loading function for additional chunks
/******/ __webpack_require__.e = function requireEnsure(chunkId) {
+/******/ var promises = [];
+/******/
+/******/
+/******/ // JSONP chunk loading for javascript
+/******/
/******/ var installedChunkData = installedChunks[chunkId];
-/******/ if(installedChunkData === 0) {
-/******/ return new Promise(function(resolve) { resolve(); });
-/******/ }
+/******/ if(installedChunkData !== 0) { // 0 means "already installed".
/******/
-/******/ // a Promise means "currently loading".
-/******/ if(installedChunkData) {
-/******/ return installedChunkData[2];
-/******/ }
+/******/ // a Promise means "currently loading".
+/******/ if(installedChunkData) {
+/******/ promises.push(installedChunkData[2]);
+/******/ } else {
+/******/ // setup Promise in chunk cache
+/******/ var promise = new Promise(function(resolve, reject) {
+/******/ installedChunkData = installedChunks[chunkId] = [resolve, reject];
+/******/ });
+/******/ promises.push(installedChunkData[2] = promise);
/******/
-/******/ // setup Promise in chunk cache
-/******/ var promise = new Promise(function(resolve, reject) {
-/******/ installedChunkData = installedChunks[chunkId] = [resolve, reject];
-/******/ });
-/******/ installedChunkData[2] = promise;
+/******/ // start chunk loading
+/******/ var head = document.getElementsByTagName('head')[0];
+/******/ var script = document.createElement('script');
/******/
-/******/ // start chunk loading
-/******/ var head = document.getElementsByTagName('head')[0];
-/******/ var script = document.createElement('script');
-/******/ script.type = 'text/javascript';
-/******/ script.charset = 'utf-8';
-/******/ script.async = true;
-/******/ script.timeout = 120000;
+/******/ script.charset = 'utf-8';
+/******/ script.timeout = 120000;
/******/
-/******/ if (__webpack_require__.nc) {
-/******/ script.setAttribute("nonce", __webpack_require__.nc);
-/******/ }
-/******/ script.src = __webpack_require__.p + "" + chunkId + ".output.js";
-/******/ var timeout = setTimeout(onScriptComplete, 120000);
-/******/ script.onerror = script.onload = onScriptComplete;
-/******/ function onScriptComplete() {
-/******/ // avoid mem leaks in IE.
-/******/ script.onerror = script.onload = null;
-/******/ clearTimeout(timeout);
-/******/ var chunk = installedChunks[chunkId];
-/******/ if(chunk !== 0) {
-/******/ if(chunk) {
-/******/ chunk[1](new Error('Loading chunk ' + chunkId + ' failed.'));
+/******/ if (__webpack_require__.nc) {
+/******/ script.setAttribute("nonce", __webpack_require__.nc);
/******/ }
-/******/ installedChunks[chunkId] = undefined;
+/******/ script.src = __webpack_require__.p + "" + chunkId + ".output.js";
+/******/ var timeout = setTimeout(function(){
+/******/ onScriptComplete({ type: 'timeout', target: script });
+/******/ }, 120000);
+/******/ script.onerror = script.onload = onScriptComplete;
+/******/ function onScriptComplete(event) {
+/******/ // avoid mem leaks in IE.
+/******/ script.onerror = script.onload = null;
+/******/ clearTimeout(timeout);
+/******/ var chunk = installedChunks[chunkId];
+/******/ if(chunk !== 0) {
+/******/ if(chunk) {
+/******/ var errorType = event && (event.type === 'load' ? 'missing' : event.type);
+/******/ var realSrc = event && event.target && event.target.src;
+/******/ var error = new Error('Loading chunk ' + chunkId + ' failed.\n(' + errorType + ': ' + realSrc + ')');
+/******/ error.type = errorType;
+/******/ error.request = realSrc;
+/******/ chunk[1](error);
+/******/ }
+/******/ installedChunks[chunkId] = undefined;
+/******/ }
+/******/ };
+/******/ head.appendChild(script);
/******/ }
-/******/ };
-/******/ head.appendChild(script);
-/******/
-/******/ return promise;
+/******/ }
+/******/ return Promise.all(promises);
/******/ };
/******/
/******/ // expose the modules object (__webpack_modules__)
@@ -194,6 +189,11 @@ module.exports = {
/******/ }
/******/ };
/******/
+/******/ // define __esModule on exports
+/******/ __webpack_require__.r = function(exports) {
+/******/ Object.defineProperty(exports, '__esModule', { value: true });
+/******/ };
+/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
@@ -207,11 +207,19 @@ module.exports = {
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
-/******/ __webpack_require__.p = "js/";
+/******/ __webpack_require__.p = "dist/";
/******/
/******/ // on error function for async loading
/******/ __webpack_require__.oe = function(err) { console.error(err); throw err; };
/******/
+/******/ var jsonpArray = window["webpackJsonp"] = window["webpackJsonp"] || [];
+/******/ var oldJsonpFunction = jsonpArray.push.bind(jsonpArray);
+/******/ jsonpArray.push = webpackJsonpCallback;
+/******/ jsonpArray = jsonpArray.slice();
+/******/ for(var i = 0; i < jsonpArray.length; i++) webpackJsonpCallback(jsonpArray[i]);
+/******/ var parentJsonpFunction = oldJsonpFunction;
+/******/
+/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 2);
/******/ })
@@ -228,16 +236,15 @@ module.exports = {
!*** ./example.js ***!
\********************/
/*! no static exports found */
-/*! all exports used */
/***/ (function(module, exports, __webpack_require__) {
// a chunks with a, b, c
-Promise.all/* require */([__webpack_require__.e(0), __webpack_require__.e(2)]).then(function() { var __WEBPACK_AMD_REQUIRE_ARRAY__ = [__webpack_require__(/*! ./a */ 0), __webpack_require__(/*! ./b */ 1), __webpack_require__(/*! ./c */ 3)]; (function(a, b, c) {}.apply(null, __WEBPACK_AMD_REQUIRE_ARRAY__));}).catch(__webpack_require__.oe);
+Promise.all(/*! AMD require */[__webpack_require__.e(0), __webpack_require__.e(2)]).then(function() {[__webpack_require__(/*! ./a */ 1), __webpack_require__(/*! ./b */ 0), __webpack_require__(/*! ./c */ 4)];}).catch(__webpack_require__.oe);
// a chunk with a, b, d
-Promise.all/* require.ensure */([__webpack_require__.e(0), __webpack_require__.e(1)]).then((function(require) {
- __webpack_require__(/*! ./b */ 1);
- __webpack_require__(/*! ./d */ 4);
+Promise.all(/*! require.ensure */[__webpack_require__.e(0), __webpack_require__.e(1)]).then((function(require) {
+ __webpack_require__(/*! ./b */ 0);
+ __webpack_require__(/*! ./d */ 3);
}).bind(null, __webpack_require__)).catch(__webpack_require__.oe);
@@ -246,139 +253,137 @@ Promise.all/* require.ensure */([__webpack_require__.e(0), __webpack_require__.e
/******/ });
```
-# js/0.output.js
+# dist/0.output.js
``` javascript
-webpackJsonp([0],[
+(window["webpackJsonp"] = window["webpackJsonp"] || []).push([[0],[
/* 0 */
/*!**************!*\
- !*** ./a.js ***!
+ !*** ./b.js ***!
\**************/
/*! no static exports found */
-/*! all exports used */
/***/ (function(module, exports) {
-module.exports = "a";
+module.exports = "b";
/***/ }),
/* 1 */
/*!**************!*\
- !*** ./b.js ***!
+ !*** ./a.js ***!
\**************/
/*! no static exports found */
-/*! all exports used */
/***/ (function(module, exports) {
-module.exports = "b";
+module.exports = "a";
/***/ })
-]);
+]]);
```
-# js/1.output.js
+# dist/1.output.js
``` javascript
-webpackJsonp([1],{
+(window["webpackJsonp"] = window["webpackJsonp"] || []).push([[1],{
-/***/ 4:
+/***/ 3:
/*!**************!*\
!*** ./d.js ***!
\**************/
/*! no static exports found */
-/*! all exports used */
/***/ (function(module, exports) {
module.exports = "d";
/***/ })
-});
+}]);
```
-# js/2.output.js
+# dist/2.output.js
``` javascript
-webpackJsonp([2],{
+(window["webpackJsonp"] = window["webpackJsonp"] || []).push([[2],{
-/***/ 3:
+/***/ 4:
/*!**************!*\
!*** ./c.js ***!
\**************/
/*! no static exports found */
-/*! all exports used */
/***/ (function(module, exports) {
module.exports = "c";
/***/ })
-});
+}]);
```
# Info
-## Uncompressed
+## Unoptimized
```
-Hash: ca87dc9e54fc3309c0fd
-Version: webpack 3.5.1
+Hash: 0a1b2c3d4e5f6a7b8c9d
+Version: webpack 4.0.0-beta.2
Asset Size Chunks Chunk Names
-0.output.js 403 bytes 0 [emitted]
-1.output.js 215 bytes 1 [emitted]
-2.output.js 215 bytes 2 [emitted]
- output.js 6.56 kB 3 [emitted] main
+0.output.js 405 bytes 0 [emitted]
+1.output.js 241 bytes 1 [emitted]
+2.output.js 241 bytes 2 [emitted]
+ output.js 7.32 KiB 3 [emitted] main
Entrypoint main = output.js
-chunk {0} 0.output.js 42 bytes {3} [rendered]
- > async commons [2] ./example.js 2:0-52
- > async commons [2] ./example.js 5:0-8:2
- [0] ./a.js 21 bytes {0} [built]
- amd require ./a [2] ./example.js 2:0-52
- require.ensure item ./a [2] ./example.js 5:0-8:2
- [1] ./b.js 21 bytes {0} [built]
- amd require ./b [2] ./example.js 2:0-52
+chunk {0} 0.output.js 42 bytes <{3}> ={1}= ={2}= [rendered] split chunk (cache group: default)
+ > ./a ./b ./c [2] ./example.js 2:0-30
+ > [2] ./example.js 5:0-8:2
+ [0] ./b.js 21 bytes {0} [built]
+ amd require ./b [2] ./example.js 2:0-30
cjs require ./b [2] ./example.js 6:1-15
-chunk {1} 1.output.js 21 bytes {3} [rendered]
+ [1] ./a.js 21 bytes {0} [built]
+ amd require ./a [2] ./example.js 2:0-30
+ require.ensure item ./a [2] ./example.js 5:0-8:2
+chunk {1} 1.output.js 21 bytes <{3}> ={0}= [rendered]
> [2] ./example.js 5:0-8:2
- [4] ./d.js 21 bytes {1} [built]
+ [3] ./d.js 21 bytes {1} [built]
cjs require ./d [2] ./example.js 7:1-15
-chunk {2} 2.output.js 21 bytes {3} [rendered]
- > [2] ./example.js 2:0-52
- [3] ./c.js 21 bytes {2} [built]
- amd require ./c [2] ./example.js 2:0-52
-chunk {3} output.js (main) 194 bytes [entry] [rendered]
- > main [2] ./example.js
- [2] ./example.js 194 bytes {3} [built]
+chunk {2} 2.output.js 21 bytes <{3}> ={0}= [rendered]
+ > ./a ./b ./c [2] ./example.js 2:0-30
+ [4] ./c.js 21 bytes {2} [built]
+ amd require ./c [2] ./example.js 2:0-30
+chunk {3} output.js (main) 172 bytes >{0}< >{1}< >{2}< [entry] [rendered]
+ > .\example.js main
+ [2] ./example.js 172 bytes {3} [built]
+ single entry .\example.js main
```
-## Minimized (uglify-js, no zip)
+## Production mode
```
-Hash: ca87dc9e54fc3309c0fd
-Version: webpack 3.5.1
- Asset Size Chunks Chunk Names
-0.output.js 78 bytes 0 [emitted]
-1.output.js 51 bytes 1 [emitted]
-2.output.js 51 bytes 2 [emitted]
- output.js 1.54 kB 3 [emitted] main
+Hash: 0a1b2c3d4e5f6a7b8c9d
+Version: webpack 4.0.0-beta.2
+ Asset Size Chunks Chunk Names
+0.output.js 118 bytes 0 [emitted]
+1.output.js 91 bytes 1 [emitted]
+2.output.js 91 bytes 2 [emitted]
+ output.js 1.73 KiB 3 [emitted] main
Entrypoint main = output.js
-chunk {0} 0.output.js 42 bytes {3} [rendered]
- > async commons [2] ./example.js 2:0-52
- > async commons [2] ./example.js 5:0-8:2
- [0] ./a.js 21 bytes {0} [built]
- amd require ./a [2] ./example.js 2:0-52
- require.ensure item ./a [2] ./example.js 5:0-8:2
- [1] ./b.js 21 bytes {0} [built]
- amd require ./b [2] ./example.js 2:0-52
+chunk {0} 0.output.js 42 bytes <{3}> ={1}= ={2}= [rendered] split chunk (cache group: default)
+ > ./a ./b ./c [2] ./example.js 2:0-30
+ > [2] ./example.js 5:0-8:2
+ [0] ./b.js 21 bytes {0} [built]
+ amd require ./b [2] ./example.js 2:0-30
cjs require ./b [2] ./example.js 6:1-15
-chunk {1} 1.output.js 21 bytes {3} [rendered]
+ [1] ./a.js 21 bytes {0} [built]
+ amd require ./a [2] ./example.js 2:0-30
+ require.ensure item ./a [2] ./example.js 5:0-8:2
+chunk {1} 1.output.js 21 bytes <{3}> ={0}= [rendered]
> [2] ./example.js 5:0-8:2
- [4] ./d.js 21 bytes {1} [built]
+ [3] ./d.js 21 bytes {1} [built]
cjs require ./d [2] ./example.js 7:1-15
-chunk {2} 2.output.js 21 bytes {3} [rendered]
- > [2] ./example.js 2:0-52
- [3] ./c.js 21 bytes {2} [built]
- amd require ./c [2] ./example.js 2:0-52
-chunk {3} output.js (main) 194 bytes [entry] [rendered]
- > main [2] ./example.js
- [2] ./example.js 194 bytes {3} [built]
+chunk {2} 2.output.js 21 bytes <{3}> ={0}= [rendered]
+ > ./a ./b ./c [2] ./example.js 2:0-30
+ [4] ./c.js 21 bytes {2} [built]
+ amd require ./c [2] ./example.js 2:0-30
+chunk {3} output.js (main) 172 bytes >{0}< >{1}< >{2}< [entry] [rendered]
+ > .\example.js main
+ [2] ./example.js 172 bytes {3} [built]
+ single entry .\example.js main
```
diff --git a/examples/extra-async-chunk/example.js b/examples/extra-async-chunk/example.js
index 8fa7384c..c2dcc270 100644
--- a/examples/extra-async-chunk/example.js
+++ b/examples/extra-async-chunk/example.js
@@ -1,5 +1,5 @@
// a chunks with a, b, c
-require(["./a", "./b", "./c"], function(a, b, c) {});
+require(["./a", "./b", "./c"]);
// a chunk with a, b, d
require.ensure(["./a"], function(require) {
diff --git a/examples/extra-async-chunk/template.md b/examples/extra-async-chunk/template.md
index 572c18da..afe51efe 100644
--- a/examples/extra-async-chunk/template.md
+++ b/examples/extra-async-chunk/template.md
@@ -1,6 +1,4 @@
-This example shows how to create a async loaded commons chunk.
-
-When a chunk has many child chunks which share common modules the `CommonsChunkPlugin` can extract these common modules into a commons chunk which is loaded in parallel to the requested child chunk.
+This example shows automatically created async commons chunks.
The example entry references two chunks:
@@ -16,7 +14,9 @@ The example entry references two chunks:
* module `b`
* module `d`
-These chunks share modules `a` and `b`. The `CommonsChunkPlugin` extract these into chunk Z:
+These chunks share modules `a` and `b`. The optimization extract these into chunk Z:
+
+Note: Actually the optimization compare size of chunk Z to some minimum value, but this is disabled from this example. In pratice there is no configuration needed for this.
* entry chunk
* async require -> chunk X & Z
@@ -38,46 +38,40 @@ Pretty useful for a router in a SPA.
{{example.js}}
```
-# webpack.config.js
-
-``` javascript
-{{webpack.config.js}}
-```
-
-# js/output.js
+# dist/output.js
``` javascript
-{{js/output.js}}
+{{dist/output.js}}
```
-# js/0.output.js
+# dist/0.output.js
``` javascript
-{{js/0.output.js}}
+{{dist/0.output.js}}
```
-# js/1.output.js
+# dist/1.output.js
``` javascript
-{{js/1.output.js}}
+{{dist/1.output.js}}
```
-# js/2.output.js
+# dist/2.output.js
``` javascript
-{{js/2.output.js}}
+{{dist/2.output.js}}
```
# Info
-## Uncompressed
+## Unoptimized
```
{{stdout}}
```
-## Minimized (uglify-js, no zip)
+## Production mode
```
-{{min:stdout}}
+{{production:stdout}}
```
diff --git a/examples/extra-async-chunk/webpack.config.js b/examples/extra-async-chunk/webpack.config.js
index f0331d1c..1ea01151 100644
--- a/examples/extra-async-chunk/webpack.config.js
+++ b/examples/extra-async-chunk/webpack.config.js
@@ -1,14 +1,9 @@
-var CommonsChunkPlugin = require("../../lib/optimize/CommonsChunkPlugin");
-
module.exports = {
- plugins: [
- new CommonsChunkPlugin({
- // process all children of the main chunk
- // if omitted it would process all chunks
- name: "main",
- // create a additional async chunk for the common modules
- // which is loaded in parallel to the requested chunks
- async: true
- })
- ]
+ // mode: "development || "production",
+ optimization: {
+ splitChunks: {
+ minSize: 0 // This example is too small
+ },
+ occurrenceOrder: true // To keep filename consistent between different modes (for example building only)
+ }
};
diff --git a/examples/harmony-interop/README.md b/examples/harmony-interop/README.md
index 5a82efe7..bb181491 100644
--- a/examples/harmony-interop/README.md
+++ b/examples/harmony-interop/README.md
@@ -64,7 +64,7 @@ export default "default";
export var named = "named";
```
-# js/output.js
+# dist/output.js
<details><summary><code>/******/ (function(modules) { /* webpackBootstrap */ })</code></summary>
@@ -115,6 +115,11 @@ export var named = "named";
/******/ }
/******/ };
/******/
+/******/ // define __esModule on exports
+/******/ __webpack_require__.r = function(exports) {
+/******/ Object.defineProperty(exports, '__esModule', { value: true });
+/******/ };
+/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
@@ -128,10 +133,11 @@ export var named = "named";
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
-/******/ __webpack_require__.p = "js/";
+/******/ __webpack_require__.p = "dist/";
+/******/
/******/
/******/ // Load entry module and return exports
-/******/ return __webpack_require__(__webpack_require__.s = 1);
+/******/ return __webpack_require__(__webpack_require__.s = 0);
/******/ })
/************************************************************************/
```
@@ -141,69 +147,67 @@ export var named = "named";
``` javascript
/******/ ([
/* 0 */
-/*!***************!*\
- !*** ./fs.js ***!
- \***************/
-/*! no static exports found */
-/*! exports used: default, readFile */
-/***/ (function(module, exports) {
-
-// an example CommonJs module
-// content is omitted for brevity
-exports.readFile = function() {};
-// using module.exports would be equivalent,
-// webpack doesn't care which syntax is used
-
-// AMD modules are also possible and equvivalent to CommonJs modules
-
-
-/***/ }),
-/* 1 */
/*!********************!*\
!*** ./example.js ***!
\********************/
-/*! exports provided: */
-/*! all exports used */
+/*! no exports provided */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
-Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
-/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__fs__ = __webpack_require__(/*! ./fs */ 0);
-/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__fs___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0__fs__);
-/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__reexport_commonjs__ = __webpack_require__(/*! ./reexport-commonjs */ 2);
-/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__example2__ = __webpack_require__(/*! ./example2 */ 3);
-/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__example2___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_2__example2__);
+__webpack_require__.r(__webpack_exports__);
+/* harmony import */ var _fs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./fs */ 1);
+/* harmony import */ var _fs__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_fs__WEBPACK_IMPORTED_MODULE_0__);
+/* harmony import */ var _reexport_commonjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./reexport-commonjs */ 2);
+/* harmony import */ var _example2__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./example2 */ 3);
+/* harmony import */ var _example2__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_example2__WEBPACK_IMPORTED_MODULE_2__);
// harmony module
// import from CommonJs module
-__WEBPACK_IMPORTED_MODULE_0__fs___default.a.readFile("file");
-Object(__WEBPACK_IMPORTED_MODULE_0__fs__["readFile"])("file");
-__WEBPACK_IMPORTED_MODULE_0__fs__["readFile"]("file");
+_fs__WEBPACK_IMPORTED_MODULE_0___default.a.readFile("file");
+Object(_fs__WEBPACK_IMPORTED_MODULE_0__["readFile"])("file");
+_fs__WEBPACK_IMPORTED_MODULE_0__["readFile"]("file");
// import from harmony module
-Object(__WEBPACK_IMPORTED_MODULE_1__reexport_commonjs__["readFile"])("file");
+Object(_reexport_commonjs__WEBPACK_IMPORTED_MODULE_1__["readFile"])("file");
// import a CommonJs module for sideeffects
+/***/ }),
+/* 1 */
+/*!***************!*\
+ !*** ./fs.js ***!
+ \***************/
+/*! no static exports found */
+/***/ (function(module, exports) {
+
+// an example CommonJs module
+// content is omitted for brevity
+exports.readFile = function() {};
+// using module.exports would be equivalent,
+// webpack doesn't care which syntax is used
+
+// AMD modules are also possible and equvivalent to CommonJs modules
+
+
/***/ }),
/* 2 */
/*!******************************!*\
!*** ./reexport-commonjs.js ***!
\******************************/
/*! no static exports found */
-/*! exports used: readFile */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
-/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__fs__ = __webpack_require__(/*! ./fs */ 0);
-/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__fs___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0__fs__);
-/* harmony namespace reexport (by used) */ if(__webpack_require__.o(__WEBPACK_IMPORTED_MODULE_0__fs__, "readFile")) __webpack_require__.d(__webpack_exports__, "readFile", function() { return __WEBPACK_IMPORTED_MODULE_0__fs__["readFile"]; });
+__webpack_require__.r(__webpack_exports__);
+/* harmony import */ var _fs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./fs */ 1);
+/* harmony import */ var _fs__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_fs__WEBPACK_IMPORTED_MODULE_0__);
+/* harmony reexport (unknown) */ for(var __WEBPACK_IMPORT_KEY__ in _fs__WEBPACK_IMPORTED_MODULE_0__) if(__WEBPACK_IMPORT_KEY__ !== 'default') (function(key) { __webpack_require__.d(__webpack_exports__, key, function() { return _fs__WEBPACK_IMPORTED_MODULE_0__[key]; }) }(__WEBPACK_IMPORT_KEY__));
// reexport a CommonJs module
// Note that the default export doesn't reexport via export *
@@ -236,11 +240,10 @@ var namedExport = module.named;
!*** ./harmony.js ***!
\********************/
/*! exports provided: default, named */
-/*! all exports used */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
-Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
+__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "named", function() { return named; });
// just some exports
/* harmony default export */ __webpack_exports__["default"] = ("default");
@@ -253,60 +256,69 @@ var named = "named";
# Info
-## Uncompressed
+## Unoptimized
```
-Hash: 756e5e3b676506d280a4
-Version: webpack 3.5.1
- Asset Size Chunks Chunk Names
-output.js 6.13 kB 0 [emitted] main
+Hash: 0a1b2c3d4e5f6a7b8c9d
+Version: webpack 4.0.0-beta.2
+ Asset Size Chunks Chunk Names
+output.js 6.13 KiB 0 [emitted] main
Entrypoint main = output.js
-chunk {0} output.js (main) 1.2 kB [entry] [rendered]
- > main [1] ./example.js
- [0] ./fs.js 265 bytes {0} [built]
- [only some exports used: default, readFile]
- harmony import ./fs [1] ./example.js 4:0-22
- harmony import ./fs [1] ./example.js 5:0-32
- harmony import ./fs [1] ./example.js 6:0-28
- harmony import ./fs [2] ./reexport-commonjs.js 2:0-21
- [1] ./example.js 389 bytes {0} [built]
+chunk {0} output.js (main) 1.17 KiB [entry] [rendered]
+ > .\example.js main
+ [0] ./example.js 389 bytes {0} [built]
[no exports]
+ single entry .\example.js main
+ [1] ./fs.js 265 bytes {0} [built]
+ harmony side effect evaluation ./fs [0] ./example.js 4:0-22
+ harmony side effect evaluation ./fs [0] ./example.js 5:0-32
+ harmony side effect evaluation ./fs [0] ./example.js 6:0-28
+ harmony import specifier ./fs [0] ./example.js 7:0-2
+ harmony import specifier ./fs [0] ./example.js 8:0-8
+ harmony import specifier ./fs [0] ./example.js 9:0-12
+ harmony side effect evaluation ./fs [2] ./reexport-commonjs.js 2:0-21
+ harmony export imported specifier ./fs [2] ./reexport-commonjs.js 2:0-21
[2] ./reexport-commonjs.js 308 bytes {0} [built]
- [only some exports used: readFile]
- harmony import ./reexport-commonjs [1] ./example.js 12:0-60
+ harmony side effect evaluation ./reexport-commonjs [0] ./example.js 12:0-60
+ harmony import specifier ./reexport-commonjs [0] ./example.js 13:0-9
[3] ./example2.js 159 bytes {0} [built]
- [no exports used]
- harmony import ./example2 [1] ./example.js 16:0-20
+ harmony side effect evaluation ./example2 [0] ./example.js 16:0-20
[4] ./harmony.js 78 bytes {0} [built]
[exports: default, named]
cjs require ./harmony [3] ./example2.js 4:13-33
```
-## Minimized (uglify-js, no zip)
+## Production mode
```
-Hash: 756e5e3b676506d280a4
-Version: webpack 3.5.1
- Asset Size Chunks Chunk Names
-output.js 1.03 kB 0 [emitted] main
+Hash: 0a1b2c3d4e5f6a7b8c9d
+Version: webpack 4.0.0-beta.2
+ Asset Size Chunks Chunk Names
+output.js 993 bytes 0 [emitted] main
Entrypoint main = output.js
-chunk {0} output.js (main) 1.2 kB [entry] [rendered]
- > main [1] ./example.js
+chunk {0} output.js (main) 1.17 KiB [entry] [rendered]
+ > .\example.js main
[0] ./fs.js 265 bytes {0} [built]
[only some exports used: default, readFile]
- harmony import ./fs [1] ./example.js 4:0-22
- harmony import ./fs [1] ./example.js 5:0-32
- harmony import ./fs [1] ./example.js 6:0-28
- harmony import ./fs [2] ./reexport-commonjs.js 2:0-21
- [1] ./example.js 389 bytes {0} [built]
- [no exports]
- [2] ./reexport-commonjs.js 308 bytes {0} [built]
+ harmony side effect evaluation ./fs [1] ./reexport-commonjs.js 2:0-21
+ harmony export imported specifier ./fs [1] ./reexport-commonjs.js 2:0-21
+ harmony side effect evaluation ./fs [4] ./example.js 4:0-22
+ harmony side effect evaluation ./fs [4] ./example.js 5:0-32
+ harmony side effect evaluation ./fs [4] ./example.js 6:0-28
+ harmony import specifier ./fs [4] ./example.js 7:0-2
+ harmony import specifier ./fs [4] ./example.js 8:0-8
+ harmony import specifier ./fs [4] ./example.js 9:0-12
+ [1] ./reexport-commonjs.js 308 bytes {0} [built]
[only some exports used: readFile]
- harmony import ./reexport-commonjs [1] ./example.js 12:0-60
- [3] ./example2.js 159 bytes {0} [built]
- [no exports used]
- harmony import ./example2 [1] ./example.js 16:0-20
- [4] ./harmony.js 78 bytes {0} [built]
+ harmony side effect evaluation ./reexport-commonjs [4] ./example.js 12:0-60
+ harmony import specifier ./reexport-commonjs [4] ./example.js 13:0-9
+ [2] ./harmony.js 78 bytes {0} [built]
[exports: default, named]
cjs require ./harmony [3] ./example2.js 4:13-33
+ [3] ./example2.js 159 bytes {0} [built]
+ [no exports used]
+ harmony side effect evaluation ./example2 [4] ./example.js 16:0-20
+ [4] ./example.js 389 bytes {0} [built]
+ [no exports]
+ single entry .\example.js main
```
\ No newline at end of file
diff --git a/examples/harmony-interop/template.md b/examples/harmony-interop/template.md
index 812cde46..ca1a7155 100644
--- a/examples/harmony-interop/template.md
+++ b/examples/harmony-interop/template.md
@@ -29,22 +29,22 @@
{{harmony.js}}
```
-# js/output.js
+# dist/output.js
``` javascript
-{{js/output.js}}
+{{dist/output.js}}
```
# Info
-## Uncompressed
+## Unoptimized
```
{{stdout}}
```
-## Minimized (uglify-js, no zip)
+## Production mode
```
-{{min:stdout}}
+{{production:stdout}}
```
\ No newline at end of file
diff --git a/examples/harmony-library/README.md b/examples/harmony-library/README.md
index 12af2314..cabdb6e8 100644
--- a/examples/harmony-library/README.md
+++ b/examples/harmony-library/README.md
@@ -3,9 +3,10 @@
``` javascript
var path = require("path");
module.exports = {
+ // mode: "development || "production",
entry: "./example",
output: {
- path: path.join(__dirname, "js"),
+ path: path.join(__dirname, "dist"),
filename: "MyLibrary.umd.js",
library: "MyLibrary",
libraryTarget: "umd"
@@ -13,7 +14,7 @@ module.exports = {
};
```
-# js/MyLibrary.umd.js
+# dist/MyLibrary.umd.js
``` javascript
(function webpackUniversalModuleDefinition(root, factory) {
@@ -25,7 +26,7 @@ module.exports = {
exports["MyLibrary"] = factory();
else
root["MyLibrary"] = factory();
-})(this, function() {
+})(window, function() {
```
<details><summary><code>return /******/ (function(modules) { /* webpackBootstrap */ })</code></summary>
@@ -76,6 +77,11 @@ return /******/ (function(modules) { // webpackBootstrap
/******/ }
/******/ };
/******/
+/******/ // define __esModule on exports
+/******/ __webpack_require__.r = function(exports) {
+/******/ Object.defineProperty(exports, '__esModule', { value: true });
+/******/ };
+/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
@@ -89,7 +95,8 @@ return /******/ (function(modules) { // webpackBootstrap
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
-/******/ __webpack_require__.p = "js/";
+/******/ __webpack_require__.p = "dist/";
+/******/
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 0);
@@ -106,13 +113,12 @@ return /******/ (function(modules) { // webpackBootstrap
!*** ./example.js ***!
\********************/
/*! exports provided: value, increment, default */
-/*! all exports used */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
-Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
+__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "value", function() { return value; });
-/* harmony export (immutable) */ __webpack_exports__["increment"] = increment;
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "increment", function() { return increment; });
var value = 0;
function increment() {
value++;
@@ -127,30 +133,32 @@ function increment() {
# Info
-## Uncompressed
+## Unoptimized
```
-Hash: 0b2bf5443af50d14e1e0
-Version: webpack 3.5.1
- Asset Size Chunks Chunk Names
-MyLibrary.umd.js 3.45 kB 0 [emitted] main
+Hash: 0a1b2c3d4e5f6a7b8c9d
+Version: webpack 4.0.0-beta.2
+ Asset Size Chunks Chunk Names
+MyLibrary.umd.js 3.56 KiB 0 [emitted] main
Entrypoint main = MyLibrary.umd.js
chunk {0} MyLibrary.umd.js (main) 97 bytes [entry] [rendered]
- > main [0] ./example.js
+ > ./example main
[0] ./example.js 97 bytes {0} [built]
[exports: value, increment, default]
+ single entry ./example main
```
-## Minimized (uglify-js, no zip)
+## Production mode
```
-Hash: 0b2bf5443af50d14e1e0
-Version: webpack 3.5.1
+Hash: 0a1b2c3d4e5f6a7b8c9d
+Version: webpack 4.0.0-beta.2
Asset Size Chunks Chunk Names
-MyLibrary.umd.js 872 bytes 0 [emitted] main
+MyLibrary.umd.js 926 bytes 0 [emitted] main
Entrypoint main = MyLibrary.umd.js
chunk {0} MyLibrary.umd.js (main) 97 bytes [entry] [rendered]
- > main [0] ./example.js
+ > ./example main
[0] ./example.js 97 bytes {0} [built]
[exports: value, increment, default]
+ single entry ./example main
```
diff --git a/examples/harmony-library/template.md b/examples/harmony-library/template.md
index d8b9c1bc..4ce63926 100644
--- a/examples/harmony-library/template.md
+++ b/examples/harmony-library/template.md
@@ -4,22 +4,22 @@
{{webpack.config.js}}
```
-# js/MyLibrary.umd.js
+# dist/MyLibrary.umd.js
``` javascript
-{{js/MyLibrary.umd.js}}
+{{dist/MyLibrary.umd.js}}
```
# Info
-## Uncompressed
+## Unoptimized
```
{{stdout}}
```
-## Minimized (uglify-js, no zip)
+## Production mode
```
-{{min:stdout}}
+{{production:stdout}}
```
diff --git a/examples/harmony-library/webpack.config.js b/examples/harmony-library/webpack.config.js
index 50ef8f0b..5700c38e 100644
--- a/examples/harmony-library/webpack.config.js
+++ b/examples/harmony-library/webpack.config.js
@@ -1,8 +1,9 @@
var path = require("path");
module.exports = {
+ // mode: "development || "production",
entry: "./example",
output: {
- path: path.join(__dirname, "js"),
+ path: path.join(__dirname, "dist"),
filename: "MyLibrary.umd.js",
library: "MyLibrary",
libraryTarget: "umd"
diff --git a/examples/harmony-unused/README.md b/examples/harmony-unused/README.md
index 099c9a50..d6fce48e 100644
--- a/examples/harmony-unused/README.md
+++ b/examples/harmony-unused/README.md
@@ -47,7 +47,7 @@ export { a, b, c } from "./abc";
export { add as reexportedAdd, multiply as reexportedMultiply } from "./math";
```
-# js/output.js
+# dist/output.js
<details><summary><code>/******/ (function(modules) { /* webpackBootstrap */ })</code></summary>
@@ -98,6 +98,11 @@ export { add as reexportedAdd, multiply as reexportedMultiply } from "./math";
/******/ }
/******/ };
/******/
+/******/ // define __esModule on exports
+/******/ __webpack_require__.r = function(exports) {
+/******/ Object.defineProperty(exports, '__esModule', { value: true });
+/******/ };
+/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
@@ -111,10 +116,11 @@ export { add as reexportedAdd, multiply as reexportedMultiply } from "./math";
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
-/******/ __webpack_require__.p = "js/";
+/******/ __webpack_require__.p = "dist/";
+/******/
/******/
/******/ // Load entry module and return exports
-/******/ return __webpack_require__(__webpack_require__.s = 1);
+/******/ return __webpack_require__(__webpack_require__.s = 0);
/******/ })
/************************************************************************/
```
@@ -124,17 +130,36 @@ export { add as reexportedAdd, multiply as reexportedMultiply } from "./math";
``` javascript
/******/ ([
/* 0 */
+/*!********************!*\
+ !*** ./example.js ***!
+ \********************/
+/*! no exports provided */
+/***/ (function(module, __webpack_exports__, __webpack_require__) {
+
+"use strict";
+__webpack_require__.r(__webpack_exports__);
+/* harmony import */ var _math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./math */ 1);
+/* harmony import */ var _library__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./library */ 2);
+
+
+
+Object(_math__WEBPACK_IMPORTED_MODULE_0__["add"])(1, 2);
+_library__WEBPACK_IMPORTED_MODULE_1__["reexportedMultiply"](1, 2);
+
+
+/***/ }),
+/* 1 */
/*!*****************!*\
!*** ./math.js ***!
\*****************/
/*! exports provided: add, multiply, list */
-/*! exports used: add, multiply */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
-/* harmony export (immutable) */ __webpack_exports__["a"] = add;
-/* harmony export (immutable) */ __webpack_exports__["b"] = multiply;
-/* unused harmony export list */
+__webpack_require__.r(__webpack_exports__);
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "add", function() { return add; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "multiply", function() { return multiply; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "list", function() { return list; });
function add() {
var sum = 0, i = 0, args = arguments, l = args.length;
while (i < l) {
@@ -157,42 +182,27 @@ function list() {
/***/ }),
-/* 1 */
+/* 2 */
/*!********************!*\
- !*** ./example.js ***!
+ !*** ./library.js ***!
\********************/
-/*! exports provided: */
-/*! all exports used */
+/*! exports provided: a, b, c, reexportedAdd, reexportedMultiply */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
-Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
-/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__math__ = __webpack_require__(/*! ./math */ 0);
-/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__library__ = __webpack_require__(/*! ./library */ 2);
+__webpack_require__.r(__webpack_exports__);
+/* harmony import */ var _abc__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./abc */ 3);
+/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _abc__WEBPACK_IMPORTED_MODULE_0__["a"]; });
+/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "b", function() { return _abc__WEBPACK_IMPORTED_MODULE_0__["b"]; });
+/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "c", function() { return _abc__WEBPACK_IMPORTED_MODULE_0__["c"]; });
-Object(__WEBPACK_IMPORTED_MODULE_0__math__["a" /* add */])(1, 2);
-__WEBPACK_IMPORTED_MODULE_1__library__["a" /* reexportedMultiply */](1, 2);
+/* harmony import */ var _math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./math */ 1);
+/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "reexportedAdd", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["add"]; });
+/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "reexportedMultiply", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["multiply"]; });
-/***/ }),
-/* 2 */
-/*!********************!*\
- !*** ./library.js ***!
- \********************/
-/*! exports provided: a, b, c, reexportedAdd, reexportedMultiply */
-/*! exports used: reexportedMultiply */
-/***/ (function(module, __webpack_exports__, __webpack_require__) {
-
-"use strict";
-/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__abc__ = __webpack_require__(/*! ./abc */ 3);
-/* unused harmony reexport a */
-/* unused harmony reexport b */
-/* unused harmony reexport c */
-/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__math__ = __webpack_require__(/*! ./math */ 0);
-/* unused harmony reexport reexportedAdd */
-/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return __WEBPACK_IMPORTED_MODULE_1__math__["b"]; });
@@ -205,9 +215,10 @@ __WEBPACK_IMPORTED_MODULE_1__library__["a" /* reexportedMultiply */](1, 2);
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
-/* unused harmony export a */
-/* unused harmony export b */
-/* unused harmony export c */
+__webpack_require__.r(__webpack_exports__);
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return a; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return b; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return c; });
function a() { console.log("a"); }
function b() { console.log("b"); }
function c() { console.log("c"); }
@@ -217,64 +228,77 @@ function c() { console.log("c"); }
/******/ ]);
```
-# js/output.js
+# dist/output.js
``` javascript
-!function(t){function n(e){if(r[e])return r[e].exports;var u=r[e]={i:e,l:!1,exports:{}};return t[e].call(u.exports,u,u.exports,n),u.l=!0,u.exports}var r={};n.m=t,n.c=r,n.d=function(t,r,e){n.o(t,r)||Object.defineProperty(t,r,{configurable:!1,enumerable:!0,get:e})},n.n=function(t){var r=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(r,"a",r),r},n.o=function(t,n){return Object.prototype.hasOwnProperty.call(t,n)},n.p="js/",n(n.s=1)}([function(t,n,r){"use strict";function e(){for(var t=0,n=0,r=arguments,e=r.length;n<e;)t+=r[n++];return t}function u(){for(var t=1,n=0,r=arguments,e=r.length;n<e;)t*=r[n++];return t}n.a=e,n.b=u},function(t,n,r){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var e=r(0),u=r(2);Object(e.a)(1,2),u.a(1,2)},function(t,n,r){"use strict";var e=(r(3),r(0));r.d(n,"a",function(){return e.b})},function(t,n,r){"use strict"}]);
+!function(t){function n(e){if(r[e])return r[e].exports;var u=r[e]={i:e,l:!1,exports:{}};return t[e].call(u.exports,u,u.exports,n),u.l=!0,u.exports}var r={};n.m=t,n.c=r,n.d=function(t,r,e){n.o(t,r)||Object.defineProperty(t,r,{configurable:!1,enumerable:!0,get:e})},n.r=function(t){Object.defineProperty(t,"__esModule",{value:!0})},n.n=function(t){var r=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(r,"a",r),r},n.o=function(t,n){return Object.prototype.hasOwnProperty.call(t,n)},n.p="dist/",n(n.s=3)}([function(t,n,r){"use strict";function e(){for(var t=0,n=0,r=arguments,e=r.length;n<e;)t+=r[n++];return t}function u(){for(var t=1,n=0,r=arguments,e=r.length;n<e;)t*=r[n++];return t}r.d(n,"a",function(){return e}),r.d(n,"b",function(){return u})},function(t,n,r){"use strict"},function(t,n,r){"use strict";r(1);var e=r(0);r.d(n,"a",function(){return e.b})},function(t,n,r){"use strict";r.r(n);var e=r(0),u=r(2);Object(e.a)(1,2),u.a(1,2)}]);
```
# Info
-## Uncompressed
+## Unoptimized
```
-Hash: 4cac4181f66e42d03af9
-Version: webpack 3.5.1
- Asset Size Chunks Chunk Names
-output.js 5.02 kB 0 [emitted] main
+Hash: 0a1b2c3d4e5f6a7b8c9d
+Version: webpack 4.0.0-beta.2
+ Asset Size Chunks Chunk Names
+output.js 5.93 KiB 0 [emitted] main
Entrypoint main = output.js
chunk {0} output.js (main) 726 bytes [entry] [rendered]
- > main [1] ./example.js
- [0] ./math.js 366 bytes {0} [built]
- [exports: add, multiply, list]
- [only some exports used: add, multiply]
- harmony import ./math [1] ./example.js 1:0-29
- harmony import ./math [2] ./library.js 2:0-78
- [1] ./example.js 119 bytes {0} [built]
+ > .\example.js main
+ [0] ./example.js 119 bytes {0} [built]
[no exports]
+ single entry .\example.js main
+ [1] ./math.js 366 bytes {0} [built]
+ [exports: add, multiply, list]
+ harmony side effect evaluation ./math [0] ./example.js 1:0-29
+ harmony import specifier ./math [0] ./example.js 4:0-3
+ harmony side effect evaluation ./math [2] ./library.js 2:0-78
+ harmony export imported specifier ./math [2] ./library.js 2:0-78
+ harmony export imported specifier ./math [2] ./library.js 2:0-78
[2] ./library.js 112 bytes {0} [built]
[exports: a, b, c, reexportedAdd, reexportedMultiply]
- [only some exports used: reexportedMultiply]
- harmony import ./library [1] ./example.js 2:0-37
+ harmony side effect evaluation ./library [0] ./example.js 2:0-37
+ harmony import specifier ./library [0] ./example.js 5:0-26
[3] ./abc.js 129 bytes {0} [built]
[exports: a, b, c]
- [no exports used]
- harmony import ./abc [2] ./library.js 1:0-32
+ harmony side effect evaluation ./abc [2] ./library.js 1:0-32
+ harmony export imported specifier ./abc [2] ./library.js 1:0-32
+ harmony export imported specifier ./abc [2] ./library.js 1:0-32
+ harmony export imported specifier ./abc [2] ./library.js 1:0-32
```
-## Minimized (uglify-js, no zip)
+## Production mode
```
-Hash: 4cac4181f66e42d03af9
-Version: webpack 3.5.1
+Hash: 0a1b2c3d4e5f6a7b8c9d
+Version: webpack 4.0.0-beta.2
Asset Size Chunks Chunk Names
-output.js 895 bytes 0 [emitted] main
+output.js 971 bytes 0 [emitted] main
Entrypoint main = output.js
chunk {0} output.js (main) 726 bytes [entry] [rendered]
- > main [1] ./example.js
+ > .\example.js main
[0] ./math.js 366 bytes {0} [built]
[exports: add, multiply, list]
[only some exports used: add, multiply]
- harmony import ./math [1] ./example.js 1:0-29
- harmony import ./math [2] ./library.js 2:0-78
- [1] ./example.js 119 bytes {0} [built]
- [no exports]
+ harmony side effect evaluation ./math [2] ./library.js 2:0-78
+ harmony export imported specifier ./math [2] ./library.js 2:0-78
+ harmony export imported specifier ./math [2] ./library.js 2:0-78
+ harmony side effect evaluation ./math [3] ./example.js 1:0-29
+ harmony import specifier ./math [3] ./example.js 4:0-3
+ [1] ./abc.js 129 bytes {0} [built]
+ [exports: a, b, c]
+ [no exports used]
+ harmony side effect evaluation ./abc [2] ./library.js 1:0-32
+ harmony export imported specifier ./abc [2] ./library.js 1:0-32
+ harmony export imported specifier ./abc [2] ./library.js 1:0-32
+ harmony export imported specifier ./abc [2] ./library.js 1:0-32
[2] ./library.js 112 bytes {0} [built]
[exports: a, b, c, reexportedAdd, reexportedMultiply]
[only some exports used: reexportedMultiply]
- harmony import ./library [1] ./example.js 2:0-37
- [3] ./abc.js 129 bytes {0} [built]
- [exports: a, b, c]
- [no exports used]
- harmony import ./abc [2] ./library.js 1:0-32
+ harmony side effect evaluation ./library [3] ./example.js 2:0-37
+ harmony import specifier ./library [3] ./example.js 5:0-26
+ [3] ./example.js 119 bytes {0} [built]
+ [no exports]
+ single entry .\example.js main
```
diff --git a/examples/harmony-unused/template.md b/examples/harmony-unused/template.md
index fd129344..f60c1c9e 100644
--- a/examples/harmony-unused/template.md
+++ b/examples/harmony-unused/template.md
@@ -24,28 +24,28 @@ In addition to that, `library.js` simulates an entry point to a big library. `li
{{library.js}}
```
-# js/output.js
+# dist/output.js
``` javascript
-{{js/output.js}}
+{{dist/output.js}}
```
-# js/output.js
+# dist/output.js
``` javascript
-{{min:js/output.js}}
+{{production:dist/output.js}}
```
# Info
-## Uncompressed
+## Unoptimized
```
{{stdout}}
```
-## Minimized (uglify-js, no zip)
+## Production mode
```
-{{min:stdout}}
+{{production:stdout}}
```
diff --git a/examples/harmony-unused/webpack.config.js b/examples/harmony-unused/webpack.config.js
new file mode 100644
index 00000000..1aa1e0e5
--- /dev/null
+++ b/examples/harmony-unused/webpack.config.js
@@ -0,0 +1,6 @@
+module.exports = {
+ // mode: "development || "production",
+ optimization: {
+ concatenateModules: false
+ }
+};
diff --git a/examples/harmony/README.md b/examples/harmony/README.md
index 17a791bd..7108d268 100644
--- a/examples/harmony/README.md
+++ b/examples/harmony/README.md
@@ -21,18 +21,20 @@ export function increment(val) {
};
```
-# js/output.js
+# dist/output.js
<details><summary><code>/******/ (function(modules) { /* webpackBootstrap */ })</code></summary>
``` javascript
/******/ (function(modules) { // webpackBootstrap
/******/ // install a JSONP callback for chunk loading
-/******/ var parentJsonpFunction = window["webpackJsonp"];
-/******/ window["webpackJsonp"] = function webpackJsonpCallback(chunkIds, moreModules, executeModules) {
+/******/ function webpackJsonpCallback(data) {
+/******/ var chunkIds = data[0];
+/******/ var moreModules = data[1]
+/******/
/******/ // add "moreModules" to the modules object,
/******/ // then flag all "chunkIds" as loaded and fire callback
-/******/ var moduleId, chunkId, i = 0, resolves = [], result;
+/******/ var moduleId, chunkId, i = 0, resolves = [];
/******/ for(;i < chunkIds.length; i++) {
/******/ chunkId = chunkIds[i];
/******/ if(installedChunks[chunkId]) {
@@ -45,21 +47,24 @@ export function increment(val) {
/******/ modules[moduleId] = moreModules[moduleId];
/******/ }
/******/ }
-/******/ if(parentJsonpFunction) parentJsonpFunction(chunkIds, moreModules, executeModules);
+/******/ if(parentJsonpFunction) parentJsonpFunction(data);
/******/ while(resolves.length) {
/******/ resolves.shift()();
/******/ }
/******/
/******/ };
/******/
+/******/
/******/ // The module cache
/******/ var installedModules = {};
/******/
-/******/ // objects to store loaded and loading chunks
+/******/ // object to store loaded and loading chunks
/******/ var installedChunks = {
/******/ 1: 0
/******/ };
/******/
+/******/
+/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
@@ -87,51 +92,60 @@ export function increment(val) {
/******/ // This file contains only the entry chunk.
/******/ // The chunk loading function for additional chunks
/******/ __webpack_require__.e = function requireEnsure(chunkId) {
+/******/ var promises = [];
+/******/
+/******/
+/******/ // JSONP chunk loading for javascript
+/******/
/******/ var installedChunkData = installedChunks[chunkId];
-/******/ if(installedChunkData === 0) {
-/******/ return new Promise(function(resolve) { resolve(); });
-/******/ }
+/******/ if(installedChunkData !== 0) { // 0 means "already installed".
/******/
-/******/ // a Promise means "currently loading".
-/******/ if(installedChunkData) {
-/******/ return installedChunkData[2];
-/******/ }
+/******/ // a Promise means "currently loading".
+/******/ if(installedChunkData) {
+/******/ promises.push(installedChunkData[2]);
+/******/ } else {
+/******/ // setup Promise in chunk cache
+/******/ var promise = new Promise(function(resolve, reject) {
+/******/ installedChunkData = installedChunks[chunkId] = [resolve, reject];
+/******/ });
+/******/ promises.push(installedChunkData[2] = promise);
/******/
-/******/ // setup Promise in chunk cache
-/******/ var promise = new Promise(function(resolve, reject) {
-/******/ installedChunkData = installedChunks[chunkId] = [resolve, reject];
-/******/ });
-/******/ installedChunkData[2] = promise;
+/******/ // start chunk loading
+/******/ var head = document.getElementsByTagName('head')[0];
+/******/ var script = document.createElement('script');
/******/
-/******/ // start chunk loading
-/******/ var head = document.getElementsByTagName('head')[0];
-/******/ var script = document.createElement('script');
-/******/ script.type = 'text/javascript';
-/******/ script.charset = 'utf-8';
-/******/ script.async = true;
-/******/ script.timeout = 120000;
+/******/ script.charset = 'utf-8';
+/******/ script.timeout = 120000;
/******/
-/******/ if (__webpack_require__.nc) {
-/******/ script.setAttribute("nonce", __webpack_require__.nc);
-/******/ }
-/******/ script.src = __webpack_require__.p + "" + chunkId + ".output.js";
-/******/ var timeout = setTimeout(onScriptComplete, 120000);
-/******/ script.onerror = script.onload = onScriptComplete;
-/******/ function onScriptComplete() {
-/******/ // avoid mem leaks in IE.
-/******/ script.onerror = script.onload = null;
-/******/ clearTimeout(timeout);
-/******/ var chunk = installedChunks[chunkId];
-/******/ if(chunk !== 0) {
-/******/ if(chunk) {
-/******/ chunk[1](new Error('Loading chunk ' + chunkId + ' failed.'));
+/******/ if (__webpack_require__.nc) {
+/******/ script.setAttribute("nonce", __webpack_require__.nc);
/******/ }
-/******/ installedChunks[chunkId] = undefined;
+/******/ script.src = __webpack_require__.p + "" + chunkId + ".output.js";
+/******/ var timeout = setTimeout(function(){
+/******/ onScriptComplete({ type: 'timeout', target: script });
+/******/ }, 120000);
+/******/ script.onerror = script.onload = onScriptComplete;
+/******/ function onScriptComplete(event) {
+/******/ // avoid mem leaks in IE.
+/******/ script.onerror = script.onload = null;
+/******/ clearTimeout(timeout);
+/******/ var chunk = installedChunks[chunkId];
+/******/ if(chunk !== 0) {
+/******/ if(chunk) {
+/******/ var errorType = event && (event.type === 'load' ? 'missing' : event.type);
+/******/ var realSrc = event && event.target && event.target.src;
+/******/ var error = new Error('Loading chunk ' + chunkId + ' failed.\n(' + errorType + ': ' + realSrc + ')');
+/******/ error.type = errorType;
+/******/ error.request = realSrc;
+/******/ chunk[1](error);
+/******/ }
+/******/ installedChunks[chunkId] = undefined;
+/******/ }
+/******/ };
+/******/ head.appendChild(script);
/******/ }
-/******/ };
-/******/ head.appendChild(script);
-/******/
-/******/ return promise;
+/******/ }
+/******/ return Promise.all(promises);
/******/ };
/******/
/******/ // expose the modules object (__webpack_modules__)
@@ -151,6 +165,11 @@ export function increment(val) {
/******/ }
/******/ };
/******/
+/******/ // define __esModule on exports
+/******/ __webpack_require__.r = function(exports) {
+/******/ Object.defineProperty(exports, '__esModule', { value: true });
+/******/ };
+/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
@@ -164,13 +183,21 @@ export function increment(val) {
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
-/******/ __webpack_require__.p = "js/";
+/******/ __webpack_require__.p = "dist/";
/******/
/******/ // on error function for async loading
/******/ __webpack_require__.oe = function(err) { console.error(err); throw err; };
/******/
+/******/ var jsonpArray = window["webpackJsonp"] = window["webpackJsonp"] || [];
+/******/ var oldJsonpFunction = jsonpArray.push.bind(jsonpArray);
+/******/ jsonpArray.push = webpackJsonpCallback;
+/******/ jsonpArray = jsonpArray.slice();
+/******/ for(var i = 0; i < jsonpArray.length; i++) webpackJsonpCallback(jsonpArray[i]);
+/******/ var parentJsonpFunction = oldJsonpFunction;
+/******/
+/******/
/******/ // Load entry module and return exports
-/******/ return __webpack_require__(__webpack_require__.s = 0);
+/******/ return __webpack_require__(__webpack_require__.s = 2);
/******/ })
/************************************************************************/
```
@@ -180,24 +207,22 @@ export function increment(val) {
``` javascript
/******/ ([
/* 0 */
-/*!********************!*\
- !*** ./example.js ***!
- \********************/
-/*! exports provided: */
-/*! all exports used */
+/*!*****************!*\
+ !*** ./math.js ***!
+ \*****************/
+/*! exports provided: add */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
-Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
-/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__increment__ = __webpack_require__(/*! ./increment */ 1);
-
-var a = 1;
-Object(__WEBPACK_IMPORTED_MODULE_0__increment__["a" /* increment */])(a); // 2
-
-// async loading
-__webpack_require__.e/* import() */(0).then(__webpack_require__.bind(null, /*! ./async-loaded */ 3)).then(function(asyncLoaded) {
- console.log(asyncLoaded);
-});
+__webpack_require__.r(__webpack_exports__);
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "add", function() { return add; });
+function add() {
+ var sum = 0, i = 0, args = arguments, l = args.length;
+ while (i < l) {
+ sum += args[i++];
+ }
+ return sum;
+}
/***/ }),
@@ -206,36 +231,37 @@ __webpack_require__.e/* import() */(0).then(__webpack_require__.bind(null, /*! .
!*** ./increment.js ***!
\**********************/
/*! exports provided: increment */
-/*! exports used: increment */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
-/* harmony export (immutable) */ __webpack_exports__["a"] = increment;
-/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__math__ = __webpack_require__(/*! ./math */ 2);
+__webpack_require__.r(__webpack_exports__);
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "increment", function() { return increment; });
+/* harmony import */ var _math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./math */ 0);
function increment(val) {
- return Object(__WEBPACK_IMPORTED_MODULE_0__math__["a" /* add */])(val, 1);
+ return Object(_math__WEBPACK_IMPORTED_MODULE_0__["add"])(val, 1);
};
/***/ }),
/* 2 */
-/*!*****************!*\
- !*** ./math.js ***!
- \*****************/
-/*! exports provided: add */
-/*! exports used: add */
+/*!********************!*\
+ !*** ./example.js ***!
+ \********************/
+/*! no exports provided */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
-/* harmony export (immutable) */ __webpack_exports__["a"] = add;
-function add() {
- var sum = 0, i = 0, args = arguments, l = args.length;
- while (i < l) {
- sum += args[i++];
- }
- return sum;
-}
+__webpack_require__.r(__webpack_exports__);
+/* harmony import */ var _increment__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./increment */ 1);
+
+var a = 1;
+Object(_increment__WEBPACK_IMPORTED_MODULE_0__["increment"])(a); // 2
+
+// async loading
+__webpack_require__.e(/*! import() */ 0).then(__webpack_require__.bind(null, /*! ./async-loaded */ 3)).then(function(asyncLoaded) {
+ console.log(asyncLoaded);
+});
/***/ })
@@ -244,58 +270,65 @@ function add() {
# Info
-## Uncompressed
+## Unoptimized
```
-Hash: f5982ea38c08a86ed265
-Version: webpack 3.5.1
+Hash: 0a1b2c3d4e5f6a7b8c9d
+Version: webpack 4.0.0-beta.2
Asset Size Chunks Chunk Names
-0.output.js 484 bytes 0 [emitted]
- output.js 7.36 kB 1 [emitted] main
+0.output.js 479 bytes 0 [emitted]
+ output.js 8.27 KiB 1 [emitted] main
Entrypoint main = output.js
-chunk {0} 0.output.js 25 bytes {1} [rendered]
- > [0] ./example.js 6:0-24
+chunk {0} 0.output.js 25 bytes <{1}> [rendered]
+ > ./async-loaded [2] ./example.js 6:0-24
[3] ./async-loaded.js 25 bytes {0} [built]
[exports: answer]
- import() ./async-loaded [0] ./example.js 6:0-24
-chunk {1} output.js (main) 419 bytes [entry] [rendered]
- > main [0] ./example.js
- [0] ./example.js 183 bytes {1} [built]
- [no exports]
+ import() ./async-loaded [2] ./example.js 6:0-24
+chunk {1} output.js (main) 419 bytes >{0}< [entry] [rendered]
+ > .\example.js main
+ [0] ./math.js 142 bytes {1} [built]
+ [exports: add]
+ harmony side effect evaluation ./math [1] ./increment.js 1:0-29
+ harmony import specifier ./math [1] ./increment.js 3:11-14
[1] ./increment.js 94 bytes {1} [built]
[exports: increment]
- [only some exports used: increment]
- harmony import ./increment [0] ./example.js 1:0-47
- [2] ./math.js 142 bytes {1} [built]
- [exports: add]
- [only some exports used: add]
- harmony import ./math [1] ./increment.js 1:0-29
+ harmony side effect evaluation ./increment [2] ./example.js 1:0-47
+ harmony import specifier ./increment [2] ./example.js 3:0-3
+ [2] ./example.js 183 bytes {1} [built]
+ [no exports]
+ single entry .\example.js main
```
-## Minimized (uglify-js, no zip)
+## Production mode
```
-Hash: f5982ea38c08a86ed265
-Version: webpack 3.5.1
+Hash: 0a1b2c3d4e5f6a7b8c9d
+Version: webpack 4.0.0-beta.2
Asset Size Chunks Chunk Names
-0.output.js 147 bytes 0 [emitted]
- output.js 1.69 kB 1 [emitted] main
+0.output.js 144 bytes 0 [emitted]
+ output.js 1.75 KiB 1 [emitted] main
Entrypoint main = output.js
-chunk {0} 0.output.js 25 bytes {1} [rendered]
- > [0] ./example.js 6:0-24
- [3] ./async-loaded.js 25 bytes {0} [built]
+chunk {0} 0.output.js 25 bytes <{1}> [rendered]
+ > ./async-loaded [] 6:0-24
+ [1] ./async-loaded.js 25 bytes {0} [built]
[exports: answer]
- import() ./async-loaded [0] ./example.js 6:0-24
-chunk {1} output.js (main) 419 bytes [entry] [rendered]
- > main [0] ./example.js
- [0] ./example.js 183 bytes {1} [built]
+ import() ./async-loaded ./example.js 6:0-24
+chunk {1} output.js (main) 419 bytes >{0}< [entry] [rendered]
+ > .\example.js main
+ [0] ./example.js + 2 modules 419 bytes {1} [built]
[no exports]
- [1] ./increment.js 94 bytes {1} [built]
- [exports: increment]
- [only some exports used: increment]
- harmony import ./increment [0] ./example.js 1:0-47
- [2] ./math.js 142 bytes {1} [built]
- [exports: add]
- [only some exports used: add]
- harmony import ./math [1] ./increment.js 1:0-29
+ single entry .\example.js main
+ | ./example.js 183 bytes [built]
+ | [no exports]
+ | single entry .\example.js main
+ | ./increment.js 94 bytes [built]
+ | [exports: increment]
+ | [only some exports used: increment]
+ | harmony side effect evaluation ./increment ./example.js 1:0-47
+ | harmony import specifier ./increment ./example.js 3:0-3
+ | ./math.js 142 bytes [built]
+ | [exports: add]
+ | [only some exports used: add]
+ | harmony side effect evaluation ./math ./increment.js 1:0-29
+ | harmony import specifier ./math ./increment.js 3:11-14
```
\ No newline at end of file
diff --git a/examples/harmony/template.md b/examples/harmony/template.md
index 67fbed66..ed2dd05a 100644
--- a/examples/harmony/template.md
+++ b/examples/harmony/template.md
@@ -11,22 +11,22 @@
{{increment.js}}
```
-# js/output.js
+# dist/output.js
``` javascript
-{{js/output.js}}
+{{dist/output.js}}
```
# Info
-## Uncompressed
+## Unoptimized
```
{{stdout}}
```
-## Minimized (uglify-js, no zip)
+## Production mode
```
-{{min:stdout}}
+{{production:stdout}}
```
\ No newline at end of file
diff --git a/examples/harmony/webpack.config.js b/examples/harmony/webpack.config.js
new file mode 100644
index 00000000..0d554bf6
--- /dev/null
+++ b/examples/harmony/webpack.config.js
@@ -0,0 +1,5 @@
+module.exports = {
+ optimization: {
+ occurrenceOrder: true // To keep filename consistent between different modes (for example building only)
+ }
+};
diff --git a/examples/http2-aggressive-splitting/README.md b/examples/http2-aggressive-splitting/README.md
index 30f54651..efafe6b2 100644
--- a/examples/http2-aggressive-splitting/README.md
+++ b/examples/http2-aggressive-splitting/README.md
@@ -20,9 +20,11 @@ The backward compatibility (non HTTP2 client) improves with bigger `maxSize`, as
var path = require("path");
var webpack = require("../../");
module.exports = {
+ // mode: "development || "production",
+ cache: true, // better performance for the AggressiveSplittingPlugin
entry: "./example",
output: {
- path: path.join(__dirname, "js"),
+ path: path.join(__dirname, "dist"),
filename: "[chunkhash].js",
chunkFilename: "[chunkhash].js"
},
@@ -35,150 +37,150 @@ module.exports = {
"process.env.NODE_ENV": JSON.stringify("production")
})
],
- recordsOutputPath: path.join(__dirname, "js", "records.json")
+ recordsOutputPath: path.join(__dirname, "dist", "records.json")
};
```
# Info
-## Uncompressed
+## Unoptimized
```
-Hash: 35256bb30300e8777ddd
-Version: webpack 3.5.1
- Asset Size Chunks Chunk Names
-04e95786881a7db62441.js 53.1 kB 7 [emitted]
-af5b936f620d7c2cf46e.js 57.4 kB 0 [emitted]
-d8035b04d59361a42a17.js 56.6 kB 2 [emitted]
-92951e4964e84e709103.js 55.9 kB 3 [emitted]
-d323f006c00a41b194cb.js 55.9 kB 4 [emitted]
-567bf6b0afa4e4baa4fb.js 53.7 kB 5 [emitted]
-435514b5a5822c639a06.js 53.7 kB 6 [emitted]
-fbb0bfdcf201839059f9.js 38.9 kB 1 [emitted]
-ebe11885009391a25f13.js 37.9 kB 8 [emitted]
-1aa11917196d1d3b05c1.js 52.1 kB 9 [emitted]
-8556f2285fd844cf9fdd.js 51 kB 10 [emitted]
-c6598918ddb96aa65fc4.js 50.7 kB 11 [emitted]
-17613f7c75a33459b935.js 41.8 kB 12 [emitted]
-8cc7b4a18437614b45e4.js 59.6 kB 13 [emitted]
-11202a345a2ce63a2fb7.js 31.3 kB 14 [emitted]
-Entrypoint main = 8cc7b4a18437614b45e4.js 11202a345a2ce63a2fb7.js 17613f7c75a33459b935.js
-chunk {0} af5b936f620d7c2cf46e.js 49.8 kB {12} {13} {14} [rendered] [recorded]
- > aggressive-splitted [14] ./example.js 2:0-22
+Hash: 0a1b2c3d4e5f6a7b8c9d
+Version: webpack 4.0.0-beta.2
+ Asset Size Chunks Chunk Names
+aae9c6dac629dd3f112e.js 54.5 KiB 7 [emitted]
+07ed7b2dfa6fe5502719.js 34.8 KiB 0 [emitted]
+987f929f287f8a6c88ac.js 52.1 KiB 2 [emitted]
+bc5ed8b126130fde4f42.js 31.1 KiB 3 [emitted]
+511009f3a8f06b7c54cb.js 43 KiB 4 [emitted]
+2a784b823ab0da1e0293.js 43.7 KiB 5 [emitted]
+0abfd767d2250ac9265a.js 46 KiB 6 [emitted]
+3147c249192926fa3521.js 12.6 KiB 1 [emitted]
+cd98376ec90f2e366b94.js 36.8 KiB 8 [emitted]
+a0f973cb054f411fba45.js 43 KiB 9 [emitted]
+ee6461bbec846ab2c762.js 37.6 KiB 10 [emitted]
+74249374b007623d16bf.js 41.7 KiB 11 [emitted]
+0a6d10836900825087ce.js 44.7 KiB 12 [emitted]
+5ec04d5529f6b78241e2.js 51.9 KiB 13 [emitted]
+38a6975540caa0156886.js 51.3 KiB 14 [emitted]
+Entrypoint main = bc5ed8b126130fde4f42.js 2a784b823ab0da1e0293.js 07ed7b2dfa6fe5502719.js
+chunk {0} 07ed7b2dfa6fe5502719.js 28.3 KiB ={3}= ={5}= >{1}< >{10}< >{11}< >{12}< >{13}< >{14}< >{2}< >{4}< >{6}< >{7}< >{8}< >{9}< [entry] [rendered]
+ > ./example main
+ [0] ./example.js 44 bytes {0} [built]
+ + 13 hidden modules
+chunk {1} 3147c249192926fa3521.js 24.9 KiB <{0}> <{3}> <{5}> ={10}= ={11}= ={12}= ={13}= ={14}= ={2}= ={4}= ={6}= ={7}= ={8}= ={9}= [rendered]
+ > react-dom [0] ./example.js 2:0-22
+ 3 modules
+chunk {2} 987f929f287f8a6c88ac.js 45.7 KiB <{0}> <{3}> <{5}> ={1}= ={10}= ={11}= ={12}= ={13}= ={14}= ={4}= ={6}= ={7}= ={8}= ={9}= [rendered] [recorded] aggressive splitted
+ > react-dom [0] ./example.js 2:0-22
23 modules
-chunk {1} fbb0bfdcf201839059f9.js 32.5 kB {12} {13} {14} [rendered] [recorded]
- > aggressive-splitted [14] ./example.js 2:0-22
- 17 modules
-chunk {2} d8035b04d59361a42a17.js 49.7 kB {12} {13} {14} [rendered] [recorded]
- > aggressive-splitted [14] ./example.js 2:0-22
- 17 modules
-chunk {3} 92951e4964e84e709103.js 49.9 kB {12} {13} {14} [rendered] [recorded]
- > aggressive-splitted [14] ./example.js 2:0-22
- 16 modules
-chunk {4} d323f006c00a41b194cb.js 49.9 kB {12} {13} {14} [rendered] [recorded]
- > aggressive-splitted [14] ./example.js 2:0-22
- 15 modules
-chunk {5} 567bf6b0afa4e4baa4fb.js 49.8 kB {12} {13} {14} [rendered] [recorded]
- > aggressive-splitted [14] ./example.js 2:0-22
- 11 modules
-chunk {6} 435514b5a5822c639a06.js 50 kB {12} {13} {14} [rendered] [recorded]
- > aggressive-splitted [14] ./example.js 2:0-22
- 11 modules
-chunk {7} 04e95786881a7db62441.js 49.9 kB {12} {13} {14} [rendered] [recorded]
- > aggressive-splitted [14] ./example.js 2:0-22
+chunk {3} bc5ed8b126130fde4f42.js 37.8 KiB ={0}= ={5}= >{1}< >{10}< >{11}< >{12}< >{13}< >{14}< >{2}< >{4}< >{6}< >{7}< >{8}< >{9}< [initial] [rendered] [recorded] aggressive splitted
+ > ./example main
+ 8 modules
+chunk {4} 511009f3a8f06b7c54cb.js 46.9 KiB <{0}> <{3}> <{5}> ={1}= ={10}= ={11}= ={12}= ={13}= ={14}= ={2}= ={6}= ={7}= ={8}= ={9}= [rendered] [recorded] aggressive splitted
+ > react-dom [0] ./example.js 2:0-22
+ 8 modules
+chunk {5} 2a784b823ab0da1e0293.js 45.7 KiB ={0}= ={3}= >{1}< >{10}< >{11}< >{12}< >{13}< >{14}< >{2}< >{4}< >{6}< >{7}< >{8}< >{9}< [initial] [rendered] [recorded] aggressive splitted
+ > ./example main
9 modules
-chunk {8} ebe11885009391a25f13.js 35.8 kB {12} {13} {14} [rendered] [recorded]
- > aggressive-splitted [14] ./example.js 2:0-22
- 6 modules
-chunk {9} 1aa11917196d1d3b05c1.js 49.9 kB {12} {13} {14} [rendered] [recorded]
- > aggressive-splitted [14] ./example.js 2:0-22
- 6 modules
-chunk {10} 8556f2285fd844cf9fdd.js 49.9 kB {12} {13} {14} [rendered] [recorded]
- > aggressive-splitted [14] ./example.js 2:0-22
- 4 modules
-chunk {11} c6598918ddb96aa65fc4.js 49.9 kB {12} {13} {14} [rendered] [recorded]
- > aggressive-splitted [14] ./example.js 2:0-22
- 4 modules
-chunk {12} 17613f7c75a33459b935.js 36.4 kB [initial] [rendered]
- > aggressive-splitted main [14] ./example.js
- [14] ./example.js 44 bytes {12} [built]
- + 14 hidden modules
-chunk {13} 8cc7b4a18437614b45e4.js 49.8 kB [entry] [rendered] [recorded]
- > aggressive-splitted main [14] ./example.js
- 13 modules
-chunk {14} 11202a345a2ce63a2fb7.js 30.2 kB [initial] [rendered] [recorded]
- > aggressive-splitted main [14] ./example.js
+chunk {6} 0abfd767d2250ac9265a.js 46.3 KiB <{0}> <{3}> <{5}> ={1}= ={10}= ={11}= ={12}= ={13}= ={14}= ={2}= ={4}= ={7}= ={8}= ={9}= [rendered] [recorded] aggressive splitted
+ > react-dom [0] ./example.js 2:0-22
+ 10 modules
+chunk {7} aae9c6dac629dd3f112e.js 62.3 KiB <{0}> <{3}> <{5}> ={1}= ={10}= ={11}= ={12}= ={13}= ={14}= ={2}= ={4}= ={6}= ={8}= ={9}= [rendered] [recorded] aggressive splitted
+ > react-dom [0] ./example.js 2:0-22
+ 7 modules
+chunk {8} cd98376ec90f2e366b94.js 43.3 KiB <{0}> <{3}> <{5}> ={1}= ={10}= ={11}= ={12}= ={13}= ={14}= ={2}= ={4}= ={6}= ={7}= ={9}= [rendered] [recorded] aggressive splitted
+ > react-dom [0] ./example.js 2:0-22
3 modules
+chunk {9} a0f973cb054f411fba45.js 44.4 KiB <{0}> <{3}> <{5}> ={1}= ={10}= ={11}= ={12}= ={13}= ={14}= ={2}= ={4}= ={6}= ={7}= ={8}= [rendered] [recorded] aggressive splitted
+ > react-dom [0] ./example.js 2:0-22
+ 10 modules
+chunk {10} ee6461bbec846ab2c762.js 34 KiB <{0}> <{3}> <{5}> ={1}= ={11}= ={12}= ={13}= ={14}= ={2}= ={4}= ={6}= ={7}= ={8}= ={9}= [rendered] [recorded] aggressive splitted
+ > react-dom [0] ./example.js 2:0-22
+ 16 modules
+chunk {11} 74249374b007623d16bf.js 48.4 KiB <{0}> <{3}> <{5}> ={1}= ={10}= ={12}= ={13}= ={14}= ={2}= ={4}= ={6}= ={7}= ={8}= ={9}= [rendered] [recorded] aggressive splitted
+ > react-dom [0] ./example.js 2:0-22
+ 6 modules
+chunk {12} 0a6d10836900825087ce.js 46.2 KiB <{0}> <{3}> <{5}> ={1}= ={10}= ={11}= ={13}= ={14}= ={2}= ={4}= ={6}= ={7}= ={8}= ={9}= [rendered] [recorded] aggressive splitted
+ > react-dom [0] ./example.js 2:0-22
+ 9 modules
+chunk {13} 5ec04d5529f6b78241e2.js 48.2 KiB <{0}> <{3}> <{5}> ={1}= ={10}= ={11}= ={12}= ={14}= ={2}= ={4}= ={6}= ={7}= ={8}= ={9}= [rendered] [recorded] aggressive splitted
+ > react-dom [0] ./example.js 2:0-22
+ 20 modules
+chunk {14} 38a6975540caa0156886.js 46.6 KiB <{0}> <{3}> <{5}> ={1}= ={10}= ={11}= ={12}= ={13}= ={2}= ={4}= ={6}= ={7}= ={8}= ={9}= [rendered] [recorded] aggressive splitted
+ > react-dom [0] ./example.js 2:0-22
+ 24 modules
```
-## Minimized (uglify-js, no zip)
+## Production mode
```
-Hash: 35256bb30300e8777ddd
-Version: webpack 3.5.1
- Asset Size Chunks Chunk Names
-04e95786881a7db62441.js 10.3 kB 7 [emitted]
-af5b936f620d7c2cf46e.js 12.3 kB 0 [emitted]
-d8035b04d59361a42a17.js 11 kB 2 [emitted]
-92951e4964e84e709103.js 9.59 kB 3 [emitted]
-d323f006c00a41b194cb.js 11.9 kB 4 [emitted]
-567bf6b0afa4e4baa4fb.js 13.3 kB 5 [emitted]
-435514b5a5822c639a06.js 11.5 kB 6 [emitted]
-fbb0bfdcf201839059f9.js 8 kB 1 [emitted]
-ebe11885009391a25f13.js 5.76 kB 8 [emitted]
-1aa11917196d1d3b05c1.js 8.25 kB 9 [emitted]
-8556f2285fd844cf9fdd.js 12.6 kB 10 [emitted]
-c6598918ddb96aa65fc4.js 10.2 kB 11 [emitted]
-17613f7c75a33459b935.js 6.32 kB 12 [emitted]
-8cc7b4a18437614b45e4.js 10.1 kB 13 [emitted]
-11202a345a2ce63a2fb7.js 6.83 kB 14 [emitted]
-Entrypoint main = 8cc7b4a18437614b45e4.js 11202a345a2ce63a2fb7.js 17613f7c75a33459b935.js
-chunk {0} af5b936f620d7c2cf46e.js 49.8 kB {12} {13} {14} [rendered] [recorded]
- > aggressive-splitted [14] ./example.js 2:0-22
- 23 modules
-chunk {1} fbb0bfdcf201839059f9.js 32.5 kB {12} {13} {14} [rendered] [recorded]
- > aggressive-splitted [14] ./example.js 2:0-22
- 17 modules
-chunk {2} d8035b04d59361a42a17.js 49.7 kB {12} {13} {14} [rendered] [recorded]
- > aggressive-splitted [14] ./example.js 2:0-22
- 17 modules
-chunk {3} 92951e4964e84e709103.js 49.9 kB {12} {13} {14} [rendered] [recorded]
- > aggressive-splitted [14] ./example.js 2:0-22
- 16 modules
-chunk {4} d323f006c00a41b194cb.js 49.9 kB {12} {13} {14} [rendered] [recorded]
- > aggressive-splitted [14] ./example.js 2:0-22
- 15 modules
-chunk {5} 567bf6b0afa4e4baa4fb.js 49.8 kB {12} {13} {14} [rendered] [recorded]
- > aggressive-splitted [14] ./example.js 2:0-22
- 11 modules
-chunk {6} 435514b5a5822c639a06.js 50 kB {12} {13} {14} [rendered] [recorded]
- > aggressive-splitted [14] ./example.js 2:0-22
- 11 modules
-chunk {7} 04e95786881a7db62441.js 49.9 kB {12} {13} {14} [rendered] [recorded]
- > aggressive-splitted [14] ./example.js 2:0-22
+Hash: 0a1b2c3d4e5f6a7b8c9d
+Version: webpack 4.0.0-beta.2
+ Asset Size Chunks Chunk Names
+7a1ec67d9e4e1019836a.js 14.8 KiB 7 [emitted]
+9baaf7bc0364c2600ef8.js 9.7 KiB 0 [emitted]
+cf3beff30352265c3fae.js 13.1 KiB 2 [emitted]
+0bc9e49d2884c20a78ae.js 7.89 KiB 3 [emitted]
+408e20e95f946dedfdd3.js 8.14 KiB 4 [emitted]
+5b44ef86854beead5c79.js 10.1 KiB 5 [emitted]
+2d761db260e810943d04.js 10.5 KiB 6 [emitted]
+148bbb5ef8fd203f5c99.js 9.97 KiB 1 [emitted]
+5efec1104bcbe14efad9.js 10.9 KiB 8 [emitted]
+050d4b543b70cc78b255.js 9.91 KiB 9 [emitted]
+2c42126f0455b98de2d0.js 12 KiB 10 [emitted]
+27d8a7d99dbd33243169.js 4.2 KiB 11 [emitted]
+f9403b4474b02c436f23.js 10.9 KiB 12 [emitted]
+97ad3a6439b7ef8470ec.js 6.41 KiB 13 [emitted]
+ed199e2ef66607136e6a.js 5.97 KiB 14 [emitted]
+Entrypoint main = 97ad3a6439b7ef8470ec.js f9403b4474b02c436f23.js ed199e2ef66607136e6a.js
+chunk {0} 9baaf7bc0364c2600ef8.js 46.6 KiB <{12}> <{13}> <{14}> ={1}= ={10}= ={11}= ={2}= ={3}= ={4}= ={5}= ={6}= ={7}= ={8}= ={9}= [rendered] [recorded] aggressive splitted
+ > react-dom [30] ./example.js 2:0-22
+ 24 modules
+chunk {1} 148bbb5ef8fd203f5c99.js 48.2 KiB <{12}> <{13}> <{14}> ={0}= ={10}= ={11}= ={2}= ={3}= ={4}= ={5}= ={6}= ={7}= ={8}= ={9}= [rendered] [recorded] aggressive splitted
+ > react-dom [30] ./example.js 2:0-22
+ 20 modules
+chunk {2} cf3beff30352265c3fae.js 46.2 KiB <{12}> <{13}> <{14}> ={0}= ={1}= ={10}= ={11}= ={3}= ={4}= ={5}= ={6}= ={7}= ={8}= ={9}= [rendered] [recorded] aggressive splitted
+ > react-dom [30] ./example.js 2:0-22
9 modules
-chunk {8} ebe11885009391a25f13.js 35.8 kB {12} {13} {14} [rendered] [recorded]
- > aggressive-splitted [14] ./example.js 2:0-22
+chunk {3} 0bc9e49d2884c20a78ae.js 48.4 KiB <{12}> <{13}> <{14}> ={0}= ={1}= ={10}= ={11}= ={2}= ={4}= ={5}= ={6}= ={7}= ={8}= ={9}= [rendered] [recorded] aggressive splitted
+ > react-dom [30] ./example.js 2:0-22
6 modules
-chunk {9} 1aa11917196d1d3b05c1.js 49.9 kB {12} {13} {14} [rendered] [recorded]
- > aggressive-splitted [14] ./example.js 2:0-22
- 6 modules
-chunk {10} 8556f2285fd844cf9fdd.js 49.9 kB {12} {13} {14} [rendered] [recorded]
- > aggressive-splitted [14] ./example.js 2:0-22
- 4 modules
-chunk {11} c6598918ddb96aa65fc4.js 49.9 kB {12} {13} {14} [rendered] [recorded]
- > aggressive-splitted [14] ./example.js 2:0-22
- 4 modules
-chunk {12} 17613f7c75a33459b935.js 36.4 kB [initial] [rendered]
- > aggressive-splitted main [14] ./example.js
- [14] ./example.js 44 bytes {12} [built]
- + 14 hidden modules
-chunk {13} 8cc7b4a18437614b45e4.js 49.8 kB [entry] [rendered] [recorded]
- > aggressive-splitted main [14] ./example.js
- 13 modules
-chunk {14} 11202a345a2ce63a2fb7.js 30.2 kB [initial] [rendered] [recorded]
- > aggressive-splitted main [14] ./example.js
+chunk {4} 408e20e95f946dedfdd3.js 34 KiB <{12}> <{13}> <{14}> ={0}= ={1}= ={10}= ={11}= ={2}= ={3}= ={5}= ={6}= ={7}= ={8}= ={9}= [rendered] [recorded] aggressive splitted
+ > react-dom [30] ./example.js 2:0-22
+ 16 modules
+chunk {5} 5b44ef86854beead5c79.js 44.4 KiB <{12}> <{13}> <{14}> ={0}= ={1}= ={10}= ={11}= ={2}= ={3}= ={4}= ={6}= ={7}= ={8}= ={9}= [rendered] [recorded] aggressive splitted
+ > react-dom [30] ./example.js 2:0-22
+ 10 modules
+chunk {6} 2d761db260e810943d04.js 43.3 KiB <{12}> <{13}> <{14}> ={0}= ={1}= ={10}= ={11}= ={2}= ={3}= ={4}= ={5}= ={7}= ={8}= ={9}= [rendered] [recorded] aggressive splitted
+ > react-dom [30] ./example.js 2:0-22
3 modules
+chunk {7} 7a1ec67d9e4e1019836a.js 62.3 KiB <{12}> <{13}> <{14}> ={0}= ={1}= ={10}= ={11}= ={2}= ={3}= ={4}= ={5}= ={6}= ={8}= ={9}= [rendered] [recorded] aggressive splitted
+ > react-dom [30] ./example.js 2:0-22
+ 7 modules
+chunk {8} 5efec1104bcbe14efad9.js 46.3 KiB <{12}> <{13}> <{14}> ={0}= ={1}= ={10}= ={11}= ={2}= ={3}= ={4}= ={5}= ={6}= ={7}= ={9}= [rendered] [recorded] aggressive splitted
+ > react-dom [30] ./example.js 2:0-22
+ 10 modules
+chunk {9} 050d4b543b70cc78b255.js 46.9 KiB <{12}> <{13}> <{14}> ={0}= ={1}= ={10}= ={11}= ={2}= ={3}= ={4}= ={5}= ={6}= ={7}= ={8}= [rendered] [recorded] aggressive splitted
+ > react-dom [30] ./example.js 2:0-22
+ 8 modules
+chunk {10} 2c42126f0455b98de2d0.js 45.7 KiB <{12}> <{13}> <{14}> ={0}= ={1}= ={11}= ={2}= ={3}= ={4}= ={5}= ={6}= ={7}= ={8}= ={9}= [rendered] [recorded] aggressive splitted
+ > react-dom [30] ./example.js 2:0-22
+ 23 modules
+chunk {11} 27d8a7d99dbd33243169.js 24.9 KiB <{12}> <{13}> <{14}> ={0}= ={1}= ={10}= ={2}= ={3}= ={4}= ={5}= ={6}= ={7}= ={8}= ={9}= [rendered]
+ > react-dom [30] ./example.js 2:0-22
+ 3 modules
+chunk {12} f9403b4474b02c436f23.js 45.7 KiB ={13}= ={14}= >{0}< >{1}< >{10}< >{11}< >{2}< >{3}< >{4}< >{5}< >{6}< >{7}< >{8}< >{9}< [initial] [rendered] [recorded] aggressive splitted
+ > ./example main
+ 9 modules
+chunk {13} 97ad3a6439b7ef8470ec.js 37.8 KiB ={12}= ={14}= >{0}< >{1}< >{10}< >{11}< >{2}< >{3}< >{4}< >{5}< >{6}< >{7}< >{8}< >{9}< [initial] [rendered] [recorded] aggressive splitted
+ > ./example main
+ 8 modules
+chunk {14} ed199e2ef66607136e6a.js 28.3 KiB ={12}= ={13}= >{0}< >{1}< >{10}< >{11}< >{2}< >{3}< >{4}< >{5}< >{6}< >{7}< >{8}< >{9}< [entry] [rendered]
+ > ./example main
+ [30] ./example.js 44 bytes {14} [built]
+ + 13 hidden modules
```
## Records
@@ -187,30 +189,30 @@ chunk {14} 11202a345a2ce63a2fb7.js 30.2 kB [initial] [rendered] [recorded]
{
"modules": {
"byIdentifier": {
- "../../node_modules/fbjs/lib/invariant.js": 0,
- "../../node_modules/react/lib/ReactElement.js": 1,
- "../../node_modules/fbjs/lib/warning.js": 2,
+ "example.js": 0,
+ "../../node_modules/react/react.js": 1,
+ "../../node_modules/react/lib/React.js": 2,
"../../node_modules/object-assign/index.js": 3,
- "../../node_modules/react/lib/reactProdInvariant.js": 4,
- "../../node_modules/fbjs/lib/emptyFunction.js": 5,
- "../../node_modules/react/lib/ReactCurrentOwner.js": 6,
- "../../node_modules/fbjs/lib/emptyObject.js": 7,
- "../../node_modules/react/lib/ReactBaseClasses.js": 8,
- "../../node_modules/react/lib/ReactNoopUpdateQueue.js": 9,
- "../../node_modules/react/lib/canDefineProperty.js": 10,
- "../../node_modules/react/lib/ReactElementSymbol.js": 11,
- "../../node_modules/react/lib/React.js": 12,
- "../../node_modules/prop-types/factory.js": 13,
- "example.js": 14,
- "../../node_modules/react/react.js": 15,
- "../../node_modules/react/lib/lowPriorityWarning.js": 16,
- "../../node_modules/react/lib/ReactChildren.js": 17,
- "../../node_modules/react/lib/PooledClass.js": 18,
- "../../node_modules/react/lib/traverseAllChildren.js": 19,
- "../../node_modules/react/lib/getIteratorFn.js": 20,
- "../../node_modules/react/lib/KeyEscapeUtils.js": 21,
- "../../node_modules/react/lib/ReactDOMFactories.js": 22,
- "../../node_modules/react/lib/ReactPropTypes.js": 23,
+ "../../node_modules/react/lib/ReactBaseClasses.js": 4,
+ "../../node_modules/react/lib/reactProdInvariant.js": 5,
+ "../../node_modules/react/lib/ReactNoopUpdateQueue.js": 6,
+ "../../node_modules/fbjs/lib/warning.js": 7,
+ "../../node_modules/fbjs/lib/emptyFunction.js": 8,
+ "../../node_modules/react/lib/canDefineProperty.js": 9,
+ "../../node_modules/fbjs/lib/emptyObject.js": 10,
+ "../../node_modules/fbjs/lib/invariant.js": 11,
+ "../../node_modules/react/lib/lowPriorityWarning.js": 12,
+ "../../node_modules/react/lib/ReactChildren.js": 13,
+ "../../node_modules/react/lib/PooledClass.js": 14,
+ "../../node_modules/react/lib/ReactElement.js": 15,
+ "../../node_modules/react/lib/ReactCurrentOwner.js": 16,
+ "../../node_modules/react/lib/ReactElementSymbol.js": 17,
+ "../../node_modules/react/lib/traverseAllChildren.js": 18,
+ "../../node_modules/react/lib/getIteratorFn.js": 19,
+ "../../node_modules/react/lib/KeyEscapeUtils.js": 20,
+ "../../node_modules/react/lib/ReactDOMFactories.js": 21,
+ "../../node_modules/react/lib/ReactPropTypes.js": 22,
+ "../../node_modules/prop-types/factory.js": 23,
"../../node_modules/prop-types/factoryWithTypeCheckers.js": 24,
"../../node_modules/prop-types/lib/ReactPropTypesSecret.js": 25,
"../../node_modules/prop-types/checkPropTypes.js": 26,
@@ -219,143 +221,143 @@ chunk {14} 11202a345a2ce63a2fb7.js 30.2 kB [initial] [rendered] [recorded]
"../../node_modules/create-react-class/factory.js": 29,
"../../node_modules/react/lib/onlyChild.js": 30,
"../../node_modules/react-dom/index.js": 31,
- "../../node_modules/react-dom/lib/reactProdInvariant.js": 32,
+ "../../node_modules/react-dom/lib/ReactDOM.js": 32,
"../../node_modules/react-dom/lib/ReactDOMComponentTree.js": 33,
- "../../node_modules/fbjs/lib/ExecutionEnvironment.js": 34,
- "../../node_modules/react-dom/lib/ReactInstrumentation.js": 35,
- "../../node_modules/react-dom/lib/ReactUpdates.js": 36,
- "../../node_modules/react-dom/lib/SyntheticEvent.js": 37,
- "../../node_modules/react-dom/lib/PooledClass.js": 38,
- "../../node_modules/react-dom/lib/DOMProperty.js": 39,
- "../../node_modules/react-dom/lib/ReactReconciler.js": 40,
- "../../node_modules/react-dom/lib/DOMLazyTree.js": 41,
- "../../node_modules/react-dom/lib/EventPropagators.js": 42,
- "../../node_modules/react-dom/lib/EventPluginHub.js": 43,
- "../../node_modules/react-dom/lib/SyntheticUIEvent.js": 44,
- "../../node_modules/react-dom/lib/ReactInstanceMap.js": 45,
- "../../node_modules/react-dom/lib/Transaction.js": 46,
- "../../node_modules/react-dom/lib/SyntheticMouseEvent.js": 47,
- "../../node_modules/react-dom/lib/setInnerHTML.js": 48,
- "../../node_modules/react-dom/lib/escapeTextContentForBrowser.js": 49,
- "../../node_modules/react-dom/lib/ReactBrowserEventEmitter.js": 50,
- "../../node_modules/react-dom/lib/EventPluginRegistry.js": 51,
- "../../node_modules/react-dom/lib/EventPluginUtils.js": 52,
- "../../node_modules/react-dom/lib/ReactErrorUtils.js": 53,
- "../../node_modules/react-dom/lib/getEventTarget.js": 54,
- "../../node_modules/react-dom/lib/isEventSupported.js": 55,
- "../../node_modules/react-dom/lib/getEventModifierState.js": 56,
- "../../node_modules/react-dom/lib/DOMChildrenOperations.js": 57,
- "../../node_modules/react-dom/lib/DOMNamespaces.js": 58,
- "../../node_modules/react-dom/lib/createMicrosoftUnsafeLocalFunction.js": 59,
- "../../node_modules/react-dom/lib/LinkedValueUtils.js": 60,
- "../../node_modules/react-dom/lib/ReactComponentEnvironment.js": 61,
- "../../node_modules/fbjs/lib/shallowEqual.js": 62,
- "../../node_modules/react-dom/lib/shouldUpdateReactComponent.js": 63,
- "../../node_modules/react-dom/lib/KeyEscapeUtils.js": 64,
- "../../node_modules/react-dom/lib/ReactUpdateQueue.js": 65,
- "../../node_modules/react-dom/lib/validateDOMNesting.js": 66,
- "../../node_modules/react-dom/lib/getEventCharCode.js": 67,
- "../../node_modules/react-dom/lib/ReactDOMComponentFlags.js": 68,
- "../../node_modules/react-dom/lib/accumulateInto.js": 69,
- "../../node_modules/react-dom/lib/forEachAccumulated.js": 70,
- "../../node_modules/react-dom/lib/getTextContentAccessor.js": 71,
- "../../node_modules/react-dom/lib/CallbackQueue.js": 72,
- "../../node_modules/react-dom/lib/ReactFeatureFlags.js": 73,
- "../../node_modules/react-dom/lib/inputValueTracking.js": 74,
- "../../node_modules/react-dom/lib/isTextInputElement.js": 75,
- "../../node_modules/react-dom/lib/ViewportMetrics.js": 76,
- "../../node_modules/react-dom/lib/setTextContent.js": 77,
- "../../node_modules/fbjs/lib/focusNode.js": 78,
- "../../node_modules/react-dom/lib/CSSProperty.js": 79,
- "../../node_modules/react-dom/lib/DOMPropertyOperations.js": 80,
- "../../node_modules/react-dom/lib/ReactDOMSelect.js": 81,
- "../../node_modules/process/browser.js": 82,
- "../../node_modules/react-dom/lib/instantiateReactComponent.js": 83,
- "../../node_modules/react-dom/lib/ReactNodeTypes.js": 84,
- "../../node_modules/react-dom/lib/ReactEmptyComponent.js": 85,
- "../../node_modules/react-dom/lib/ReactHostComponent.js": 86,
- "../../node_modules/react-dom/lib/traverseAllChildren.js": 87,
- "../../node_modules/react/lib/ReactComponentTreeHook.js": 88,
- "../../node_modules/fbjs/lib/EventListener.js": 89,
- "../../node_modules/react-dom/lib/ReactInputSelection.js": 90,
- "../../node_modules/fbjs/lib/getActiveElement.js": 91,
- "../../node_modules/react-dom/lib/ReactMount.js": 92,
- "../../node_modules/react-dom/lib/getHostComponentFromComposite.js": 93,
- "../../node_modules/react-dom/lib/ReactDOM.js": 94,
- "../../node_modules/react-dom/lib/ReactDefaultInjection.js": 95,
- "../../node_modules/react-dom/lib/ARIADOMPropertyConfig.js": 96,
- "../../node_modules/react-dom/lib/BeforeInputEventPlugin.js": 97,
- "../../node_modules/react-dom/lib/FallbackCompositionState.js": 98,
- "../../node_modules/react-dom/lib/SyntheticCompositionEvent.js": 99,
- "../../node_modules/react-dom/lib/SyntheticInputEvent.js": 100,
- "../../node_modules/react-dom/lib/ChangeEventPlugin.js": 101,
- "../../node_modules/react-dom/lib/ReactRef.js": 102,
- "../../node_modules/react-dom/lib/ReactOwner.js": 103,
- "../../node_modules/react-dom/lib/DefaultEventPluginOrder.js": 104,
- "../../node_modules/react-dom/lib/EnterLeaveEventPlugin.js": 105,
- "../../node_modules/react-dom/lib/HTMLDOMPropertyConfig.js": 106,
- "../../node_modules/react-dom/lib/ReactComponentBrowserEnvironment.js": 107,
- "../../node_modules/react-dom/lib/Danger.js": 108,
- "../../node_modules/fbjs/lib/createNodesFromMarkup.js": 109,
- "../../node_modules/fbjs/lib/createArrayFromMixed.js": 110,
- "../../node_modules/fbjs/lib/getMarkupWrap.js": 111,
- "../../node_modules/react-dom/lib/ReactDOMIDOperations.js": 112,
- "../../node_modules/react-dom/lib/ReactDOMComponent.js": 113,
- "../../node_modules/react-dom/lib/AutoFocusUtils.js": 114,
- "../../node_modules/react-dom/lib/CSSPropertyOperations.js": 115,
- "../../node_modules/fbjs/lib/camelizeStyleName.js": 116,
- "../../node_modules/fbjs/lib/camelize.js": 117,
- "../../node_modules/react-dom/lib/dangerousStyleValue.js": 118,
- "../../node_modules/fbjs/lib/hyphenateStyleName.js": 119,
- "../../node_modules/fbjs/lib/hyphenate.js": 120,
- "../../node_modules/fbjs/lib/memoizeStringOnly.js": 121,
- "../../node_modules/react-dom/lib/quoteAttributeValueForBrowser.js": 122,
- "../../node_modules/react-dom/lib/ReactEventEmitterMixin.js": 123,
- "../../node_modules/react-dom/lib/getVendorPrefixedEventName.js": 124,
- "../../node_modules/react-dom/lib/ReactDOMInput.js": 125,
- "../../node_modules/react-dom/lib/ReactPropTypesSecret.js": 126,
- "../../node_modules/react-dom/lib/ReactDOMOption.js": 127,
- "../../node_modules/react-dom/lib/ReactDOMTextarea.js": 128,
- "../../node_modules/react-dom/lib/ReactMultiChild.js": 129,
- "../../node_modules/react-dom/lib/ReactChildReconciler.js": 130,
- "../../node_modules/react-dom/lib/ReactCompositeComponent.js": 131,
- "../../node_modules/react/lib/getNextDebugID.js": 132,
- "../../node_modules/react-dom/lib/ReactElementSymbol.js": 133,
- "../../node_modules/react-dom/lib/getIteratorFn.js": 134,
- "../../node_modules/react-dom/lib/flattenChildren.js": 135,
- "../../node_modules/react-dom/lib/ReactServerRenderingTransaction.js": 136,
- "../../node_modules/react-dom/lib/ReactServerUpdateQueue.js": 137,
- "../../node_modules/react-dom/lib/ReactDOMEmptyComponent.js": 138,
- "../../node_modules/react-dom/lib/ReactDOMTreeTraversal.js": 139,
- "../../node_modules/react-dom/lib/ReactDOMTextComponent.js": 140,
- "../../node_modules/react-dom/lib/ReactDefaultBatchingStrategy.js": 141,
- "../../node_modules/react-dom/lib/ReactEventListener.js": 142,
- "../../node_modules/fbjs/lib/getUnboundedScrollPosition.js": 143,
- "../../node_modules/react-dom/lib/ReactInjection.js": 144,
- "../../node_modules/react-dom/lib/ReactReconcileTransaction.js": 145,
- "../../node_modules/react-dom/lib/ReactDOMSelection.js": 146,
- "../../node_modules/react-dom/lib/getNodeForCharacterOffset.js": 147,
- "../../node_modules/fbjs/lib/containsNode.js": 148,
- "../../node_modules/fbjs/lib/isTextNode.js": 149,
- "../../node_modules/fbjs/lib/isNode.js": 150,
- "../../node_modules/react-dom/lib/SVGDOMPropertyConfig.js": 151,
- "../../node_modules/react-dom/lib/SelectEventPlugin.js": 152,
- "../../node_modules/react-dom/lib/SimpleEventPlugin.js": 153,
- "../../node_modules/react-dom/lib/SyntheticAnimationEvent.js": 154,
- "../../node_modules/react-dom/lib/SyntheticClipboardEvent.js": 155,
- "../../node_modules/react-dom/lib/SyntheticFocusEvent.js": 156,
- "../../node_modules/react-dom/lib/SyntheticKeyboardEvent.js": 157,
- "../../node_modules/react-dom/lib/getEventKey.js": 158,
- "../../node_modules/react-dom/lib/SyntheticDragEvent.js": 159,
- "../../node_modules/react-dom/lib/SyntheticTouchEvent.js": 160,
- "../../node_modules/react-dom/lib/SyntheticTransitionEvent.js": 161,
- "../../node_modules/react-dom/lib/SyntheticWheelEvent.js": 162,
- "../../node_modules/react-dom/lib/ReactDOMContainerInfo.js": 163,
- "../../node_modules/react-dom/lib/ReactDOMFeatureFlags.js": 164,
- "../../node_modules/react-dom/lib/ReactMarkupChecksum.js": 165,
- "../../node_modules/react-dom/lib/adler32.js": 166,
- "../../node_modules/react-dom/lib/ReactVersion.js": 167,
- "../../node_modules/react-dom/lib/findDOMNode.js": 168,
+ "../../node_modules/react-dom/lib/reactProdInvariant.js": 34,
+ "../../node_modules/react-dom/lib/DOMProperty.js": 35,
+ "../../node_modules/react-dom/lib/ReactDOMComponentFlags.js": 36,
+ "../../node_modules/react-dom/lib/ReactDefaultInjection.js": 37,
+ "../../node_modules/react-dom/lib/ARIADOMPropertyConfig.js": 38,
+ "../../node_modules/react-dom/lib/BeforeInputEventPlugin.js": 39,
+ "../../node_modules/react-dom/lib/EventPropagators.js": 40,
+ "../../node_modules/react-dom/lib/EventPluginHub.js": 41,
+ "../../node_modules/react-dom/lib/EventPluginRegistry.js": 42,
+ "../../node_modules/react-dom/lib/EventPluginUtils.js": 43,
+ "../../node_modules/react-dom/lib/ReactErrorUtils.js": 44,
+ "../../node_modules/react-dom/lib/accumulateInto.js": 45,
+ "../../node_modules/react-dom/lib/forEachAccumulated.js": 46,
+ "../../node_modules/fbjs/lib/ExecutionEnvironment.js": 47,
+ "../../node_modules/react-dom/lib/FallbackCompositionState.js": 48,
+ "../../node_modules/react-dom/lib/PooledClass.js": 49,
+ "../../node_modules/react-dom/lib/getTextContentAccessor.js": 50,
+ "../../node_modules/react-dom/lib/SyntheticCompositionEvent.js": 51,
+ "../../node_modules/react-dom/lib/SyntheticEvent.js": 52,
+ "../../node_modules/react-dom/lib/SyntheticInputEvent.js": 53,
+ "../../node_modules/react-dom/lib/ChangeEventPlugin.js": 54,
+ "../../node_modules/react-dom/lib/ReactUpdates.js": 55,
+ "../../node_modules/react-dom/lib/CallbackQueue.js": 56,
+ "../../node_modules/react-dom/lib/ReactFeatureFlags.js": 57,
+ "../../node_modules/react-dom/lib/ReactReconciler.js": 58,
+ "../../node_modules/react-dom/lib/ReactRef.js": 59,
+ "../../node_modules/react-dom/lib/ReactOwner.js": 60,
+ "../../node_modules/react-dom/lib/ReactInstrumentation.js": 61,
+ "../../node_modules/react-dom/lib/Transaction.js": 62,
+ "../../node_modules/react-dom/lib/inputValueTracking.js": 63,
+ "../../node_modules/react-dom/lib/getEventTarget.js": 64,
+ "../../node_modules/react-dom/lib/isEventSupported.js": 65,
+ "../../node_modules/react-dom/lib/isTextInputElement.js": 66,
+ "../../node_modules/react-dom/lib/DefaultEventPluginOrder.js": 67,
+ "../../node_modules/react-dom/lib/EnterLeaveEventPlugin.js": 68,
+ "../../node_modules/react-dom/lib/SyntheticMouseEvent.js": 69,
+ "../../node_modules/react-dom/lib/SyntheticUIEvent.js": 70,
+ "../../node_modules/react-dom/lib/ViewportMetrics.js": 71,
+ "../../node_modules/react-dom/lib/getEventModifierState.js": 72,
+ "../../node_modules/react-dom/lib/HTMLDOMPropertyConfig.js": 73,
+ "../../node_modules/react-dom/lib/ReactComponentBrowserEnvironment.js": 74,
+ "../../node_modules/react-dom/lib/DOMChildrenOperations.js": 75,
+ "../../node_modules/react-dom/lib/DOMLazyTree.js": 76,
+ "../../node_modules/react-dom/lib/DOMNamespaces.js": 77,
+ "../../node_modules/react-dom/lib/setInnerHTML.js": 78,
+ "../../node_modules/react-dom/lib/createMicrosoftUnsafeLocalFunction.js": 79,
+ "../../node_modules/react-dom/lib/setTextContent.js": 80,
+ "../../node_modules/react-dom/lib/escapeTextContentForBrowser.js": 81,
+ "../../node_modules/react-dom/lib/Danger.js": 82,
+ "../../node_modules/fbjs/lib/createNodesFromMarkup.js": 83,
+ "../../node_modules/fbjs/lib/createArrayFromMixed.js": 84,
+ "../../node_modules/fbjs/lib/getMarkupWrap.js": 85,
+ "../../node_modules/react-dom/lib/ReactDOMIDOperations.js": 86,
+ "../../node_modules/react-dom/lib/ReactDOMComponent.js": 87,
+ "../../node_modules/react-dom/lib/AutoFocusUtils.js": 88,
+ "../../node_modules/fbjs/lib/focusNode.js": 89,
+ "../../node_modules/react-dom/lib/CSSPropertyOperations.js": 90,
+ "../../node_modules/react-dom/lib/CSSProperty.js": 91,
+ "../../node_modules/fbjs/lib/camelizeStyleName.js": 92,
+ "../../node_modules/fbjs/lib/camelize.js": 93,
+ "../../node_modules/react-dom/lib/dangerousStyleValue.js": 94,
+ "../../node_modules/fbjs/lib/hyphenateStyleName.js": 95,
+ "../../node_modules/fbjs/lib/hyphenate.js": 96,
+ "../../node_modules/fbjs/lib/memoizeStringOnly.js": 97,
+ "../../node_modules/react-dom/lib/DOMPropertyOperations.js": 98,
+ "../../node_modules/react-dom/lib/quoteAttributeValueForBrowser.js": 99,
+ "../../node_modules/react-dom/lib/ReactBrowserEventEmitter.js": 100,
+ "../../node_modules/react-dom/lib/ReactEventEmitterMixin.js": 101,
+ "../../node_modules/react-dom/lib/getVendorPrefixedEventName.js": 102,
+ "../../node_modules/react-dom/lib/ReactDOMInput.js": 103,
+ "../../node_modules/react-dom/lib/LinkedValueUtils.js": 104,
+ "../../node_modules/react-dom/lib/ReactPropTypesSecret.js": 105,
+ "../../node_modules/react-dom/lib/ReactDOMOption.js": 106,
+ "../../node_modules/react-dom/lib/ReactDOMSelect.js": 107,
+ "../../node_modules/react-dom/lib/ReactDOMTextarea.js": 108,
+ "../../node_modules/react-dom/lib/ReactMultiChild.js": 109,
+ "../../node_modules/react-dom/lib/ReactComponentEnvironment.js": 110,
+ "../../node_modules/react-dom/lib/ReactInstanceMap.js": 111,
+ "../../node_modules/react-dom/lib/ReactChildReconciler.js": 112,
+ "../../node_modules/process/browser.js": 113,
+ "../../node_modules/react-dom/lib/instantiateReactComponent.js": 114,
+ "../../node_modules/react-dom/lib/ReactCompositeComponent.js": 115,
+ "../../node_modules/react-dom/lib/ReactNodeTypes.js": 116,
+ "../../node_modules/fbjs/lib/shallowEqual.js": 117,
+ "../../node_modules/react-dom/lib/shouldUpdateReactComponent.js": 118,
+ "../../node_modules/react-dom/lib/ReactEmptyComponent.js": 119,
+ "../../node_modules/react-dom/lib/ReactHostComponent.js": 120,
+ "../../node_modules/react/lib/getNextDebugID.js": 121,
+ "../../node_modules/react-dom/lib/KeyEscapeUtils.js": 122,
+ "../../node_modules/react-dom/lib/traverseAllChildren.js": 123,
+ "../../node_modules/react-dom/lib/ReactElementSymbol.js": 124,
+ "../../node_modules/react-dom/lib/getIteratorFn.js": 125,
+ "../../node_modules/react/lib/ReactComponentTreeHook.js": 126,
+ "../../node_modules/react-dom/lib/flattenChildren.js": 127,
+ "../../node_modules/react-dom/lib/ReactServerRenderingTransaction.js": 128,
+ "../../node_modules/react-dom/lib/ReactServerUpdateQueue.js": 129,
+ "../../node_modules/react-dom/lib/ReactUpdateQueue.js": 130,
+ "../../node_modules/react-dom/lib/validateDOMNesting.js": 131,
+ "../../node_modules/react-dom/lib/ReactDOMEmptyComponent.js": 132,
+ "../../node_modules/react-dom/lib/ReactDOMTreeTraversal.js": 133,
+ "../../node_modules/react-dom/lib/ReactDOMTextComponent.js": 134,
+ "../../node_modules/react-dom/lib/ReactDefaultBatchingStrategy.js": 135,
+ "../../node_modules/react-dom/lib/ReactEventListener.js": 136,
+ "../../node_modules/fbjs/lib/EventListener.js": 137,
+ "../../node_modules/fbjs/lib/getUnboundedScrollPosition.js": 138,
+ "../../node_modules/react-dom/lib/ReactInjection.js": 139,
+ "../../node_modules/react-dom/lib/ReactReconcileTransaction.js": 140,
+ "../../node_modules/react-dom/lib/ReactInputSelection.js": 141,
+ "../../node_modules/react-dom/lib/ReactDOMSelection.js": 142,
+ "../../node_modules/react-dom/lib/getNodeForCharacterOffset.js": 143,
+ "../../node_modules/fbjs/lib/containsNode.js": 144,
+ "../../node_modules/fbjs/lib/isTextNode.js": 145,
+ "../../node_modules/fbjs/lib/isNode.js": 146,
+ "../../node_modules/fbjs/lib/getActiveElement.js": 147,
+ "../../node_modules/react-dom/lib/SVGDOMPropertyConfig.js": 148,
+ "../../node_modules/react-dom/lib/SelectEventPlugin.js": 149,
+ "../../node_modules/react-dom/lib/SimpleEventPlugin.js": 150,
+ "../../node_modules/react-dom/lib/SyntheticAnimationEvent.js": 151,
+ "../../node_modules/react-dom/lib/SyntheticClipboardEvent.js": 152,
+ "../../node_modules/react-dom/lib/SyntheticFocusEvent.js": 153,
+ "../../node_modules/react-dom/lib/SyntheticKeyboardEvent.js": 154,
+ "../../node_modules/react-dom/lib/getEventCharCode.js": 155,
+ "../../node_modules/react-dom/lib/getEventKey.js": 156,
+ "../../node_modules/react-dom/lib/SyntheticDragEvent.js": 157,
+ "../../node_modules/react-dom/lib/SyntheticTouchEvent.js": 158,
+ "../../node_modules/react-dom/lib/SyntheticTransitionEvent.js": 159,
+ "../../node_modules/react-dom/lib/SyntheticWheelEvent.js": 160,
+ "../../node_modules/react-dom/lib/ReactMount.js": 161,
+ "../../node_modules/react-dom/lib/ReactDOMContainerInfo.js": 162,
+ "../../node_modules/react-dom/lib/ReactDOMFeatureFlags.js": 163,
+ "../../node_modules/react-dom/lib/ReactMarkupChecksum.js": 164,
+ "../../node_modules/react-dom/lib/adler32.js": 165,
+ "../../node_modules/react-dom/lib/ReactVersion.js": 166,
+ "../../node_modules/react-dom/lib/findDOMNode.js": 167,
+ "../../node_modules/react-dom/lib/getHostComponentFromComposite.js": 168,
"../../node_modules/react-dom/lib/renderSubtreeIntoContainer.js": 169
},
"usedIds": {
@@ -533,276 +535,281 @@ chunk {14} 11202a345a2ce63a2fb7.js 30.2 kB [initial] [rendered] [recorded]
},
"chunks": {
"byName": {},
- "byBlocks": {
- "example.js:0/0:0": 0,
- "example.js:0/0:1": 1,
- "example.js:0/0:2": 2,
- "example.js:0/0:3": 3,
- "example.js:0/0:4": 4,
- "example.js:0/0:5": 5,
- "example.js:0/0:6": 6,
- "example.js:0/0:7": 7,
- "example.js:0/0:8": 8,
- "example.js:0/0:9": 9,
- "example.js:0/0:10": 10,
- "example.js:0/0:11": 11
+ "bySource": {
+ "11 example.js react-dom": 1,
+ "0 example.js react-dom": 2,
+ "1 example.js react-dom": 4,
+ "2 example.js react-dom": 6,
+ "3 example.js react-dom": 7,
+ "4 example.js react-dom": 8,
+ "5 example.js react-dom": 9,
+ "6 example.js react-dom": 10,
+ "7 example.js react-dom": 11,
+ "8 example.js react-dom": 12,
+ "9 example.js react-dom": 13,
+ "10 example.js react-dom": 14
},
- "usedIds": {
- "0": 0,
- "1": 1,
- "2": 2,
- "3": 3,
- "4": 4,
- "5": 5,
- "6": 6,
- "7": 7,
- "8": 8,
- "9": 9,
- "10": 10,
- "11": 11,
- "12": 12,
- "13": 13,
- "14": 14
- }
+ "usedIds": [
+ 0,
+ 1,
+ 2,
+ 3,
+ 4,
+ 5,
+ 6,
+ 7,
+ 8,
+ 9,
+ 10,
+ 11,
+ 12,
+ 13,
+ 14
+ ]
},
"aggressiveSplits": [
{
"modules": [
- "../../node_modules/react-dom/index.js",
+ "../../node_modules/fbjs/lib/EventListener.js",
"../../node_modules/fbjs/lib/ExecutionEnvironment.js",
- "../../node_modules/fbjs/lib/shallowEqual.js",
+ "../../node_modules/fbjs/lib/camelize.js",
+ "../../node_modules/fbjs/lib/camelizeStyleName.js",
+ "../../node_modules/fbjs/lib/containsNode.js",
+ "../../node_modules/fbjs/lib/createArrayFromMixed.js",
+ "../../node_modules/fbjs/lib/createNodesFromMarkup.js",
"../../node_modules/fbjs/lib/focusNode.js",
- "../../node_modules/react-dom/lib/CSSProperty.js",
- "../../node_modules/process/browser.js",
- "../../node_modules/fbjs/lib/EventListener.js",
"../../node_modules/fbjs/lib/getActiveElement.js",
- "../../node_modules/react-dom/lib/ARIADOMPropertyConfig.js",
- "../../node_modules/react-dom/lib/BeforeInputEventPlugin.js",
- "../../node_modules/fbjs/lib/createNodesFromMarkup.js",
- "../../node_modules/fbjs/lib/createArrayFromMixed.js",
"../../node_modules/fbjs/lib/getMarkupWrap.js",
- "../../node_modules/react-dom/lib/AutoFocusUtils.js",
- "../../node_modules/fbjs/lib/camelizeStyleName.js",
- "../../node_modules/fbjs/lib/camelize.js",
- "../../node_modules/fbjs/lib/hyphenateStyleName.js",
- "../../node_modules/fbjs/lib/hyphenate.js",
- "../../node_modules/fbjs/lib/memoizeStringOnly.js",
"../../node_modules/fbjs/lib/getUnboundedScrollPosition.js",
- "../../node_modules/fbjs/lib/containsNode.js",
+ "../../node_modules/fbjs/lib/hyphenate.js",
+ "../../node_modules/fbjs/lib/hyphenateStyleName.js",
+ "../../node_modules/fbjs/lib/isNode.js",
"../../node_modules/fbjs/lib/isTextNode.js",
- "../../node_modules/fbjs/lib/isNode.js"
- ],
- "hash": "af5b936f620d7c2cf46e0e11bd2b48e3",
- "id": 0
- },
- {
- "modules": [
- "../../node_modules/react-dom/lib/reactProdInvariant.js",
- "../../node_modules/react-dom/lib/setInnerHTML.js",
- "../../node_modules/react-dom/lib/getEventTarget.js",
- "../../node_modules/react-dom/lib/isEventSupported.js",
- "../../node_modules/react-dom/lib/getEventModifierState.js",
- "../../node_modules/react-dom/lib/getTextContentAccessor.js",
- "../../node_modules/react-dom/lib/inputValueTracking.js",
- "../../node_modules/react-dom/lib/isTextInputElement.js",
- "../../node_modules/react-dom/lib/instantiateReactComponent.js",
- "../../node_modules/react-dom/lib/getHostComponentFromComposite.js",
- "../../node_modules/react-dom/lib/quoteAttributeValueForBrowser.js",
- "../../node_modules/react-dom/lib/getVendorPrefixedEventName.js",
- "../../node_modules/react-dom/lib/getIteratorFn.js",
- "../../node_modules/react-dom/lib/flattenChildren.js",
- "../../node_modules/react-dom/lib/getNodeForCharacterOffset.js",
- "../../node_modules/react-dom/lib/getEventKey.js",
- "../../node_modules/react-dom/lib/renderSubtreeIntoContainer.js"
- ],
- "hash": "fbb0bfdcf201839059f94a4681a34acf",
- "id": 1
- },
- {
- "modules": [
- "../../node_modules/react-dom/lib/ReactInstrumentation.js",
- "../../node_modules/react-dom/lib/ReactInstanceMap.js",
- "../../node_modules/react-dom/lib/ReactErrorUtils.js",
- "../../node_modules/react-dom/lib/ReactFeatureFlags.js",
- "../../node_modules/react-dom/lib/ReactNodeTypes.js",
- "../../node_modules/react-dom/lib/ReactHostComponent.js",
- "../../node_modules/react-dom/lib/ReactInputSelection.js",
- "../../node_modules/react-dom/lib/ReactDefaultInjection.js",
- "../../node_modules/react-dom/lib/ReactRef.js",
- "../../node_modules/react-dom/lib/ReactOwner.js",
- "../../node_modules/react-dom/lib/ReactDOMTextarea.js",
- "../../node_modules/react-dom/lib/ReactDOMTextComponent.js",
- "../../node_modules/react-dom/lib/ReactEventListener.js",
- "../../node_modules/react-dom/lib/ReactInjection.js",
- "../../node_modules/react-dom/lib/ReactDOMSelection.js",
- "../../node_modules/react-dom/lib/SyntheticAnimationEvent.js",
- "../../node_modules/react-dom/lib/ReactMarkupChecksum.js"
+ "../../node_modules/fbjs/lib/memoizeStringOnly.js",
+ "../../node_modules/fbjs/lib/shallowEqual.js",
+ "../../node_modules/process/browser.js",
+ "../../node_modules/react-dom/index.js",
+ "../../node_modules/react-dom/lib/ARIADOMPropertyConfig.js",
+ "../../node_modules/react-dom/lib/AutoFocusUtils.js",
+ "../../node_modules/react-dom/lib/BeforeInputEventPlugin.js",
+ "../../node_modules/react-dom/lib/CSSProperty.js"
],
- "hash": "d8035b04d59361a42a17d4fc01467f19",
+ "size": 46843,
+ "hash": "987f929f287f8a6c88ac92f1fbcd45be",
"id": 2
},
{
"modules": [
- "../../node_modules/react-dom/lib/SyntheticEvent.js",
- "../../node_modules/react-dom/lib/SyntheticUIEvent.js",
- "../../node_modules/react-dom/lib/Transaction.js",
- "../../node_modules/react-dom/lib/SyntheticMouseEvent.js",
- "../../node_modules/react-dom/lib/escapeTextContentForBrowser.js",
- "../../node_modules/react-dom/lib/createMicrosoftUnsafeLocalFunction.js",
- "../../node_modules/react-dom/lib/getEventCharCode.js",
- "../../node_modules/react-dom/lib/accumulateInto.js",
- "../../node_modules/react-dom/lib/forEachAccumulated.js",
- "../../node_modules/react-dom/lib/dangerousStyleValue.js",
- "../../node_modules/react-dom/lib/SimpleEventPlugin.js",
- "../../node_modules/react-dom/lib/SyntheticTouchEvent.js",
- "../../node_modules/react-dom/lib/SyntheticTransitionEvent.js",
- "../../node_modules/react-dom/lib/SyntheticWheelEvent.js",
- "../../node_modules/react-dom/lib/adler32.js",
- "../../node_modules/react-dom/lib/findDOMNode.js"
+ "../../node_modules/create-react-class/factory.js",
+ "../../node_modules/fbjs/lib/emptyFunction.js",
+ "../../node_modules/fbjs/lib/emptyObject.js",
+ "../../node_modules/fbjs/lib/invariant.js",
+ "../../node_modules/fbjs/lib/warning.js",
+ "../../node_modules/object-assign/index.js",
+ "../../node_modules/prop-types/checkPropTypes.js",
+ "../../node_modules/prop-types/factory.js"
],
- "hash": "92951e4964e84e7091031112e8d066b1",
+ "size": 38697,
+ "hash": "bc5ed8b126130fde4f428f05cac600ce",
"id": 3
},
{
"modules": [
- "../../node_modules/react-dom/lib/ReactDOMComponentTree.js",
- "../../node_modules/react-dom/lib/PooledClass.js",
- "../../node_modules/react-dom/lib/ReactBrowserEventEmitter.js",
- "../../node_modules/react-dom/lib/LinkedValueUtils.js",
- "../../node_modules/react-dom/lib/ReactDOMComponentFlags.js",
- "../../node_modules/react-dom/lib/ReactDOM.js",
- "../../node_modules/react-dom/lib/ReactDOMIDOperations.js",
- "../../node_modules/react-dom/lib/ReactDOMOption.js",
- "../../node_modules/react-dom/lib/ReactChildReconciler.js",
- "../../node_modules/react-dom/lib/ReactElementSymbol.js",
- "../../node_modules/react-dom/lib/ReactDOMEmptyComponent.js",
- "../../node_modules/react-dom/lib/ReactDefaultBatchingStrategy.js",
- "../../node_modules/react-dom/lib/ReactDOMContainerInfo.js",
- "../../node_modules/react-dom/lib/ReactDOMFeatureFlags.js",
- "../../node_modules/react-dom/lib/ReactVersion.js"
+ "../../node_modules/react-dom/lib/CSSPropertyOperations.js",
+ "../../node_modules/react-dom/lib/CallbackQueue.js",
+ "../../node_modules/react-dom/lib/ChangeEventPlugin.js",
+ "../../node_modules/react-dom/lib/DOMChildrenOperations.js",
+ "../../node_modules/react-dom/lib/DOMLazyTree.js",
+ "../../node_modules/react-dom/lib/DOMNamespaces.js",
+ "../../node_modules/react-dom/lib/DOMProperty.js",
+ "../../node_modules/react-dom/lib/DOMPropertyOperations.js"
],
- "hash": "d323f006c00a41b194cbeb3dcea2634a",
+ "size": 47979,
+ "hash": "511009f3a8f06b7c54cbbcccac9d6dfb",
"id": 4
},
{
"modules": [
- "../../node_modules/react-dom/lib/ReactUpdates.js",
- "../../node_modules/react-dom/lib/ReactReconciler.js",
- "../../node_modules/react-dom/lib/ReactUpdateQueue.js",
- "../../node_modules/react-dom/lib/ViewportMetrics.js",
- "../../node_modules/react-dom/lib/SyntheticInputEvent.js",
- "../../node_modules/react-dom/lib/ReactServerUpdateQueue.js",
- "../../node_modules/react-dom/lib/SVGDOMPropertyConfig.js",
- "../../node_modules/react-dom/lib/SelectEventPlugin.js",
- "../../node_modules/react-dom/lib/SyntheticFocusEvent.js",
- "../../node_modules/react-dom/lib/SyntheticKeyboardEvent.js",
- "../../node_modules/react-dom/lib/SyntheticDragEvent.js"
+ "../../node_modules/prop-types/factoryWithTypeCheckers.js",
+ "../../node_modules/prop-types/lib/ReactPropTypesSecret.js",
+ "../../node_modules/react/lib/KeyEscapeUtils.js",
+ "../../node_modules/react/lib/PooledClass.js",
+ "../../node_modules/react/lib/React.js",
+ "../../node_modules/react/lib/ReactBaseClasses.js",
+ "../../node_modules/react/lib/ReactChildren.js",
+ "../../node_modules/react/lib/ReactCurrentOwner.js",
+ "../../node_modules/react/lib/ReactDOMFactories.js"
],
- "hash": "567bf6b0afa4e4baa4fba1a99e1a9298",
+ "size": 46762,
+ "hash": "2a784b823ab0da1e02933326e6e3f80f",
"id": 5
},
{
"modules": [
- "../../node_modules/react-dom/lib/EventPropagators.js",
+ "../../node_modules/react-dom/lib/Danger.js",
+ "../../node_modules/react-dom/lib/DefaultEventPluginOrder.js",
+ "../../node_modules/react-dom/lib/EnterLeaveEventPlugin.js",
"../../node_modules/react-dom/lib/EventPluginHub.js",
"../../node_modules/react-dom/lib/EventPluginRegistry.js",
"../../node_modules/react-dom/lib/EventPluginUtils.js",
- "../../node_modules/react-dom/lib/ReactComponentEnvironment.js",
- "../../node_modules/react-dom/lib/KeyEscapeUtils.js",
+ "../../node_modules/react-dom/lib/EventPropagators.js",
"../../node_modules/react-dom/lib/FallbackCompositionState.js",
- "../../node_modules/react-dom/lib/DefaultEventPluginOrder.js",
- "../../node_modules/react-dom/lib/EnterLeaveEventPlugin.js",
"../../node_modules/react-dom/lib/HTMLDOMPropertyConfig.js",
- "../../node_modules/react-dom/lib/Danger.js"
+ "../../node_modules/react-dom/lib/KeyEscapeUtils.js"
],
- "hash": "435514b5a5822c639a062f7ecb8fcd04",
+ "size": 47455,
+ "hash": "0abfd767d2250ac9265a7fa790d9e9f5",
"id": 6
},
{
"modules": [
- "../../node_modules/react-dom/lib/DOMProperty.js",
- "../../node_modules/react-dom/lib/DOMLazyTree.js",
- "../../node_modules/react-dom/lib/DOMChildrenOperations.js",
- "../../node_modules/react-dom/lib/DOMNamespaces.js",
- "../../node_modules/react-dom/lib/CallbackQueue.js",
- "../../node_modules/react-dom/lib/DOMPropertyOperations.js",
- "../../node_modules/react-dom/lib/ChangeEventPlugin.js",
+ "../../node_modules/react-dom/lib/LinkedValueUtils.js",
+ "../../node_modules/react-dom/lib/PooledClass.js",
+ "../../node_modules/react-dom/lib/ReactBrowserEventEmitter.js",
+ "../../node_modules/react-dom/lib/ReactChildReconciler.js",
"../../node_modules/react-dom/lib/ReactComponentBrowserEnvironment.js",
- "../../node_modules/react-dom/lib/CSSPropertyOperations.js"
+ "../../node_modules/react-dom/lib/ReactComponentEnvironment.js",
+ "../../node_modules/react-dom/lib/ReactCompositeComponent.js"
],
- "hash": "04e95786881a7db62441637cbcef06cb",
+ "size": 63814,
+ "hash": "aae9c6dac629dd3f112ead84c645f3fa",
"id": 7
},
{
"modules": [
- "../../node_modules/react-dom/lib/shouldUpdateReactComponent.js",
- "../../node_modules/react-dom/lib/validateDOMNesting.js",
- "../../node_modules/react-dom/lib/setTextContent.js",
- "../../node_modules/react-dom/lib/traverseAllChildren.js",
- "../../node_modules/react/lib/ReactComponentTreeHook.js",
- "../../node_modules/react/lib/getNextDebugID.js"
+ "../../node_modules/react-dom/lib/ReactDOM.js",
+ "../../node_modules/react-dom/lib/ReactDOMComponent.js",
+ "../../node_modules/react-dom/lib/ReactDOMComponentFlags.js"
],
- "hash": "ebe11885009391a25f13a5d3ebd9a80b",
+ "size": 44366,
+ "hash": "cd98376ec90f2e366b9425f7247176e1",
"id": 8
},
{
"modules": [
- "../../node_modules/react-dom/lib/ReactMount.js",
- "../../node_modules/react-dom/lib/SyntheticCompositionEvent.js",
- "../../node_modules/react-dom/lib/ReactMultiChild.js",
- "../../node_modules/react-dom/lib/ReactServerRenderingTransaction.js",
- "../../node_modules/react-dom/lib/ReactReconcileTransaction.js",
- "../../node_modules/react-dom/lib/SyntheticClipboardEvent.js"
+ "../../node_modules/react-dom/lib/ReactDOMComponentTree.js",
+ "../../node_modules/react-dom/lib/ReactDOMContainerInfo.js",
+ "../../node_modules/react-dom/lib/ReactDOMEmptyComponent.js",
+ "../../node_modules/react-dom/lib/ReactDOMFeatureFlags.js",
+ "../../node_modules/react-dom/lib/ReactDOMIDOperations.js",
+ "../../node_modules/react-dom/lib/ReactDOMInput.js",
+ "../../node_modules/react-dom/lib/ReactDOMOption.js",
+ "../../node_modules/react-dom/lib/ReactDOMSelect.js",
+ "../../node_modules/react-dom/lib/ReactDOMSelection.js",
+ "../../node_modules/react-dom/lib/ReactDOMTextComponent.js"
],
- "hash": "1aa11917196d1d3b05c1ff41ee1672ee",
+ "size": 45476,
+ "hash": "a0f973cb054f411fba45bd946c5bf6e3",
"id": 9
},
{
"modules": [
- "../../node_modules/react-dom/lib/ReactDOMSelect.js",
- "../../node_modules/react-dom/lib/ReactDOMComponent.js",
- "../../node_modules/react-dom/lib/ReactPropTypesSecret.js",
- "../../node_modules/react-dom/lib/ReactDOMTreeTraversal.js"
+ "../../node_modules/react-dom/lib/ReactDOMTextarea.js",
+ "../../node_modules/react-dom/lib/ReactDOMTreeTraversal.js",
+ "../../node_modules/react-dom/lib/ReactDefaultBatchingStrategy.js",
+ "../../node_modules/react-dom/lib/ReactDefaultInjection.js",
+ "../../node_modules/react-dom/lib/ReactElementSymbol.js",
+ "../../node_modules/react-dom/lib/ReactEmptyComponent.js",
+ "../../node_modules/react-dom/lib/ReactErrorUtils.js",
+ "../../node_modules/react-dom/lib/ReactEventEmitterMixin.js",
+ "../../node_modules/react-dom/lib/ReactEventListener.js",
+ "../../node_modules/react-dom/lib/ReactFeatureFlags.js",
+ "../../node_modules/react-dom/lib/ReactHostComponent.js",
+ "../../node_modules/react-dom/lib/ReactInjection.js",
+ "../../node_modules/react-dom/lib/ReactInputSelection.js",
+ "../../node_modules/react-dom/lib/ReactInstanceMap.js",
+ "../../node_modules/react-dom/lib/ReactInstrumentation.js",
+ "../../node_modules/react-dom/lib/ReactMarkupChecksum.js"
],
- "hash": "8556f2285fd844cf9fdd4d78370aba33",
+ "size": 34770,
+ "hash": "ee6461bbec846ab2c7626a8d8fd1fb21",
"id": 10
},
{
"modules": [
- "../../node_modules/react-dom/lib/ReactEmptyComponent.js",
- "../../node_modules/react-dom/lib/ReactEventEmitterMixin.js",
- "../../node_modules/react-dom/lib/ReactDOMInput.js",
- "../../node_modules/react-dom/lib/ReactCompositeComponent.js"
+ "../../node_modules/react-dom/lib/ReactMount.js",
+ "../../node_modules/react-dom/lib/ReactMultiChild.js",
+ "../../node_modules/react-dom/lib/ReactNodeTypes.js",
+ "../../node_modules/react-dom/lib/ReactOwner.js",
+ "../../node_modules/react-dom/lib/ReactPropTypesSecret.js",
+ "../../node_modules/react-dom/lib/ReactReconcileTransaction.js"
],
- "hash": "c6598918ddb96aa65fc4325d8fd9d499",
+ "size": 49575,
+ "hash": "74249374b007623d16bffa559688d7d5",
"id": 11
},
{
"modules": [
- "../../node_modules/fbjs/lib/invariant.js",
- "../../node_modules/fbjs/lib/warning.js",
- "../../node_modules/object-assign/index.js",
- "../../node_modules/fbjs/lib/emptyFunction.js",
- "../../node_modules/fbjs/lib/emptyObject.js",
- "../../node_modules/react/lib/React.js",
- "../../node_modules/prop-types/factory.js",
- "../../node_modules/react/react.js",
- "../../node_modules/react/lib/PooledClass.js",
- "../../node_modules/react/lib/KeyEscapeUtils.js",
- "../../node_modules/prop-types/lib/ReactPropTypesSecret.js",
- "../../node_modules/prop-types/checkPropTypes.js",
- "../../node_modules/create-react-class/factory.js"
+ "../../node_modules/react-dom/lib/ReactReconciler.js",
+ "../../node_modules/react-dom/lib/ReactRef.js",
+ "../../node_modules/react-dom/lib/ReactServerRenderingTransaction.js",
+ "../../node_modules/react-dom/lib/ReactServerUpdateQueue.js",
+ "../../node_modules/react-dom/lib/ReactUpdateQueue.js",
+ "../../node_modules/react-dom/lib/ReactUpdates.js",
+ "../../node_modules/react-dom/lib/ReactVersion.js",
+ "../../node_modules/react-dom/lib/SVGDOMPropertyConfig.js",
+ "../../node_modules/react-dom/lib/SelectEventPlugin.js"
],
- "hash": "8cc7b4a18437614b45e423a1395b571d",
+ "size": 47320,
+ "hash": "0a6d10836900825087ce02acffa0b1c0",
+ "id": 12
+ },
+ {
+ "modules": [
+ "../../node_modules/react-dom/lib/SimpleEventPlugin.js",
+ "../../node_modules/react-dom/lib/SyntheticAnimationEvent.js",
+ "../../node_modules/react-dom/lib/SyntheticClipboardEvent.js",
+ "../../node_modules/react-dom/lib/SyntheticCompositionEvent.js",
+ "../../node_modules/react-dom/lib/SyntheticDragEvent.js",
+ "../../node_modules/react-dom/lib/SyntheticEvent.js",
+ "../../node_modules/react-dom/lib/SyntheticFocusEvent.js",
+ "../../node_modules/react-dom/lib/SyntheticInputEvent.js",
+ "../../node_modules/react-dom/lib/SyntheticKeyboardEvent.js",
+ "../../node_modules/react-dom/lib/SyntheticMouseEvent.js",
+ "../../node_modules/react-dom/lib/SyntheticTouchEvent.js",
+ "../../node_modules/react-dom/lib/SyntheticTransitionEvent.js",
+ "../../node_modules/react-dom/lib/SyntheticUIEvent.js",
+ "../../node_modules/react-dom/lib/SyntheticWheelEvent.js",
+ "../../node_modules/react-dom/lib/Transaction.js",
+ "../../node_modules/react-dom/lib/ViewportMetrics.js",
+ "../../node_modules/react-dom/lib/accumulateInto.js",
+ "../../node_modules/react-dom/lib/adler32.js",
+ "../../node_modules/react-dom/lib/createMicrosoftUnsafeLocalFunction.js",
+ "../../node_modules/react-dom/lib/dangerousStyleValue.js"
+ ],
+ "size": 49350,
+ "hash": "5ec04d5529f6b78241e25db6f0254a6f",
"id": 13
},
{
"modules": [
- "../../node_modules/react/lib/ReactBaseClasses.js",
- "../../node_modules/react/lib/ReactChildren.js",
- "../../node_modules/prop-types/factoryWithTypeCheckers.js"
+ "../../node_modules/react-dom/lib/escapeTextContentForBrowser.js",
+ "../../node_modules/react-dom/lib/findDOMNode.js",
+ "../../node_modules/react-dom/lib/flattenChildren.js",
+ "../../node_modules/react-dom/lib/forEachAccumulated.js",
+ "../../node_modules/react-dom/lib/getEventCharCode.js",
+ "../../node_modules/react-dom/lib/getEventKey.js",
+ "../../node_modules/react-dom/lib/getEventModifierState.js",
+ "../../node_modules/react-dom/lib/getEventTarget.js",
+ "../../node_modules/react-dom/lib/getHostComponentFromComposite.js",
+ "../../node_modules/react-dom/lib/getIteratorFn.js",
+ "../../node_modules/react-dom/lib/getNodeForCharacterOffset.js",
+ "../../node_modules/react-dom/lib/getTextContentAccessor.js",
+ "../../node_modules/react-dom/lib/getVendorPrefixedEventName.js",
+ "../../node_modules/react-dom/lib/inputValueTracking.js",
+ "../../node_modules/react-dom/lib/instantiateReactComponent.js",
+ "../../node_modules/react-dom/lib/isEventSupported.js",
+ "../../node_modules/react-dom/lib/isTextInputElement.js",
+ "../../node_modules/react-dom/lib/quoteAttributeValueForBrowser.js",
+ "../../node_modules/react-dom/lib/reactProdInvariant.js",
+ "../../node_modules/react-dom/lib/renderSubtreeIntoContainer.js",
+ "../../node_modules/react-dom/lib/setInnerHTML.js",
+ "../../node_modules/react-dom/lib/setTextContent.js",
+ "../../node_modules/react-dom/lib/shouldUpdateReactComponent.js",
+ "../../node_modules/react-dom/lib/traverseAllChildren.js"
],
- "hash": "11202a345a2ce63a2fb79589ee7d9edd",
+ "size": 47718,
+ "hash": "38a6975540caa0156886a92323a43231",
"id": 14
}
]
diff --git a/examples/http2-aggressive-splitting/template.md b/examples/http2-aggressive-splitting/template.md
index c599d583..8ddec598 100644
--- a/examples/http2-aggressive-splitting/template.md
+++ b/examples/http2-aggressive-splitting/template.md
@@ -22,20 +22,20 @@ The backward compatibility (non HTTP2 client) improves with bigger `maxSize`, as
# Info
-## Uncompressed
+## Unoptimized
```
{{stdout}}
```
-## Minimized (uglify-js, no zip)
+## Production mode
```
-{{min:stdout}}
+{{production:stdout}}
```
## Records
```
-{{js/records.json}}
+{{dist/records.json}}
```
diff --git a/examples/http2-aggressive-splitting/webpack.config.js b/examples/http2-aggressive-splitting/webpack.config.js
index e875b026..5150993a 100644
--- a/examples/http2-aggressive-splitting/webpack.config.js
+++ b/examples/http2-aggressive-splitting/webpack.config.js
@@ -1,9 +1,11 @@
var path = require("path");
var webpack = require("../../");
module.exports = {
+ // mode: "development || "production",
+ cache: true, // better performance for the AggressiveSplittingPlugin
entry: "./example",
output: {
- path: path.join(__dirname, "js"),
+ path: path.join(__dirname, "dist"),
filename: "[chunkhash].js",
chunkFilename: "[chunkhash].js"
},
@@ -16,5 +18,5 @@ module.exports = {
"process.env.NODE_ENV": JSON.stringify("production")
})
],
- recordsOutputPath: path.join(__dirname, "js", "records.json")
+ recordsOutputPath: path.join(__dirname, "dist", "records.json")
};
diff --git a/examples/hybrid-routing/README.md b/examples/hybrid-routing/README.md
index a2627cd5..de9402a0 100644
--- a/examples/hybrid-routing/README.md
+++ b/examples/hybrid-routing/README.md
@@ -2,31 +2,29 @@
``` javascript
var path = require("path");
-var CommonsChunkPlugin = require("../../lib/optimize/CommonsChunkPlugin");
module.exports = {
+ // mode: "development || "production",
entry: {
// The entry points for the pages
- pageA: "./aEntry",
- pageB: "./bEntry",
-
- // This file contains common modules but also the router entry
- "commons": "./router"
+ // They also contains router
+ pageA: ["./aEntry", "./router"],
+ pageB: ["./bEntry", "./router"],
},
output: {
- path: path.join(__dirname, "js"),
+ path: path.join(__dirname, "dist"),
publicPath: "js/",
filename: "[name].bundle.js",
- chunkFilename: "[id].chunk.js"
+ chunkFilename: "[name].chunk.js"
},
- plugins: [
- // Extract common modules from the entries to the commons.js file
+ optimization: {
+ // Extract common modules from initial chunks too
// This is optional, but good for performance.
- new CommonsChunkPlugin({
- name: "commons",
- filename: "commons.js"
- })
- // The pages cannot run without the commons.js file now.
- ]
+ splitChunks: {
+ chunks: "all",
+ minSize: 0 // This example is too small
+ },
+ occurrenceOrder: true // To keep filename consistent between different modes (for example building only)
+ }
};
```
@@ -66,15 +64,9 @@ window.onLinkToPage = function onLinkToPage(name) { // name is "a" or "b"
// overwriting the RegExp with the ContextReplacementPlugin, or
// using the require.context method.
- // The bundle-loader is used to create a chunk from the page
- // -> Pages are only loaded on demand
-
// This line may throw a exception on runtime if the page wasn't found.
- var pageBundle = require("bundle-loader!./" + name + "Page");
-
- // Wait until the chunk is loaded
- pageBundle(function(page) {
- render(page);
+ import(/* webpackChunkName: "[request]" */`./${name}Page`).then(page => {;
+ render(page.default);
});
}
```
@@ -85,24 +77,116 @@ window.onLinkToPage = function onLinkToPage(name) { // name is "a" or "b"
<html>
<head></head>
<body>
- <script src="js/commons.js" charset="utf-8"></script>
- <script src="js/pageA.bundle.js" charset="utf-8"></script>
+ <script async src="dist/pageA~pageB.chunk.js" charset="utf-8"></script>
+ <script async src="dist/aPage.chunk.js" charset="utf-8"></script>
+ <script async src="dist/pageA.bundle.js" charset="utf-8"></script>
</body>
</html>
```
-# js/commons.js
+# dist/pageA~pageB.chunk.js
+
+``` javascript
+(window["webpackJsonp"] = window["webpackJsonp"] || []).push([[2],[
+/* 0 */
+/*!*******************!*\
+ !*** ./render.js ***!
+ \*******************/
+/*! no static exports found */
+/***/ (function(module, exports) {
+
+module.exports = function(page) {
+ console.log(page());
+};
+
+/***/ }),
+/* 1 */,
+/* 2 */
+/*!*******************!*\
+ !*** ./router.js ***!
+ \*******************/
+/*! no static exports found */
+/***/ (function(module, exports, __webpack_require__) {
+
+var render = __webpack_require__(/*! ./render */ 0);
+
+// Event when another page should be opened
+// Maybe hook click on links, hashchange or popstate
+window.onLinkToPage = function onLinkToPage(name) { // name is "a" or "b"
+ // require the page with a dynamic require
+
+ // It's important that this require only matches the pages
+ // elsewise there is blood in the bundle. Here this is done with a
+ // specific file prefix. It's also possible to use a directory,
+ // overwriting the RegExp with the ContextReplacementPlugin, or
+ // using the require.context method.
+
+ // This line may throw a exception on runtime if the page wasn't found.
+ __webpack_require__(6)(`./${name}Page`).then(page => {;
+ render(page.default);
+ });
+}
+
+
+/***/ }),
+/* 3 */,
+/* 4 */,
+/* 5 */,
+/* 6 */
+/*!********************************************!*\
+ !*** . lazy ^\.\/.*Page$ namespace object ***!
+ \********************************************/
+/*! no static exports found */
+/***/ (function(module, exports, __webpack_require__) {
+
+var map = {
+ "./aPage": [
+ 3,
+ 1
+ ],
+ "./bPage": [
+ 1,
+ 0
+ ]
+};
+function webpackAsyncContext(req) {
+ var ids = map[req];
+ if(!ids) {
+ return Promise.resolve().then(function() {
+ var e = new Error('Cannot find module "' + req + '".');
+ e.code = 'MODULE_NOT_FOUND';
+ throw e;
+ });
+ }
+ return __webpack_require__.e(ids[1]).then(function() {
+ var module = __webpack_require__(ids[0]);
+ return (typeof module === "object" && module && module.__esModule ? module : /* fake namespace object */ { "default": module });
+ });
+}
+webpackAsyncContext.keys = function webpackAsyncContextKeys() {
+ return Object.keys(map);
+};
+webpackAsyncContext.id = 6;
+module.exports = webpackAsyncContext;
+
+/***/ })
+]]);
+```
+
+# dist/pageA.bundle.js
<details><summary><code>/******/ (function(modules) { /* webpackBootstrap */ })</code></summary>
``` javascript
/******/ (function(modules) { // webpackBootstrap
/******/ // install a JSONP callback for chunk loading
-/******/ var parentJsonpFunction = window["webpackJsonp"];
-/******/ window["webpackJsonp"] = function webpackJsonpCallback(chunkIds, moreModules, executeModules) {
+/******/ function webpackJsonpCallback(data) {
+/******/ var chunkIds = data[0];
+/******/ var moreModules = data[1]
+/******/ var executeModules = data[2];
/******/ // add "moreModules" to the modules object,
/******/ // then flag all "chunkIds" as loaded and fire callback
-/******/ var moduleId, chunkId, i = 0, resolves = [], result;
+/******/ var moduleId, chunkId, i = 0, resolves = [];
/******/ for(;i < chunkIds.length; i++) {
/******/ chunkId = chunkIds[i];
/******/ if(installedChunks[chunkId]) {
@@ -115,26 +199,44 @@ window.onLinkToPage = function onLinkToPage(name) { // name is "a" or "b"
/******/ modules[moduleId] = moreModules[moduleId];
/******/ }
/******/ }
-/******/ if(parentJsonpFunction) parentJsonpFunction(chunkIds, moreModules, executeModules);
+/******/ if(parentJsonpFunction) parentJsonpFunction(data);
/******/ while(resolves.length) {
/******/ resolves.shift()();
/******/ }
-/******/ if(executeModules) {
-/******/ for(i=0; i < executeModules.length; i++) {
-/******/ result = __webpack_require__(__webpack_require__.s = executeModules[i]);
+/******/
+/******/ // add entry modules from loaded chunk to deferred list
+/******/ deferredModules.push.apply(deferredModules, executeModules || []);
+/******/
+/******/ // run deferred modules when all chunks ready
+/******/ return checkDeferredModules();
+/******/ };
+/******/ function checkDeferredModules() {
+/******/ var result;
+/******/ for(var i = 0; i < deferredModules.length; i++) {
+/******/ var deferredModule = deferredModules[i];
+/******/ var fullfilled = true;
+/******/ for(var j = 1; j < deferredModule.length; j++) {
+/******/ var depId = deferredModule[j];
+/******/ if(installedChunks[depId] !== 0) fullfilled = false;
+/******/ }
+/******/ if(fullfilled) {
+/******/ deferredModules.splice(i--, 1);
+/******/ result = __webpack_require__(__webpack_require__.s = deferredModule[0]);
/******/ }
/******/ }
/******/ return result;
-/******/ };
+/******/ }
/******/
/******/ // The module cache
/******/ var installedModules = {};
/******/
-/******/ // objects to store loaded and loading chunks
+/******/ // object to store loaded and loading chunks
/******/ var installedChunks = {
/******/ 4: 0
/******/ };
/******/
+/******/ var deferredModules = [];
+/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
@@ -162,51 +264,60 @@ window.onLinkToPage = function onLinkToPage(name) { // name is "a" or "b"
/******/ // This file contains only the entry chunk.
/******/ // The chunk loading function for additional chunks
/******/ __webpack_require__.e = function requireEnsure(chunkId) {
+/******/ var promises = [];
+/******/
+/******/
+/******/ // JSONP chunk loading for javascript
+/******/
/******/ var installedChunkData = installedChunks[chunkId];
-/******/ if(installedChunkData === 0) {
-/******/ return new Promise(function(resolve) { resolve(); });
-/******/ }
+/******/ if(installedChunkData !== 0) { // 0 means "already installed".
/******/
-/******/ // a Promise means "currently loading".
-/******/ if(installedChunkData) {
-/******/ return installedChunkData[2];
-/******/ }
+/******/ // a Promise means "currently loading".
+/******/ if(installedChunkData) {
+/******/ promises.push(installedChunkData[2]);
+/******/ } else {
+/******/ // setup Promise in chunk cache
+/******/ var promise = new Promise(function(resolve, reject) {
+/******/ installedChunkData = installedChunks[chunkId] = [resolve, reject];
+/******/ });
+/******/ promises.push(installedChunkData[2] = promise);
/******/
-/******/ // setup Promise in chunk cache
-/******/ var promise = new Promise(function(resolve, reject) {
-/******/ installedChunkData = installedChunks[chunkId] = [resolve, reject];
-/******/ });
-/******/ installedChunkData[2] = promise;
+/******/ // start chunk loading
+/******/ var head = document.getElementsByTagName('head')[0];
+/******/ var script = document.createElement('script');
/******/
-/******/ // start chunk loading
-/******/ var head = document.getElementsByTagName('head')[0];
-/******/ var script = document.createElement('script');
-/******/ script.type = 'text/javascript';
-/******/ script.charset = 'utf-8';
-/******/ script.async = true;
-/******/ script.timeout = 120000;
+/******/ script.charset = 'utf-8';
+/******/ script.timeout = 120000;
/******/
-/******/ if (__webpack_require__.nc) {
-/******/ script.setAttribute("nonce", __webpack_require__.nc);
-/******/ }
-/******/ script.src = __webpack_require__.p + "" + chunkId + ".chunk.js";
-/******/ var timeout = setTimeout(onScriptComplete, 120000);
-/******/ script.onerror = script.onload = onScriptComplete;
-/******/ function onScriptComplete() {
-/******/ // avoid mem leaks in IE.
-/******/ script.onerror = script.onload = null;
-/******/ clearTimeout(timeout);
-/******/ var chunk = installedChunks[chunkId];
-/******/ if(chunk !== 0) {
-/******/ if(chunk) {
-/******/ chunk[1](new Error('Loading chunk ' + chunkId + ' failed.'));
+/******/ if (__webpack_require__.nc) {
+/******/ script.setAttribute("nonce", __webpack_require__.nc);
/******/ }
-/******/ installedChunks[chunkId] = undefined;
+/******/ script.src = __webpack_require__.p + "" + ({"0":"bPage"}[chunkId]||chunkId) + ".chunk.js";
+/******/ var timeout = setTimeout(function(){
+/******/ onScriptComplete({ type: 'timeout', target: script });
+/******/ }, 120000);
+/******/ script.onerror = script.onload = onScriptComplete;
+/******/ function onScriptComplete(event) {
+/******/ // avoid mem leaks in IE.
+/******/ script.onerror = script.onload = null;
+/******/ clearTimeout(timeout);
+/******/ var chunk = installedChunks[chunkId];
+/******/ if(chunk !== 0) {
+/******/ if(chunk) {
+/******/ var errorType = event && (event.type === 'load' ? 'missing' : event.type);
+/******/ var realSrc = event && event.target && event.target.src;
+/******/ var error = new Error('Loading chunk ' + chunkId + ' failed.\n(' + errorType + ': ' + realSrc + ')');
+/******/ error.type = errorType;
+/******/ error.request = realSrc;
+/******/ chunk[1](error);
+/******/ }
+/******/ installedChunks[chunkId] = undefined;
+/******/ }
+/******/ };
+/******/ head.appendChild(script);
/******/ }
-/******/ };
-/******/ head.appendChild(script);
-/******/
-/******/ return promise;
+/******/ }
+/******/ return Promise.all(promises);
/******/ };
/******/
/******/ // expose the modules object (__webpack_modules__)
@@ -226,6 +337,11 @@ window.onLinkToPage = function onLinkToPage(name) { // name is "a" or "b"
/******/ }
/******/ };
/******/
+/******/ // define __esModule on exports
+/******/ __webpack_require__.r = function(exports) {
+/******/ Object.defineProperty(exports, '__esModule', { value: true });
+/******/ };
+/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
@@ -239,13 +355,23 @@ window.onLinkToPage = function onLinkToPage(name) { // name is "a" or "b"
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
-/******/ __webpack_require__.p = "js/";
+/******/ __webpack_require__.p = "dist/";
/******/
/******/ // on error function for async loading
/******/ __webpack_require__.oe = function(err) { console.error(err); throw err; };
/******/
-/******/ // Load entry module and return exports
-/******/ return __webpack_require__(__webpack_require__.s = 5);
+/******/ var jsonpArray = window["webpackJsonp"] = window["webpackJsonp"] || [];
+/******/ var oldJsonpFunction = jsonpArray.push.bind(jsonpArray);
+/******/ jsonpArray.push = webpackJsonpCallback;
+/******/ jsonpArray = jsonpArray.slice();
+/******/ for(var i = 0; i < jsonpArray.length; i++) webpackJsonpCallback(jsonpArray[i]);
+/******/ var parentJsonpFunction = oldJsonpFunction;
+/******/
+/******/
+/******/ // add entry module to deferred list
+/******/ deferredModules.push([8,2,1]);
+/******/ // run deferred modules when ready
+/******/ return checkDeferredModules();
/******/ })
/************************************************************************/
```
@@ -253,185 +379,47 @@ window.onLinkToPage = function onLinkToPage(name) { // name is "a" or "b"
</details>
``` javascript
-/******/ ([
-/* 0 */
-/*!*******************!*\
- !*** ./render.js ***!
- \*******************/
-/*! no static exports found */
-/*! all exports used */
-/***/ (function(module, exports) {
+/******/ ({
-module.exports = function(page) {
- console.log(page());
-};
-
-/***/ }),
-/* 1 */,
-/* 2 */,
-/* 3 */,
-/* 4 */,
-/* 5 */
+/***/ 7:
/*!*******************!*\
- !*** ./router.js ***!
+ !*** ./aEntry.js ***!
\*******************/
/*! no static exports found */
-/*! all exports used */
/***/ (function(module, exports, __webpack_require__) {
+// Just show the page "a"
var render = __webpack_require__(/*! ./render */ 0);
-
-// Event when another page should be opened
-// Maybe hook click on links, hashchange or popstate
-window.onLinkToPage = function onLinkToPage(name) { // name is "a" or "b"
- // require the page with a dynamic require
-
- // It's important that this require only matches the pages
- // elsewise there is blood in the bundle. Here this is done with a
- // specific file prefix. It's also possible to use a directory,
- // overwriting the RegExp with the ContextReplacementPlugin, or
- // using the require.context method.
-
- // The bundle-loader is used to create a chunk from the page
- // -> Pages are only loaded on demand
-
- // This line may throw a exception on runtime if the page wasn't found.
- var pageBundle = __webpack_require__(/*! bundle-loader!. */ 6)("./" + name + "Page");
-
- // Wait until the chunk is loaded
- pageBundle(function(page) {
- render(page);
- });
-}
-
+render(__webpack_require__(/*! ./aPage */ 3));
/***/ }),
-/* 6 */
-/*!***********************************************************!*\
- !*** . (webpack)/node_modules/bundle-loader ^\.\/.*Page$ ***!
- \***********************************************************/
-/*! no static exports found */
-/*! all exports used */
-/***/ (function(module, exports, __webpack_require__) {
-
-var map = {
- "./aPage": 7,
- "./bPage": 8
-};
-function webpackContext(req) {
- return __webpack_require__(webpackContextResolve(req));
-};
-function webpackContextResolve(req) {
- var id = map[req];
- if(!(id + 1)) // check for number or string
- throw new Error("Cannot find module '" + req + "'.");
- return id;
-};
-webpackContext.keys = function webpackContextKeys() {
- return Object.keys(map);
-};
-webpackContext.resolve = webpackContextResolve;
-module.exports = webpackContext;
-webpackContext.id = 6;
-/***/ }),
-/* 7 */
-/*!*******************************************************!*\
- !*** (webpack)/node_modules/bundle-loader!./aPage.js ***!
- \*******************************************************/
+/***/ 8:
+/*!*******************************!*\
+ !*** multi ./aEntry ./router ***!
+ \*******************************/
/*! no static exports found */
-/*! all exports used */
/***/ (function(module, exports, __webpack_require__) {
-var cbs = [],
- data;
-module.exports = function(cb) {
- if(cbs) cbs.push(cb);
- else cb(data);
-}
-__webpack_require__.e/* require.ensure */(1).then((function(require) {
- data = __webpack_require__(/*! !./aPage.js */ 1);
- var callbacks = cbs;
- cbs = null;
- for(var i = 0, l = callbacks.length; i < l; i++) {
- callbacks[i](data);
- }
-}).bind(null, __webpack_require__)).catch(__webpack_require__.oe);
+__webpack_require__(/*! ./aEntry */7);
+module.exports = __webpack_require__(/*! ./router */2);
-/***/ }),
-/* 8 */
-/*!*******************************************************!*\
- !*** (webpack)/node_modules/bundle-loader!./bPage.js ***!
- \*******************************************************/
-/*! no static exports found */
-/*! all exports used */
-/***/ (function(module, exports, __webpack_require__) {
-
-var cbs = [],
- data;
-module.exports = function(cb) {
- if(cbs) cbs.push(cb);
- else cb(data);
-}
-__webpack_require__.e/* require.ensure */(0).then((function(require) {
- data = __webpack_require__(/*! !./bPage.js */ 2);
- var callbacks = cbs;
- cbs = null;
- for(var i = 0, l = callbacks.length; i < l; i++) {
- callbacks[i](data);
- }
-}).bind(null, __webpack_require__)).catch(__webpack_require__.oe);
/***/ })
-/******/ ]);
-```
-# js/pageA.bundle.js
-
-``` javascript
-webpackJsonp([3,1],[
-/* 0 */,
-/* 1 */
-/*!******************!*\
- !*** ./aPage.js ***!
- \******************/
-/*! no static exports found */
-/*! all exports used */
-/***/ (function(module, exports) {
-
-module.exports = function() {
- return "This is page A.";
-};
-
-/***/ }),
-/* 2 */,
-/* 3 */
-/*!*******************!*\
- !*** ./aEntry.js ***!
- \*******************/
-/*! no static exports found */
-/*! all exports used */
-/***/ (function(module, exports, __webpack_require__) {
-
-// Just show the page "a"
-var render = __webpack_require__(/*! ./render */ 0);
-render(__webpack_require__(/*! ./aPage */ 1));
-
-/***/ })
-],[3]);
+/******/ });
```
-# js/1.chunk.js
+# dist/aPage.chunk.js
``` javascript
-webpackJsonp([1],[
-/* 0 */,
-/* 1 */
+(window["webpackJsonp"] = window["webpackJsonp"] || []).push([[1],{
+
+/***/ 3:
/*!******************!*\
!*** ./aPage.js ***!
\******************/
/*! no static exports found */
-/*! all exports used */
/***/ (function(module, exports) {
module.exports = function() {
@@ -439,109 +427,114 @@ module.exports = function() {
};
/***/ })
-]);
+
+}]);
```
# Info
-## Uncompressed
+## Unoptimized
```
-Hash: 4b00bdf84d7923f55b44
-Version: webpack 3.5.1
- Asset Size Chunks Chunk Names
- 0.chunk.js 267 bytes 0 [emitted]
- 1.chunk.js 273 bytes 1 [emitted]
-pageB.bundle.js 630 bytes 2, 0 [emitted] pageB
-pageA.bundle.js 621 bytes 3, 1 [emitted] pageA
- commons.js 9.59 kB 4 [emitted] commons
-Entrypoint pageA = commons.js pageA.bundle.js
-Entrypoint pageB = commons.js pageB.bundle.js
-Entrypoint commons = commons.js
-chunk {0} 0.chunk.js 61 bytes {4} [rendered]
- > [8] (webpack)/node_modules/bundle-loader!./bPage.js 7:0-14:2
- [2] ./bPage.js 61 bytes {0} {2} [built]
+Hash: 0a1b2c3d4e5f6a7b8c9d
+Version: webpack 4.0.0-beta.2
+ Asset Size Chunks Chunk Names
+ bPage.chunk.js 299 bytes 0 [emitted] bPage
+ aPage.chunk.js 293 bytes 1 [emitted] aPage
+pageA~pageB.chunk.js 2.16 KiB 2 [emitted] pageA~pageB
+ pageB.bundle.js 8.2 KiB 3 [emitted] pageB
+ pageA.bundle.js 8.2 KiB 4 [emitted] pageA
+Entrypoint pageA = pageA~pageB.chunk.js aPage.chunk.js pageA.bundle.js
+Entrypoint pageB = pageA~pageB.chunk.js bPage.chunk.js pageB.bundle.js
+chunk {0} bPage.chunk.js (bPage) 61 bytes <{1}> <{2}> <{4}> ={2}= ={3}= >{1}< [initial] [rendered] reused as split chunk (cache group: default)
+ > pageB
+ > ./bPage [6] . lazy ^\.\/.*Page$ namespace object ./bPage
+ > ./bPage [6] . lazy ^\.\/.*Page$ namespace object ./bPage
+ [1] ./bPage.js 61 bytes {0} [built]
cjs require ./bPage [4] ./bEntry.js 3:7-25
- cjs require !!./bPage.js [8] (webpack)/node_modules/bundle-loader!./bPage.js 8:8-31
-chunk {1} 1.chunk.js 61 bytes {4} [rendered]
- > [7] (webpack)/node_modules/bundle-loader!./aPage.js 7:0-14:2
- [1] ./aPage.js 61 bytes {1} {3} [built]
- cjs require ./aPage [3] ./aEntry.js 3:7-25
- cjs require !!./aPage.js [7] (webpack)/node_modules/bundle-loader!./aPage.js 8:8-31
-chunk {2} pageB.bundle.js (pageB) 150 bytes {4} [initial] [rendered]
- > pageB [4] ./bEntry.js
- [2] ./bPage.js 61 bytes {0} {2} [built]
- cjs require ./bPage [4] ./bEntry.js 3:7-25
- cjs require !!./bPage.js [8] (webpack)/node_modules/bundle-loader!./bPage.js 8:8-31
- [4] ./bEntry.js 89 bytes {2} [built]
-chunk {3} pageA.bundle.js (pageA) 150 bytes {4} [initial] [rendered]
- > pageA [3] ./aEntry.js
- [1] ./aPage.js 61 bytes {1} {3} [built]
- cjs require ./aPage [3] ./aEntry.js 3:7-25
- cjs require !!./aPage.js [7] (webpack)/node_modules/bundle-loader!./aPage.js 8:8-31
- [3] ./aEntry.js 89 bytes {3} [built]
-chunk {4} commons.js (commons) 1.71 kB [entry] [rendered]
- > commons [5] ./router.js
- [0] ./render.js 60 bytes {4} [built]
- cjs require ./render [3] ./aEntry.js 2:13-32
+ context element ./bPage [6] . lazy ^\.\/.*Page$ namespace object ./bPage
+chunk {1} aPage.chunk.js (aPage) 61 bytes <{0}> <{2}> <{3}> ={2}= ={4}= >{0}< [initial] [rendered] reused as split chunk (cache group: default)
+ > pageA
+ > ./aPage [6] . lazy ^\.\/.*Page$ namespace object ./aPage
+ > ./aPage [6] . lazy ^\.\/.*Page$ namespace object ./aPage
+ [3] ./aPage.js 61 bytes {1} [built]
+ context element ./aPage [6] . lazy ^\.\/.*Page$ namespace object ./aPage
+ cjs require ./aPage [7] ./aEntry.js 3:7-25
+chunk {2} pageA~pageB.chunk.js (pageA~pageB) 970 bytes ={0}= ={1}= ={3}= ={4}= >{0}< >{1}< [initial] [rendered] split chunk (cache group: default) (name: pageA~pageB)
+ > pageA
+ > pageB
+ [0] ./render.js 60 bytes {2} [built]
+ cjs require ./render [2] ./router.js 1:13-32
cjs require ./render [4] ./bEntry.js 2:13-32
- cjs require ./render [5] ./router.js 1:13-32
- [5] ./router.js 903 bytes {4} [built]
- [6] . (webpack)/node_modules/bundle-loader ^\.\/.*Page$ 184 bytes {4} [built]
- cjs require context bundle-loader!. [5] ./router.js 18:18-61
- [7] (webpack)/node_modules/bundle-loader!./aPage.js 282 bytes {4} [optional] [built]
- context element ./aPage [6] . (webpack)/node_modules/bundle-loader ^\.\/.*Page$ ./aPage
- [8] (webpack)/node_modules/bundle-loader!./bPage.js 282 bytes {4} [optional] [built]
- context element ./bPage [6] . (webpack)/node_modules/bundle-loader ^\.\/.*Page$ ./bPage
+ cjs require ./render [7] ./aEntry.js 2:13-32
+ [2] ./router.js 750 bytes {2} [built]
+ single entry ./router [5] multi ./bEntry ./router pageB:100001
+ single entry ./router [8] multi ./aEntry ./router pageA:100001
+ [6] . lazy ^\.\/.*Page$ namespace object 160 bytes {2} [built]
+ import() context lazy . [2] ./router.js 15:1-59
+chunk {3} pageB.bundle.js (pageB) 129 bytes ={0}= ={2}= >{1}< [entry] [rendered]
+ > pageB
+ [4] ./bEntry.js 89 bytes {3} [built]
+ single entry ./bEntry [5] multi ./bEntry ./router pageB:100000
+ [5] multi ./bEntry ./router 40 bytes {3} [built]
+ multi entry
+chunk {4} pageA.bundle.js (pageA) 129 bytes ={1}= ={2}= >{0}< [entry] [rendered]
+ > pageA
+ [7] ./aEntry.js 89 bytes {4} [built]
+ single entry ./aEntry [8] multi ./aEntry ./router pageA:100000
+ [8] multi ./aEntry ./router 40 bytes {4} [built]
+ multi entry
```
-## Minimized (uglify-js, no zip)
+## Production mode
```
-Hash: 4b00bdf84d7923f55b44
-Version: webpack 3.5.1
- Asset Size Chunks Chunk Names
- 0.chunk.js 83 bytes 0 [emitted]
- 1.chunk.js 82 bytes 1 [emitted]
-pageB.bundle.js 118 bytes 2, 0 [emitted] pageB
-pageA.bundle.js 117 bytes 3, 1 [emitted] pageA
- commons.js 2.13 kB 4 [emitted] commons
-Entrypoint pageA = commons.js pageA.bundle.js
-Entrypoint pageB = commons.js pageB.bundle.js
-Entrypoint commons = commons.js
-chunk {0} 0.chunk.js 61 bytes {4} [rendered]
- > [8] (webpack)/node_modules/bundle-loader!./bPage.js 7:0-14:2
- [2] ./bPage.js 61 bytes {0} {2} [built]
- cjs require ./bPage [4] ./bEntry.js 3:7-25
- cjs require !!./bPage.js [8] (webpack)/node_modules/bundle-loader!./bPage.js 8:8-31
-chunk {1} 1.chunk.js 61 bytes {4} [rendered]
- > [7] (webpack)/node_modules/bundle-loader!./aPage.js 7:0-14:2
- [1] ./aPage.js 61 bytes {1} {3} [built]
- cjs require ./aPage [3] ./aEntry.js 3:7-25
- cjs require !!./aPage.js [7] (webpack)/node_modules/bundle-loader!./aPage.js 8:8-31
-chunk {2} pageB.bundle.js (pageB) 150 bytes {4} [initial] [rendered]
- > pageB [4] ./bEntry.js
- [2] ./bPage.js 61 bytes {0} {2} [built]
+Hash: 0a1b2c3d4e5f6a7b8c9d
+Version: webpack 4.0.0-beta.2
+ Asset Size Chunks Chunk Names
+ bPage.chunk.js 122 bytes 0 [emitted] bPage
+ aPage.chunk.js 123 bytes 1 [emitted] aPage
+pageA~pageB.chunk.js 589 bytes 2 [emitted] pageA~pageB
+ pageB.bundle.js 1.85 KiB 3 [emitted] pageB
+ pageA.bundle.js 1.85 KiB 4 [emitted] pageA
+Entrypoint pageA = pageA~pageB.chunk.js aPage.chunk.js pageA.bundle.js
+Entrypoint pageB = pageA~pageB.chunk.js bPage.chunk.js pageB.bundle.js
+chunk {0} bPage.chunk.js (bPage) 61 bytes <{1}> <{2}> <{4}> ={2}= ={3}= >{1}< [initial] [rendered] reused as split chunk (cache group: default)
+ > pageB
+ > ./bPage [6] . lazy ^\.\/.*Page$ namespace object ./bPage
+ > ./bPage [6] . lazy ^\.\/.*Page$ namespace object ./bPage
+ [1] ./bPage.js 61 bytes {0} [built]
cjs require ./bPage [4] ./bEntry.js 3:7-25
- cjs require !!./bPage.js [8] (webpack)/node_modules/bundle-loader!./bPage.js 8:8-31
- [4] ./bEntry.js 89 bytes {2} [built]
-chunk {3} pageA.bundle.js (pageA) 150 bytes {4} [initial] [rendered]
- > pageA [3] ./aEntry.js
- [1] ./aPage.js 61 bytes {1} {3} [built]
- cjs require ./aPage [3] ./aEntry.js 3:7-25
- cjs require !!./aPage.js [7] (webpack)/node_modules/bundle-loader!./aPage.js 8:8-31
- [3] ./aEntry.js 89 bytes {3} [built]
-chunk {4} commons.js (commons) 1.71 kB [entry] [rendered]
- > commons [5] ./router.js
- [0] ./render.js 60 bytes {4} [built]
- cjs require ./render [3] ./aEntry.js 2:13-32
+ context element ./bPage [6] . lazy ^\.\/.*Page$ namespace object ./bPage
+chunk {1} aPage.chunk.js (aPage) 61 bytes <{0}> <{2}> <{3}> ={2}= ={4}= >{0}< [initial] [rendered] reused as split chunk (cache group: default)
+ > pageA
+ > ./aPage [6] . lazy ^\.\/.*Page$ namespace object ./aPage
+ > ./aPage [6] . lazy ^\.\/.*Page$ namespace object ./aPage
+ [3] ./aPage.js 61 bytes {1} [built]
+ context element ./aPage [6] . lazy ^\.\/.*Page$ namespace object ./aPage
+ cjs require ./aPage [7] ./aEntry.js 3:7-25
+chunk {2} pageA~pageB.chunk.js (pageA~pageB) 970 bytes ={0}= ={1}= ={3}= ={4}= >{0}< >{1}< [initial] [rendered] split chunk (cache group: default) (name: pageA~pageB)
+ > pageA
+ > pageB
+ [0] ./render.js 60 bytes {2} [built]
+ cjs require ./render [2] ./router.js 1:13-32
cjs require ./render [4] ./bEntry.js 2:13-32
- cjs require ./render [5] ./router.js 1:13-32
- [5] ./router.js 903 bytes {4} [built]
- [6] . (webpack)/node_modules/bundle-loader ^\.\/.*Page$ 184 bytes {4} [built]
- cjs require context bundle-loader!. [5] ./router.js 18:18-61
- [7] (webpack)/node_modules/bundle-loader!./aPage.js 282 bytes {4} [optional] [built]
- context element ./aPage [6] . (webpack)/node_modules/bundle-loader ^\.\/.*Page$ ./aPage
- [8] (webpack)/node_modules/bundle-loader!./bPage.js 282 bytes {4} [optional] [built]
- context element ./bPage [6] . (webpack)/node_modules/bundle-loader ^\.\/.*Page$ ./bPage
+ cjs require ./render [7] ./aEntry.js 2:13-32
+ [2] ./router.js 750 bytes {2} [built]
+ single entry ./router [5] multi ./bEntry ./router pageB:100001
+ single entry ./router [8] multi ./aEntry ./router pageA:100001
+ [6] . lazy ^\.\/.*Page$ namespace object 160 bytes {2} [built]
+ import() context lazy . [2] ./router.js 15:1-59
+chunk {3} pageB.bundle.js (pageB) 129 bytes ={0}= ={2}= >{1}< [entry] [rendered]
+ > pageB
+ [4] ./bEntry.js 89 bytes {3} [built]
+ single entry ./bEntry [5] multi ./bEntry ./router pageB:100000
+ [5] multi ./bEntry ./router 40 bytes {3} [built]
+ multi entry
+chunk {4} pageA.bundle.js (pageA) 129 bytes ={1}= ={2}= >{0}< [entry] [rendered]
+ > pageA
+ [7] ./aEntry.js 89 bytes {4} [built]
+ single entry ./aEntry [8] multi ./aEntry ./router pageA:100000
+ [8] multi ./aEntry ./router 40 bytes {4} [built]
+ multi entry
```
diff --git a/examples/hybrid-routing/pageA.html b/examples/hybrid-routing/pageA.html
index 553e8c42..fc248c39 100644
--- a/examples/hybrid-routing/pageA.html
+++ b/examples/hybrid-routing/pageA.html
@@ -1,7 +1,8 @@
<html>
<head></head>
<body>
- <script src="js/commons.js" charset="utf-8"></script>
- <script src="js/pageA.bundle.js" charset="utf-8"></script>
+ <script async src="dist/pageA~pageB.chunk.js" charset="utf-8"></script>
+ <script async src="dist/aPage.chunk.js" charset="utf-8"></script>
+ <script async src="dist/pageA.bundle.js" charset="utf-8"></script>
</body>
-</html>
\ No newline at end of file
+</html>
diff --git a/examples/hybrid-routing/pageB.html b/examples/hybrid-routing/pageB.html
index ffc9f4fa..594212b5 100644
--- a/examples/hybrid-routing/pageB.html
+++ b/examples/hybrid-routing/pageB.html
@@ -1,7 +1,8 @@
<html>
<head></head>
<body>
- <script src="js/commons.js" charset="utf-8"></script>
- <script src="js/pageB.bundle.js" charset="utf-8"></script>
+ <script async src="dist/pageA~pageB.chunk.js" charset="utf-8"></script>
+ <script async src="dist/bPage.chunk.js" charset="utf-8"></script>
+ <script async src="dist/pageB.bundle.js" charset="utf-8"></script>
</body>
-</html>
\ No newline at end of file
+</html>
diff --git a/examples/hybrid-routing/router.js b/examples/hybrid-routing/router.js
index c94d4265..75f34e34 100644
--- a/examples/hybrid-routing/router.js
+++ b/examples/hybrid-routing/router.js
@@ -11,14 +11,8 @@ window.onLinkToPage = function onLinkToPage(name) { // name is "a" or "b"
// overwriting the RegExp with the ContextReplacementPlugin, or
// using the require.context method.
- // The bundle-loader is used to create a chunk from the page
- // -> Pages are only loaded on demand
-
// This line may throw a exception on runtime if the page wasn't found.
- var pageBundle = require("bundle-loader!./" + name + "Page");
-
- // Wait until the chunk is loaded
- pageBundle(function(page) {
- render(page);
+ import(/* webpackChunkName: "[request]" */`./${name}Page`).then(page => {;
+ render(page.default);
});
}
diff --git a/examples/hybrid-routing/template.md b/examples/hybrid-routing/template.md
index 0784c59b..ed01015b 100644
--- a/examples/hybrid-routing/template.md
+++ b/examples/hybrid-routing/template.md
@@ -32,34 +32,34 @@
{{pageA.html}}
```
-# js/commons.js
+# dist/pageA~pageB.chunk.js
``` javascript
-{{js/commons.js}}
+{{dist/pageA~pageB.chunk.js}}
```
-# js/pageA.bundle.js
+# dist/pageA.bundle.js
``` javascript
-{{js/pageA.bundle.js}}
+{{dist/pageA.bundle.js}}
```
-# js/1.chunk.js
+# dist/aPage.chunk.js
``` javascript
-{{js/1.chunk.js}}
+{{dist/aPage.chunk.js}}
```
# Info
-## Uncompressed
+## Unoptimized
```
{{stdout}}
```
-## Minimized (uglify-js, no zip)
+## Production mode
```
-{{min:stdout}}
+{{production:stdout}}
```
diff --git a/examples/hybrid-routing/webpack.config.js b/examples/hybrid-routing/webpack.config.js
index e9a3b08c..7a6bbafe 100644
--- a/examples/hybrid-routing/webpack.config.js
+++ b/examples/hybrid-routing/webpack.config.js
@@ -1,27 +1,25 @@
var path = require("path");
-var CommonsChunkPlugin = require("../../lib/optimize/CommonsChunkPlugin");
module.exports = {
+ // mode: "development || "production",
entry: {
// The entry points for the pages
- pageA: "./aEntry",
- pageB: "./bEntry",
-
- // This file contains common modules but also the router entry
- "commons": "./router"
+ // They also contains router
+ pageA: ["./aEntry", "./router"],
+ pageB: ["./bEntry", "./router"]
},
output: {
- path: path.join(__dirname, "js"),
+ path: path.join(__dirname, "dist"),
publicPath: "js/",
filename: "[name].bundle.js",
- chunkFilename: "[id].chunk.js"
+ chunkFilename: "[name].chunk.js"
},
- plugins: [
- // Extract common modules from the entries to the commons.js file
+ optimization: {
+ // Extract common modules from initial chunks too
// This is optional, but good for performance.
- new CommonsChunkPlugin({
- name: "commons",
- filename: "commons.js"
- })
- // The pages cannot run without the commons.js file now.
- ]
+ splitChunks: {
+ chunks: "all",
+ minSize: 0 // This example is too small
+ },
+ occurrenceOrder: true // To keep filename consistent between different modes (for example building only)
+ }
};
diff --git a/examples/i18n/README.md b/examples/i18n/README.md
index 154b2036..70d3e3d4 100644
--- a/examples/i18n/README.md
+++ b/examples/i18n/README.md
@@ -24,9 +24,10 @@ var languages = {
module.exports = Object.keys(languages).map(function(language) {
return {
name: language,
+ // mode: "development || "production",
entry: "./example",
output: {
- path: path.join(__dirname, "js"),
+ path: path.join(__dirname, "dist"),
filename: language + ".output.js"
},
plugins: [
@@ -46,7 +47,7 @@ module.exports = Object.keys(languages).map(function(language) {
}
```
-# js/de.output.js
+# dist/de.output.js
<details><summary><code>/******/ (function(modules) { /* webpackBootstrap */ })</code></summary>
@@ -97,6 +98,11 @@ module.exports = Object.keys(languages).map(function(language) {
/******/ }
/******/ };
/******/
+/******/ // define __esModule on exports
+/******/ __webpack_require__.r = function(exports) {
+/******/ Object.defineProperty(exports, '__esModule', { value: true });
+/******/ };
+/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
@@ -110,7 +116,8 @@ module.exports = Object.keys(languages).map(function(language) {
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
-/******/ __webpack_require__.p = "js/";
+/******/ __webpack_require__.p = "dist/";
+/******/
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 0);
@@ -127,7 +134,6 @@ module.exports = Object.keys(languages).map(function(language) {
!*** ./example.js ***!
\********************/
/*! no static exports found */
-/*! all exports used */
/***/ (function(module, exports, __webpack_require__) {
console.log("Hallo Welt");
@@ -137,7 +143,7 @@ console.log("Missing Text");
/******/ ]);
```
-# js/en.output.js
+# dist/en.output.js
``` javascript
/******/ (function(modules) { // webpackBootstrap
@@ -186,6 +192,11 @@ console.log("Missing Text");
/******/ }
/******/ };
/******/
+/******/ // define __esModule on exports
+/******/ __webpack_require__.r = function(exports) {
+/******/ Object.defineProperty(exports, '__esModule', { value: true });
+/******/ };
+/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
@@ -199,7 +210,8 @@ console.log("Missing Text");
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
-/******/ __webpack_require__.p = "js/";
+/******/ __webpack_require__.p = "dist/";
+/******/
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 0);
@@ -211,7 +223,6 @@ console.log("Missing Text");
!*** ./example.js ***!
\********************/
/*! no static exports found */
-/*! all exports used */
/***/ (function(module, exports, __webpack_require__) {
console.log("Hello World");
@@ -223,53 +234,57 @@ console.log("Missing Text");
# Info
-## Uncompressed
+## Unoptimized
```
-Hash: b61d16621736c97f557e52b4d8e68140f1345ef8
-Version: webpack 3.5.1
+Hash: 0a1b2c3d4e5f6a7b8c9d
+Version: webpack 4.0.0-beta.2
Child en:
- Hash: b61d16621736c97f557e
+ Hash: 0a1b2c3d4e5f6a7b8c9d
Asset Size Chunks Chunk Names
- en.output.js 2.69 kB 0 [emitted] main
+ en.output.js 2.8 KiB 0 [emitted] main
Entrypoint main = en.output.js
chunk {0} en.output.js (main) 65 bytes [entry] [rendered]
- > main [0] ./example.js
+ > ./example main
[0] ./example.js 65 bytes {0} [built]
+ single entry ./example main
Child de:
- Hash: 52b4d8e68140f1345ef8
+ Hash: 0a1b2c3d4e5f6a7b8c9d
Asset Size Chunks Chunk Names
- de.output.js 2.69 kB 0 [emitted] main
+ de.output.js 2.8 KiB 0 [emitted] main
Entrypoint main = de.output.js
chunk {0} de.output.js (main) 65 bytes [entry] [rendered]
- > main [0] ./example.js
+ > ./example main
[0] ./example.js 65 bytes {0} [built] [1 warning]
+ single entry ./example main
WARNING in ./example.js
Missing localization: Missing Text
```
-## Minimized (uglify-js, no zip)
+## Production mode
```
-Hash: b61d16621736c97f557e52b4d8e68140f1345ef8
-Version: webpack 3.5.1
+Hash: 0a1b2c3d4e5f6a7b8c9d
+Version: webpack 4.0.0-beta.2
Child en:
- Hash: b61d16621736c97f557e
+ Hash: 0a1b2c3d4e5f6a7b8c9d
Asset Size Chunks Chunk Names
- en.output.js 538 bytes 0 [emitted] main
+ en.output.js 606 bytes 0 [emitted] main
Entrypoint main = en.output.js
chunk {0} en.output.js (main) 65 bytes [entry] [rendered]
- > main [0] ./example.js
+ > ./example main
[0] ./example.js 65 bytes {0} [built]
+ single entry ./example main
Child de:
- Hash: 52b4d8e68140f1345ef8
+ Hash: 0a1b2c3d4e5f6a7b8c9d
Asset Size Chunks Chunk Names
- de.output.js 537 bytes 0 [emitted] main
+ de.output.js 605 bytes 0 [emitted] main
Entrypoint main = de.output.js
chunk {0} de.output.js (main) 65 bytes [entry] [rendered]
- > main [0] ./example.js
+ > ./example main
[0] ./example.js 65 bytes {0} [built] [1 warning]
+ single entry ./example main
WARNING in ./example.js
Missing localization: Missing Text
diff --git a/examples/i18n/template.md b/examples/i18n/template.md
index 2d213678..88d5f719 100644
--- a/examples/i18n/template.md
+++ b/examples/i18n/template.md
@@ -23,28 +23,28 @@ The I18nPlugin replaces every occurrence of the i18n function `__(...)` with a c
{{de.json}}
```
-# js/de.output.js
+# dist/de.output.js
``` javascript
-{{js/de.output.js}}
+{{dist/de.output.js}}
```
-# js/en.output.js
+# dist/en.output.js
``` javascript
-{{js/en.output.js}}
+{{dist/en.output.js}}
```
# Info
-## Uncompressed
+## Unoptimized
```
{{stdout}}
```
-## Minimized (uglify-js, no zip)
+## Production mode
```
-{{min:stdout}}
+{{production:stdout}}
```
\ No newline at end of file
diff --git a/examples/i18n/webpack.config.js b/examples/i18n/webpack.config.js
index 30d44621..cc0267fa 100644
--- a/examples/i18n/webpack.config.js
+++ b/examples/i18n/webpack.config.js
@@ -1,21 +1,18 @@
var path = require("path");
var I18nPlugin = require("i18n-webpack-plugin");
var languages = {
- "en": null,
- "de": require("./de.json")
+ en: null,
+ de: require("./de.json")
};
module.exports = Object.keys(languages).map(function(language) {
return {
name: language,
+ // mode: "development || "production",
entry: "./example",
output: {
- path: path.join(__dirname, "js"),
+ path: path.join(__dirname, "dist"),
filename: language + ".output.js"
},
- plugins: [
- new I18nPlugin(
- languages[language]
- )
- ]
+ plugins: [new I18nPlugin(languages[language])]
};
});
diff --git a/examples/loader/README.md b/examples/loader/README.md
index cd8d8a83..ca02180d 100644
--- a/examples/loader/README.md
+++ b/examples/loader/README.md
@@ -31,7 +31,7 @@ module.exports = function(content) {
}
```
-# js/output.js
+# dist/output.js
<details><summary><code>/******/ (function(modules) { /* webpackBootstrap */ })</code></summary>
@@ -82,6 +82,11 @@ module.exports = function(content) {
/******/ }
/******/ };
/******/
+/******/ // define __esModule on exports
+/******/ __webpack_require__.r = function(exports) {
+/******/ Object.defineProperty(exports, '__esModule', { value: true });
+/******/ };
+/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
@@ -95,10 +100,11 @@ module.exports = function(content) {
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
-/******/ __webpack_require__.p = "js/";
+/******/ __webpack_require__.p = "dist/";
+/******/
/******/
/******/ // Load entry module and return exports
-/******/ return __webpack_require__(__webpack_require__.s = 1);
+/******/ return __webpack_require__(__webpack_require__.s = 0);
/******/ })
/************************************************************************/
```
@@ -108,59 +114,55 @@ module.exports = function(content) {
``` javascript
/******/ ([
/* 0 */
-/*!****************************************************!*\
- !*** (webpack)/node_modules/css-loader!./test.css ***!
- \****************************************************/
-/*! no static exports found */
-/*! all exports used */
-/***/ (function(module, exports, __webpack_require__) {
-
-exports = module.exports = __webpack_require__(/*! ../../node_modules/css-loader/lib/css-base.js */ 3)(undefined);
-// imports
-
-
-// module
-exports.push([module.i, ".some-class {\r\n\tcolor: hotpink;\r\n}\r\n", ""]);
-
-// exports
-
-
-/***/ }),
-/* 1 */
/*!********************!*\
!*** ./example.js ***!
\********************/
/*! no static exports found */
-/*! all exports used */
/***/ (function(module, exports, __webpack_require__) {
// use our loader
-console.dir(__webpack_require__(/*! ./loader!./file */ 2));
+console.dir(__webpack_require__(/*! ./loader!./file */ 1));
// use buildin css loader
-console.dir(__webpack_require__(/*! ./test.css */ 0)); // default by extension
-console.dir(__webpack_require__(/*! css-loader!./test.css */ 0)); // manual
+console.dir(__webpack_require__(/*! ./test.css */ 2)); // default by extension
+console.dir(__webpack_require__(/*! css-loader!./test.css */ 2)); // manual
/***/ }),
-/* 2 */
+/* 1 */
/*!*****************************!*\
!*** ./loader.js!./file.js ***!
\*****************************/
/*! no static exports found */
-/*! all exports used */
/***/ (function(module, exports) {
exports.answer = 42;
exports.foo = "bar";
+/***/ }),
+/* 2 */
+/*!****************************************************!*\
+ !*** (webpack)/node_modules/css-loader!./test.css ***!
+ \****************************************************/
+/*! no static exports found */
+/***/ (function(module, exports, __webpack_require__) {
+
+exports = module.exports = __webpack_require__(/*! ../../node_modules/css-loader/lib/css-base.js */ 3)(undefined);
+// imports
+
+
+// module
+exports.push([module.i, ".some-class {\r\n\tcolor: hotpink;\r\n}\r\n", ""]);
+
+// exports
+
+
/***/ }),
/* 3 */
/*!*********************************************************!*\
!*** (webpack)/node_modules/css-loader/lib/css-base.js ***!
\*********************************************************/
/*! no static exports found */
-/*! all exports used */
/***/ (function(module, exports) {
/*
@@ -257,40 +259,42 @@ Prints in node.js (`enhanced-require example.js`) and in browser:
# Info
-## Uncompressed
+## Unoptimized
```
-Hash: c15a21a2e67111e1cd94
-Version: webpack 3.5.1
+Hash: 0a1b2c3d4e5f6a7b8c9d
+Version: webpack 4.0.0-beta.2
Asset Size Chunks Chunk Names
-output.js 6.24 kB 0 [emitted] main
+output.js 6.2 KiB 0 [emitted] main
Entrypoint main = output.js
-chunk {0} output.js (main) 2.72 kB [entry] [rendered]
- > main [1] ./example.js
- [0] (webpack)/node_modules/css-loader!./test.css 209 bytes {0} [built]
- cjs require !css-loader!./test.css [1] ./example.js 6:12-45
- cjs require ./test.css [1] ./example.js 5:12-33
- [1] ./example.js 210 bytes {0} [built]
- [2] ./loader.js!./file.js 41 bytes {0} [built]
- cjs require ./loader!./file [1] ./example.js 2:12-38
+chunk {0} output.js (main) 2.66 KiB [entry] [rendered]
+ > .\example.js main
+ [0] ./example.js 210 bytes {0} [built]
+ single entry .\example.js main
+ [1] ./loader.js!./file.js 41 bytes {0} [built]
+ cjs require ./loader!./file [0] ./example.js 2:12-38
+ [2] (webpack)/node_modules/css-loader!./test.css 209 bytes {0} [built]
+ cjs require !css-loader!./test.css [0] ./example.js 6:12-45
+ cjs require ./test.css [0] ./example.js 5:12-33
+ 1 hidden module
```
-## Minimized (uglify-js, no zip)
+## Production mode
```
-Hash: 1848e785d8b4fe1c67d0
-Version: webpack 3.5.1
- Asset Size Chunks Chunk Names
-output.js 1.48 kB 0 [emitted] main
+Hash: 0a1b2c3d4e5f6a7b8c9d
+Version: webpack 4.0.0-beta.2
+ Asset Size Chunks Chunk Names
+output.js 1.53 KiB 0 [emitted] main
Entrypoint main = output.js
-chunk {0} output.js (main) 2.7 kB [entry] [rendered]
- > main [1] ./example.js
- [0] (webpack)/node_modules/css-loader!./test.css 192 bytes {0} [built]
- cjs require !css-loader!./test.css [1] ./example.js 6:12-45
- cjs require ./test.css [1] ./example.js 5:12-33
- [1] ./example.js 210 bytes {0} [built]
+chunk {0} output.js (main) 2.66 KiB [entry] [rendered]
+ > .\example.js main
+ [0] (webpack)/node_modules/css-loader!./test.css 209 bytes {0} [built]
+ cjs require !css-loader!./test.css [3] ./example.js 6:12-45
+ cjs require ./test.css [3] ./example.js 5:12-33
[2] ./loader.js!./file.js 41 bytes {0} [built]
- cjs require ./loader!./file [1] ./example.js 2:12-38
+ cjs require ./loader!./file [3] ./example.js 2:12-38
+ [3] ./example.js 210 bytes {0} [built]
+ single entry .\example.js main
+ 1 hidden module
```
diff --git a/examples/loader/template.md b/examples/loader/template.md
index fff5c493..1480a840 100644
--- a/examples/loader/template.md
+++ b/examples/loader/template.md
@@ -22,10 +22,10 @@
{{test.css}}
```
-# js/output.js
+# dist/output.js
``` javascript
-{{js/output.js}}
+{{dist/output.js}}
```
# Console output
@@ -40,14 +40,14 @@ Prints in node.js (`enhanced-require example.js`) and in browser:
# Info
-## Uncompressed
+## Unoptimized
```
{{stdout}}
```
-## Minimized (uglify-js, no zip)
+## Production mode
```
-{{min:stdout}}
+{{production:stdout}}
```
diff --git a/examples/loader/webpack.config.js b/examples/loader/webpack.config.js
index 9c261688..73f1713f 100644
--- a/examples/loader/webpack.config.js
+++ b/examples/loader/webpack.config.js
@@ -1,7 +1,11 @@
module.exports = {
+ // mode: "development || "production",
module: {
- loaders: [
- { test: /\.css$/, loader: "css-loader" }
+ rules: [
+ {
+ test: /\.css$/,
+ loader: "css-loader"
+ }
]
}
};
diff --git a/examples/mixed/README.md b/examples/mixed/README.md
index 85e02904..1a49a5ef 100644
--- a/examples/mixed/README.md
+++ b/examples/mixed/README.md
@@ -54,18 +54,20 @@ require(
);
```
-# js/output.js
+# dist/output.js
<details><summary><code>/******/ (function(modules) { /* webpackBootstrap */ })</code></summary>
``` javascript
/******/ (function(modules) { // webpackBootstrap
/******/ // install a JSONP callback for chunk loading
-/******/ var parentJsonpFunction = window["webpackJsonp"];
-/******/ window["webpackJsonp"] = function webpackJsonpCallback(chunkIds, moreModules, executeModules) {
+/******/ function webpackJsonpCallback(data) {
+/******/ var chunkIds = data[0];
+/******/ var moreModules = data[1]
+/******/
/******/ // add "moreModules" to the modules object,
/******/ // then flag all "chunkIds" as loaded and fire callback
-/******/ var moduleId, chunkId, i = 0, resolves = [], result;
+/******/ var moduleId, chunkId, i = 0, resolves = [];
/******/ for(;i < chunkIds.length; i++) {
/******/ chunkId = chunkIds[i];
/******/ if(installedChunks[chunkId]) {
@@ -78,21 +80,24 @@ require(
/******/ modules[moduleId] = moreModules[moduleId];
/******/ }
/******/ }
-/******/ if(parentJsonpFunction) parentJsonpFunction(chunkIds, moreModules, executeModules);
+/******/ if(parentJsonpFunction) parentJsonpFunction(data);
/******/ while(resolves.length) {
/******/ resolves.shift()();
/******/ }
/******/
/******/ };
/******/
+/******/
/******/ // The module cache
/******/ var installedModules = {};
/******/
-/******/ // objects to store loaded and loading chunks
+/******/ // object to store loaded and loading chunks
/******/ var installedChunks = {
/******/ 1: 0
/******/ };
/******/
+/******/
+/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
@@ -120,51 +125,60 @@ require(
/******/ // This file contains only the entry chunk.
/******/ // The chunk loading function for additional chunks
/******/ __webpack_require__.e = function requireEnsure(chunkId) {
+/******/ var promises = [];
+/******/
+/******/
+/******/ // JSONP chunk loading for javascript
+/******/
/******/ var installedChunkData = installedChunks[chunkId];
-/******/ if(installedChunkData === 0) {
-/******/ return new Promise(function(resolve) { resolve(); });
-/******/ }
+/******/ if(installedChunkData !== 0) { // 0 means "already installed".
/******/
-/******/ // a Promise means "currently loading".
-/******/ if(installedChunkData) {
-/******/ return installedChunkData[2];
-/******/ }
+/******/ // a Promise means "currently loading".
+/******/ if(installedChunkData) {
+/******/ promises.push(installedChunkData[2]);
+/******/ } else {
+/******/ // setup Promise in chunk cache
+/******/ var promise = new Promise(function(resolve, reject) {
+/******/ installedChunkData = installedChunks[chunkId] = [resolve, reject];
+/******/ });
+/******/ promises.push(installedChunkData[2] = promise);
/******/
-/******/ // setup Promise in chunk cache
-/******/ var promise = new Promise(function(resolve, reject) {
-/******/ installedChunkData = installedChunks[chunkId] = [resolve, reject];
-/******/ });
-/******/ installedChunkData[2] = promise;
+/******/ // start chunk loading
+/******/ var head = document.getElementsByTagName('head')[0];
+/******/ var script = document.createElement('script');
/******/
-/******/ // start chunk loading
-/******/ var head = document.getElementsByTagName('head')[0];
-/******/ var script = document.createElement('script');
-/******/ script.type = 'text/javascript';
-/******/ script.charset = 'utf-8';
-/******/ script.async = true;
-/******/ script.timeout = 120000;
+/******/ script.charset = 'utf-8';
+/******/ script.timeout = 120000;
/******/
-/******/ if (__webpack_require__.nc) {
-/******/ script.setAttribute("nonce", __webpack_require__.nc);
-/******/ }
-/******/ script.src = __webpack_require__.p + "" + chunkId + ".output.js";
-/******/ var timeout = setTimeout(onScriptComplete, 120000);
-/******/ script.onerror = script.onload = onScriptComplete;
-/******/ function onScriptComplete() {
-/******/ // avoid mem leaks in IE.
-/******/ script.onerror = script.onload = null;
-/******/ clearTimeout(timeout);
-/******/ var chunk = installedChunks[chunkId];
-/******/ if(chunk !== 0) {
-/******/ if(chunk) {
-/******/ chunk[1](new Error('Loading chunk ' + chunkId + ' failed.'));
+/******/ if (__webpack_require__.nc) {
+/******/ script.setAttribute("nonce", __webpack_require__.nc);
/******/ }
-/******/ installedChunks[chunkId] = undefined;
+/******/ script.src = __webpack_require__.p + "" + chunkId + ".output.js";
+/******/ var timeout = setTimeout(function(){
+/******/ onScriptComplete({ type: 'timeout', target: script });
+/******/ }, 120000);
+/******/ script.onerror = script.onload = onScriptComplete;
+/******/ function onScriptComplete(event) {
+/******/ // avoid mem leaks in IE.
+/******/ script.onerror = script.onload = null;
+/******/ clearTimeout(timeout);
+/******/ var chunk = installedChunks[chunkId];
+/******/ if(chunk !== 0) {
+/******/ if(chunk) {
+/******/ var errorType = event && (event.type === 'load' ? 'missing' : event.type);
+/******/ var realSrc = event && event.target && event.target.src;
+/******/ var error = new Error('Loading chunk ' + chunkId + ' failed.\n(' + errorType + ': ' + realSrc + ')');
+/******/ error.type = errorType;
+/******/ error.request = realSrc;
+/******/ chunk[1](error);
+/******/ }
+/******/ installedChunks[chunkId] = undefined;
+/******/ }
+/******/ };
+/******/ head.appendChild(script);
/******/ }
-/******/ };
-/******/ head.appendChild(script);
-/******/
-/******/ return promise;
+/******/ }
+/******/ return Promise.all(promises);
/******/ };
/******/
/******/ // expose the modules object (__webpack_modules__)
@@ -184,6 +198,11 @@ require(
/******/ }
/******/ };
/******/
+/******/ // define __esModule on exports
+/******/ __webpack_require__.r = function(exports) {
+/******/ Object.defineProperty(exports, '__esModule', { value: true });
+/******/ };
+/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
@@ -197,11 +216,19 @@ require(
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
-/******/ __webpack_require__.p = "js/";
+/******/ __webpack_require__.p = "dist/";
/******/
/******/ // on error function for async loading
/******/ __webpack_require__.oe = function(err) { console.error(err); throw err; };
/******/
+/******/ var jsonpArray = window["webpackJsonp"] = window["webpackJsonp"] || [];
+/******/ var oldJsonpFunction = jsonpArray.push.bind(jsonpArray);
+/******/ jsonpArray.push = webpackJsonpCallback;
+/******/ jsonpArray = jsonpArray.slice();
+/******/ for(var i = 0; i < jsonpArray.length; i++) webpackJsonpCallback(jsonpArray[i]);
+/******/ var parentJsonpFunction = oldJsonpFunction;
+/******/
+/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 3);
/******/ })
@@ -213,56 +240,53 @@ require(
``` javascript
/******/ ([
/* 0 */
-/*!*********************!*\
- !*** ./commonjs.js ***!
- \*********************/
-/*! no static exports found */
-/*! all exports used */
-/***/ (function(module, exports, __webpack_require__) {
-
-// CommonJs Module Format
-module.exports = 123;
-
-// but you can use amd style requires
-new Promise(function(resolve) { resolve(); }).then(function() { var __WEBPACK_AMD_REQUIRE_ARRAY__ = [__webpack_require__(/*! ./amd */ 1), __webpack_require__(/*! ./harmony */ 2)]; (function(amd1, harmony) {
- var amd2 = __webpack_require__(/*! ./amd */ 1);
- var harmony2 = __webpack_require__(/*! ./harmony */ 2);
- }.apply(null, __WEBPACK_AMD_REQUIRE_ARRAY__));}).catch(__webpack_require__.oe);
-
-/***/ }),
-/* 1 */
/*!****************!*\
!*** ./amd.js ***!
\****************/
/*! no static exports found */
-/*! all exports used */
/***/ (function(module, exports, __webpack_require__) {
var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;// AMD Module Format
-!(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(/*! ./commonjs */ 0), __webpack_require__(/*! ./harmony */ 2)], __WEBPACK_AMD_DEFINE_RESULT__ = function(commonjs1, harmony1) {
+!(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(/*! ./commonjs */ 1), __webpack_require__(/*! ./harmony */ 2)], __WEBPACK_AMD_DEFINE_RESULT__ = (function(commonjs1, harmony1) {
// but you can use CommonJs-style requires:
- var commonjs2 = __webpack_require__(/*! ./commonjs */ 0);
+ var commonjs2 = __webpack_require__(/*! ./commonjs */ 1);
var harmony2 = __webpack_require__(/*! ./harmony */ 2);
// Do something...
return 456;
- }.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),
+ }).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),
__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
+/***/ }),
+/* 1 */
+/*!*********************!*\
+ !*** ./commonjs.js ***!
+ \*********************/
+/*! no static exports found */
+/***/ (function(module, exports, __webpack_require__) {
+
+// CommonJs Module Format
+module.exports = 123;
+
+// but you can use amd style requires
+Promise.resolve(/*! AMD require */).then(function() { var __WEBPACK_AMD_REQUIRE_ARRAY__ = [__webpack_require__(/*! ./amd */ 0), __webpack_require__(/*! ./harmony */ 2)]; (function(amd1, harmony) {
+ var amd2 = __webpack_require__(/*! ./amd */ 0);
+ var harmony2 = __webpack_require__(/*! ./harmony */ 2);
+ }).apply(null, __WEBPACK_AMD_REQUIRE_ARRAY__);}).catch(__webpack_require__.oe);
+
/***/ }),
/* 2 */
/*!********************!*\
!*** ./harmony.js ***!
\********************/
/*! exports provided: default */
-/*! all exports used */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
-Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
-/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__commonjs__ = __webpack_require__(/*! ./commonjs */ 0);
-/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__commonjs___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0__commonjs__);
-/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__amd__ = __webpack_require__(/*! ./amd */ 1);
-/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__amd___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1__amd__);
+__webpack_require__.r(__webpack_exports__);
+/* harmony import */ var _commonjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./commonjs */ 1);
+/* harmony import */ var _commonjs__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_commonjs__WEBPACK_IMPORTED_MODULE_0__);
+/* harmony import */ var _amd__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./amd */ 0);
+/* harmony import */ var _amd__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_amd__WEBPACK_IMPORTED_MODULE_1__);
// ES6 Modules
@@ -276,57 +300,62 @@ Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
!*** ./example.js ***!
\********************/
/*! no static exports found */
-/*! all exports used */
/***/ (function(module, exports, __webpack_require__) {
// CommonJs-style requires
-var commonjs1 = __webpack_require__(/*! ./commonjs */ 0);
-var amd1 = __webpack_require__(/*! ./amd */ 1);
+var commonjs1 = __webpack_require__(/*! ./commonjs */ 1);
+var amd1 = __webpack_require__(/*! ./amd */ 0);
var harmony1 = __webpack_require__(/*! ./harmony */ 2);
// AMD-style requires (with all webpack features)
-__webpack_require__.e/* require */(0).then(function() { var __WEBPACK_AMD_REQUIRE_ARRAY__ = [
- __webpack_require__(/*! ./commonjs */ 0), __webpack_require__(/*! ./amd */ 1),
- __webpack_require__(/*! ../require.context/templates */ 4)("./"+amd1+".js"),
- Math.random() < 0.5 ? __webpack_require__(/*! ./commonjs */ 0) : __webpack_require__(/*! ./amd */ 1)]; (function(commonjs2, amd2, template, randModule) {
+__webpack_require__.e(/*! AMD require */ 0).then(function() { var __WEBPACK_AMD_REQUIRE_ARRAY__ = [
+ __webpack_require__(/*! ./commonjs */ 1), __webpack_require__(/*! ./amd */ 0),
+ __webpack_require__(4)("./"+amd1+".js"),
+ Math.random() < 0.5 ? __webpack_require__(/*! ./commonjs */ 1) : __webpack_require__(/*! ./amd */ 0)]; (function(commonjs2, amd2, template, randModule) {
// Do something with it...
- }.apply(null, __WEBPACK_AMD_REQUIRE_ARRAY__));}).catch(__webpack_require__.oe);
+ }).apply(null, __WEBPACK_AMD_REQUIRE_ARRAY__);}).catch(__webpack_require__.oe);
/***/ })
/******/ ]);
```
-# js/0.output.js
+# dist/0.output.js
``` javascript
-webpackJsonp([0],[
+(window["webpackJsonp"] = window["webpackJsonp"] || []).push([[0],[
/* 0 */,
/* 1 */,
/* 2 */,
/* 3 */,
/* 4 */
-/*!*************************************************!*\
- !*** ../require.context/templates ^\.\/.*\.js$ ***!
- \*************************************************/
+/*!******************************************************!*\
+ !*** ../require.context/templates sync ^\.\/.*\.js$ ***!
+ \******************************************************/
/*! no static exports found */
-/*! all exports used */
/***/ (function(module, exports, __webpack_require__) {
var map = {
- "./a.js": 5,
+ "./a.js": 7,
"./b.js": 6,
- "./c.js": 7
+ "./c.js": 5
};
+
+
function webpackContext(req) {
- return __webpack_require__(webpackContextResolve(req));
-};
+ var id = webpackContextResolve(req);
+ var module = __webpack_require__(id);
+ return module;
+}
function webpackContextResolve(req) {
var id = map[req];
- if(!(id + 1)) // check for number or string
- throw new Error("Cannot find module '" + req + "'.");
+ if(!(id + 1)) { // check for number or string
+ var e = new Error('Cannot find module "' + req + '".');
+ e.code = 'MODULE_NOT_FOUND';
+ throw e;
+ }
return id;
-};
+}
webpackContext.keys = function webpackContextKeys() {
return Object.keys(map);
};
@@ -337,14 +366,13 @@ webpackContext.id = 4;
/***/ }),
/* 5 */
/*!*****************************************!*\
- !*** ../require.context/templates/a.js ***!
+ !*** ../require.context/templates/c.js ***!
\*****************************************/
/*! no static exports found */
-/*! all exports used */
/***/ (function(module, exports) {
module.exports = function() {
- return "This text was generated by template A";
+ return "This text was generated by template C";
}
/***/ }),
@@ -353,7 +381,6 @@ module.exports = function() {
!*** ../require.context/templates/b.js ***!
\*****************************************/
/*! no static exports found */
-/*! all exports used */
/***/ (function(module, exports) {
module.exports = function() {
@@ -363,108 +390,109 @@ module.exports = function() {
/***/ }),
/* 7 */
/*!*****************************************!*\
- !*** ../require.context/templates/c.js ***!
+ !*** ../require.context/templates/a.js ***!
\*****************************************/
/*! no static exports found */
-/*! all exports used */
/***/ (function(module, exports) {
module.exports = function() {
- return "This text was generated by template C";
+ return "This text was generated by template A";
}
/***/ })
-]);
+]]);
```
# Info
-## Uncompressed
+## Unoptimized
```
-Hash: ec4ce5e31af3a13d93fa
-Version: webpack 3.5.1
- Asset Size Chunks Chunk Names
-0.output.js 1.86 kB 0 [emitted]
- output.js 9.08 kB 1 [emitted] main
+Hash: 0a1b2c3d4e5f6a7b8c9d
+Version: webpack 4.0.0-beta.2
+ Asset Size Chunks Chunk Names
+0.output.js 1.87 KiB 0 [emitted]
+ output.js 9.76 KiB 1 [emitted] main
Entrypoint main = output.js
-chunk {0} 0.output.js 439 bytes {1} [rendered]
+chunk {0} 0.output.js 439 bytes <{1}> [rendered]
> [3] ./example.js 7:0-14:1
- [4] ../require.context/templates ^\.\/.*\.js$ 193 bytes {0} [built]
+ [4] ../require.context/templates sync ^\.\/.*\.js$ 193 bytes {0} [built]
amd require context ../require.context/templates [3] ./example.js 7:0-14:1
- [5] ../require.context/templates/a.js 82 bytes {0} [optional] [built]
- context element ./a.js [4] ../require.context/templates ^\.\/.*\.js$ ./a.js
+ [5] ../require.context/templates/c.js 82 bytes {0} [optional] [built]
+ context element ./c.js [4] ../require.context/templates sync ^\.\/.*\.js$ ./c.js
[6] ../require.context/templates/b.js 82 bytes {0} [optional] [built]
- context element ./b.js [4] ../require.context/templates ^\.\/.*\.js$ ./b.js
- [7] ../require.context/templates/c.js 82 bytes {0} [optional] [built]
- context element ./c.js [4] ../require.context/templates ^\.\/.*\.js$ ./c.js
-chunk {1} output.js (main) 1.05 kB [entry] [rendered]
- > main [3] ./example.js
- [0] ./commonjs.js 233 bytes {1} [built]
- amd require ./commonjs [1] ./amd.js 2:0-12:1
- cjs require ./commonjs [1] ./amd.js 7:18-39
- harmony import ./commonjs [2] ./harmony.js 2:0-34
- cjs require ./commonjs [3] ./example.js 2:16-37
- amd require ./commonjs [3] ./example.js 7:0-14:1
- amd require ./commonjs [3] ./example.js 7:0-14:1
- [1] ./amd.js 309 bytes {1} [built]
- amd require ./amd [0] ./commonjs.js 5:0-11:1
- cjs require ./amd [0] ./commonjs.js 8:13-29
- harmony import ./amd [2] ./harmony.js 3:0-24
+ context element ./b.js [4] ../require.context/templates sync ^\.\/.*\.js$ ./b.js
+ [7] ../require.context/templates/a.js 82 bytes {0} [optional] [built]
+ context element ./a.js [4] ../require.context/templates sync ^\.\/.*\.js$ ./a.js
+chunk {1} output.js (main) 1.03 KiB >{0}< [entry] [rendered]
+ > .\example.js main
+ [0] ./amd.js 309 bytes {1} [built]
+ amd require ./amd [1] ./commonjs.js 5:0-11:1
+ cjs require ./amd [1] ./commonjs.js 8:13-29
+ harmony side effect evaluation ./amd [2] ./harmony.js 3:0-24
cjs require ./amd [3] ./example.js 3:11-27
amd require ./amd [3] ./example.js 7:0-14:1
amd require ./amd [3] ./example.js 7:0-14:1
+ [1] ./commonjs.js 233 bytes {1} [built]
+ amd require ./commonjs [0] ./amd.js 2:0-12:1
+ cjs require ./commonjs [0] ./amd.js 7:18-39
+ harmony side effect evaluation ./commonjs [2] ./harmony.js 2:0-34
+ cjs require ./commonjs [3] ./example.js 2:16-37
+ amd require ./commonjs [3] ./example.js 7:0-14:1
+ amd require ./commonjs [3] ./example.js 7:0-14:1
[2] ./harmony.js 101 bytes {1} [built]
[exports: default]
- amd require ./harmony [0] ./commonjs.js 5:0-11:1
- cjs require ./harmony [0] ./commonjs.js 9:17-37
- amd require ./harmony [1] ./amd.js 2:0-12:1
- cjs require ./harmony [1] ./amd.js 8:17-37
+ amd require ./harmony [0] ./amd.js 2:0-12:1
+ cjs require ./harmony [0] ./amd.js 8:17-37
+ amd require ./harmony [1] ./commonjs.js 5:0-11:1
+ cjs require ./harmony [1] ./commonjs.js 9:17-37
cjs require ./harmony [3] ./example.js 4:15-35
[3] ./example.js 410 bytes {1} [built]
+ single entry .\example.js main
```
-## Minimized (uglify-js, no zip)
+## Production mode
```
-Hash: ec4ce5e31af3a13d93fa
-Version: webpack 3.5.1
+Hash: 0a1b2c3d4e5f6a7b8c9d
+Version: webpack 4.0.0-beta.2
Asset Size Chunks Chunk Names
-0.output.js 523 bytes 0 [emitted]
- output.js 1.89 kB 1 [emitted] main
+0.output.js 606 bytes 0 [emitted]
+ output.js 2.04 KiB 1 [emitted] main
Entrypoint main = output.js
-chunk {0} 0.output.js 439 bytes {1} [rendered]
+chunk {0} 0.output.js 439 bytes <{1}> [rendered]
> [3] ./example.js 7:0-14:1
- [4] ../require.context/templates ^\.\/.*\.js$ 193 bytes {0} [built]
+ [4] ../require.context/templates sync ^\.\/.*\.js$ 193 bytes {0} [built]
amd require context ../require.context/templates [3] ./example.js 7:0-14:1
- [5] ../require.context/templates/a.js 82 bytes {0} [optional] [built]
- context element ./a.js [4] ../require.context/templates ^\.\/.*\.js$ ./a.js
+ [5] ../require.context/templates/c.js 82 bytes {0} [optional] [built]
+ context element ./c.js [4] ../require.context/templates sync ^\.\/.*\.js$ ./c.js
[6] ../require.context/templates/b.js 82 bytes {0} [optional] [built]
- context element ./b.js [4] ../require.context/templates ^\.\/.*\.js$ ./b.js
- [7] ../require.context/templates/c.js 82 bytes {0} [optional] [built]
- context element ./c.js [4] ../require.context/templates ^\.\/.*\.js$ ./c.js
-chunk {1} output.js (main) 1.05 kB [entry] [rendered]
- > main [3] ./example.js
- [0] ./commonjs.js 233 bytes {1} [built]
- amd require ./commonjs [1] ./amd.js 2:0-12:1
- cjs require ./commonjs [1] ./amd.js 7:18-39
- harmony import ./commonjs [2] ./harmony.js 2:0-34
- cjs require ./commonjs [3] ./example.js 2:16-37
- amd require ./commonjs [3] ./example.js 7:0-14:1
- amd require ./commonjs [3] ./example.js 7:0-14:1
- [1] ./amd.js 309 bytes {1} [built]
- amd require ./amd [0] ./commonjs.js 5:0-11:1
- cjs require ./amd [0] ./commonjs.js 8:13-29
- harmony import ./amd [2] ./harmony.js 3:0-24
+ context element ./b.js [4] ../require.context/templates sync ^\.\/.*\.js$ ./b.js
+ [7] ../require.context/templates/a.js 82 bytes {0} [optional] [built]
+ context element ./a.js [4] ../require.context/templates sync ^\.\/.*\.js$ ./a.js
+chunk {1} output.js (main) 1.03 KiB >{0}< [entry] [rendered]
+ > .\example.js main
+ [0] ./amd.js 309 bytes {1} [built]
+ amd require ./amd [1] ./commonjs.js 5:0-11:1
+ cjs require ./amd [1] ./commonjs.js 8:13-29
+ harmony side effect evaluation ./amd [2] ./harmony.js 3:0-24
cjs require ./amd [3] ./example.js 3:11-27
amd require ./amd [3] ./example.js 7:0-14:1
amd require ./amd [3] ./example.js 7:0-14:1
+ [1] ./commonjs.js 233 bytes {1} [built]
+ amd require ./commonjs [0] ./amd.js 2:0-12:1
+ cjs require ./commonjs [0] ./amd.js 7:18-39
+ harmony side effect evaluation ./commonjs [2] ./harmony.js 2:0-34
+ cjs require ./commonjs [3] ./example.js 2:16-37
+ amd require ./commonjs [3] ./example.js 7:0-14:1
+ amd require ./commonjs [3] ./example.js 7:0-14:1
[2] ./harmony.js 101 bytes {1} [built]
[exports: default]
- amd require ./harmony [0] ./commonjs.js 5:0-11:1
- cjs require ./harmony [0] ./commonjs.js 9:17-37
- amd require ./harmony [1] ./amd.js 2:0-12:1
- cjs require ./harmony [1] ./amd.js 8:17-37
+ amd require ./harmony [0] ./amd.js 2:0-12:1
+ cjs require ./harmony [0] ./amd.js 8:17-37
+ amd require ./harmony [1] ./commonjs.js 5:0-11:1
+ cjs require ./harmony [1] ./commonjs.js 9:17-37
cjs require ./harmony [3] ./example.js 4:15-35
[3] ./example.js 410 bytes {1} [built]
+ single entry .\example.js main
```
diff --git a/examples/mixed/template.md b/examples/mixed/template.md
index eaebc4d1..aba51a1f 100644
--- a/examples/mixed/template.md
+++ b/examples/mixed/template.md
@@ -20,28 +20,28 @@ You see that everything is working nicely together.
{{commonjs.js}}
```
-# js/output.js
+# dist/output.js
``` javascript
-{{js/output.js}}
+{{dist/output.js}}
```
-# js/0.output.js
+# dist/0.output.js
``` javascript
-{{js/0.output.js}}
+{{dist/0.output.js}}
```
# Info
-## Uncompressed
+## Unoptimized
```
{{stdout}}
```
-## Minimized (uglify-js, no zip)
+## Production mode
```
-{{min:stdout}}
+{{production:stdout}}
```
diff --git a/examples/mixed/webpack.config.js b/examples/mixed/webpack.config.js
new file mode 100644
index 00000000..0d554bf6
--- /dev/null
+++ b/examples/mixed/webpack.config.js
@@ -0,0 +1,5 @@
+module.exports = {
+ optimization: {
+ occurrenceOrder: true // To keep filename consistent between different modes (for example building only)
+ }
+};
diff --git a/examples/move-to-parent/README.md b/examples/move-to-parent/README.md
deleted file mode 100644
index 6acb8b9a..00000000
--- a/examples/move-to-parent/README.md
+++ /dev/null
@@ -1,297 +0,0 @@
-This example shows example of using the CommonsChunkPlugin for moving modules from child-chunks to the parent chunk.
-
-The `CommonsChunkPlugin` is used with `selectedChunks = false` argument to check for common modules in the child-chunks.
-
-Without the plugin the pages would have this chunks:
-
-* page
- * chunk: a
- * chunk: a, b
- * chunk: a, b, c
- * chunk: a, b, c, d
-
-Using the `CommonsChunkPlugin` without `minChunks` argument only moves modules which are shared by all children (here only module `a`):
-
-* pageA: a
- * chunk: b
- * chunk: b, c
- * chunk: b, c, d
-
-With `minChunks = 3`:
-
-* pageB: a, b
- * chunk: c
- * chunk: c, d
-
-It's also possible to provide a function instead of a number for `minChunks`. The function is called for each module to decide if the module should be moved or not (see pageC and pageD):
-
-* pageC: a, c, d
- * chunk: b
-
-# page.js
-
-``` javascript
-require(["./a"]);
-require(["./a", "./b"]);
-require(["./a", "./b", "./c"]);
-require(["./a", "./b", "./c", "./d"]);
-```
-
-# webpack.config.js
-
-``` javascript
-var path = require("path");
-var CommonsChunkPlugin = require("../../lib/optimize/CommonsChunkPlugin");
-var outputOptions = {
- path: path.join(__dirname, "js"),
- filename: "[name].bundle.js",
- chunkFilename: "[id].chunk.js"
-};
-module.exports = [{
- name: "page",
- entry: {
- page: "./page"
- },
- output: outputOptions
-}, {
- name: "pageA",
- entry: {
- pageA: "./page"
- },
- output: outputOptions,
- plugins: [
- //check for common modules in children of pageA and move them to the parent
- new CommonsChunkPlugin({
- name: "pageA",
- children: true
- }),
- ]
-}, {
- name: "pageB",
- entry: {
- pageB: "./page"
- },
- output: outputOptions,
- plugins: [
- // the same for pageB but move them if at least 3 children share the module
- new CommonsChunkPlugin({
- name: "pageB",
- children: true,
- minChunks: 3
- }),
- ]
-}, {
- name: "pageC",
- entry: {
- pageC: "./page"
- },
- output: outputOptions,
- plugins: [
- // the same for pageC and pageD but with a custom logic for moving
- new CommonsChunkPlugin({
- name: "pageC",
- children: true,
- minChunks: function(module, count) {
- // move only module "b"
- return !/b\.js/.test(module.identifier());
- }
- })
- ]
-}];
-```
-
-# Info
-
-## Uncompressed
-
-```
-Hash: 32754229c1b49aaf5dd3020f354a206f830a17560d92a3529fe0380101f3e2c85f80fcddae09adcf
-Version: webpack 3.5.1
-Child page:
- Hash: 32754229c1b49aaf5dd3
- Asset Size Chunks Chunk Names
- 0.chunk.js 800 bytes 0, 1, 2, 3 [emitted]
- 1.chunk.js 598 bytes 1, 2, 3 [emitted]
- 2.chunk.js 405 bytes 2, 3 [emitted]
- 3.chunk.js 212 bytes 3 [emitted]
- page.bundle.js 6.62 kB 4 [emitted] page
- Entrypoint page = page.bundle.js
- chunk {0} 0.chunk.js 84 bytes {4} [rendered]
- > [3] ./page.js 4:0-37
- [0] ./a.js 21 bytes {0} {1} {2} {3} [built]
- [1] ./b.js 21 bytes {0} {1} {2} [built]
- [2] ./c.js 21 bytes {0} {1} [built]
- [4] ./d.js 21 bytes {0} [built]
- chunk {1} 1.chunk.js 63 bytes {4} [rendered]
- > [3] ./page.js 3:0-30
- [0] ./a.js 21 bytes {0} {1} {2} {3} [built]
- [1] ./b.js 21 bytes {0} {1} {2} [built]
- [2] ./c.js 21 bytes {0} {1} [built]
- chunk {2} 2.chunk.js 42 bytes {4} [rendered]
- > [3] ./page.js 2:0-23
- [0] ./a.js 21 bytes {0} {1} {2} {3} [built]
- [1] ./b.js 21 bytes {0} {1} {2} [built]
- chunk {3} 3.chunk.js 21 bytes {4} [rendered]
- > [3] ./page.js 1:0-16
- [0] ./a.js 21 bytes {0} {1} {2} {3} [built]
- chunk {4} page.bundle.js (page) 118 bytes [entry] [rendered]
- > page [3] ./page.js
- [3] ./page.js 118 bytes {4} [built]
-Child pageA:
- Hash: 020f354a206f830a1756
- Asset Size Chunks Chunk Names
- 0.chunk.js 616 bytes 0, 1, 2 [emitted]
- 1.chunk.js 414 bytes 1, 2 [emitted]
- 2.chunk.js 221 bytes 2 [emitted]
- pageA.bundle.js 6.83 kB 3 [emitted] pageA
- Entrypoint pageA = pageA.bundle.js
- chunk {0} 0.chunk.js 63 bytes {3} [rendered]
- > [3] ./page.js 4:0-37
- [1] ./b.js 21 bytes {0} {1} {2} [built]
- [2] ./c.js 21 bytes {0} {1} [built]
- [4] ./d.js 21 bytes {0} [built]
- chunk {1} 1.chunk.js 42 bytes {3} [rendered]
- > [3] ./page.js 3:0-30
- [1] ./b.js 21 bytes {0} {1} {2} [built]
- [2] ./c.js 21 bytes {0} {1} [built]
- chunk {2} 2.chunk.js 21 bytes {3} [rendered]
- > [3] ./page.js 2:0-23
- [1] ./b.js 21 bytes {0} {1} {2} [built]
- chunk {3} pageA.bundle.js (pageA) 139 bytes [entry] [rendered]
- > pageA [3] ./page.js
- [0] ./a.js 21 bytes {3} [built]
- [3] ./page.js 118 bytes {3} [built]
-Child pageB:
- Hash: 0d92a3529fe0380101f3
- Asset Size Chunks Chunk Names
- 0.chunk.js 432 bytes 0, 1 [emitted]
- 1.chunk.js 215 bytes 1 [emitted]
- pageB.bundle.js 7.02 kB 2 [emitted] pageB
- Entrypoint pageB = pageB.bundle.js
- chunk {0} 0.chunk.js 42 bytes {2} [rendered]
- > [3] ./page.js 4:0-37
- [2] ./c.js 21 bytes {0} {1} [built]
- [4] ./d.js 21 bytes {0} [built]
- chunk {1} 1.chunk.js 21 bytes {2} [rendered]
- > [3] ./page.js 3:0-30
- [2] ./c.js 21 bytes {0} {1} [built]
- chunk {2} pageB.bundle.js (pageB) 160 bytes [entry] [rendered]
- > pageB [3] ./page.js
- [0] ./a.js 21 bytes {2} [built]
- [1] ./b.js 21 bytes {2} [built]
- [3] ./page.js 118 bytes {2} [built]
-Child pageC:
- Hash: e2c85f80fcddae09adcf
- Asset Size Chunks Chunk Names
- 0.chunk.js 221 bytes 0 [emitted]
- pageC.bundle.js 7.23 kB 1 [emitted] pageC
- Entrypoint pageC = pageC.bundle.js
- chunk {0} 0.chunk.js 21 bytes {1} [rendered]
- > duplicate [3] ./page.js 2:0-23
- > duplicate [3] ./page.js 3:0-30
- > duplicate [3] ./page.js 4:0-37
- [1] ./b.js 21 bytes {0} [built]
- chunk {1} pageC.bundle.js (pageC) 181 bytes [entry] [rendered]
- > pageC [3] ./page.js
- [0] ./a.js 21 bytes {1} [built]
- [2] ./c.js 21 bytes {1} [built]
- [3] ./page.js 118 bytes {1} [built]
- [4] ./d.js 21 bytes {1} [built]
-```
-
-## Minimized (uglify-js, no zip)
-
-```
-Hash: 32754229c1b49aaf5dd3020f354a206f830a17560d92a3529fe0380101f3e2c85f80fcddae09adcf
-Version: webpack 3.5.1
-Child page:
- Hash: 32754229c1b49aaf5dd3
- Asset Size Chunks Chunk Names
- 0.chunk.js 143 bytes 0, 1, 2, 3 [emitted]
- 1.chunk.js 111 bytes 1, 2, 3 [emitted]
- 2.chunk.js 80 bytes 2, 3 [emitted]
- 3.chunk.js 49 bytes 3 [emitted]
- page.bundle.js 1.54 kB 4 [emitted] page
- Entrypoint page = page.bundle.js
- chunk {0} 0.chunk.js 84 bytes {4} [rendered]
- > [3] ./page.js 4:0-37
- [0] ./a.js 21 bytes {0} {1} {2} {3} [built]
- [1] ./b.js 21 bytes {0} {1} {2} [built]
- [2] ./c.js 21 bytes {0} {1} [built]
- [4] ./d.js 21 bytes {0} [built]
- chunk {1} 1.chunk.js 63 bytes {4} [rendered]
- > [3] ./page.js 3:0-30
- [0] ./a.js 21 bytes {0} {1} {2} {3} [built]
- [1] ./b.js 21 bytes {0} {1} {2} [built]
- [2] ./c.js 21 bytes {0} {1} [built]
- chunk {2} 2.chunk.js 42 bytes {4} [rendered]
- > [3] ./page.js 2:0-23
- [0] ./a.js 21 bytes {0} {1} {2} {3} [built]
- [1] ./b.js 21 bytes {0} {1} {2} [built]
- chunk {3} 3.chunk.js 21 bytes {4} [rendered]
- > [3] ./page.js 1:0-16
- [0] ./a.js 21 bytes {0} {1} {2} {3} [built]
- chunk {4} page.bundle.js (page) 118 bytes [entry] [rendered]
- > page [3] ./page.js
- [3] ./page.js 118 bytes {4} [built]
-Child pageA:
- Hash: 020f354a206f830a1756
- Asset Size Chunks Chunk Names
- 0.chunk.js 113 bytes 0, 1, 2 [emitted]
- 1.chunk.js 81 bytes 1, 2 [emitted]
- 2.chunk.js 50 bytes 2 [emitted]
- pageA.bundle.js 1.59 kB 3 [emitted] pageA
- Entrypoint pageA = pageA.bundle.js
- chunk {0} 0.chunk.js 63 bytes {3} [rendered]
- > [3] ./page.js 4:0-37
- [1] ./b.js 21 bytes {0} {1} {2} [built]
- [2] ./c.js 21 bytes {0} {1} [built]
- [4] ./d.js 21 bytes {0} [built]
- chunk {1} 1.chunk.js 42 bytes {3} [rendered]
- > [3] ./page.js 3:0-30
- [1] ./b.js 21 bytes {0} {1} {2} [built]
- [2] ./c.js 21 bytes {0} {1} [built]
- chunk {2} 2.chunk.js 21 bytes {3} [rendered]
- > [3] ./page.js 2:0-23
- [1] ./b.js 21 bytes {0} {1} {2} [built]
- chunk {3} pageA.bundle.js (pageA) 139 bytes [entry] [rendered]
- > pageA [3] ./page.js
- [0] ./a.js 21 bytes {3} [built]
- [3] ./page.js 118 bytes {3} [built]
-Child pageB:
- Hash: 0d92a3529fe0380101f3
- Asset Size Chunks Chunk Names
- 0.chunk.js 83 bytes 0, 1 [emitted]
- 1.chunk.js 51 bytes 1 [emitted]
- pageB.bundle.js 1.64 kB 2 [emitted] pageB
- Entrypoint pageB = pageB.bundle.js
- chunk {0} 0.chunk.js 42 bytes {2} [rendered]
- > [3] ./page.js 4:0-37
- [2] ./c.js 21 bytes {0} {1} [built]
- [4] ./d.js 21 bytes {0} [built]
- chunk {1} 1.chunk.js 21 bytes {2} [rendered]
- > [3] ./page.js 3:0-30
- [2] ./c.js 21 bytes {0} {1} [built]
- chunk {2} pageB.bundle.js (pageB) 160 bytes [entry] [rendered]
- > pageB [3] ./page.js
- [0] ./a.js 21 bytes {2} [built]
- [1] ./b.js 21 bytes {2} [built]
- [3] ./page.js 118 bytes {2} [built]
-Child pageC:
- Hash: e2c85f80fcddae09adcf
- Asset Size Chunks Chunk Names
- 0.chunk.js 50 bytes 0 [emitted]
- pageC.bundle.js 1.65 kB 1 [emitted] pageC
- Entrypoint pageC = pageC.bundle.js
- chunk {0} 0.chunk.js 21 bytes {1} [rendered]
- > duplicate [3] ./page.js 2:0-23
- > duplicate [3] ./page.js 3:0-30
- > duplicate [3] ./page.js 4:0-37
- [1] ./b.js 21 bytes {0} [built]
- chunk {1} pageC.bundle.js (pageC) 181 bytes [entry] [rendered]
- > pageC [3] ./page.js
- [0] ./a.js 21 bytes {1} [built]
- [2] ./c.js 21 bytes {1} [built]
- [3] ./page.js 118 bytes {1} [built]
- [4] ./d.js 21 bytes {1} [built]
-```
diff --git a/examples/move-to-parent/a.js b/examples/move-to-parent/a.js
deleted file mode 100644
index 01cd3e71..00000000
--- a/examples/move-to-parent/a.js
+++ /dev/null
@@ -1 +0,0 @@
-module.exports = "a";
\ No newline at end of file
diff --git a/examples/move-to-parent/b.js b/examples/move-to-parent/b.js
deleted file mode 100644
index fba3204f..00000000
--- a/examples/move-to-parent/b.js
+++ /dev/null
@@ -1 +0,0 @@
-module.exports = "b";
\ No newline at end of file
diff --git a/examples/move-to-parent/build.js b/examples/move-to-parent/build.js
deleted file mode 100644
index 8e0c3190..00000000
--- a/examples/move-to-parent/build.js
+++ /dev/null
@@ -1,3 +0,0 @@
-global.NO_TARGET_ARGS = true;
-global.NO_REASONS = true;
-require("../build-common");
diff --git a/examples/move-to-parent/c.js b/examples/move-to-parent/c.js
deleted file mode 100644
index ebaf7584..00000000
--- a/examples/move-to-parent/c.js
+++ /dev/null
@@ -1 +0,0 @@
-module.exports = "c";
\ No newline at end of file
diff --git a/examples/move-to-parent/d.js b/examples/move-to-parent/d.js
deleted file mode 100644
index 76e86216..00000000
--- a/examples/move-to-parent/d.js
+++ /dev/null
@@ -1 +0,0 @@
-module.exports = "d";
\ No newline at end of file
diff --git a/examples/move-to-parent/page.js b/examples/move-to-parent/page.js
deleted file mode 100644
index 6f7e3730..00000000
--- a/examples/move-to-parent/page.js
+++ /dev/null
@@ -1,4 +0,0 @@
-require(["./a"]);
-require(["./a", "./b"]);
-require(["./a", "./b", "./c"]);
-require(["./a", "./b", "./c", "./d"]);
diff --git a/examples/move-to-parent/template.md b/examples/move-to-parent/template.md
deleted file mode 100644
index 67e512a5..00000000
--- a/examples/move-to-parent/template.md
+++ /dev/null
@@ -1,55 +0,0 @@
-This example shows example of using the CommonsChunkPlugin for moving modules from child-chunks to the parent chunk.
-
-The `CommonsChunkPlugin` is used with `selectedChunks = false` argument to check for common modules in the child-chunks.
-
-Without the plugin the pages would have this chunks:
-
-* page
- * chunk: a
- * chunk: a, b
- * chunk: a, b, c
- * chunk: a, b, c, d
-
-Using the `CommonsChunkPlugin` without `minChunks` argument only moves modules which are shared by all children (here only module `a`):
-
-* pageA: a
- * chunk: b
- * chunk: b, c
- * chunk: b, c, d
-
-With `minChunks = 3`:
-
-* pageB: a, b
- * chunk: c
- * chunk: c, d
-
-It's also possible to provide a function instead of a number for `minChunks`. The function is called for each module to decide if the module should be moved or not (see pageC and pageD):
-
-* pageC: a, c, d
- * chunk: b
-
-# page.js
-
-``` javascript
-{{page.js}}
-```
-
-# webpack.config.js
-
-``` javascript
-{{webpack.config.js}}
-```
-
-# Info
-
-## Uncompressed
-
-```
-{{stdout}}
-```
-
-## Minimized (uglify-js, no zip)
-
-```
-{{min:stdout}}
-```
diff --git a/examples/move-to-parent/webpack.config.js b/examples/move-to-parent/webpack.config.js
deleted file mode 100644
index f39633ea..00000000
--- a/examples/move-to-parent/webpack.config.js
+++ /dev/null
@@ -1,58 +0,0 @@
-var path = require("path");
-var CommonsChunkPlugin = require("../../lib/optimize/CommonsChunkPlugin");
-var outputOptions = {
- path: path.join(__dirname, "js"),
- filename: "[name].bundle.js",
- chunkFilename: "[id].chunk.js"
-};
-module.exports = [{
- name: "page",
- entry: {
- page: "./page"
- },
- output: outputOptions
-}, {
- name: "pageA",
- entry: {
- pageA: "./page"
- },
- output: outputOptions,
- plugins: [
- //check for common modules in children of pageA and move them to the parent
- new CommonsChunkPlugin({
- name: "pageA",
- children: true
- }),
- ]
-}, {
- name: "pageB",
- entry: {
- pageB: "./page"
- },
- output: outputOptions,
- plugins: [
- // the same for pageB but move them if at least 3 children share the module
- new CommonsChunkPlugin({
- name: "pageB",
- children: true,
- minChunks: 3
- }),
- ]
-}, {
- name: "pageC",
- entry: {
- pageC: "./page"
- },
- output: outputOptions,
- plugins: [
- // the same for pageC and pageD but with a custom logic for moving
- new CommonsChunkPlugin({
- name: "pageC",
- children: true,
- minChunks: function(module, count) {
- // move only module "b"
- return !/b\.js/.test(module.identifier());
- }
- })
- ]
-}];
diff --git a/examples/multi-compiler/README.md b/examples/multi-compiler/README.md
index ab4746d9..f7882565 100644
--- a/examples/multi-compiler/README.md
+++ b/examples/multi-compiler/README.md
@@ -14,11 +14,13 @@ console.log("Running " + ENV + " build");
var path = require("path");
var webpack = require("../../");
module.exports = [
+
{
name: "mobile",
+ // mode: "development || "production",
entry: "./example",
output: {
- path: path.join(__dirname, "js"),
+ path: path.join(__dirname, "dist"),
filename: "mobile.js"
},
plugins: [
@@ -27,11 +29,13 @@ module.exports = [
})
]
},
+
{
name: "desktop",
+ // mode: "development || "production",
entry: "./example",
output: {
- path: path.join(__dirname, "js"),
+ path: path.join(__dirname, "dist"),
filename: "desktop.js"
},
plugins: [
@@ -40,10 +44,11 @@ module.exports = [
})
]
}
+
];
```
-# js/desktop.js
+# dist/desktop.js
<details><summary><code>/******/ (function(modules) { /* webpackBootstrap */ })</code></summary>
@@ -94,6 +99,11 @@ module.exports = [
/******/ }
/******/ };
/******/
+/******/ // define __esModule on exports
+/******/ __webpack_require__.r = function(exports) {
+/******/ Object.defineProperty(exports, '__esModule', { value: true });
+/******/ };
+/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
@@ -107,7 +117,8 @@ module.exports = [
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
-/******/ __webpack_require__.p = "js/";
+/******/ __webpack_require__.p = "dist/";
+/******/
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 0);
@@ -124,19 +135,16 @@ module.exports = [
!*** ./example.js ***!
\********************/
/*! no static exports found */
-/*! all exports used */
/***/ (function(module, exports, __webpack_require__) {
-if(false) {
- require("./mobile-stuff");
-}
+if(false) {}
console.log("Running " + "desktop" + " build");
/***/ })
/******/ ]);
```
-# js/mobile.js
+# dist/mobile.js
``` javascript
/******/ (function(modules) { // webpackBootstrap
@@ -185,6 +193,11 @@ console.log("Running " + "desktop" + " build");
/******/ }
/******/ };
/******/
+/******/ // define __esModule on exports
+/******/ __webpack_require__.r = function(exports) {
+/******/ Object.defineProperty(exports, '__esModule', { value: true });
+/******/ };
+/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
@@ -198,7 +211,8 @@ console.log("Running " + "desktop" + " build");
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
-/******/ __webpack_require__.p = "js/";
+/******/ __webpack_require__.p = "dist/";
+/******/
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 0);
@@ -210,7 +224,6 @@ console.log("Running " + "desktop" + " build");
!*** ./example.js ***!
\********************/
/*! no static exports found */
-/*! all exports used */
/***/ (function(module, exports, __webpack_require__) {
if(true) {
@@ -224,7 +237,6 @@ console.log("Running " + "mobile" + " build");
!*** ./mobile-stuff.js ***!
\*************************/
/*! no static exports found */
-/*! all exports used */
/***/ (function(module, exports) {
// mobile only stuff
@@ -235,52 +247,56 @@ console.log("Running " + "mobile" + " build");
# Info
-## Uncompressed
+## Unoptimized
```
-Hash: a201abd2de73265dd538cceba4bc5163d755f291
-Version: webpack 3.5.1
+Hash: 0a1b2c3d4e5f6a7b8c9d
+Version: webpack 4.0.0-beta.2
Child mobile:
- Hash: a201abd2de73265dd538
- Asset Size Chunks Chunk Names
- mobile.js 2.96 kB 0 [emitted] main
+ Hash: 0a1b2c3d4e5f6a7b8c9d
+ Asset Size Chunks Chunk Names
+ mobile.js 3.04 KiB 0 [emitted] main
Entrypoint main = mobile.js
chunk {0} mobile.js (main) 117 bytes [entry] [rendered]
- > main [0] ./example.js
+ > ./example main
[0] ./example.js 97 bytes {0} [built]
+ single entry ./example main
[1] ./mobile-stuff.js 20 bytes {0} [built]
cjs require ./mobile-stuff [0] ./example.js 2:1-26
Child desktop:
- Hash: cceba4bc5163d755f291
+ Hash: 0a1b2c3d4e5f6a7b8c9d
Asset Size Chunks Chunk Names
- desktop.js 2.72 kB 0 [emitted] main
+ desktop.js 2.8 KiB 0 [emitted] main
Entrypoint main = desktop.js
chunk {0} desktop.js (main) 97 bytes [entry] [rendered]
- > main [0] ./example.js
+ > ./example main
[0] ./example.js 97 bytes {0} [built]
+ single entry ./example main
```
-## Minimized (uglify-js, no zip)
+## Production mode
```
-Hash: a201abd2de73265dd538cceba4bc5163d755f291
-Version: webpack 3.5.1
+Hash: 0a1b2c3d4e5f6a7b8c9d
+Version: webpack 4.0.0-beta.2
Child mobile:
- Hash: a201abd2de73265dd538
+ Hash: 0a1b2c3d4e5f6a7b8c9d
Asset Size Chunks Chunk Names
- mobile.js 540 bytes 0 [emitted] main
+ mobile.js 608 bytes 0 [emitted] main
Entrypoint main = mobile.js
chunk {0} mobile.js (main) 117 bytes [entry] [rendered]
- > main [0] ./example.js
- [0] ./example.js 97 bytes {0} [built]
- [1] ./mobile-stuff.js 20 bytes {0} [built]
- cjs require ./mobile-stuff [0] ./example.js 2:1-26
+ > ./example main
+ [0] ./mobile-stuff.js 20 bytes {0} [built]
+ cjs require ./mobile-stuff [1] ./example.js 2:1-26
+ [1] ./example.js 97 bytes {0} [built]
+ single entry ./example main
Child desktop:
- Hash: cceba4bc5163d755f291
+ Hash: 0a1b2c3d4e5f6a7b8c9d
Asset Size Chunks Chunk Names
- desktop.js 520 bytes 0 [emitted] main
+ desktop.js 588 bytes 0 [emitted] main
Entrypoint main = desktop.js
chunk {0} desktop.js (main) 97 bytes [entry] [rendered]
- > main [0] ./example.js
+ > ./example main
[0] ./example.js 97 bytes {0} [built]
+ single entry ./example main
```
\ No newline at end of file
diff --git a/examples/multi-compiler/template.md b/examples/multi-compiler/template.md
index f275eab5..f1d65349 100644
--- a/examples/multi-compiler/template.md
+++ b/examples/multi-compiler/template.md
@@ -11,28 +11,28 @@
{{webpack.config.js}}
```
-# js/desktop.js
+# dist/desktop.js
``` javascript
-{{js/desktop.js}}
+{{dist/desktop.js}}
```
-# js/mobile.js
+# dist/mobile.js
``` javascript
-{{js/mobile.js}}
+{{dist/mobile.js}}
```
# Info
-## Uncompressed
+## Unoptimized
```
{{stdout}}
```
-## Minimized (uglify-js, no zip)
+## Production mode
```
-{{min:stdout}}
+{{production:stdout}}
```
\ No newline at end of file
diff --git a/examples/multi-compiler/webpack.config.js b/examples/multi-compiler/webpack.config.js
index b6f932f2..4fc30886 100644
--- a/examples/multi-compiler/webpack.config.js
+++ b/examples/multi-compiler/webpack.config.js
@@ -3,9 +3,10 @@ var webpack = require("../../");
module.exports = [
{
name: "mobile",
+ // mode: "development || "production",
entry: "./example",
output: {
- path: path.join(__dirname, "js"),
+ path: path.join(__dirname, "dist"),
filename: "mobile.js"
},
plugins: [
@@ -14,11 +15,13 @@ module.exports = [
})
]
},
+
{
name: "desktop",
+ // mode: "development || "production",
entry: "./example",
output: {
- path: path.join(__dirname, "js"),
+ path: path.join(__dirname, "dist"),
filename: "desktop.js"
},
plugins: [
diff --git a/examples/multi-part-library/README.md b/examples/multi-part-library/README.md
index 920f7fae..22cd4240 100644
--- a/examples/multi-part-library/README.md
+++ b/examples/multi-part-library/README.md
@@ -17,12 +17,13 @@ Note: When your library has dependencies that should not be included in the comp
``` javascript
var path = require("path");
module.exports = {
+ // mode: "development || "production",
entry: {
alpha: "./alpha",
beta: "./beta"
},
output: {
- path: path.join(__dirname, "js"),
+ path: path.join(__dirname, "dist"),
filename: "MyLibrary.[name].js",
library: ["MyLibrary", "[name]"],
libraryTarget: "umd"
@@ -30,7 +31,7 @@ module.exports = {
};
```
-# js/MyLibrary.alpha.js
+# dist/MyLibrary.alpha.js
``` javascript
(function webpackUniversalModuleDefinition(root, factory) {
@@ -42,7 +43,7 @@ module.exports = {
exports["alpha"] = factory();
else
root["MyLibrary"] = root["MyLibrary"] || {}, root["MyLibrary"]["alpha"] = factory();
-})(this, function() {
+})(window, function() {
```
<details><summary><code>return /******/ (function(modules) { /* webpackBootstrap */ })</code></summary>
@@ -93,6 +94,11 @@ return /******/ (function(modules) { // webpackBootstrap
/******/ }
/******/ };
/******/
+/******/ // define __esModule on exports
+/******/ __webpack_require__.r = function(exports) {
+/******/ Object.defineProperty(exports, '__esModule', { value: true });
+/******/ };
+/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
@@ -106,7 +112,8 @@ return /******/ (function(modules) { // webpackBootstrap
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
-/******/ __webpack_require__.p = "js/";
+/******/ __webpack_require__.p = "dist/";
+/******/
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 0);
@@ -123,7 +130,6 @@ return /******/ (function(modules) { // webpackBootstrap
!*** ./alpha.js ***!
\******************/
/*! no static exports found */
-/*! all exports used */
/***/ (function(module, exports) {
module.exports = "alpha";
@@ -133,7 +139,7 @@ module.exports = "alpha";
});
```
-# js/MyLibrary.beta.js
+# dist/MyLibrary.beta.js
``` javascript
(function webpackUniversalModuleDefinition(root, factory) {
@@ -145,7 +151,7 @@ module.exports = "alpha";
exports["beta"] = factory();
else
root["MyLibrary"] = root["MyLibrary"] || {}, root["MyLibrary"]["beta"] = factory();
-})(this, function() {
+})(window, function() {
return /******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
@@ -192,6 +198,11 @@ return /******/ (function(modules) { // webpackBootstrap
/******/ }
/******/ };
/******/
+/******/ // define __esModule on exports
+/******/ __webpack_require__.r = function(exports) {
+/******/ Object.defineProperty(exports, '__esModule', { value: true });
+/******/ };
+/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
@@ -205,7 +216,8 @@ return /******/ (function(modules) { // webpackBootstrap
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
-/******/ __webpack_require__.p = "js/";
+/******/ __webpack_require__.p = "dist/";
+/******/
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 1);
@@ -218,7 +230,6 @@ return /******/ (function(modules) { // webpackBootstrap
!*** ./beta.js ***!
\*****************/
/*! no static exports found */
-/*! all exports used */
/***/ (function(module, exports) {
module.exports = "beta";
@@ -230,38 +241,42 @@ module.exports = "beta";
# Info
-## Uncompressed
+## Unoptimized
```
-Hash: e5033b72cf0ec9da1ad7
-Version: webpack 3.5.1
- Asset Size Chunks Chunk Names
- MyLibrary.beta.js 3.06 kB 0 [emitted] beta
-MyLibrary.alpha.js 3.05 kB 1 [emitted] alpha
+Hash: 0a1b2c3d4e5f6a7b8c9d
+Version: webpack 4.0.0-beta.2
+ Asset Size Chunks Chunk Names
+MyLibrary.alpha.js 3.16 KiB 0 [emitted] alpha
+ MyLibrary.beta.js 3.16 KiB 1 [emitted] beta
Entrypoint alpha = MyLibrary.alpha.js
Entrypoint beta = MyLibrary.beta.js
-chunk {0} MyLibrary.beta.js (beta) 24 bytes [entry] [rendered]
- > beta [1] ./beta.js
- [1] ./beta.js 24 bytes {0} [built]
-chunk {1} MyLibrary.alpha.js (alpha) 25 bytes [entry] [rendered]
- > alpha [0] ./alpha.js
- [0] ./alpha.js 25 bytes {1} [built]
+chunk {0} MyLibrary.alpha.js (alpha) 25 bytes [entry] [rendered]
+ > ./alpha alpha
+ [0] ./alpha.js 25 bytes {0} [built]
+ single entry ./alpha alpha
+chunk {1} MyLibrary.beta.js (beta) 24 bytes [entry] [rendered]
+ > ./beta beta
+ [1] ./beta.js 24 bytes {1} [built]
+ single entry ./beta beta
```
-## Minimized (uglify-js, no zip)
+## Production mode
```
-Hash: e5033b72cf0ec9da1ad7
-Version: webpack 3.5.1
+Hash: 0a1b2c3d4e5f6a7b8c9d
+Version: webpack 4.0.0-beta.2
Asset Size Chunks Chunk Names
- MyLibrary.beta.js 759 bytes 0 [emitted] beta
-MyLibrary.alpha.js 761 bytes 1 [emitted] alpha
+ MyLibrary.beta.js 828 bytes 0 [emitted] beta
+MyLibrary.alpha.js 832 bytes 1 [emitted] alpha
Entrypoint alpha = MyLibrary.alpha.js
Entrypoint beta = MyLibrary.beta.js
chunk {0} MyLibrary.beta.js (beta) 24 bytes [entry] [rendered]
- > beta [1] ./beta.js
- [1] ./beta.js 24 bytes {0} [built]
+ > ./beta beta
+ [0] ./beta.js 24 bytes {0} [built]
+ single entry ./beta beta
chunk {1} MyLibrary.alpha.js (alpha) 25 bytes [entry] [rendered]
- > alpha [0] ./alpha.js
- [0] ./alpha.js 25 bytes {1} [built]
+ > ./alpha alpha
+ [1] ./alpha.js 25 bytes {1} [built]
+ single entry ./alpha alpha
```
diff --git a/examples/multi-part-library/template.md b/examples/multi-part-library/template.md
index c7d52639..900b16da 100644
--- a/examples/multi-part-library/template.md
+++ b/examples/multi-part-library/template.md
@@ -18,28 +18,28 @@ Note: When your library has dependencies that should not be included in the comp
{{webpack.config.js}}
```
-# js/MyLibrary.alpha.js
+# dist/MyLibrary.alpha.js
``` javascript
-{{js/MyLibrary.alpha.js}}
+{{dist/MyLibrary.alpha.js}}
```
-# js/MyLibrary.beta.js
+# dist/MyLibrary.beta.js
``` javascript
-{{js/MyLibrary.beta.js}}
+{{dist/MyLibrary.beta.js}}
```
# Info
-## Uncompressed
+## Unoptimized
```
{{stdout}}
```
-## Minimized (uglify-js, no zip)
+## Production mode
```
-{{min:stdout}}
+{{production:stdout}}
```
diff --git a/examples/multi-part-library/webpack.config.js b/examples/multi-part-library/webpack.config.js
index a747606b..f79be11f 100644
--- a/examples/multi-part-library/webpack.config.js
+++ b/examples/multi-part-library/webpack.config.js
@@ -1,11 +1,12 @@
var path = require("path");
module.exports = {
+ // mode: "development || "production",
entry: {
alpha: "./alpha",
beta: "./beta"
},
output: {
- path: path.join(__dirname, "js"),
+ path: path.join(__dirname, "dist"),
filename: "MyLibrary.[name].js",
library: ["MyLibrary", "[name]"],
libraryTarget: "umd"
diff --git a/examples/multiple-commons-chunks/README.md b/examples/multiple-commons-chunks/README.md
deleted file mode 100644
index 68b2cabf..00000000
--- a/examples/multiple-commons-chunks/README.md
+++ /dev/null
@@ -1,503 +0,0 @@
-# pageA.js
-
-``` javascript
-require("./modules/a-b-c");
-require("./modules/a-b");
-require("./modules/a-c");
-```
-
-# adminPageA.js
-
-``` javascript
-require("./modules/a-b-c");
-require("./modules/admin");
-```
-
-# webpack.config.js
-
-``` javascript
-var path = require("path");
-var CommonsChunkPlugin = require("../../lib/optimize/CommonsChunkPlugin");
-module.exports = {
- entry: {
- pageA: "./pageA",
- pageB: "./pageB",
- pageC: "./pageC",
- adminPageA: "./adminPageA",
- adminPageB: "./adminPageB",
- adminPageC: "./adminPageC",
- },
- output: {
- path: path.join(__dirname, "js"),
- filename: "[name].js"
- },
- plugins: [
- new CommonsChunkPlugin({
- name: "admin-commons",
- chunks: ["adminPageA", "adminPageB"]
- }),
- new CommonsChunkPlugin({
- name: "commons",
- chunks: ["pageA", "pageB", "admin-commons"],
- minChunks: 2
- }),
- new CommonsChunkPlugin({
- name: "c-commons",
- chunks: ["pageC", "adminPageC"]
- }),
- ]
-};
-```
-
-# pageA.html
-
-``` html
-<html>
- <head></head>
- <body>
- <script src="js/commons.js" charset="utf-8"></script>
- <script src="js/pageA.js" charset="utf-8"></script>
- </body>
-</html>
-```
-
-# adminPageA.html
-
-``` html
-<html>
- <head></head>
- <body>
- <script src="js/commons.js" charset="utf-8"></script>
- <script src="js/admin-commons.js" charset="utf-8"></script>
- <script src="js/adminPageA.js" charset="utf-8"></script>
- </body>
-</html>
-```
-
-# js/commons.js
-
-<details><summary><code>/******/ (function(modules) { /* webpackBootstrap */ })</code></summary>
-
-``` javascript
-/******/ (function(modules) { // webpackBootstrap
-/******/ // install a JSONP callback for chunk loading
-/******/ var parentJsonpFunction = window["webpackJsonp"];
-/******/ window["webpackJsonp"] = function webpackJsonpCallback(chunkIds, moreModules, executeModules) {
-/******/ // add "moreModules" to the modules object,
-/******/ // then flag all "chunkIds" as loaded and fire callback
-/******/ var moduleId, chunkId, i = 0, resolves = [], result;
-/******/ for(;i < chunkIds.length; i++) {
-/******/ chunkId = chunkIds[i];
-/******/ if(installedChunks[chunkId]) {
-/******/ resolves.push(installedChunks[chunkId][0]);
-/******/ }
-/******/ installedChunks[chunkId] = 0;
-/******/ }
-/******/ for(moduleId in moreModules) {
-/******/ if(Object.prototype.hasOwnProperty.call(moreModules, moduleId)) {
-/******/ modules[moduleId] = moreModules[moduleId];
-/******/ }
-/******/ }
-/******/ if(parentJsonpFunction) parentJsonpFunction(chunkIds, moreModules, executeModules);
-/******/ while(resolves.length) {
-/******/ resolves.shift()();
-/******/ }
-/******/ if(executeModules) {
-/******/ for(i=0; i < executeModules.length; i++) {
-/******/ result = __webpack_require__(__webpack_require__.s = executeModules[i]);
-/******/ }
-/******/ }
-/******/ return result;
-/******/ };
-/******/
-/******/ // The module cache
-/******/ var installedModules = {};
-/******/
-/******/ // objects to store loaded and loading chunks
-/******/ var installedChunks = {
-/******/ 7: 0,
-/******/ 8: 0
-/******/ };
-/******/
-/******/ // The require function
-/******/ function __webpack_require__(moduleId) {
-/******/
-/******/ // Check if module is in cache
-/******/ if(installedModules[moduleId]) {
-/******/ return installedModules[moduleId].exports;
-/******/ }
-/******/ // Create a new module (and put it into the cache)
-/******/ var module = installedModules[moduleId] = {
-/******/ i: moduleId,
-/******/ l: false,
-/******/ exports: {}
-/******/ };
-/******/
-/******/ // Execute the module function
-/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
-/******/
-/******/ // Flag the module as loaded
-/******/ module.l = true;
-/******/
-/******/ // Return the exports of the module
-/******/ return module.exports;
-/******/ }
-/******/
-/******/ // This file contains only the entry chunk.
-/******/ // The chunk loading function for additional chunks
-/******/ __webpack_require__.e = function requireEnsure(chunkId) {
-/******/ var installedChunkData = installedChunks[chunkId];
-/******/ if(installedChunkData === 0) {
-/******/ return new Promise(function(resolve) { resolve(); });
-/******/ }
-/******/
-/******/ // a Promise means "currently loading".
-/******/ if(installedChunkData) {
-/******/ return installedChunkData[2];
-/******/ }
-/******/
-/******/ // setup Promise in chunk cache
-/******/ var promise = new Promise(function(resolve, reject) {
-/******/ installedChunkData = installedChunks[chunkId] = [resolve, reject];
-/******/ });
-/******/ installedChunkData[2] = promise;
-/******/
-/******/ // start chunk loading
-/******/ var head = document.getElementsByTagName('head')[0];
-/******/ var script = document.createElement('script');
-/******/ script.type = 'text/javascript';
-/******/ script.charset = 'utf-8';
-/******/ script.async = true;
-/******/ script.timeout = 120000;
-/******/
-/******/ if (__webpack_require__.nc) {
-/******/ script.setAttribute("nonce", __webpack_require__.nc);
-/******/ }
-/******/ script.src = __webpack_require__.p + "" + chunkId + ".js";
-/******/ var timeout = setTimeout(onScriptComplete, 120000);
-/******/ script.onerror = script.onload = onScriptComplete;
-/******/ function onScriptComplete() {
-/******/ // avoid mem leaks in IE.
-/******/ script.onerror = script.onload = null;
-/******/ clearTimeout(timeout);
-/******/ var chunk = installedChunks[chunkId];
-/******/ if(chunk !== 0) {
-/******/ if(chunk) {
-/******/ chunk[1](new Error('Loading chunk ' + chunkId + ' failed.'));
-/******/ }
-/******/ installedChunks[chunkId] = undefined;
-/******/ }
-/******/ };
-/******/ head.appendChild(script);
-/******/
-/******/ return promise;
-/******/ };
-/******/
-/******/ // expose the modules object (__webpack_modules__)
-/******/ __webpack_require__.m = modules;
-/******/
-/******/ // expose the module cache
-/******/ __webpack_require__.c = installedModules;
-/******/
-/******/ // define getter function for harmony exports
-/******/ __webpack_require__.d = function(exports, name, getter) {
-/******/ if(!__webpack_require__.o(exports, name)) {
-/******/ Object.defineProperty(exports, name, {
-/******/ configurable: false,
-/******/ enumerable: true,
-/******/ get: getter
-/******/ });
-/******/ }
-/******/ };
-/******/
-/******/ // getDefaultExport function for compatibility with non-harmony modules
-/******/ __webpack_require__.n = function(module) {
-/******/ var getter = module && module.__esModule ?
-/******/ function getDefault() { return module['default']; } :
-/******/ function getModuleExports() { return module; };
-/******/ __webpack_require__.d(getter, 'a', getter);
-/******/ return getter;
-/******/ };
-/******/
-/******/ // Object.prototype.hasOwnProperty.call
-/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
-/******/
-/******/ // __webpack_public_path__
-/******/ __webpack_require__.p = "js/";
-/******/
-/******/ // on error function for async loading
-/******/ __webpack_require__.oe = function(err) { console.error(err); throw err; };
-/******/ })
-/************************************************************************/
-```
-
-</details>
-
-``` javascript
-/******/ ([
-/* 0 */
-/*!**************************!*\
- !*** ./modules/a-b-c.js ***!
- \**************************/
-/*! no static exports found */
-/*! all exports used */
-/***/ (function(module, exports) {
-
-
-
-/***/ }),
-/* 1 */,
-/* 2 */,
-/* 3 */,
-/* 4 */
-/*!************************!*\
- !*** ./modules/a-b.js ***!
- \************************/
-/*! no static exports found */
-/*! all exports used */
-/***/ (function(module, exports) {
-
-
-
-/***/ })
-/******/ ]);
-```
-
-# js/pageA.js
-
-``` javascript
-webpackJsonp([2],{
-
-/***/ 2:
-/*!************************!*\
- !*** ./modules/a-c.js ***!
- \************************/
-/*! no static exports found */
-/*! all exports used */
-/***/ (function(module, exports) {
-
-
-
-/***/ }),
-
-/***/ 5:
-/*!******************!*\
- !*** ./pageA.js ***!
- \******************/
-/*! no static exports found */
-/*! all exports used */
-/***/ (function(module, exports, __webpack_require__) {
-
-__webpack_require__(/*! ./modules/a-b-c */ 0);
-__webpack_require__(/*! ./modules/a-b */ 4);
-__webpack_require__(/*! ./modules/a-c */ 2);
-
-
-/***/ })
-
-},[5]);
-```
-
-# js/admin-commons.js
-
-``` javascript
-webpackJsonp([4],[
-/* 0 */,
-/* 1 */
-/*!**************************!*\
- !*** ./modules/admin.js ***!
- \**************************/
-/*! no static exports found */
-/*! all exports used */
-/***/ (function(module, exports) {
-
-
-
-/***/ })
-]);
-```
-
-# js/adminPageA.js
-
-``` javascript
-webpackJsonp([6],{
-
-/***/ 8:
-/*!***********************!*\
- !*** ./adminPageA.js ***!
- \***********************/
-/*! no static exports found */
-/*! all exports used */
-/***/ (function(module, exports, __webpack_require__) {
-
-__webpack_require__(/*! ./modules/a-b-c */ 0);
-__webpack_require__(/*! ./modules/admin */ 1);
-
-/***/ })
-
-},[8]);
-```
-
-# Info
-
-## Uncompressed
-
-```
-Hash: 3ef8f91b150be0e10937
-Version: webpack 3.5.1
- Asset Size Chunks Chunk Names
- pageC.js 813 bytes 0 [emitted] pageC
- pageB.js 573 bytes 1 [emitted] pageB
- pageA.js 573 bytes 2 [emitted] pageA
- adminPageC.js 552 bytes 3, 4 [emitted] adminPageC
-admin-commons.js 236 bytes 4 [emitted] admin-commons
- adminPageB.js 340 bytes 5 [emitted] adminPageB
- adminPageA.js 340 bytes 6 [emitted] adminPageA
- commons.js 6.24 kB 7, 8 [emitted] commons
- c-commons.js 5.99 kB 8 [emitted] c-commons
-Entrypoint pageA = commons.js pageA.js
-Entrypoint pageB = commons.js pageB.js
-Entrypoint pageC = c-commons.js pageC.js
-Entrypoint adminPageA = commons.js admin-commons.js adminPageA.js
-Entrypoint adminPageB = commons.js admin-commons.js adminPageB.js
-Entrypoint adminPageC = c-commons.js adminPageC.js
-chunk {0} pageC.js (pageC) 83 bytes {8} [initial] [rendered]
- > pageC [7] ./pageC.js
- [2] ./modules/a-c.js 0 bytes {0} {2} [built]
- cjs require ./modules/a-c [5] ./pageA.js 3:0-24
- cjs require ./modules/a-c [7] ./pageC.js 3:0-24
- [3] ./modules/b-c.js 0 bytes {0} {1} [built]
- cjs require ./modules/b-c [6] ./pageB.js 3:0-24
- cjs require ./modules/b-c [7] ./pageC.js 2:0-24
- [7] ./pageC.js 83 bytes {0} [built]
-chunk {1} pageB.js (pageB) 83 bytes {7} [initial] [rendered]
- > pageB [6] ./pageB.js
- [3] ./modules/b-c.js 0 bytes {0} {1} [built]
- cjs require ./modules/b-c [6] ./pageB.js 3:0-24
- cjs require ./modules/b-c [7] ./pageC.js 2:0-24
- [6] ./pageB.js 83 bytes {1} [built]
-chunk {2} pageA.js (pageA) 83 bytes {7} [initial] [rendered]
- > pageA [5] ./pageA.js
- [2] ./modules/a-c.js 0 bytes {0} {2} [built]
- cjs require ./modules/a-c [5] ./pageA.js 3:0-24
- cjs require ./modules/a-c [7] ./pageC.js 3:0-24
- [5] ./pageA.js 83 bytes {2} [built]
-chunk {3} adminPageC.js (adminPageC) 56 bytes {8} [initial] [rendered]
- > adminPageC [10] ./adminPageC.js
- [1] ./modules/admin.js 0 bytes {3} {4} [built]
- cjs require ./modules/admin [8] ./adminPageA.js 2:0-26
- cjs require ./modules/admin [9] ./adminPageB.js 2:0-26
- cjs require ./modules/admin [10] ./adminPageC.js 2:0-26
- [10] ./adminPageC.js 56 bytes {3} [built]
-chunk {4} admin-commons.js (admin-commons) 0 bytes {7} [initial] [rendered]
- [1] ./modules/admin.js 0 bytes {3} {4} [built]
- cjs require ./modules/admin [8] ./adminPageA.js 2:0-26
- cjs require ./modules/admin [9] ./adminPageB.js 2:0-26
- cjs require ./modules/admin [10] ./adminPageC.js 2:0-26
-chunk {5} adminPageB.js (adminPageB) 56 bytes {4} [initial] [rendered]
- > adminPageB [9] ./adminPageB.js
- [9] ./adminPageB.js 56 bytes {5} [built]
-chunk {6} adminPageA.js (adminPageA) 56 bytes {4} [initial] [rendered]
- > adminPageA [8] ./adminPageA.js
- [8] ./adminPageA.js 56 bytes {6} [built]
-chunk {7} commons.js (commons) 0 bytes [entry] [rendered]
- [0] ./modules/a-b-c.js 0 bytes {7} {8} [built]
- cjs require ./modules/a-b-c [5] ./pageA.js 1:0-26
- cjs require ./modules/a-b-c [6] ./pageB.js 1:0-26
- cjs require ./modules/a-b-c [7] ./pageC.js 1:0-26
- cjs require ./modules/a-b-c [8] ./adminPageA.js 1:0-26
- cjs require ./modules/a-b-c [9] ./adminPageB.js 1:0-26
- cjs require ./modules/a-b-c [10] ./adminPageC.js 1:0-26
- [4] ./modules/a-b.js 0 bytes {7} [built]
- cjs require ./modules/a-b [5] ./pageA.js 2:0-24
- cjs require ./modules/a-b [6] ./pageB.js 2:0-24
-chunk {8} c-commons.js (c-commons) 0 bytes [entry] [rendered]
- [0] ./modules/a-b-c.js 0 bytes {7} {8} [built]
- cjs require ./modules/a-b-c [5] ./pageA.js 1:0-26
- cjs require ./modules/a-b-c [6] ./pageB.js 1:0-26
- cjs require ./modules/a-b-c [7] ./pageC.js 1:0-26
- cjs require ./modules/a-b-c [8] ./adminPageA.js 1:0-26
- cjs require ./modules/a-b-c [9] ./adminPageB.js 1:0-26
- cjs require ./modules/a-b-c [10] ./adminPageC.js 1:0-26
-```
-
-## Minimized (uglify-js, no zip)
-
-```
-Hash: 3ef8f91b150be0e10937
-Version: webpack 3.5.1
- Asset Size Chunks Chunk Names
- pageC.js 93 bytes 0 [emitted] pageC
- pageB.js 76 bytes 1 [emitted] pageB
- pageA.js 76 bytes 2 [emitted] pageA
- adminPageC.js 75 bytes 3, 4 [emitted] adminPageC
-admin-commons.js 37 bytes 4 [emitted] admin-commons
- adminPageB.js 53 bytes 5 [emitted] adminPageB
- adminPageA.js 53 bytes 6 [emitted] adminPageA
- commons.js 1.4 kB 7, 8 [emitted] commons
- c-commons.js 1.38 kB 8 [emitted] c-commons
-Entrypoint pageA = commons.js pageA.js
-Entrypoint pageB = commons.js pageB.js
-Entrypoint pageC = c-commons.js pageC.js
-Entrypoint adminPageA = commons.js admin-commons.js adminPageA.js
-Entrypoint adminPageB = commons.js admin-commons.js adminPageB.js
-Entrypoint adminPageC = c-commons.js adminPageC.js
-chunk {0} pageC.js (pageC) 83 bytes {8} [initial] [rendered]
- > pageC [7] ./pageC.js
- [2] ./modules/a-c.js 0 bytes {0} {2} [built]
- cjs require ./modules/a-c [5] ./pageA.js 3:0-24
- cjs require ./modules/a-c [7] ./pageC.js 3:0-24
- [3] ./modules/b-c.js 0 bytes {0} {1} [built]
- cjs require ./modules/b-c [6] ./pageB.js 3:0-24
- cjs require ./modules/b-c [7] ./pageC.js 2:0-24
- [7] ./pageC.js 83 bytes {0} [built]
-chunk {1} pageB.js (pageB) 83 bytes {7} [initial] [rendered]
- > pageB [6] ./pageB.js
- [3] ./modules/b-c.js 0 bytes {0} {1} [built]
- cjs require ./modules/b-c [6] ./pageB.js 3:0-24
- cjs require ./modules/b-c [7] ./pageC.js 2:0-24
- [6] ./pageB.js 83 bytes {1} [built]
-chunk {2} pageA.js (pageA) 83 bytes {7} [initial] [rendered]
- > pageA [5] ./pageA.js
- [2] ./modules/a-c.js 0 bytes {0} {2} [built]
- cjs require ./modules/a-c [5] ./pageA.js 3:0-24
- cjs require ./modules/a-c [7] ./pageC.js 3:0-24
- [5] ./pageA.js 83 bytes {2} [built]
-chunk {3} adminPageC.js (adminPageC) 56 bytes {8} [initial] [rendered]
- > adminPageC [10] ./adminPageC.js
- [1] ./modules/admin.js 0 bytes {3} {4} [built]
- cjs require ./modules/admin [8] ./adminPageA.js 2:0-26
- cjs require ./modules/admin [9] ./adminPageB.js 2:0-26
- cjs require ./modules/admin [10] ./adminPageC.js 2:0-26
- [10] ./adminPageC.js 56 bytes {3} [built]
-chunk {4} admin-commons.js (admin-commons) 0 bytes {7} [initial] [rendered]
- [1] ./modules/admin.js 0 bytes {3} {4} [built]
- cjs require ./modules/admin [8] ./adminPageA.js 2:0-26
- cjs require ./modules/admin [9] ./adminPageB.js 2:0-26
- cjs require ./modules/admin [10] ./adminPageC.js 2:0-26
-chunk {5} adminPageB.js (adminPageB) 56 bytes {4} [initial] [rendered]
- > adminPageB [9] ./adminPageB.js
- [9] ./adminPageB.js 56 bytes {5} [built]
-chunk {6} adminPageA.js (adminPageA) 56 bytes {4} [initial] [rendered]
- > adminPageA [8] ./adminPageA.js
- [8] ./adminPageA.js 56 bytes {6} [built]
-chunk {7} commons.js (commons) 0 bytes [entry] [rendered]
- [0] ./modules/a-b-c.js 0 bytes {7} {8} [built]
- cjs require ./modules/a-b-c [5] ./pageA.js 1:0-26
- cjs require ./modules/a-b-c [6] ./pageB.js 1:0-26
- cjs require ./modules/a-b-c [7] ./pageC.js 1:0-26
- cjs require ./modules/a-b-c [8] ./adminPageA.js 1:0-26
- cjs require ./modules/a-b-c [9] ./adminPageB.js 1:0-26
- cjs require ./modules/a-b-c [10] ./adminPageC.js 1:0-26
- [4] ./modules/a-b.js 0 bytes {7} [built]
- cjs require ./modules/a-b [5] ./pageA.js 2:0-24
- cjs require ./modules/a-b [6] ./pageB.js 2:0-24
-chunk {8} c-commons.js (c-commons) 0 bytes [entry] [rendered]
- [0] ./modules/a-b-c.js 0 bytes {7} {8} [built]
- cjs require ./modules/a-b-c [5] ./pageA.js 1:0-26
- cjs require ./modules/a-b-c [6] ./pageB.js 1:0-26
- cjs require ./modules/a-b-c [7] ./pageC.js 1:0-26
- cjs require ./modules/a-b-c [8] ./adminPageA.js 1:0-26
- cjs require ./modules/a-b-c [9] ./adminPageB.js 1:0-26
- cjs require ./modules/a-b-c [10] ./adminPageC.js 1:0-26
-```
diff --git a/examples/multiple-commons-chunks/adminPageA.html b/examples/multiple-commons-chunks/adminPageA.html
deleted file mode 100644
index 6df4d755..00000000
--- a/examples/multiple-commons-chunks/adminPageA.html
+++ /dev/null
@@ -1,8 +0,0 @@
-<html>
- <head></head>
- <body>
- <script src="js/commons.js" charset="utf-8"></script>
- <script src="js/admin-commons.js" charset="utf-8"></script>
- <script src="js/adminPageA.js" charset="utf-8"></script>
- </body>
-</html>
\ No newline at end of file
diff --git a/examples/multiple-commons-chunks/adminPageA.js b/examples/multiple-commons-chunks/adminPageA.js
deleted file mode 100644
index 61142890..00000000
--- a/examples/multiple-commons-chunks/adminPageA.js
+++ /dev/null
@@ -1,2 +0,0 @@
-require("./modules/a-b-c");
-require("./modules/admin");
\ No newline at end of file
diff --git a/examples/multiple-commons-chunks/adminPageB.js b/examples/multiple-commons-chunks/adminPageB.js
deleted file mode 100644
index 61142890..00000000
--- a/examples/multiple-commons-chunks/adminPageB.js
+++ /dev/null
@@ -1,2 +0,0 @@
-require("./modules/a-b-c");
-require("./modules/admin");
\ No newline at end of file
diff --git a/examples/multiple-commons-chunks/adminPageC.js b/examples/multiple-commons-chunks/adminPageC.js
deleted file mode 100644
index 61142890..00000000
--- a/examples/multiple-commons-chunks/adminPageC.js
+++ /dev/null
@@ -1,2 +0,0 @@
-require("./modules/a-b-c");
-require("./modules/admin");
\ No newline at end of file
diff --git a/examples/multiple-commons-chunks/build.js b/examples/multiple-commons-chunks/build.js
deleted file mode 100644
index 7492e9f9..00000000
--- a/examples/multiple-commons-chunks/build.js
+++ /dev/null
@@ -1,2 +0,0 @@
-global.NO_TARGET_ARGS = true;
-require("../build-common");
diff --git a/examples/multiple-commons-chunks/common.js b/examples/multiple-commons-chunks/common.js
deleted file mode 100644
index 5215d62f..00000000
--- a/examples/multiple-commons-chunks/common.js
+++ /dev/null
@@ -1 +0,0 @@
-module.exports = "Common";
\ No newline at end of file
diff --git a/examples/multiple-commons-chunks/modules/a-b.js b/examples/multiple-commons-chunks/modules/a-b.js
deleted file mode 100644
index e69de29b..00000000
diff --git a/examples/multiple-commons-chunks/modules/a-c.js b/examples/multiple-commons-chunks/modules/a-c.js
deleted file mode 100644
index e69de29b..00000000
diff --git a/examples/multiple-commons-chunks/modules/admin.js b/examples/multiple-commons-chunks/modules/admin.js
deleted file mode 100644
index e69de29b..00000000
diff --git a/examples/multiple-commons-chunks/modules/b-c.js b/examples/multiple-commons-chunks/modules/b-c.js
deleted file mode 100644
index e69de29b..00000000
diff --git a/examples/multiple-commons-chunks/pageA.html b/examples/multiple-commons-chunks/pageA.html
deleted file mode 100644
index 8c13ce75..00000000
--- a/examples/multiple-commons-chunks/pageA.html
+++ /dev/null
@@ -1,7 +0,0 @@
-<html>
- <head></head>
- <body>
- <script src="js/commons.js" charset="utf-8"></script>
- <script src="js/pageA.js" charset="utf-8"></script>
- </body>
-</html>
\ No newline at end of file
diff --git a/examples/multiple-commons-chunks/pageA.js b/examples/multiple-commons-chunks/pageA.js
deleted file mode 100644
index d16ac995..00000000
--- a/examples/multiple-commons-chunks/pageA.js
+++ /dev/null
@@ -1,3 +0,0 @@
-require("./modules/a-b-c");
-require("./modules/a-b");
-require("./modules/a-c");
diff --git a/examples/multiple-commons-chunks/pageB.js b/examples/multiple-commons-chunks/pageB.js
deleted file mode 100644
index d0135fcf..00000000
--- a/examples/multiple-commons-chunks/pageB.js
+++ /dev/null
@@ -1,3 +0,0 @@
-require("./modules/a-b-c");
-require("./modules/a-b");
-require("./modules/b-c");
diff --git a/examples/multiple-commons-chunks/pageC.js b/examples/multiple-commons-chunks/pageC.js
deleted file mode 100644
index 2f4592a2..00000000
--- a/examples/multiple-commons-chunks/pageC.js
+++ /dev/null
@@ -1,3 +0,0 @@
-require("./modules/a-b-c");
-require("./modules/b-c");
-require("./modules/a-c");
diff --git a/examples/multiple-commons-chunks/template.md b/examples/multiple-commons-chunks/template.md
deleted file mode 100644
index 1f43b69b..00000000
--- a/examples/multiple-commons-chunks/template.md
+++ /dev/null
@@ -1,67 +0,0 @@
-# pageA.js
-
-``` javascript
-{{pageA.js}}
-```
-
-# adminPageA.js
-
-``` javascript
-{{adminPageA.js}}
-```
-
-# webpack.config.js
-
-``` javascript
-{{webpack.config.js}}
-```
-
-# pageA.html
-
-``` html
-{{pageA.html}}
-```
-
-# adminPageA.html
-
-``` html
-{{adminPageA.html}}
-```
-
-# js/commons.js
-
-``` javascript
-{{js/commons.js}}
-```
-
-# js/pageA.js
-
-``` javascript
-{{js/pageA.js}}
-```
-
-# js/admin-commons.js
-
-``` javascript
-{{js/admin-commons.js}}
-```
-
-# js/adminPageA.js
-
-``` javascript
-{{js/adminPageA.js}}
-```
-
-# Info
-
-## Uncompressed
-
-```
-{{stdout}}
-```
-
-## Minimized (uglify-js, no zip)
-
-```
-{{min:stdout}}
-```
diff --git a/examples/multiple-commons-chunks/webpack.config.js b/examples/multiple-commons-chunks/webpack.config.js
deleted file mode 100644
index e1a66ea3..00000000
--- a/examples/multiple-commons-chunks/webpack.config.js
+++ /dev/null
@@ -1,31 +0,0 @@
-var path = require("path");
-var CommonsChunkPlugin = require("../../lib/optimize/CommonsChunkPlugin");
-module.exports = {
- entry: {
- pageA: "./pageA",
- pageB: "./pageB",
- pageC: "./pageC",
- adminPageA: "./adminPageA",
- adminPageB: "./adminPageB",
- adminPageC: "./adminPageC",
- },
- output: {
- path: path.join(__dirname, "js"),
- filename: "[name].js"
- },
- plugins: [
- new CommonsChunkPlugin({
- name: "admin-commons",
- chunks: ["adminPageA", "adminPageB"]
- }),
- new CommonsChunkPlugin({
- name: "commons",
- chunks: ["pageA", "pageB", "admin-commons"],
- minChunks: 2
- }),
- new CommonsChunkPlugin({
- name: "c-commons",
- chunks: ["pageC", "adminPageC"]
- }),
- ]
-};
diff --git a/examples/multiple-entry-points-commons-chunk-css-bundle/README.md b/examples/multiple-entry-points-commons-chunk-css-bundle/README.md
deleted file mode 100644
index 55c7cac8..00000000
--- a/examples/multiple-entry-points-commons-chunk-css-bundle/README.md
+++ /dev/null
@@ -1,339 +0,0 @@
-
-# a.js
-
-``` javascript
-require("./style.css");
-require("./styleA.css");
-```
-
-# b.js
-
-``` javascript
-require("./style.css");
-require("./styleB.css");
-```
-
-# c.js
-
-``` javascript
-require("./styleC.css");
-```
-
-# style.css
-
-``` css
-body {
- background: url(image.png);
-}
-```
-
-# styleA.css
-
-``` css
-.a {
- background: url(imageA.png);
-}
-```
-
-# styleB.css
-
-``` css
-.b {
- background: url(imageB.png);
-}
-```
-
-# styleC.css
-
-``` css
-@import "style.css";
-.c {
- background: url(imageC.png);
-}
-```
-
-# webpack.config.js
-
-``` javascript
-var path = require("path");
-var CommonsChunkPlugin = require("../../lib/optimize/CommonsChunkPlugin");
-var ExtractTextPlugin = require("extract-text-webpack-plugin");
-module.exports = {
- entry: {
- A: "./a",
- B: "./b",
- C: "./c",
- },
- output: {
- path: path.join(__dirname, "js"),
- filename: "[name].js"
- },
- module: {
- loaders: [
- {
- test: /\.css$/,
- use: ExtractTextPlugin.extract({
- fallback: "style-loader",
- use: "css-loader"
- })
- },
- { test: /\.png$/, loader: "file-loader" }
- ]
- },
- plugins: [
- new CommonsChunkPlugin({
- name: "commons",
- filename: "commons.js",
- chunks: ["A", "B"]
- }),
- new ExtractTextPlugin({
- filename: "[name].css"
- }),
- ]
-};
-```
-
-# js/A.js
-
-``` javascript
-webpackJsonp([1],[
-/* 0 */,
-/* 1 */
-/*!**************!*\
- !*** ./a.js ***!
- \**************/
-/*! no static exports found */
-/*! all exports used */
-/***/ (function(module, exports, __webpack_require__) {
-
-__webpack_require__(/*! ./style.css */ 0);
-__webpack_require__(/*! ./styleA.css */ 2);
-
-
-/***/ }),
-/* 2 */
-/*!********************!*\
- !*** ./styleA.css ***!
- \********************/
-/*! no static exports found */
-/*! all exports used */
-/***/ (function(module, exports) {
-
-// removed by extract-text-webpack-plugin
-
-/***/ })
-],[1]);
-```
-
-# js/commons.css
-
-``` css
-body {
- background: url(js/ce21cbdd9b894e6af794813eb3fdaf60.png);
-}
-```
-
-# js/A.css
-
-``` css
-.a {
- background: url(js/d090b6fba0f6d326d282a19146ff54a7.png);
-}
-```
-
-# js/B.css
-
-``` css
-.b {
- background: url(js/16155c689e517682064c99893cb832cc.png);
-}
-```
-
-# js/B.css (Minimized)
-
-``` css
-.b{background:url(js/16155c689e517682064c99893cb832cc.png)}
-```
-
-# js/C.css
-
-``` css
-body {
- background: url(js/ce21cbdd9b894e6af794813eb3fdaf60.png);
-}
-.c {
- background: url(js/c2a2f62d69330b7d787782f5010f9d13.png);
-}
-```
-
-# js/C.css (Minimized)
-
-``` css
-body{background:url(js/ce21cbdd9b894e6af794813eb3fdaf60.png)}.c{background:url(js/c2a2f62d69330b7d787782f5010f9d13.png)}
-```
-
-# Info
-
-## Uncompressed
-
-```
-Hash: b6d05f310264e74bb969
-Version: webpack 3.5.1
- Asset Size Chunks Chunk Names
- C.js 2.89 kB 2 [emitted] C
-d090b6fba0f6d326d282a19146ff54a7.png 120 bytes [emitted]
-ce21cbdd9b894e6af794813eb3fdaf60.png 119 bytes [emitted]
-c2a2f62d69330b7d787782f5010f9d13.png 120 bytes [emitted]
- B.js 561 bytes 0 [emitted] B
- A.js 543 bytes 1 [emitted] A
-16155c689e517682064c99893cb832cc.png 120 bytes [emitted]
- commons.js 6.01 kB 3 [emitted] commons
- A.css 69 bytes 1 [emitted] A
- B.css 69 bytes 0 [emitted] B
- C.css 140 bytes 2 [emitted] C
- commons.css 71 bytes 3 [emitted] commons
-Entrypoint A = commons.js commons.css A.js A.css
-Entrypoint B = commons.js commons.css B.js B.css
-Entrypoint C = C.js C.css
-chunk {0} B.js, B.css (B) 92 bytes {3} [initial] [rendered]
- > B [3] ./b.js
- [3] ./b.js 51 bytes {0} [built]
- [4] ./styleB.css 41 bytes {0} [built]
- cjs require ./styleB.css [3] ./b.js 2:0-23
-chunk {1} A.js, A.css (A) 92 bytes {3} [initial] [rendered]
- > A [1] ./a.js
- [1] ./a.js 51 bytes {1} [built]
- [2] ./styleA.css 41 bytes {1} [built]
- cjs require ./styleA.css [1] ./a.js 2:0-23
-chunk {2} C.js, C.css (C) 67 bytes [entry] [rendered]
- > C [5] ./c.js
- [5] ./c.js 26 bytes {2} [built]
- [6] ./styleC.css 41 bytes {2} [built]
- cjs require ./styleC.css [5] ./c.js 1:0-23
-chunk {3} commons.js, commons.css (commons) 41 bytes [entry] [rendered]
- [0] ./style.css 41 bytes {3} [built]
- cjs require ./style.css [1] ./a.js 1:0-22
- cjs require ./style.css [3] ./b.js 1:0-22
-Child extract-text-webpack-plugin ../../node_modules/extract-text-webpack-plugin/dist ../../node_modules/css-loader/index.js!styleA.css:
- 1 asset
- Entrypoint undefined = extract-text-webpack-plugin-output-filename
- chunk {0} extract-text-webpack-plugin-output-filename 2.58 kB [entry] [rendered]
- > [0] (webpack)/node_modules/css-loader!./styleA.css
- [0] (webpack)/node_modules/css-loader!./styleA.css 234 bytes {0} [built]
- [2] ./imageA.png 82 bytes {0} [built]
- cjs require ./imageA.png [0] (webpack)/node_modules/css-loader!./styleA.css 6:56-79
- + 1 hidden module
-Child extract-text-webpack-plugin ../../node_modules/extract-text-webpack-plugin/dist ../../node_modules/css-loader/index.js!styleB.css:
- 1 asset
- Entrypoint undefined = extract-text-webpack-plugin-output-filename
- chunk {0} extract-text-webpack-plugin-output-filename 2.58 kB [entry] [rendered]
- > [0] (webpack)/node_modules/css-loader!./styleB.css
- [0] (webpack)/node_modules/css-loader!./styleB.css 234 bytes {0} [built]
- [2] ./imageB.png 82 bytes {0} [built]
- cjs require ./imageB.png [0] (webpack)/node_modules/css-loader!./styleB.css 6:56-79
- + 1 hidden module
-Child extract-text-webpack-plugin ../../node_modules/extract-text-webpack-plugin/dist ../../node_modules/css-loader/index.js!style.css:
- 1 asset
- Entrypoint undefined = extract-text-webpack-plugin-output-filename
- chunk {0} extract-text-webpack-plugin-output-filename 2.58 kB [entry] [rendered]
- > [0] (webpack)/node_modules/css-loader!./style.css
- [0] (webpack)/node_modules/css-loader!./style.css 235 bytes {0} [built]
- [2] ./image.png 82 bytes {0} [built]
- cjs require ./image.png [0] (webpack)/node_modules/css-loader!./style.css 6:58-80
- + 1 hidden module
-Child extract-text-webpack-plugin ../../node_modules/extract-text-webpack-plugin/dist ../../node_modules/css-loader/index.js!styleC.css:
- 2 assets
- Entrypoint undefined = extract-text-webpack-plugin-output-filename
- chunk {0} extract-text-webpack-plugin-output-filename 2.97 kB [entry] [rendered]
- > [1] (webpack)/node_modules/css-loader!./styleC.css
- [1] (webpack)/node_modules/css-loader!./styleC.css 313 bytes {0} [built]
- [2] (webpack)/node_modules/css-loader!./style.css 235 bytes {0} [built]
- cjs require -!../../node_modules/css-loader/index.js!./style.css [1] (webpack)/node_modules/css-loader!./styleC.css 3:10-73
- [3] ./image.png 82 bytes {0} [built]
- cjs require ./image.png [2] (webpack)/node_modules/css-loader!./style.css 6:58-80
- [4] ./imageC.png 82 bytes {0} [built]
- cjs require ./imageC.png [1] (webpack)/node_modules/css-loader!./styleC.css 6:56-79
- + 1 hidden module
-```
-
-## Minimized (uglify-js, no zip)
-
-```
-Hash: 71684330ef0116733460
-Version: webpack 3.5.1
- Asset Size Chunks Chunk Names
- C.js 508 bytes 2 [emitted] C
-d090b6fba0f6d326d282a19146ff54a7.png 120 bytes [emitted]
-ce21cbdd9b894e6af794813eb3fdaf60.png 119 bytes [emitted]
-c2a2f62d69330b7d787782f5010f9d13.png 120 bytes [emitted]
- B.js 70 bytes 0 [emitted] B
- A.js 68 bytes 1 [emitted] A
-16155c689e517682064c99893cb832cc.png 120 bytes [emitted]
- commons.js 1.38 kB 3 [emitted] commons
- A.css 59 bytes 1 [emitted] A
- B.css 59 bytes 0 [emitted] B
- C.css 120 bytes 2 [emitted] C
- commons.css 61 bytes 3 [emitted] commons
-Entrypoint A = commons.js commons.css A.js A.css
-Entrypoint B = commons.js commons.css B.js B.css
-Entrypoint C = C.js C.css
-chunk {0} B.js, B.css (B) 92 bytes {3} [initial] [rendered]
- > B [3] ./b.js
- [3] ./b.js 51 bytes {0} [built]
- [4] ./styleB.css 41 bytes {0} [built]
- cjs require ./styleB.css [3] ./b.js 2:0-23
-chunk {1} A.js, A.css (A) 92 bytes {3} [initial] [rendered]
- > A [1] ./a.js
- [1] ./a.js 51 bytes {1} [built]
- [2] ./styleA.css 41 bytes {1} [built]
- cjs require ./styleA.css [1] ./a.js 2:0-23
-chunk {2} C.js, C.css (C) 67 bytes [entry] [rendered]
- > C [5] ./c.js
- [5] ./c.js 26 bytes {2} [built]
- [6] ./styleC.css 41 bytes {2} [built]
- cjs require ./styleC.css [5] ./c.js 1:0-23
-chunk {3} commons.js, commons.css (commons) 41 bytes [entry] [rendered]
- [0] ./style.css 41 bytes {3} [built]
- cjs require ./style.css [1] ./a.js 1:0-22
- cjs require ./style.css [3] ./b.js 1:0-22
-Child extract-text-webpack-plugin ../../node_modules/extract-text-webpack-plugin/dist ../../node_modules/css-loader/index.js!styleA.css:
- 1 asset
- Entrypoint undefined = extract-text-webpack-plugin-output-filename
- chunk {0} extract-text-webpack-plugin-output-filename 2.56 kB [entry] [rendered]
- > [0] (webpack)/node_modules/css-loader!./styleA.css
- [0] (webpack)/node_modules/css-loader!./styleA.css 217 bytes {0} [built]
- [2] ./imageA.png 82 bytes {0} [built]
- cjs require ./imageA.png [0] (webpack)/node_modules/css-loader!./styleA.css 6:48-71
- + 1 hidden module
-Child extract-text-webpack-plugin ../../node_modules/extract-text-webpack-plugin/dist ../../node_modules/css-loader/index.js!styleB.css:
- 1 asset
- Entrypoint undefined = extract-text-webpack-plugin-output-filename
- chunk {0} extract-text-webpack-plugin-output-filename 2.56 kB [entry] [rendered]
- > [0] (webpack)/node_modules/css-loader!./styleB.css
- [0] (webpack)/node_modules/css-loader!./styleB.css 217 bytes {0} [built]
- [2] ./imageB.png 82 bytes {0} [built]
- cjs require ./imageB.png [0] (webpack)/node_modules/css-loader!./styleB.css 6:48-71
- + 1 hidden module
-Child extract-text-webpack-plugin ../../node_modules/extract-text-webpack-plugin/dist ../../node_modules/css-loader/index.js!style.css:
- 1 asset
- Entrypoint undefined = extract-text-webpack-plugin-output-filename
- chunk {0} extract-text-webpack-plugin-output-filename 2.56 kB [entry] [rendered]
- > [0] (webpack)/node_modules/css-loader!./style.css
- [0] (webpack)/node_modules/css-loader!./style.css 218 bytes {0} [built]
- [2] ./image.png 82 bytes {0} [built]
- cjs require ./image.png [0] (webpack)/node_modules/css-loader!./style.css 6:50-72
- + 1 hidden module
-Child extract-text-webpack-plugin ../../node_modules/extract-text-webpack-plugin/dist ../../node_modules/css-loader/index.js!styleC.css:
- 2 assets
- Entrypoint undefined = extract-text-webpack-plugin-output-filename
- chunk {0} extract-text-webpack-plugin-output-filename 2.94 kB [entry] [rendered]
- > [1] (webpack)/node_modules/css-loader!./styleC.css
- [1] (webpack)/node_modules/css-loader!./styleC.css 296 bytes {0} [built]
- [2] (webpack)/node_modules/css-loader!./style.css 218 bytes {0} [built]
- cjs require -!../../node_modules/css-loader/index.js!./style.css [1] (webpack)/node_modules/css-loader!./styleC.css 3:10-73
- [3] ./image.png 82 bytes {0} [built]
- cjs require ./image.png [2] (webpack)/node_modules/css-loader!./style.css 6:50-72
- [4] ./imageC.png 82 bytes {0} [built]
- cjs require ./imageC.png [1] (webpack)/node_modules/css-loader!./styleC.css 6:48-71
- + 1 hidden module
-```
diff --git a/examples/multiple-entry-points-commons-chunk-css-bundle/a.js b/examples/multiple-entry-points-commons-chunk-css-bundle/a.js
deleted file mode 100644
index b134979c..00000000
--- a/examples/multiple-entry-points-commons-chunk-css-bundle/a.js
+++ /dev/null
@@ -1,2 +0,0 @@
-require("./style.css");
-require("./styleA.css");
diff --git a/examples/multiple-entry-points-commons-chunk-css-bundle/b.js b/examples/multiple-entry-points-commons-chunk-css-bundle/b.js
deleted file mode 100644
index 4c6d8e76..00000000
--- a/examples/multiple-entry-points-commons-chunk-css-bundle/b.js
+++ /dev/null
@@ -1,2 +0,0 @@
-require("./style.css");
-require("./styleB.css");
diff --git a/examples/multiple-entry-points-commons-chunk-css-bundle/build.js b/examples/multiple-entry-points-commons-chunk-css-bundle/build.js
deleted file mode 100644
index 39292a5b..00000000
--- a/examples/multiple-entry-points-commons-chunk-css-bundle/build.js
+++ /dev/null
@@ -1,2 +0,0 @@
-global.NO_TARGET_ARGS = true;
-require("../build-common");
\ No newline at end of file
diff --git a/examples/multiple-entry-points-commons-chunk-css-bundle/c.js b/examples/multiple-entry-points-commons-chunk-css-bundle/c.js
deleted file mode 100644
index c2d1242a..00000000
--- a/examples/multiple-entry-points-commons-chunk-css-bundle/c.js
+++ /dev/null
@@ -1 +0,0 @@
-require("./styleC.css");
diff --git a/examples/multiple-entry-points-commons-chunk-css-bundle/image.png b/examples/multiple-entry-points-commons-chunk-css-bundle/image.png
deleted file mode 100644
index 818c71d0..00000000
Binary files a/examples/multiple-entry-points-commons-chunk-css-bundle/image.png and /dev/null differ
diff --git a/examples/multiple-entry-points-commons-chunk-css-bundle/imageA.png b/examples/multiple-entry-points-commons-chunk-css-bundle/imageA.png
deleted file mode 100644
index 087ac802..00000000
Binary files a/examples/multiple-entry-points-commons-chunk-css-bundle/imageA.png and /dev/null differ
diff --git a/examples/multiple-entry-points-commons-chunk-css-bundle/imageB.png b/examples/multiple-entry-points-commons-chunk-css-bundle/imageB.png
deleted file mode 100644
index 591d39d0..00000000
Binary files a/examples/multiple-entry-points-commons-chunk-css-bundle/imageB.png and /dev/null differ
diff --git a/examples/multiple-entry-points-commons-chunk-css-bundle/imageC.png b/examples/multiple-entry-points-commons-chunk-css-bundle/imageC.png
deleted file mode 100644
index 6a147725..00000000
Binary files a/examples/multiple-entry-points-commons-chunk-css-bundle/imageC.png and /dev/null differ
diff --git a/examples/multiple-entry-points-commons-chunk-css-bundle/style.css b/examples/multiple-entry-points-commons-chunk-css-bundle/style.css
deleted file mode 100644
index cb7e20ae..00000000
--- a/examples/multiple-entry-points-commons-chunk-css-bundle/style.css
+++ /dev/null
@@ -1,3 +0,0 @@
-body {
- background: url(image.png);
-}
diff --git a/examples/multiple-entry-points-commons-chunk-css-bundle/styleA.css b/examples/multiple-entry-points-commons-chunk-css-bundle/styleA.css
deleted file mode 100644
index 99034416..00000000
--- a/examples/multiple-entry-points-commons-chunk-css-bundle/styleA.css
+++ /dev/null
@@ -1,3 +0,0 @@
-.a {
- background: url(imageA.png);
-}
diff --git a/examples/multiple-entry-points-commons-chunk-css-bundle/styleB.css b/examples/multiple-entry-points-commons-chunk-css-bundle/styleB.css
deleted file mode 100644
index 6fecf0ef..00000000
--- a/examples/multiple-entry-points-commons-chunk-css-bundle/styleB.css
+++ /dev/null
@@ -1,3 +0,0 @@
-.b {
- background: url(imageB.png);
-}
diff --git a/examples/multiple-entry-points-commons-chunk-css-bundle/styleC.css b/examples/multiple-entry-points-commons-chunk-css-bundle/styleC.css
deleted file mode 100644
index bb1ac069..00000000
--- a/examples/multiple-entry-points-commons-chunk-css-bundle/styleC.css
+++ /dev/null
@@ -1,4 +0,0 @@
-@import "style.css";
-.c {
- background: url(imageC.png);
-}
diff --git a/examples/multiple-entry-points-commons-chunk-css-bundle/template.md b/examples/multiple-entry-points-commons-chunk-css-bundle/template.md
deleted file mode 100644
index ac885b51..00000000
--- a/examples/multiple-entry-points-commons-chunk-css-bundle/template.md
+++ /dev/null
@@ -1,104 +0,0 @@
-
-# a.js
-
-``` javascript
-{{a.js}}
-```
-
-# b.js
-
-``` javascript
-{{b.js}}
-```
-
-# c.js
-
-``` javascript
-{{c.js}}
-```
-
-# style.css
-
-``` css
-{{style.css}}
-```
-
-# styleA.css
-
-``` css
-{{styleA.css}}
-```
-
-# styleB.css
-
-``` css
-{{styleB.css}}
-```
-
-# styleC.css
-
-``` css
-{{styleC.css}}
-```
-
-# webpack.config.js
-
-``` javascript
-{{webpack.config.js}}
-```
-
-# js/A.js
-
-``` javascript
-{{js/A.js}}
-```
-
-# js/commons.css
-
-``` css
-{{js/commons.css}}
-```
-
-# js/A.css
-
-``` css
-{{js/A.css}}
-```
-
-# js/B.css
-
-``` css
-{{js/B.css}}
-```
-
-# js/B.css (Minimized)
-
-``` css
-{{min:js/B.css}}
-```
-
-# js/C.css
-
-``` css
-{{js/C.css}}
-```
-
-# js/C.css (Minimized)
-
-``` css
-{{min:js/C.css}}
-```
-
-# Info
-
-## Uncompressed
-
-```
-{{stdout}}
-```
-
-## Minimized (uglify-js, no zip)
-
-```
-{{min:stdout}}
-```
diff --git a/examples/multiple-entry-points-commons-chunk-css-bundle/webpack.config.js b/examples/multiple-entry-points-commons-chunk-css-bundle/webpack.config.js
deleted file mode 100644
index f2abafdb..00000000
--- a/examples/multiple-entry-points-commons-chunk-css-bundle/webpack.config.js
+++ /dev/null
@@ -1,36 +0,0 @@
-var path = require("path");
-var CommonsChunkPlugin = require("../../lib/optimize/CommonsChunkPlugin");
-var ExtractTextPlugin = require("extract-text-webpack-plugin");
-module.exports = {
- entry: {
- A: "./a",
- B: "./b",
- C: "./c",
- },
- output: {
- path: path.join(__dirname, "js"),
- filename: "[name].js"
- },
- module: {
- loaders: [
- {
- test: /\.css$/,
- use: ExtractTextPlugin.extract({
- fallback: "style-loader",
- use: "css-loader"
- })
- },
- { test: /\.png$/, loader: "file-loader" }
- ]
- },
- plugins: [
- new CommonsChunkPlugin({
- name: "commons",
- filename: "commons.js",
- chunks: ["A", "B"]
- }),
- new ExtractTextPlugin({
- filename: "[name].css"
- }),
- ]
-};
diff --git a/examples/multiple-entry-points/README.md b/examples/multiple-entry-points/README.md
index d2b7b897..78770d45 100644
--- a/examples/multiple-entry-points/README.md
+++ b/examples/multiple-entry-points/README.md
@@ -2,15 +2,17 @@ This example shows how to use multiple entry points with a commons chunk.
In this example you have two (HTML) pages `pageA` and `pageB`. You want to create individual bundles for each page. In addition to this you want to create a shared bundle that contains all modules used in both pages (assuming there are many/big modules in common). The pages also use Code Splitting to load a less used part of the features on demand.
-You can see how to define multiple entry points via the `entry` option and the required changes (`[name]`) in the `output` option. You can also see how to use the CommonsChunkPlugin.
+You can see how to define multiple entry points via the `entry` option.
+
+You can use
You can see the output files:
* `commons.js` contains:
+ * module `common.js` which is used in both pages
+* `pageA.js` contains: (`pageB.js` is similar)
* the module system
* chunk loading logic
- * module `common.js` which is used in both pages
-* `pageA.bundle.js` contains: (`pageB.bundle.js` is similar)
* the entry point `pageA.js`
* it would contain any other module that is only used by `pageA`
* `0.chunk.js` is an additional chunk which is used by both pages. It contains:
@@ -48,24 +50,25 @@ require.ensure(["./shared"], function(require) {
# webpack.config.js
``` javascript
-var path = require("path");
-var CommonsChunkPlugin = require("../../lib/optimize/CommonsChunkPlugin");
module.exports = {
+ // mode: "development || "production",
entry: {
pageA: "./pageA",
pageB: "./pageB"
},
- output: {
- path: path.join(__dirname, "js"),
- filename: "[name].bundle.js",
- chunkFilename: "[id].chunk.js"
- },
- plugins: [
- new CommonsChunkPlugin({
- filename: "commons.js",
- name: "commons"
- })
- ]
+ optimization: {
+ splitChunks: {
+ cacheGroups: {
+ commons: {
+ name: "commons",
+ chunks: "initial",
+ minChunks: 2,
+ minSize: 0
+ }
+ }
+ },
+ occurrenceOrder: true // To keep filename consistent between different modes (for example building only)
+ }
};
```
@@ -81,18 +84,38 @@ module.exports = {
</html>
```
-# js/commons.js
+# dist/commons.js
+
+``` javascript
+(window["webpackJsonp"] = window["webpackJsonp"] || []).push([[1],[
+/* 0 */,
+/* 1 */
+/*!*******************!*\
+ !*** ./common.js ***!
+ \*******************/
+/*! no static exports found */
+/***/ (function(module, exports) {
+
+module.exports = "Common";
+
+/***/ })
+]]);
+```
+
+# dist/pageA.js
<details><summary><code>/******/ (function(modules) { /* webpackBootstrap */ })</code></summary>
``` javascript
/******/ (function(modules) { // webpackBootstrap
/******/ // install a JSONP callback for chunk loading
-/******/ var parentJsonpFunction = window["webpackJsonp"];
-/******/ window["webpackJsonp"] = function webpackJsonpCallback(chunkIds, moreModules, executeModules) {
+/******/ function webpackJsonpCallback(data) {
+/******/ var chunkIds = data[0];
+/******/ var moreModules = data[1]
+/******/ var executeModules = data[2];
/******/ // add "moreModules" to the modules object,
/******/ // then flag all "chunkIds" as loaded and fire callback
-/******/ var moduleId, chunkId, i = 0, resolves = [], result;
+/******/ var moduleId, chunkId, i = 0, resolves = [];
/******/ for(;i < chunkIds.length; i++) {
/******/ chunkId = chunkIds[i];
/******/ if(installedChunks[chunkId]) {
@@ -105,26 +128,44 @@ module.exports = {
/******/ modules[moduleId] = moreModules[moduleId];
/******/ }
/******/ }
-/******/ if(parentJsonpFunction) parentJsonpFunction(chunkIds, moreModules, executeModules);
+/******/ if(parentJsonpFunction) parentJsonpFunction(data);
/******/ while(resolves.length) {
/******/ resolves.shift()();
/******/ }
-/******/ if(executeModules) {
-/******/ for(i=0; i < executeModules.length; i++) {
-/******/ result = __webpack_require__(__webpack_require__.s = executeModules[i]);
+/******/
+/******/ // add entry modules from loaded chunk to deferred list
+/******/ deferredModules.push.apply(deferredModules, executeModules || []);
+/******/
+/******/ // run deferred modules when all chunks ready
+/******/ return checkDeferredModules();
+/******/ };
+/******/ function checkDeferredModules() {
+/******/ var result;
+/******/ for(var i = 0; i < deferredModules.length; i++) {
+/******/ var deferredModule = deferredModules[i];
+/******/ var fullfilled = true;
+/******/ for(var j = 1; j < deferredModule.length; j++) {
+/******/ var depId = deferredModule[j];
+/******/ if(installedChunks[depId] !== 0) fullfilled = false;
+/******/ }
+/******/ if(fullfilled) {
+/******/ deferredModules.splice(i--, 1);
+/******/ result = __webpack_require__(__webpack_require__.s = deferredModule[0]);
/******/ }
/******/ }
/******/ return result;
-/******/ };
+/******/ }
/******/
/******/ // The module cache
/******/ var installedModules = {};
/******/
-/******/ // objects to store loaded and loading chunks
+/******/ // object to store loaded and loading chunks
/******/ var installedChunks = {
/******/ 3: 0
/******/ };
/******/
+/******/ var deferredModules = [];
+/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
@@ -152,51 +193,60 @@ module.exports = {
/******/ // This file contains only the entry chunk.
/******/ // The chunk loading function for additional chunks
/******/ __webpack_require__.e = function requireEnsure(chunkId) {
+/******/ var promises = [];
+/******/
+/******/
+/******/ // JSONP chunk loading for javascript
+/******/
/******/ var installedChunkData = installedChunks[chunkId];
-/******/ if(installedChunkData === 0) {
-/******/ return new Promise(function(resolve) { resolve(); });
-/******/ }
+/******/ if(installedChunkData !== 0) { // 0 means "already installed".
/******/
-/******/ // a Promise means "currently loading".
-/******/ if(installedChunkData) {
-/******/ return installedChunkData[2];
-/******/ }
+/******/ // a Promise means "currently loading".
+/******/ if(installedChunkData) {
+/******/ promises.push(installedChunkData[2]);
+/******/ } else {
+/******/ // setup Promise in chunk cache
+/******/ var promise = new Promise(function(resolve, reject) {
+/******/ installedChunkData = installedChunks[chunkId] = [resolve, reject];
+/******/ });
+/******/ promises.push(installedChunkData[2] = promise);
/******/
-/******/ // setup Promise in chunk cache
-/******/ var promise = new Promise(function(resolve, reject) {
-/******/ installedChunkData = installedChunks[chunkId] = [resolve, reject];
-/******/ });
-/******/ installedChunkData[2] = promise;
-/******/
-/******/ // start chunk loading
-/******/ var head = document.getElementsByTagName('head')[0];
-/******/ var script = document.createElement('script');
-/******/ script.type = 'text/javascript';
-/******/ script.charset = 'utf-8';
-/******/ script.async = true;
-/******/ script.timeout = 120000;
-/******/
-/******/ if (__webpack_require__.nc) {
-/******/ script.setAttribute("nonce", __webpack_require__.nc);
-/******/ }
-/******/ script.src = __webpack_require__.p + "" + chunkId + ".chunk.js";
-/******/ var timeout = setTimeout(onScriptComplete, 120000);
-/******/ script.onerror = script.onload = onScriptComplete;
-/******/ function onScriptComplete() {
-/******/ // avoid mem leaks in IE.
-/******/ script.onerror = script.onload = null;
-/******/ clearTimeout(timeout);
-/******/ var chunk = installedChunks[chunkId];
-/******/ if(chunk !== 0) {
-/******/ if(chunk) {
-/******/ chunk[1](new Error('Loading chunk ' + chunkId + ' failed.'));
+/******/ // start chunk loading
+/******/ var head = document.getElementsByTagName('head')[0];
+/******/ var script = document.createElement('script');
+/******/
+/******/ script.charset = 'utf-8';
+/******/ script.timeout = 120000;
+/******/
+/******/ if (__webpack_require__.nc) {
+/******/ script.setAttribute("nonce", __webpack_require__.nc);
/******/ }
-/******/ installedChunks[chunkId] = undefined;
+/******/ script.src = __webpack_require__.p + "" + ({}[chunkId]||chunkId) + ".js";
+/******/ var timeout = setTimeout(function(){
+/******/ onScriptComplete({ type: 'timeout', target: script });
+/******/ }, 120000);
+/******/ script.onerror = script.onload = onScriptComplete;
+/******/ function onScriptComplete(event) {
+/******/ // avoid mem leaks in IE.
+/******/ script.onerror = script.onload = null;
+/******/ clearTimeout(timeout);
+/******/ var chunk = installedChunks[chunkId];
+/******/ if(chunk !== 0) {
+/******/ if(chunk) {
+/******/ var errorType = event && (event.type === 'load' ? 'missing' : event.type);
+/******/ var realSrc = event && event.target && event.target.src;
+/******/ var error = new Error('Loading chunk ' + chunkId + ' failed.\n(' + errorType + ': ' + realSrc + ')');
+/******/ error.type = errorType;
+/******/ error.request = realSrc;
+/******/ chunk[1](error);
+/******/ }
+/******/ installedChunks[chunkId] = undefined;
+/******/ }
+/******/ };
+/******/ head.appendChild(script);
/******/ }
-/******/ };
-/******/ head.appendChild(script);
-/******/
-/******/ return promise;
+/******/ }
+/******/ return Promise.all(promises);
/******/ };
/******/
/******/ // expose the modules object (__webpack_modules__)
@@ -216,6 +266,11 @@ module.exports = {
/******/ }
/******/ };
/******/
+/******/ // define __esModule on exports
+/******/ __webpack_require__.r = function(exports) {
+/******/ Object.defineProperty(exports, '__esModule', { value: true });
+/******/ };
+/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
@@ -229,10 +284,23 @@ module.exports = {
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
-/******/ __webpack_require__.p = "js/";
+/******/ __webpack_require__.p = "dist/";
/******/
/******/ // on error function for async loading
/******/ __webpack_require__.oe = function(err) { console.error(err); throw err; };
+/******/
+/******/ var jsonpArray = window["webpackJsonp"] = window["webpackJsonp"] || [];
+/******/ var oldJsonpFunction = jsonpArray.push.bind(jsonpArray);
+/******/ jsonpArray.push = webpackJsonpCallback;
+/******/ jsonpArray = jsonpArray.slice();
+/******/ for(var i = 0; i < jsonpArray.length; i++) webpackJsonpCallback(jsonpArray[i]);
+/******/ var parentJsonpFunction = oldJsonpFunction;
+/******/
+/******/
+/******/ // add entry module to deferred list
+/******/ deferredModules.push([3,1]);
+/******/ // run deferred modules when ready
+/******/ return checkDeferredModules();
/******/ })
/************************************************************************/
```
@@ -240,152 +308,334 @@ module.exports = {
</details>
``` javascript
-/******/ ([
-/* 0 */
-/*!*******************!*\
- !*** ./common.js ***!
- \*******************/
-/*! no static exports found */
-/*! all exports used */
-/***/ (function(module, exports) {
-
-module.exports = "Common";
-
-/***/ })
-/******/ ]);
-```
-
-# js/pageA.bundle.js
-
-``` javascript
-webpackJsonp([2],{
+/******/ ({
-/***/ 2:
+/***/ 3:
/*!******************!*\
!*** ./pageA.js ***!
\******************/
/*! no static exports found */
-/*! all exports used */
/***/ (function(module, exports, __webpack_require__) {
-var common = __webpack_require__(/*! ./common */ 0);
-__webpack_require__.e/* require */(0).then(function() { var __WEBPACK_AMD_REQUIRE_ARRAY__ = [__webpack_require__(/*! ./shared */ 1)]; (function(shared) {
+var common = __webpack_require__(/*! ./common */ 1);
+__webpack_require__.e(/*! AMD require */ 0).then(function() { var __WEBPACK_AMD_REQUIRE_ARRAY__ = [__webpack_require__(/*! ./shared */ 0)]; (function(shared) {
shared("This is page A");
-}.apply(null, __WEBPACK_AMD_REQUIRE_ARRAY__));}).catch(__webpack_require__.oe);
+}).apply(null, __WEBPACK_AMD_REQUIRE_ARRAY__);}).catch(__webpack_require__.oe);
/***/ })
-},[2]);
+/******/ });
```
-# js/pageB.bundle.js
+# dist/pageB.js
``` javascript
-webpackJsonp([1],{
+/******/ (function(modules) { // webpackBootstrap
+/******/ // install a JSONP callback for chunk loading
+/******/ function webpackJsonpCallback(data) {
+/******/ var chunkIds = data[0];
+/******/ var moreModules = data[1]
+/******/ var executeModules = data[2];
+/******/ // add "moreModules" to the modules object,
+/******/ // then flag all "chunkIds" as loaded and fire callback
+/******/ var moduleId, chunkId, i = 0, resolves = [];
+/******/ for(;i < chunkIds.length; i++) {
+/******/ chunkId = chunkIds[i];
+/******/ if(installedChunks[chunkId]) {
+/******/ resolves.push(installedChunks[chunkId][0]);
+/******/ }
+/******/ installedChunks[chunkId] = 0;
+/******/ }
+/******/ for(moduleId in moreModules) {
+/******/ if(Object.prototype.hasOwnProperty.call(moreModules, moduleId)) {
+/******/ modules[moduleId] = moreModules[moduleId];
+/******/ }
+/******/ }
+/******/ if(parentJsonpFunction) parentJsonpFunction(data);
+/******/ while(resolves.length) {
+/******/ resolves.shift()();
+/******/ }
+/******/
+/******/ // add entry modules from loaded chunk to deferred list
+/******/ deferredModules.push.apply(deferredModules, executeModules || []);
+/******/
+/******/ // run deferred modules when all chunks ready
+/******/ return checkDeferredModules();
+/******/ };
+/******/ function checkDeferredModules() {
+/******/ var result;
+/******/ for(var i = 0; i < deferredModules.length; i++) {
+/******/ var deferredModule = deferredModules[i];
+/******/ var fullfilled = true;
+/******/ for(var j = 1; j < deferredModule.length; j++) {
+/******/ var depId = deferredModule[j];
+/******/ if(installedChunks[depId] !== 0) fullfilled = false;
+/******/ }
+/******/ if(fullfilled) {
+/******/ deferredModules.splice(i--, 1);
+/******/ result = __webpack_require__(__webpack_require__.s = deferredModule[0]);
+/******/ }
+/******/ }
+/******/ return result;
+/******/ }
+/******/
+/******/ // The module cache
+/******/ var installedModules = {};
+/******/
+/******/ // object to store loaded and loading chunks
+/******/ var installedChunks = {
+/******/ 2: 0
+/******/ };
+/******/
+/******/ var deferredModules = [];
+/******/
+/******/ // The require function
+/******/ function __webpack_require__(moduleId) {
+/******/
+/******/ // Check if module is in cache
+/******/ if(installedModules[moduleId]) {
+/******/ return installedModules[moduleId].exports;
+/******/ }
+/******/ // Create a new module (and put it into the cache)
+/******/ var module = installedModules[moduleId] = {
+/******/ i: moduleId,
+/******/ l: false,
+/******/ exports: {}
+/******/ };
+/******/
+/******/ // Execute the module function
+/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
+/******/
+/******/ // Flag the module as loaded
+/******/ module.l = true;
+/******/
+/******/ // Return the exports of the module
+/******/ return module.exports;
+/******/ }
+/******/
+/******/ // This file contains only the entry chunk.
+/******/ // The chunk loading function for additional chunks
+/******/ __webpack_require__.e = function requireEnsure(chunkId) {
+/******/ var promises = [];
+/******/
+/******/
+/******/ // JSONP chunk loading for javascript
+/******/
+/******/ var installedChunkData = installedChunks[chunkId];
+/******/ if(installedChunkData !== 0) { // 0 means "already installed".
+/******/
+/******/ // a Promise means "currently loading".
+/******/ if(installedChunkData) {
+/******/ promises.push(installedChunkData[2]);
+/******/ } else {
+/******/ // setup Promise in chunk cache
+/******/ var promise = new Promise(function(resolve, reject) {
+/******/ installedChunkData = installedChunks[chunkId] = [resolve, reject];
+/******/ });
+/******/ promises.push(installedChunkData[2] = promise);
+/******/
+/******/ // start chunk loading
+/******/ var head = document.getElementsByTagName('head')[0];
+/******/ var script = document.createElement('script');
+/******/
+/******/ script.charset = 'utf-8';
+/******/ script.timeout = 120000;
+/******/
+/******/ if (__webpack_require__.nc) {
+/******/ script.setAttribute("nonce", __webpack_require__.nc);
+/******/ }
+/******/ script.src = __webpack_require__.p + "" + ({}[chunkId]||chunkId) + ".js";
+/******/ var timeout = setTimeout(function(){
+/******/ onScriptComplete({ type: 'timeout', target: script });
+/******/ }, 120000);
+/******/ script.onerror = script.onload = onScriptComplete;
+/******/ function onScriptComplete(event) {
+/******/ // avoid mem leaks in IE.
+/******/ script.onerror = script.onload = null;
+/******/ clearTimeout(timeout);
+/******/ var chunk = installedChunks[chunkId];
+/******/ if(chunk !== 0) {
+/******/ if(chunk) {
+/******/ var errorType = event && (event.type === 'load' ? 'missing' : event.type);
+/******/ var realSrc = event && event.target && event.target.src;
+/******/ var error = new Error('Loading chunk ' + chunkId + ' failed.\n(' + errorType + ': ' + realSrc + ')');
+/******/ error.type = errorType;
+/******/ error.request = realSrc;
+/******/ chunk[1](error);
+/******/ }
+/******/ installedChunks[chunkId] = undefined;
+/******/ }
+/******/ };
+/******/ head.appendChild(script);
+/******/ }
+/******/ }
+/******/ return Promise.all(promises);
+/******/ };
+/******/
+/******/ // expose the modules object (__webpack_modules__)
+/******/ __webpack_require__.m = modules;
+/******/
+/******/ // expose the module cache
+/******/ __webpack_require__.c = installedModules;
+/******/
+/******/ // define getter function for harmony exports
+/******/ __webpack_require__.d = function(exports, name, getter) {
+/******/ if(!__webpack_require__.o(exports, name)) {
+/******/ Object.defineProperty(exports, name, {
+/******/ configurable: false,
+/******/ enumerable: true,
+/******/ get: getter
+/******/ });
+/******/ }
+/******/ };
+/******/
+/******/ // define __esModule on exports
+/******/ __webpack_require__.r = function(exports) {
+/******/ Object.defineProperty(exports, '__esModule', { value: true });
+/******/ };
+/******/
+/******/ // getDefaultExport function for compatibility with non-harmony modules
+/******/ __webpack_require__.n = function(module) {
+/******/ var getter = module && module.__esModule ?
+/******/ function getDefault() { return module['default']; } :
+/******/ function getModuleExports() { return module; };
+/******/ __webpack_require__.d(getter, 'a', getter);
+/******/ return getter;
+/******/ };
+/******/
+/******/ // Object.prototype.hasOwnProperty.call
+/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
+/******/
+/******/ // __webpack_public_path__
+/******/ __webpack_require__.p = "dist/";
+/******/
+/******/ // on error function for async loading
+/******/ __webpack_require__.oe = function(err) { console.error(err); throw err; };
+/******/
+/******/ var jsonpArray = window["webpackJsonp"] = window["webpackJsonp"] || [];
+/******/ var oldJsonpFunction = jsonpArray.push.bind(jsonpArray);
+/******/ jsonpArray.push = webpackJsonpCallback;
+/******/ jsonpArray = jsonpArray.slice();
+/******/ for(var i = 0; i < jsonpArray.length; i++) webpackJsonpCallback(jsonpArray[i]);
+/******/ var parentJsonpFunction = oldJsonpFunction;
+/******/
+/******/
+/******/ // add entry module to deferred list
+/******/ deferredModules.push([2,1]);
+/******/ // run deferred modules when ready
+/******/ return checkDeferredModules();
+/******/ })
+/************************************************************************/
+/******/ ({
-/***/ 3:
+/***/ 2:
/*!******************!*\
!*** ./pageB.js ***!
\******************/
/*! no static exports found */
-/*! all exports used */
/***/ (function(module, exports, __webpack_require__) {
-var common = __webpack_require__(/*! ./common */ 0);
-__webpack_require__.e/* require.ensure */(0/* duplicate */).then((function(require) {
- var shared = __webpack_require__(/*! ./shared */ 1);
+var common = __webpack_require__(/*! ./common */ 1);
+__webpack_require__.e(/*! require.ensure */ 0).then((function(require) {
+ var shared = __webpack_require__(/*! ./shared */ 0);
shared("This is page B");
}).bind(null, __webpack_require__)).catch(__webpack_require__.oe);
/***/ })
-},[3]);
+/******/ });
```
-# js/0.chunk.js
+# dist/0.js
``` javascript
-webpackJsonp([0],[
-/* 0 */,
-/* 1 */
+(window["webpackJsonp"] = window["webpackJsonp"] || []).push([[0],[
+/* 0 */
/*!*******************!*\
!*** ./shared.js ***!
\*******************/
/*! no static exports found */
-/*! all exports used */
/***/ (function(module, exports, __webpack_require__) {
-var common = __webpack_require__(/*! ./common */ 0);
+var common = __webpack_require__(/*! ./common */ 1);
module.exports = function(msg) {
console.log(msg);
};
/***/ })
-]);
+]]);
```
# Info
-## Uncompressed
+## Unoptimized
```
-Hash: 4f8af9066e2b5dda0f23
-Version: webpack 3.5.1
- Asset Size Chunks Chunk Names
- 0.chunk.js 346 bytes 0 [emitted]
-pageB.bundle.js 521 bytes 1 [emitted] pageB
-pageA.bundle.js 547 bytes 2 [emitted] pageA
- commons.js 6 kB 3 [emitted] commons
-Entrypoint pageA = commons.js pageA.bundle.js
-Entrypoint pageB = commons.js pageB.bundle.js
-chunk {0} 0.chunk.js 91 bytes {1} {2} [rendered]
- > duplicate [2] ./pageA.js 2:0-4:2
- > duplicate [3] ./pageB.js 2:0-5:2
- [1] ./shared.js 91 bytes {0} [built]
- amd require ./shared [2] ./pageA.js 2:0-4:2
- require.ensure item ./shared [3] ./pageB.js 2:0-5:2
- cjs require ./shared [3] ./pageB.js 3:14-33
-chunk {1} pageB.bundle.js (pageB) 152 bytes {3} [initial] [rendered]
- > pageB [3] ./pageB.js
- [3] ./pageB.js 152 bytes {1} [built]
-chunk {2} pageA.bundle.js (pageA) 108 bytes {3} [initial] [rendered]
- > pageA [2] ./pageA.js
- [2] ./pageA.js 108 bytes {2} [built]
-chunk {3} commons.js (commons) 26 bytes [entry] [rendered]
- [0] ./common.js 26 bytes {3} [built]
- cjs require ./common [1] ./shared.js 1:13-32
- cjs require ./common [2] ./pageA.js 1:13-32
- cjs require ./common [3] ./pageB.js 1:13-32
+Hash: 0a1b2c3d4e5f6a7b8c9d
+Version: webpack 4.0.0-beta.1
+ Asset Size Chunks Chunk Names
+ 0.js 363 bytes 0 [emitted]
+commons.js 267 bytes 1 [emitted] commons
+ pageB.js 8.02 KiB 2 [emitted] pageB
+ pageA.js 8.06 KiB 3 [emitted] pageA
+Entrypoint pageA = commons.js pageA.js
+Entrypoint pageB = commons.js pageB.js
+chunk {0} 0.js 91 bytes <{1}> <{2}> <{3}> [rendered]
+ > [2] ./pageB.js 2:0-5:2
+ > ./shared [3] ./pageA.js 2:0-4:2
+ [0] ./shared.js 91 bytes {0} [built]
+ require.ensure item ./shared [2] ./pageB.js 2:0-5:2
+ cjs require ./shared [2] ./pageB.js 3:14-33
+ amd require ./shared [3] ./pageA.js 2:0-4:2
+chunk {1} commons.js (commons) 26 bytes ={2}= ={3}= >{0}< [initial] [rendered] split chunk (cache group: commons) (name: commons)
+ > ./pageB pageB
+ > ./pageA pageA
+ [1] ./common.js 26 bytes {1} [built]
+ cjs require ./common [0] ./shared.js 1:13-32
+ cjs require ./common [2] ./pageB.js 1:13-32
+ cjs require ./common [3] ./pageA.js 1:13-32
+chunk {2} pageB.js (pageB) 152 bytes ={1}= >{0}< [entry] [rendered]
+ > ./pageB pageB
+ [2] ./pageB.js 152 bytes {2} [built]
+ single entry ./pageB pageB
+chunk {3} pageA.js (pageA) 108 bytes ={1}= >{0}< [entry] [rendered]
+ > ./pageA pageA
+ [3] ./pageA.js 108 bytes {3} [built]
+ single entry ./pageA pageA
```
-## Minimized (uglify-js, no zip)
+## Production mode
```
-Hash: 4f8af9066e2b5dda0f23
-Version: webpack 3.5.1
- Asset Size Chunks Chunk Names
- 0.chunk.js 81 bytes 0 [emitted]
-pageB.bundle.js 122 bytes 1 [emitted] pageB
-pageA.bundle.js 147 bytes 2 [emitted] pageA
- commons.js 1.4 kB 3 [emitted] commons
-Entrypoint pageA = commons.js pageA.bundle.js
-Entrypoint pageB = commons.js pageB.bundle.js
-chunk {0} 0.chunk.js 91 bytes {1} {2} [rendered]
- > duplicate [2] ./pageA.js 2:0-4:2
- > duplicate [3] ./pageB.js 2:0-5:2
- [1] ./shared.js 91 bytes {0} [built]
- amd require ./shared [2] ./pageA.js 2:0-4:2
- require.ensure item ./shared [3] ./pageB.js 2:0-5:2
- cjs require ./shared [3] ./pageB.js 3:14-33
-chunk {1} pageB.bundle.js (pageB) 152 bytes {3} [initial] [rendered]
- > pageB [3] ./pageB.js
- [3] ./pageB.js 152 bytes {1} [built]
-chunk {2} pageA.bundle.js (pageA) 108 bytes {3} [initial] [rendered]
- > pageA [2] ./pageA.js
- [2] ./pageA.js 108 bytes {2} [built]
-chunk {3} commons.js (commons) 26 bytes [entry] [rendered]
- [0] ./common.js 26 bytes {3} [built]
- cjs require ./common [1] ./shared.js 1:13-32
- cjs require ./common [2] ./pageA.js 1:13-32
- cjs require ./common [3] ./pageB.js 1:13-32
+Hash: 0a1b2c3d4e5f6a7b8c9d
+Version: webpack 4.0.0-beta.1
+ Asset Size Chunks Chunk Names
+ 0.js 120 bytes 0 [emitted]
+commons.js 95 bytes 1 [emitted] commons
+ pageB.js 1.86 KiB 2 [emitted] pageB
+ pageA.js 1.89 KiB 3 [emitted] pageA
+Entrypoint pageA = commons.js pageA.js
+Entrypoint pageB = commons.js pageB.js
+chunk {0} 0.js 91 bytes <{1}> <{2}> <{3}> [rendered]
+ > [2] ./pageB.js 2:0-5:2
+ > ./shared [3] ./pageA.js 2:0-4:2
+ [0] ./shared.js 91 bytes {0} [built]
+ require.ensure item ./shared [2] ./pageB.js 2:0-5:2
+ cjs require ./shared [2] ./pageB.js 3:14-33
+ amd require ./shared [3] ./pageA.js 2:0-4:2
+chunk {1} commons.js (commons) 26 bytes ={2}= ={3}= >{0}< [initial] [rendered] split chunk (cache group: commons) (name: commons)
+ > ./pageB pageB
+ > ./pageA pageA
+ [1] ./common.js 26 bytes {1} [built]
+ cjs require ./common [0] ./shared.js 1:13-32
+ cjs require ./common [2] ./pageB.js 1:13-32
+ cjs require ./common [3] ./pageA.js 1:13-32
+chunk {2} pageB.js (pageB) 152 bytes ={1}= >{0}< [entry] [rendered]
+ > ./pageB pageB
+ [2] ./pageB.js 152 bytes {2} [built]
+ single entry ./pageB pageB
+chunk {3} pageA.js (pageA) 108 bytes ={1}= >{0}< [entry] [rendered]
+ > ./pageA pageA
+ [3] ./pageA.js 108 bytes {3} [built]
+ single entry ./pageA pageA
```
diff --git a/examples/multiple-entry-points/template.md b/examples/multiple-entry-points/template.md
index 9cf0bd2c..4b0ea594 100644
--- a/examples/multiple-entry-points/template.md
+++ b/examples/multiple-entry-points/template.md
@@ -2,15 +2,17 @@ This example shows how to use multiple entry points with a commons chunk.
In this example you have two (HTML) pages `pageA` and `pageB`. You want to create individual bundles for each page. In addition to this you want to create a shared bundle that contains all modules used in both pages (assuming there are many/big modules in common). The pages also use Code Splitting to load a less used part of the features on demand.
-You can see how to define multiple entry points via the `entry` option and the required changes (`[name]`) in the `output` option. You can also see how to use the CommonsChunkPlugin.
+You can see how to define multiple entry points via the `entry` option.
+
+You can use
You can see the output files:
* `commons.js` contains:
+ * module `common.js` which is used in both pages
+* `pageA.js` contains: (`pageB.js` is similar)
* the module system
* chunk loading logic
- * module `common.js` which is used in both pages
-* `pageA.bundle.js` contains: (`pageB.bundle.js` is similar)
* the entry point `pageA.js`
* it would contain any other module that is only used by `pageA`
* `0.chunk.js` is an additional chunk which is used by both pages. It contains:
@@ -50,40 +52,40 @@ You can also see the info that is printed to console. It shows among others:
{{pageA.html}}
```
-# js/commons.js
+# dist/commons.js
``` javascript
-{{js/commons.js}}
+{{dist/commons.js}}
```
-# js/pageA.bundle.js
+# dist/pageA.js
``` javascript
-{{js/pageA.bundle.js}}
+{{dist/pageA.js}}
```
-# js/pageB.bundle.js
+# dist/pageB.js
``` javascript
-{{js/pageB.bundle.js}}
+{{dist/pageB.js}}
```
-# js/0.chunk.js
+# dist/0.js
``` javascript
-{{js/0.chunk.js}}
+{{dist/0.js}}
```
# Info
-## Uncompressed
+## Unoptimized
```
{{stdout}}
```
-## Minimized (uglify-js, no zip)
+## Production mode
```
-{{min:stdout}}
+{{production:stdout}}
```
diff --git a/examples/multiple-entry-points/webpack.config.js b/examples/multiple-entry-points/webpack.config.js
index 01561581..9927b2f0 100644
--- a/examples/multiple-entry-points/webpack.config.js
+++ b/examples/multiple-entry-points/webpack.config.js
@@ -1,19 +1,20 @@
-var path = require("path");
-var CommonsChunkPlugin = require("../../lib/optimize/CommonsChunkPlugin");
module.exports = {
+ // mode: "development || "production",
entry: {
pageA: "./pageA",
pageB: "./pageB"
},
- output: {
- path: path.join(__dirname, "js"),
- filename: "[name].bundle.js",
- chunkFilename: "[id].chunk.js"
- },
- plugins: [
- new CommonsChunkPlugin({
- filename: "commons.js",
- name: "commons"
- })
- ]
+ optimization: {
+ splitChunks: {
+ cacheGroups: {
+ commons: {
+ name: "commons",
+ chunks: "initial",
+ minChunks: 2,
+ minSize: 0
+ }
+ }
+ },
+ occurrenceOrder: true // To keep filename consistent between different modes (for example building only)
+ }
};
diff --git a/examples/named-chunks/README.md b/examples/named-chunks/README.md
index aabbe660..39ce7652 100644
--- a/examples/named-chunks/README.md
+++ b/examples/named-chunks/README.md
@@ -24,18 +24,20 @@ require.ensure(["b"], function(require) {
```
-# js/output.js
+# dist/output.js
<details><summary><code>/******/ (function(modules) { /* webpackBootstrap */ })</code></summary>
``` javascript
/******/ (function(modules) { // webpackBootstrap
/******/ // install a JSONP callback for chunk loading
-/******/ var parentJsonpFunction = window["webpackJsonp"];
-/******/ window["webpackJsonp"] = function webpackJsonpCallback(chunkIds, moreModules, executeModules) {
+/******/ function webpackJsonpCallback(data) {
+/******/ var chunkIds = data[0];
+/******/ var moreModules = data[1]
+/******/
/******/ // add "moreModules" to the modules object,
/******/ // then flag all "chunkIds" as loaded and fire callback
-/******/ var moduleId, chunkId, i = 0, resolves = [], result;
+/******/ var moduleId, chunkId, i = 0, resolves = [];
/******/ for(;i < chunkIds.length; i++) {
/******/ chunkId = chunkIds[i];
/******/ if(installedChunks[chunkId]) {
@@ -48,21 +50,24 @@ require.ensure(["b"], function(require) {
/******/ modules[moduleId] = moreModules[moduleId];
/******/ }
/******/ }
-/******/ if(parentJsonpFunction) parentJsonpFunction(chunkIds, moreModules, executeModules);
+/******/ if(parentJsonpFunction) parentJsonpFunction(data);
/******/ while(resolves.length) {
/******/ resolves.shift()();
/******/ }
/******/
/******/ };
/******/
+/******/
/******/ // The module cache
/******/ var installedModules = {};
/******/
-/******/ // objects to store loaded and loading chunks
+/******/ // object to store loaded and loading chunks
/******/ var installedChunks = {
/******/ 2: 0
/******/ };
/******/
+/******/
+/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
@@ -90,51 +95,60 @@ require.ensure(["b"], function(require) {
/******/ // This file contains only the entry chunk.
/******/ // The chunk loading function for additional chunks
/******/ __webpack_require__.e = function requireEnsure(chunkId) {
+/******/ var promises = [];
+/******/
+/******/
+/******/ // JSONP chunk loading for javascript
+/******/
/******/ var installedChunkData = installedChunks[chunkId];
-/******/ if(installedChunkData === 0) {
-/******/ return new Promise(function(resolve) { resolve(); });
-/******/ }
+/******/ if(installedChunkData !== 0) { // 0 means "already installed".
/******/
-/******/ // a Promise means "currently loading".
-/******/ if(installedChunkData) {
-/******/ return installedChunkData[2];
-/******/ }
+/******/ // a Promise means "currently loading".
+/******/ if(installedChunkData) {
+/******/ promises.push(installedChunkData[2]);
+/******/ } else {
+/******/ // setup Promise in chunk cache
+/******/ var promise = new Promise(function(resolve, reject) {
+/******/ installedChunkData = installedChunks[chunkId] = [resolve, reject];
+/******/ });
+/******/ promises.push(installedChunkData[2] = promise);
/******/
-/******/ // setup Promise in chunk cache
-/******/ var promise = new Promise(function(resolve, reject) {
-/******/ installedChunkData = installedChunks[chunkId] = [resolve, reject];
-/******/ });
-/******/ installedChunkData[2] = promise;
+/******/ // start chunk loading
+/******/ var head = document.getElementsByTagName('head')[0];
+/******/ var script = document.createElement('script');
/******/
-/******/ // start chunk loading
-/******/ var head = document.getElementsByTagName('head')[0];
-/******/ var script = document.createElement('script');
-/******/ script.type = 'text/javascript';
-/******/ script.charset = 'utf-8';
-/******/ script.async = true;
-/******/ script.timeout = 120000;
+/******/ script.charset = 'utf-8';
+/******/ script.timeout = 120000;
/******/
-/******/ if (__webpack_require__.nc) {
-/******/ script.setAttribute("nonce", __webpack_require__.nc);
-/******/ }
-/******/ script.src = __webpack_require__.p + "" + chunkId + ".output.js";
-/******/ var timeout = setTimeout(onScriptComplete, 120000);
-/******/ script.onerror = script.onload = onScriptComplete;
-/******/ function onScriptComplete() {
-/******/ // avoid mem leaks in IE.
-/******/ script.onerror = script.onload = null;
-/******/ clearTimeout(timeout);
-/******/ var chunk = installedChunks[chunkId];
-/******/ if(chunk !== 0) {
-/******/ if(chunk) {
-/******/ chunk[1](new Error('Loading chunk ' + chunkId + ' failed.'));
+/******/ if (__webpack_require__.nc) {
+/******/ script.setAttribute("nonce", __webpack_require__.nc);
/******/ }
-/******/ installedChunks[chunkId] = undefined;
+/******/ script.src = __webpack_require__.p + "" + chunkId + ".output.js";
+/******/ var timeout = setTimeout(function(){
+/******/ onScriptComplete({ type: 'timeout', target: script });
+/******/ }, 120000);
+/******/ script.onerror = script.onload = onScriptComplete;
+/******/ function onScriptComplete(event) {
+/******/ // avoid mem leaks in IE.
+/******/ script.onerror = script.onload = null;
+/******/ clearTimeout(timeout);
+/******/ var chunk = installedChunks[chunkId];
+/******/ if(chunk !== 0) {
+/******/ if(chunk) {
+/******/ var errorType = event && (event.type === 'load' ? 'missing' : event.type);
+/******/ var realSrc = event && event.target && event.target.src;
+/******/ var error = new Error('Loading chunk ' + chunkId + ' failed.\n(' + errorType + ': ' + realSrc + ')');
+/******/ error.type = errorType;
+/******/ error.request = realSrc;
+/******/ chunk[1](error);
+/******/ }
+/******/ installedChunks[chunkId] = undefined;
+/******/ }
+/******/ };
+/******/ head.appendChild(script);
/******/ }
-/******/ };
-/******/ head.appendChild(script);
-/******/
-/******/ return promise;
+/******/ }
+/******/ return Promise.all(promises);
/******/ };
/******/
/******/ // expose the modules object (__webpack_modules__)
@@ -154,6 +168,11 @@ require.ensure(["b"], function(require) {
/******/ }
/******/ };
/******/
+/******/ // define __esModule on exports
+/******/ __webpack_require__.r = function(exports) {
+/******/ Object.defineProperty(exports, '__esModule', { value: true });
+/******/ };
+/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
@@ -167,13 +186,21 @@ require.ensure(["b"], function(require) {
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
-/******/ __webpack_require__.p = "js/";
+/******/ __webpack_require__.p = "dist/";
/******/
/******/ // on error function for async loading
/******/ __webpack_require__.oe = function(err) { console.error(err); throw err; };
/******/
+/******/ var jsonpArray = window["webpackJsonp"] = window["webpackJsonp"] || [];
+/******/ var oldJsonpFunction = jsonpArray.push.bind(jsonpArray);
+/******/ jsonpArray.push = webpackJsonpCallback;
+/******/ jsonpArray = jsonpArray.slice();
+/******/ for(var i = 0; i < jsonpArray.length; i++) webpackJsonpCallback(jsonpArray[i]);
+/******/ var parentJsonpFunction = oldJsonpFunction;
+/******/
+/******/
/******/ // Load entry module and return exports
-/******/ return __webpack_require__(__webpack_require__.s = 2);
+/******/ return __webpack_require__(__webpack_require__.s = 3);
/******/ })
/************************************************************************/
```
@@ -185,60 +212,57 @@ require.ensure(["b"], function(require) {
/* 0 */,
/* 1 */,
/* 2 */
+/*!***************************!*\
+ !*** ./node_modules/a.js ***!
+ \***************************/
+/*! no static exports found */
+/***/ (function(module, exports) {
+
+// module a
+
+/***/ }),
+/* 3 */
/*!********************!*\
!*** ./example.js ***!
\********************/
/*! no static exports found */
-/*! all exports used */
/***/ (function(module, exports, __webpack_require__) {
-var a = __webpack_require__(/*! a */ 3);
+var a = __webpack_require__(/*! a */ 2);
-__webpack_require__.e/* require.ensure */(0/*! my own chunk */).then((function(require) {
+__webpack_require__.e(/*! require.ensure | my own chunk */ 1).then((function(require) {
// a named chunk
var c = __webpack_require__(/*! c */ 4);
}).bind(null, __webpack_require__)).catch(__webpack_require__.oe);
-__webpack_require__.e/* require.ensure */(0/*! my own chunk */).then((function(require) {
+__webpack_require__.e(/*! require.ensure | my own chunk */ 1).then((function(require) {
// another chunk with the same name
var d = __webpack_require__(/*! d */ 1);
}).bind(null, __webpack_require__)).catch(__webpack_require__.oe);
-__webpack_require__.e/* require.ensure */(0/*! my own chunk */).then((function(require) {
+__webpack_require__.e(/*! require.ensure | my own chunk */ 1).then((function(require) {
// the same again
}).bind(null, __webpack_require__)).catch(__webpack_require__.oe);
-__webpack_require__.e/* require.ensure */(1).then((function(require) {
+__webpack_require__.e(/*! require.ensure */ 0).then((function(require) {
// chunk without name
var d = __webpack_require__(/*! d */ 1);
}).bind(null, __webpack_require__)).catch(__webpack_require__.oe);
-/***/ }),
-/* 3 */
-/*!***************************!*\
- !*** ./node_modules/a.js ***!
- \***************************/
-/*! no static exports found */
-/*! all exports used */
-/***/ (function(module, exports) {
-
-// module a
-
/***/ })
/******/ ]);
```
-# js/0.output.js
+# dist/0.output.js
``` javascript
-webpackJsonp([0,1],[
+(window["webpackJsonp"] = window["webpackJsonp"] || []).push([[0],[
/* 0 */
/*!***************************!*\
!*** ./node_modules/b.js ***!
\***************************/
/*! no static exports found */
-/*! all exports used */
/***/ (function(module, exports) {
// module b
@@ -249,38 +273,23 @@ webpackJsonp([0,1],[
!*** ./node_modules/d.js ***!
\***************************/
/*! no static exports found */
-/*! all exports used */
/***/ (function(module, exports) {
// module d
-/***/ }),
-/* 2 */,
-/* 3 */,
-/* 4 */
-/*!***************************!*\
- !*** ./node_modules/c.js ***!
- \***************************/
-/*! no static exports found */
-/*! all exports used */
-/***/ (function(module, exports) {
-
-// module c
-
/***/ })
-]);
+]]);
```
-# js/1.output.js
+# dist/1.output.js
``` javascript
-webpackJsonp([1],[
+(window["webpackJsonp"] = window["webpackJsonp"] || []).push([[1],[
/* 0 */
/*!***************************!*\
!*** ./node_modules/b.js ***!
\***************************/
/*! no static exports found */
-/*! all exports used */
/***/ (function(module, exports) {
// module b
@@ -291,61 +300,74 @@ webpackJsonp([1],[
!*** ./node_modules/d.js ***!
\***************************/
/*! no static exports found */
-/*! all exports used */
/***/ (function(module, exports) {
// module d
+/***/ }),
+/* 2 */,
+/* 3 */,
+/* 4 */
+/*!***************************!*\
+ !*** ./node_modules/c.js ***!
+ \***************************/
+/*! no static exports found */
+/***/ (function(module, exports) {
+
+// module c
+
/***/ })
-]);
+]]);
```
# Info
-## Uncompressed
+## Unoptimized
```
-Hash: 1e92144469a06ecc61e5
-Version: webpack 3.5.1
+Hash: 0a1b2c3d4e5f6a7b8c9d
+Version: webpack 4.0.0-beta.2
Asset Size Chunks Chunk Names
-0.output.js 701 bytes 0, 1 [emitted] my own chunk
-1.output.js 461 bytes 1 [emitted]
- output.js 7.04 kB 2 [emitted] main
+0.output.js 463 bytes 0 [emitted]
+1.output.js 677 bytes 1 [emitted] my own chunk
+ output.js 7.86 KiB 2 [emitted] main
Entrypoint main = output.js
-chunk {0} 0.output.js (my own chunk) 33 bytes {2} [rendered]
- > my own chunk [2] ./example.js 3:0-6:18
- > my own chunk [2] ./example.js 8:0-11:18
- > my own chunk [2] ./example.js 13:0-15:18
- 3 modules
-chunk {1} 1.output.js 22 bytes {2} [rendered]
- > [2] ./example.js 17:0-20:2
+chunk {0} 0.output.js 22 bytes <{2}> [rendered]
+ > [3] ./example.js 17:0-20:2
2 modules
-chunk {2} output.js (main) 452 bytes [entry] [rendered]
- > main [2] ./example.js
- [2] ./example.js 441 bytes {2} [built]
+chunk {1} 1.output.js (my own chunk) 33 bytes <{2}> [rendered]
+ > [3] ./example.js 13:0-15:18
+ > [3] ./example.js 3:0-6:18
+ > [3] ./example.js 8:0-11:18
+ 3 modules
+chunk {2} output.js (main) 452 bytes >{0}< >{1}< [entry] [rendered]
+ > .\example.js main
+ [3] ./example.js 441 bytes {2} [built]
+ single entry .\example.js main
+ 1 hidden module
```
-## Minimized (uglify-js, no zip)
+## Production mode
```
-Hash: 1e92144469a06ecc61e5
-Version: webpack 3.5.1
- Asset Size Chunks Chunk Names
-0.output.js 72 bytes 0, 1 [emitted] my own chunk
-1.output.js 52 bytes 1 [emitted]
- output.js 1.58 kB 2 [emitted] main
+Hash: 0a1b2c3d4e5f6a7b8c9d
+Version: webpack 4.0.0-beta.2
+ Asset Size Chunks Chunk Names
+0.output.js 92 bytes 0 [emitted]
+1.output.js 112 bytes 1, 0 [emitted] my own chunk
+ output.js 1.82 KiB 2 [emitted] main
Entrypoint main = output.js
-chunk {0} 0.output.js (my own chunk) 33 bytes {2} [rendered]
- > my own chunk [2] ./example.js 3:0-6:18
- > my own chunk [2] ./example.js 8:0-11:18
- > my own chunk [2] ./example.js 13:0-15:18
- 3 modules
-chunk {1} 1.output.js 22 bytes {2} [rendered]
- > [2] ./example.js 17:0-20:2
+chunk {0} 0.output.js 22 bytes <{2}> [rendered]
+ > [3] ./example.js 17:0-20:2
2 modules
-chunk {2} output.js (main) 452 bytes [entry] [rendered]
- > main [2] ./example.js
- [2] ./example.js 441 bytes {2} [built]
+chunk {1} 1.output.js (my own chunk) 33 bytes <{2}> [rendered]
+ > [3] ./example.js 13:0-15:18
+ > [3] ./example.js 3:0-6:18
+ > [3] ./example.js 8:0-11:18
+ 3 modules
+chunk {2} output.js (main) 452 bytes >{0}< >{1}< [entry] [rendered]
+ > .\example.js main
+ [3] ./example.js 441 bytes {2} [built]
+ single entry .\example.js main
+ 1 hidden module
```
diff --git a/examples/named-chunks/template.md b/examples/named-chunks/template.md
index b1a29e29..ef6baf49 100644
--- a/examples/named-chunks/template.md
+++ b/examples/named-chunks/template.md
@@ -5,34 +5,34 @@
```
-# js/output.js
+# dist/output.js
``` javascript
-{{js/output.js}}
+{{dist/output.js}}
```
-# js/0.output.js
+# dist/0.output.js
``` javascript
-{{js/0.output.js}}
+{{dist/0.output.js}}
```
-# js/1.output.js
+# dist/1.output.js
``` javascript
-{{js/1.output.js}}
+{{dist/1.output.js}}
```
# Info
-## Uncompressed
+## Unoptimized
```
{{stdout}}
```
-## Minimized (uglify-js, no zip)
+## Production mode
```
-{{min:stdout}}
+{{production:stdout}}
```
diff --git a/examples/named-chunks/webpack.config.js b/examples/named-chunks/webpack.config.js
new file mode 100644
index 00000000..0d554bf6
--- /dev/null
+++ b/examples/named-chunks/webpack.config.js
@@ -0,0 +1,5 @@
+module.exports = {
+ optimization: {
+ occurrenceOrder: true // To keep filename consistent between different modes (for example building only)
+ }
+};
diff --git a/examples/require.context/README.md b/examples/require.context/README.md
index ba8db6f5..1fefd39a 100644
--- a/examples/require.context/README.md
+++ b/examples/require.context/README.md
@@ -22,7 +22,7 @@ module.exports = function() {
}
```
-# js/output.js
+# dist/output.js
<details><summary><code>/******/ (function(modules) { /* webpackBootstrap */ })</code></summary>
@@ -73,6 +73,11 @@ module.exports = function() {
/******/ }
/******/ };
/******/
+/******/ // define __esModule on exports
+/******/ __webpack_require__.r = function(exports) {
+/******/ Object.defineProperty(exports, '__esModule', { value: true });
+/******/ };
+/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
@@ -86,10 +91,11 @@ module.exports = function() {
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
-/******/ __webpack_require__.p = "js/";
+/******/ __webpack_require__.p = "dist/";
+/******/
/******/
/******/ // Load entry module and return exports
-/******/ return __webpack_require__(__webpack_require__.s = 3);
+/******/ return __webpack_require__(__webpack_require__.s = 0);
/******/ })
/************************************************************************/
```
@@ -99,11 +105,63 @@ module.exports = function() {
``` javascript
/******/ ([
/* 0 */
+/*!********************!*\
+ !*** ./example.js ***!
+ \********************/
+/*! no static exports found */
+/***/ (function(module, exports, __webpack_require__) {
+
+function getTemplate(templateName) {
+ return __webpack_require__(1)("./"+templateName);
+}
+console.log(getTemplate("a"));
+console.log(getTemplate("b"));
+
+/***/ }),
+/* 1 */
+/*!*********************************!*\
+ !*** ./templates sync ^\.\/.*$ ***!
+ \*********************************/
+/*! no static exports found */
+/***/ (function(module, exports, __webpack_require__) {
+
+var map = {
+ "./a": 2,
+ "./a.js": 2,
+ "./b": 3,
+ "./b.js": 3,
+ "./c": 4,
+ "./c.js": 4
+};
+
+
+function webpackContext(req) {
+ var id = webpackContextResolve(req);
+ var module = __webpack_require__(id);
+ return module;
+}
+function webpackContextResolve(req) {
+ var id = map[req];
+ if(!(id + 1)) { // check for number or string
+ var e = new Error('Cannot find module "' + req + '".');
+ e.code = 'MODULE_NOT_FOUND';
+ throw e;
+ }
+ return id;
+}
+webpackContext.keys = function webpackContextKeys() {
+ return Object.keys(map);
+};
+webpackContext.resolve = webpackContextResolve;
+module.exports = webpackContext;
+webpackContext.id = 1;
+
+/***/ }),
+/* 2 */
/*!************************!*\
!*** ./templates/a.js ***!
\************************/
/*! no static exports found */
-/*! all exports used */
/***/ (function(module, exports) {
module.exports = function() {
@@ -111,12 +169,11 @@ module.exports = function() {
}
/***/ }),
-/* 1 */
+/* 3 */
/*!************************!*\
!*** ./templates/b.js ***!
\************************/
/*! no static exports found */
-/*! all exports used */
/***/ (function(module, exports) {
module.exports = function() {
@@ -124,118 +181,71 @@ module.exports = function() {
}
/***/ }),
-/* 2 */
+/* 4 */
/*!************************!*\
!*** ./templates/c.js ***!
\************************/
/*! no static exports found */
-/*! all exports used */
/***/ (function(module, exports) {
module.exports = function() {
return "This text was generated by template C";
}
-/***/ }),
-/* 3 */
-/*!********************!*\
- !*** ./example.js ***!
- \********************/
-/*! no static exports found */
-/*! all exports used */
-/***/ (function(module, exports, __webpack_require__) {
-
-function getTemplate(templateName) {
- return __webpack_require__(/*! ./templates */ 4)("./"+templateName);
-}
-console.log(getTemplate("a"));
-console.log(getTemplate("b"));
-
-/***/ }),
-/* 4 */
-/*!****************************!*\
- !*** ./templates ^\.\/.*$ ***!
- \****************************/
-/*! no static exports found */
-/*! all exports used */
-/***/ (function(module, exports, __webpack_require__) {
-
-var map = {
- "./a": 0,
- "./a.js": 0,
- "./b": 1,
- "./b.js": 1,
- "./c": 2,
- "./c.js": 2
-};
-function webpackContext(req) {
- return __webpack_require__(webpackContextResolve(req));
-};
-function webpackContextResolve(req) {
- var id = map[req];
- if(!(id + 1)) // check for number or string
- throw new Error("Cannot find module '" + req + "'.");
- return id;
-};
-webpackContext.keys = function webpackContextKeys() {
- return Object.keys(map);
-};
-webpackContext.resolve = webpackContextResolve;
-module.exports = webpackContext;
-webpackContext.id = 4;
-
/***/ })
/******/ ]);
```
# Info
-## Uncompressed
+## Unoptimized
```
-Hash: acf02a400c4d02cc105a
-Version: webpack 3.5.1
- Asset Size Chunks Chunk Names
-output.js 4.42 kB 0 [emitted] main
+Hash: 0a1b2c3d4e5f6a7b8c9d
+Version: webpack 4.0.0-beta.2
+ Asset Size Chunks Chunk Names
+output.js 4.48 KiB 0 [emitted] main
Entrypoint main = output.js
chunk {0} output.js (main) 613 bytes [entry] [rendered]
- > main [3] ./example.js
- [0] ./templates/a.js 82 bytes {0} [optional] [built]
- context element ./a.js [4] ./templates ^\.\/.*$ ./a.js
- context element ./a [4] ./templates ^\.\/.*$ ./a
- [1] ./templates/b.js 82 bytes {0} [optional] [built]
- context element ./b.js [4] ./templates ^\.\/.*$ ./b.js
- context element ./b [4] ./templates ^\.\/.*$ ./b
- [2] ./templates/c.js 82 bytes {0} [optional] [built]
- context element ./c.js [4] ./templates ^\.\/.*$ ./c.js
- context element ./c [4] ./templates ^\.\/.*$ ./c
- [3] ./example.js 150 bytes {0} [built]
- [4] ./templates ^\.\/.*$ 217 bytes {0} [built]
- cjs require context ./templates [3] ./example.js 2:8-44
+ > .\example.js main
+ [0] ./example.js 150 bytes {0} [built]
+ single entry .\example.js main
+ [1] ./templates sync ^\.\/.*$ 217 bytes {0} [built]
+ cjs require context ./templates [0] ./example.js 2:8-44
+ [2] ./templates/a.js 82 bytes {0} [optional] [built]
+ context element ./a.js [1] ./templates sync ^\.\/.*$ ./a.js
+ context element ./a [1] ./templates sync ^\.\/.*$ ./a
+ [3] ./templates/b.js 82 bytes {0} [optional] [built]
+ context element ./b.js [1] ./templates sync ^\.\/.*$ ./b.js
+ context element ./b [1] ./templates sync ^\.\/.*$ ./b
+ [4] ./templates/c.js 82 bytes {0} [optional] [built]
+ context element ./c.js [1] ./templates sync ^\.\/.*$ ./c.js
+ context element ./c [1] ./templates sync ^\.\/.*$ ./c
```
-## Minimized (uglify-js, no zip)
+## Production mode
```
-Hash: acf02a400c4d02cc105a
-Version: webpack 3.5.1
- Asset Size Chunks Chunk Names
-output.js 1.08 kB 0 [emitted] main
+Hash: 0a1b2c3d4e5f6a7b8c9d
+Version: webpack 4.0.0-beta.2
+ Asset Size Chunks Chunk Names
+output.js 1.16 KiB 0 [emitted] main
Entrypoint main = output.js
chunk {0} output.js (main) 613 bytes [entry] [rendered]
- > main [3] ./example.js
- [0] ./templates/a.js 82 bytes {0} [optional] [built]
- context element ./a.js [4] ./templates ^\.\/.*$ ./a.js
- context element ./a [4] ./templates ^\.\/.*$ ./a
+ > .\example.js main
+ [0] ./templates/c.js 82 bytes {0} [optional] [built]
+ context element ./c.js [3] ./templates sync ^\.\/.*$ ./c.js
+ context element ./c [3] ./templates sync ^\.\/.*$ ./c
[1] ./templates/b.js 82 bytes {0} [optional] [built]
- context element ./b.js [4] ./templates ^\.\/.*$ ./b.js
- context element ./b [4] ./templates ^\.\/.*$ ./b
- [2] ./templates/c.js 82 bytes {0} [optional] [built]
- context element ./c.js [4] ./templates ^\.\/.*$ ./c.js
- context element ./c [4] ./templates ^\.\/.*$ ./c
- [3] ./example.js 150 bytes {0} [built]
- [4] ./templates ^\.\/.*$ 217 bytes {0} [built]
- cjs require context ./templates [3] ./example.js 2:8-44
+ context element ./b.js [3] ./templates sync ^\.\/.*$ ./b.js
+ context element ./b [3] ./templates sync ^\.\/.*$ ./b
+ [2] ./templates/a.js 82 bytes {0} [optional] [built]
+ context element ./a.js [3] ./templates sync ^\.\/.*$ ./a.js
+ context element ./a [3] ./templates sync ^\.\/.*$ ./a
+ [3] ./templates sync ^\.\/.*$ 217 bytes {0} [built]
+ cjs require context ./templates [4] ./example.js 2:8-44
+ [4] ./example.js 150 bytes {0} [built]
+ single entry .\example.js main
```
# Code Splitting
diff --git a/examples/require.context/template.md b/examples/require.context/template.md
index 6ba8ff03..815ce7fe 100644
--- a/examples/require.context/template.md
+++ b/examples/require.context/template.md
@@ -18,24 +18,24 @@ module.exports = function() {
}
```
-# js/output.js
+# dist/output.js
``` javascript
-{{js/output.js}}
+{{dist/output.js}}
```
# Info
-## Uncompressed
+## Unoptimized
```
{{stdout}}
```
-## Minimized (uglify-js, no zip)
+## Production mode
```
-{{min:stdout}}
+{{production:stdout}}
```
# Code Splitting
diff --git a/examples/require.resolve/README.md b/examples/require.resolve/README.md
index ab9fb42b..efb35906 100644
--- a/examples/require.resolve/README.md
+++ b/examples/require.resolve/README.md
@@ -23,7 +23,7 @@ if(a == a2) throw new Error("Cache clear failed :(");
module.exports = Math.random();
```
-# js/output.js
+# dist/output.js
<details><summary><code>/******/ (function(modules) { /* webpackBootstrap */ })</code></summary>
@@ -74,6 +74,11 @@ module.exports = Math.random();
/******/ }
/******/ };
/******/
+/******/ // define __esModule on exports
+/******/ __webpack_require__.r = function(exports) {
+/******/ Object.defineProperty(exports, '__esModule', { value: true });
+/******/ };
+/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
@@ -87,10 +92,11 @@ module.exports = Math.random();
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
-/******/ __webpack_require__.p = "js/";
+/******/ __webpack_require__.p = "dist/";
+/******/
/******/
/******/ // Load entry module and return exports
-/******/ return __webpack_require__(__webpack_require__.s = 1);
+/******/ return __webpack_require__(__webpack_require__.s = 0);
/******/ })
/************************************************************************/
```
@@ -100,74 +106,74 @@ module.exports = Math.random();
``` javascript
/******/ ([
/* 0 */
-/*!**************!*\
- !*** ./a.js ***!
- \**************/
-/*! no static exports found */
-/*! all exports used */
-/***/ (function(module, exports) {
-
-module.exports = Math.random();
-
-/***/ }),
-/* 1 */
/*!********************!*\
!*** ./example.js ***!
\********************/
/*! no static exports found */
-/*! all exports used */
/***/ (function(module, exports, __webpack_require__) {
-var a = __webpack_require__(/*! ./a */ 0);
+var a = __webpack_require__(/*! ./a */ 1);
// get module id
-var aId = /*require.resolve*/(/*! ./a.js */ 0);
+var aId = /*require.resolve*/(/*! ./a.js */ 1);
// clear module in require.cache
delete __webpack_require__.c[aId];
// require module again, it should be reexecuted
-var a2 = __webpack_require__(/*! ./a */ 0);
+var a2 = __webpack_require__(/*! ./a */ 1);
// vertify it
if(a == a2) throw new Error("Cache clear failed :(");
+/***/ }),
+/* 1 */
+/*!**************!*\
+ !*** ./a.js ***!
+ \**************/
+/*! no static exports found */
+/***/ (function(module, exports) {
+
+module.exports = Math.random();
+
/***/ })
/******/ ]);
```
# Info
-## Uncompressed
+## Unoptimized
```
-Hash: 4ed342adc60583d992ab
-Version: webpack 3.5.1
- Asset Size Chunks Chunk Names
-output.js 3.18 kB 0 [emitted] main
+Hash: 0a1b2c3d4e5f6a7b8c9d
+Version: webpack 4.0.0-beta.2
+ Asset Size Chunks Chunk Names
+output.js 3.26 KiB 0 [emitted] main
Entrypoint main = output.js
chunk {0} output.js (main) 326 bytes [entry] [rendered]
- > main [1] ./example.js
- [0] ./a.js 31 bytes {0} [built]
- require.resolve ./a.js [1] ./example.js 4:10-35
- cjs require ./a [1] ./example.js 1:8-22
- cjs require ./a [1] ./example.js 10:9-23
- [1] ./example.js 295 bytes {0} [built]
+ > .\example.js main
+ [0] ./example.js 295 bytes {0} [built]
+ single entry .\example.js main
+ [1] ./a.js 31 bytes {0} [built]
+ require.resolve ./a.js [0] ./example.js 4:10-35
+ cjs require ./a [0] ./example.js 1:8-22
+ cjs require ./a [0] ./example.js 10:9-23
```
-## Minimized (uglify-js, no zip)
+## Production mode
```
-Hash: 4ed342adc60583d992ab
-Version: webpack 3.5.1
+Hash: 0a1b2c3d4e5f6a7b8c9d
+Version: webpack 4.0.0-beta.2
Asset Size Chunks Chunk Names
-output.js 599 bytes 0 [emitted] main
+output.js 667 bytes 0 [emitted] main
Entrypoint main = output.js
chunk {0} output.js (main) 326 bytes [entry] [rendered]
- > main [1] ./example.js
+ > .\example.js main
[0] ./a.js 31 bytes {0} [built]
require.resolve ./a.js [1] ./example.js 4:10-35
cjs require ./a [1] ./example.js 1:8-22
cjs require ./a [1] ./example.js 10:9-23
[1] ./example.js 295 bytes {0} [built]
+ single entry .\example.js main
```
diff --git a/examples/require.resolve/template.md b/examples/require.resolve/template.md
index a3a35de7..d991ada6 100644
--- a/examples/require.resolve/template.md
+++ b/examples/require.resolve/template.md
@@ -11,22 +11,22 @@
{{a.js}}
```
-# js/output.js
+# dist/output.js
``` javascript
-{{js/output.js}}
+{{dist/output.js}}
```
# Info
-## Uncompressed
+## Unoptimized
```
{{stdout}}
```
-## Minimized (uglify-js, no zip)
+## Production mode
```
-{{min:stdout}}
+{{production:stdout}}
```
diff --git a/examples/scope-hoisting/README.md b/examples/scope-hoisting/README.md
index fd9c88d0..24cfd34b 100644
--- a/examples/scope-hoisting/README.md
+++ b/examples/scope-hoisting/README.md
@@ -101,30 +101,33 @@ export var y = "y";
# webpack.config.js
``` javascript
-var webpack = require("../../");
-
module.exports = {
- plugins: [
- new webpack.optimize.ModuleConcatenationPlugin()
- ]
+ // mode: "development" || "production",
+ optimization: {
+ usedExports: true,
+ concatenateModules: true,
+ occurrenceOrder: true // To keep filename consistent between different modes (for example building only)
+ }
};
```
-# js/output.js
+# dist/output.js
<details><summary><code>/******/ (function(modules) { /* webpackBootstrap */ })</code></summary>
``` javascript
/******/ (function(modules) { // webpackBootstrap
/******/ // install a JSONP callback for chunk loading
-/******/ var parentJsonpFunction = window["webpackJsonp"];
-/******/ window["webpackJsonp"] = function webpackJsonpCallback(chunkIds, moreModules, executeModules) {
+/******/ function webpackJsonpCallback(data) {
+/******/ var chunkIds = data[0];
+/******/ var moreModules = data[1]
+/******/
/******/ // add "moreModules" to the modules object,
/******/ // then flag all "chunkIds" as loaded and fire callback
-/******/ var moduleId, chunkId, i = 0, resolves = [], result;
+/******/ var moduleId, chunkId, i = 0, resolves = [];
/******/ for(;i < chunkIds.length; i++) {
/******/ chunkId = chunkIds[i];
/******/ if(installedChunks[chunkId]) {
@@ -137,21 +140,24 @@ module.exports = {
/******/ modules[moduleId] = moreModules[moduleId];
/******/ }
/******/ }
-/******/ if(parentJsonpFunction) parentJsonpFunction(chunkIds, moreModules, executeModules);
+/******/ if(parentJsonpFunction) parentJsonpFunction(data);
/******/ while(resolves.length) {
/******/ resolves.shift()();
/******/ }
/******/
/******/ };
/******/
+/******/
/******/ // The module cache
/******/ var installedModules = {};
/******/
-/******/ // objects to store loaded and loading chunks
+/******/ // object to store loaded and loading chunks
/******/ var installedChunks = {
/******/ 1: 0
/******/ };
/******/
+/******/
+/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
@@ -179,51 +185,60 @@ module.exports = {
/******/ // This file contains only the entry chunk.
/******/ // The chunk loading function for additional chunks
/******/ __webpack_require__.e = function requireEnsure(chunkId) {
+/******/ var promises = [];
+/******/
+/******/
+/******/ // JSONP chunk loading for javascript
+/******/
/******/ var installedChunkData = installedChunks[chunkId];
-/******/ if(installedChunkData === 0) {
-/******/ return new Promise(function(resolve) { resolve(); });
-/******/ }
+/******/ if(installedChunkData !== 0) { // 0 means "already installed".
/******/
-/******/ // a Promise means "currently loading".
-/******/ if(installedChunkData) {
-/******/ return installedChunkData[2];
-/******/ }
+/******/ // a Promise means "currently loading".
+/******/ if(installedChunkData) {
+/******/ promises.push(installedChunkData[2]);
+/******/ } else {
+/******/ // setup Promise in chunk cache
+/******/ var promise = new Promise(function(resolve, reject) {
+/******/ installedChunkData = installedChunks[chunkId] = [resolve, reject];
+/******/ });
+/******/ promises.push(installedChunkData[2] = promise);
/******/
-/******/ // setup Promise in chunk cache
-/******/ var promise = new Promise(function(resolve, reject) {
-/******/ installedChunkData = installedChunks[chunkId] = [resolve, reject];
-/******/ });
-/******/ installedChunkData[2] = promise;
+/******/ // start chunk loading
+/******/ var head = document.getElementsByTagName('head')[0];
+/******/ var script = document.createElement('script');
/******/
-/******/ // start chunk loading
-/******/ var head = document.getElementsByTagName('head')[0];
-/******/ var script = document.createElement('script');
-/******/ script.type = 'text/javascript';
-/******/ script.charset = 'utf-8';
-/******/ script.async = true;
-/******/ script.timeout = 120000;
+/******/ script.charset = 'utf-8';
+/******/ script.timeout = 120000;
/******/
-/******/ if (__webpack_require__.nc) {
-/******/ script.setAttribute("nonce", __webpack_require__.nc);
-/******/ }
-/******/ script.src = __webpack_require__.p + "" + chunkId + ".output.js";
-/******/ var timeout = setTimeout(onScriptComplete, 120000);
-/******/ script.onerror = script.onload = onScriptComplete;
-/******/ function onScriptComplete() {
-/******/ // avoid mem leaks in IE.
-/******/ script.onerror = script.onload = null;
-/******/ clearTimeout(timeout);
-/******/ var chunk = installedChunks[chunkId];
-/******/ if(chunk !== 0) {
-/******/ if(chunk) {
-/******/ chunk[1](new Error('Loading chunk ' + chunkId + ' failed.'));
+/******/ if (__webpack_require__.nc) {
+/******/ script.setAttribute("nonce", __webpack_require__.nc);
/******/ }
-/******/ installedChunks[chunkId] = undefined;
+/******/ script.src = __webpack_require__.p + "" + chunkId + ".output.js";
+/******/ var timeout = setTimeout(function(){
+/******/ onScriptComplete({ type: 'timeout', target: script });
+/******/ }, 120000);
+/******/ script.onerror = script.onload = onScriptComplete;
+/******/ function onScriptComplete(event) {
+/******/ // avoid mem leaks in IE.
+/******/ script.onerror = script.onload = null;
+/******/ clearTimeout(timeout);
+/******/ var chunk = installedChunks[chunkId];
+/******/ if(chunk !== 0) {
+/******/ if(chunk) {
+/******/ var errorType = event && (event.type === 'load' ? 'missing' : event.type);
+/******/ var realSrc = event && event.target && event.target.src;
+/******/ var error = new Error('Loading chunk ' + chunkId + ' failed.\n(' + errorType + ': ' + realSrc + ')');
+/******/ error.type = errorType;
+/******/ error.request = realSrc;
+/******/ chunk[1](error);
+/******/ }
+/******/ installedChunks[chunkId] = undefined;
+/******/ }
+/******/ };
+/******/ head.appendChild(script);
/******/ }
-/******/ };
-/******/ head.appendChild(script);
-/******/
-/******/ return promise;
+/******/ }
+/******/ return Promise.all(promises);
/******/ };
/******/
/******/ // expose the modules object (__webpack_modules__)
@@ -243,6 +258,11 @@ module.exports = {
/******/ }
/******/ };
/******/
+/******/ // define __esModule on exports
+/******/ __webpack_require__.r = function(exports) {
+/******/ Object.defineProperty(exports, '__esModule', { value: true });
+/******/ };
+/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
@@ -256,11 +276,19 @@ module.exports = {
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
-/******/ __webpack_require__.p = "js/";
+/******/ __webpack_require__.p = "dist/";
/******/
/******/ // on error function for async loading
/******/ __webpack_require__.oe = function(err) { console.error(err); throw err; };
/******/
+/******/ var jsonpArray = window["webpackJsonp"] = window["webpackJsonp"] || [];
+/******/ var oldJsonpFunction = jsonpArray.push.bind(jsonpArray);
+/******/ jsonpArray.push = webpackJsonpCallback;
+/******/ jsonpArray = jsonpArray.slice();
+/******/ for(var i = 0; i < jsonpArray.length; i++) webpackJsonpCallback(jsonpArray[i]);
+/******/ var parentJsonpFunction = oldJsonpFunction;
+/******/
+/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 1);
/******/ })
@@ -280,7 +308,6 @@ module.exports = {
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
-Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
// CONCATENATED MODULE: ./node_modules/shared2.js
// shared2 module
@@ -299,13 +326,13 @@ var x = "x";
/*!********************************!*\
!*** ./example.js + 2 modules ***!
\********************************/
-/*! exports provided: */
+/*! no exports provided */
/*! all exports used */
-/*! ModuleConcatenation bailout: Module is an entry point */
+/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/a.js because of ./node_modules/c.js */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
-Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
+__webpack_require__.r(__webpack_exports__);
// EXTERNAL MODULE: ./node_modules/shared.js + 1 modules
var shared = __webpack_require__(0);
@@ -325,7 +352,7 @@ function b_a() {
-__webpack_require__.e/* import() */(0).then(__webpack_require__.bind(null, /*! ./lazy */ 3)).then(function(lazy) {
+__webpack_require__.e(/*! import() */ 0).then(__webpack_require__.bind(null, /*! ./lazy */ 3)).then(function(lazy) {
console.log(a, b_a(), shared["a" /* x */], shared["b" /* y */], lazy.c, lazy.d.a, lazy.x, lazy.y);
});
@@ -334,10 +361,10 @@ __webpack_require__.e/* import() */(0).then(__webpack_require__.bind(null, /*! .
/******/ ]);
```
-# js/0.output.js
+# dist/0.output.js
``` javascript
-webpackJsonp([0],[
+(window["webpackJsonp"] = window["webpackJsonp"] || []).push([[0],[
/* 0 */,
/* 1 */,
/* 2 */
@@ -360,17 +387,16 @@ exports.c = "e";
\*****************************/
/*! exports provided: d, c, x, y */
/*! all exports used */
-/*! ModuleConcatenation bailout: Module is referenced from these modules with unsupported syntax: ./example.js (referenced with import()) */
+/*! ModuleConcatenation bailout: Cannot concat with ./node_modules/c.js because of ./node_modules/shared.js */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
-Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
+__webpack_require__.r(__webpack_exports__);
var d_namespaceObject = {};
__webpack_require__.d(d_namespaceObject, "a", function() { return a; });
// EXTERNAL MODULE: ./node_modules/cjs.js
var cjs = __webpack_require__(2);
-var cjs_default = /*#__PURE__*/__webpack_require__.n(cjs);
// EXTERNAL MODULE: ./node_modules/shared.js + 1 modules
var shared = __webpack_require__(0);
@@ -398,65 +424,91 @@ var a = "d";
/***/ })
-]);
+]]);
```
Minimized
``` javascript
-webpackJsonp([0],[,,function(n,r){r.c="e"},function(n,r,t){"use strict";Object.defineProperty(r,"__esModule",{value:!0});var e={};t.d(e,"a",function(){return d});var u=t(2),c=t(0),o=String.fromCharCode(u.c.charCodeAt(0)-2),d="d";t.d(r,"c",function(){return o}),t.d(r,"x",function(){return c.a}),t.d(r,"y",function(){return c.b}),t.d(r,"d",function(){return e})}]);
+(window.webpackJsonp=window.webpackJsonp||[]).push([[0],[,,function(n,r){r.c="e"},function(n,r,t){"use strict";t.r(r);var c={};t.d(c,"a",function(){return e});var o=t(2),u=t(0),d=String.fromCharCode(o.c.charCodeAt(0)-2),e="d";t.d(r,"c",function(){return d}),t.d(r,"x",function(){return u.a}),t.d(r,"y",function(){return u.b}),t.d(r,"d",function(){return c})}]]);
```
# Info
-## Uncompressed
+## Unoptimized
```
-Hash: 6596ce0a50ccbbaa89c6
-Version: webpack 3.5.1
- Asset Size Chunks Chunk Names
-0.output.js 1.9 kB 0 [emitted]
- output.js 7.39 kB 1 [emitted] main
+Hash: 0a1b2c3d4e5f6a7b8c9d
+Version: webpack 4.0.0-beta.2
+ Asset Size Chunks Chunk Names
+0.output.js 1.78 KiB 0 [emitted]
+ output.js 8.2 KiB 1 [emitted] main
Entrypoint main = output.js
-chunk {0} 0.output.js 286 bytes {1} [rendered]
- > [] 4:0-16
+chunk {0} 0.output.js 286 bytes <{1}> [rendered]
+ > ./lazy [] 4:0-16
[3] ./lazy.js + 2 modules 242 bytes {0} [built]
[exports: d, c, x, y]
- import() ./lazy [] ./example.js 4:0-16
+ import() ./lazy ./example.js 4:0-16
+ | ./lazy.js 60 bytes [built]
+ | [exports: d, c, x, y]
+ | import() ./lazy ./example.js 4:0-16
+ | + 2 hidden modules
+ 1 hidden module
-chunk {1} output.js (main) 390 bytes [entry] [rendered]
- > main []
+chunk {1} output.js (main) 390 bytes >{0}< [entry] [rendered]
+ > .\example.js main
[0] ./node_modules/shared.js + 1 modules 105 bytes {1} [built]
[exports: x, y]
[only some exports used: x, y]
- harmony import shared [1] ./example.js + 2 modules 3:0-23
- harmony import shared [3] ./lazy.js + 2 modules 6:0-30
+ harmony side effect evaluation shared [1] ./example.js + 2 modules 3:0-23
+ harmony export imported specifier shared [1] ./example.js + 2 modules 3:0-23
+ harmony side effect evaluation shared [3] ./lazy.js + 2 modules 6:0-30
+ harmony export imported specifier shared [3] ./lazy.js + 2 modules 6:0-30
+ harmony export imported specifier shared [3] ./lazy.js + 2 modules 6:0-30
+ | 2 modules
[1] ./example.js + 2 modules 285 bytes {1} [built]
[no exports]
+ single entry .\example.js main
+ | ./example.js 167 bytes [built]
+ | [no exports]
+ | single entry .\example.js main
+ | + 2 hidden modules
```
-## Minimized (uglify-js, no zip)
+## Production mode
```
-Hash: 6596ce0a50ccbbaa89c6
-Version: webpack 3.5.1
+Hash: 0a1b2c3d4e5f6a7b8c9d
+Version: webpack 4.0.0-beta.2
Asset Size Chunks Chunk Names
-0.output.js 364 bytes 0 [emitted]
- output.js 1.66 kB 1 [emitted] main
+0.output.js 362 bytes 0 [emitted]
+ output.js 1.8 KiB 1 [emitted] main
Entrypoint main = output.js
-chunk {0} 0.output.js 286 bytes {1} [rendered]
- > [] 4:0-16
+chunk {0} 0.output.js 286 bytes <{1}> [rendered]
+ > ./lazy [] 4:0-16
[3] ./lazy.js + 2 modules 242 bytes {0} [built]
[exports: d, c, x, y]
- import() ./lazy [] ./example.js 4:0-16
+ import() ./lazy ./example.js 4:0-16
+ | ./lazy.js 60 bytes [built]
+ | [exports: d, c, x, y]
+ | import() ./lazy ./example.js 4:0-16
+ | + 2 hidden modules
+ 1 hidden module
-chunk {1} output.js (main) 390 bytes [entry] [rendered]
- > main []
+chunk {1} output.js (main) 390 bytes >{0}< [entry] [rendered]
+ > .\example.js main
[0] ./node_modules/shared.js + 1 modules 105 bytes {1} [built]
[exports: x, y]
[only some exports used: x, y]
- harmony import shared [1] ./example.js + 2 modules 3:0-23
- harmony import shared [3] ./lazy.js + 2 modules 6:0-30
+ harmony side effect evaluation shared [1] ./example.js + 2 modules 3:0-23
+ harmony export imported specifier shared [1] ./example.js + 2 modules 3:0-23
+ harmony side effect evaluation shared [3] ./lazy.js + 2 modules 6:0-30
+ harmony export imported specifier shared [3] ./lazy.js + 2 modules 6:0-30
+ harmony export imported specifier shared [3] ./lazy.js + 2 modules 6:0-30
+ | 2 modules
[1] ./example.js + 2 modules 285 bytes {1} [built]
[no exports]
+ single entry .\example.js main
+ | ./example.js 167 bytes [built]
+ | [no exports]
+ | single entry .\example.js main
+ | + 2 hidden modules
```
diff --git a/examples/scope-hoisting/template.md b/examples/scope-hoisting/template.md
index ff01791a..2aaf5408 100644
--- a/examples/scope-hoisting/template.md
+++ b/examples/scope-hoisting/template.md
@@ -85,34 +85,34 @@ While module concatentation identifiers in modules are renamed to avoid conflict
-# js/output.js
+# dist/output.js
``` javascript
-{{js/output.js}}
+{{dist/output.js}}
```
-# js/0.output.js
+# dist/0.output.js
``` javascript
-{{js/0.output.js}}
+{{dist/0.output.js}}
```
Minimized
``` javascript
-{{min:js/0.output.js}}
+{{production:dist/0.output.js}}
```
# Info
-## Uncompressed
+## Unoptimized
```
{{stdout}}
```
-## Minimized (uglify-js, no zip)
+## Production mode
```
-{{min:stdout}}
+{{production:stdout}}
```
diff --git a/examples/scope-hoisting/webpack.config.js b/examples/scope-hoisting/webpack.config.js
index da883a7c..4bb808aa 100644
--- a/examples/scope-hoisting/webpack.config.js
+++ b/examples/scope-hoisting/webpack.config.js
@@ -1,7 +1,8 @@
-var webpack = require("../../");
-
module.exports = {
- plugins: [
- new webpack.optimize.ModuleConcatenationPlugin()
- ]
+ // mode: "development" || "production",
+ optimization: {
+ usedExports: true,
+ concatenateModules: true,
+ occurrenceOrder: true // To keep filename consistent between different modes (for example building only)
+ }
};
diff --git a/examples/side-effects/README.md b/examples/side-effects/README.md
new file mode 100644
index 00000000..47922433
--- /dev/null
+++ b/examples/side-effects/README.md
@@ -0,0 +1,330 @@
+This example shows how the `sideEffects` flag for library authors works.
+
+The example contains a large library, `big-module`. `big-module` contains multiple child modules: `a`, `b` and `c`. The exports from the child modules are re-exported in the entry module (`index.js`) of the library. A consumer uses **some** of the exports, importing them from the library via `import { a, b } from "big-module"`. According to the EcmaScript spec, all child modules _must_ be evaluated because they could contain side effects.
+
+The `"sideEffects": false` flag in `big-module`'s `package.json` indicates that the package's modules have no side effects (on evaluation) and only expose exports. This allows tools like webpack to optimize re-exports. In the case `import { a, b } from "big-module-with-flag"` is rewritten to `import { a } from "big-module-with-flag/a"; import { b } from "big-module-with-flag/b"`.
+
+The example contains two variants of `big-module`. `big-module` has no `sideEffects` flag and `big-module-with-flag` has the `sideEffects` flag. The example client imports `a` and `b` from each of the variants.
+
+After being built by webpack, the output bundle contains `index.js` `a.js` `b.js` `c.js` from `big-module`, but only `a.js` and `b.js` from `big-module-with-flag`.
+
+Advantages:
+
+* Smaller bundles
+* Faster bootup
+
+# example.js
+
+``` javascript
+import { a as a1, b as b1 } from "big-module";
+import { a as a2, b as b2 } from "big-module-with-flag";
+
+console.log(
+ a1,
+ b1,
+ a2,
+ b2
+);
+```
+
+# node_modules/big-module/package.json
+
+``` javascript
+{
+ "name": "big-module"
+}
+```
+
+# node_modules/big-module-with-flag/package.json
+
+``` javascript
+{
+ "name": "big-module-with-flag",
+ "sideEffects": false
+}
+```
+
+# node_modules/big-module(-with-flag)/index.js
+
+``` javascript
+export { a } from "./a";
+export { b } from "./b";
+export { c } from "./c";
+```
+
+# dist/output.js
+
+<details><summary><code>/******/ (function(modules) { /* webpackBootstrap */ })</code></summary>
+
+``` javascript
+/******/ (function(modules) { // webpackBootstrap
+/******/ // The module cache
+/******/ var installedModules = {};
+/******/
+/******/ // The require function
+/******/ function __webpack_require__(moduleId) {
+/******/
+/******/ // Check if module is in cache
+/******/ if(installedModules[moduleId]) {
+/******/ return installedModules[moduleId].exports;
+/******/ }
+/******/ // Create a new module (and put it into the cache)
+/******/ var module = installedModules[moduleId] = {
+/******/ i: moduleId,
+/******/ l: false,
+/******/ exports: {}
+/******/ };
+/******/
+/******/ // Execute the module function
+/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
+/******/
+/******/ // Flag the module as loaded
+/******/ module.l = true;
+/******/
+/******/ // Return the exports of the module
+/******/ return module.exports;
+/******/ }
+/******/
+/******/
+/******/ // expose the modules object (__webpack_modules__)
+/******/ __webpack_require__.m = modules;
+/******/
+/******/ // expose the module cache
+/******/ __webpack_require__.c = installedModules;
+/******/
+/******/ // define getter function for harmony exports
+/******/ __webpack_require__.d = function(exports, name, getter) {
+/******/ if(!__webpack_require__.o(exports, name)) {
+/******/ Object.defineProperty(exports, name, {
+/******/ configurable: false,
+/******/ enumerable: true,
+/******/ get: getter
+/******/ });
+/******/ }
+/******/ };
+/******/
+/******/ // define __esModule on exports
+/******/ __webpack_require__.r = function(exports) {
+/******/ Object.defineProperty(exports, '__esModule', { value: true });
+/******/ };
+/******/
+/******/ // getDefaultExport function for compatibility with non-harmony modules
+/******/ __webpack_require__.n = function(module) {
+/******/ var getter = module && module.__esModule ?
+/******/ function getDefault() { return module['default']; } :
+/******/ function getModuleExports() { return module; };
+/******/ __webpack_require__.d(getter, 'a', getter);
+/******/ return getter;
+/******/ };
+/******/
+/******/ // Object.prototype.hasOwnProperty.call
+/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
+/******/
+/******/ // __webpack_public_path__
+/******/ __webpack_require__.p = "dist/";
+/******/
+/******/
+/******/ // Load entry module and return exports
+/******/ return __webpack_require__(__webpack_require__.s = 0);
+/******/ })
+/************************************************************************/
+```
+
+</details>
+
+``` javascript
+/******/ ([
+/* 0 */
+/*!********************!*\
+ !*** ./example.js ***!
+ \********************/
+/*! no exports provided */
+/***/ (function(module, __webpack_exports__, __webpack_require__) {
+
+"use strict";
+__webpack_require__.r(__webpack_exports__);
+/* harmony import */ var big_module__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! big-module */ 1);
+/* harmony import */ var big_module_with_flag__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! big-module-with-flag */ 5);
+
+
+
+console.log(
+ big_module__WEBPACK_IMPORTED_MODULE_0__["a"],
+ big_module__WEBPACK_IMPORTED_MODULE_0__["b"],
+ big_module_with_flag__WEBPACK_IMPORTED_MODULE_1__["a"],
+ big_module_with_flag__WEBPACK_IMPORTED_MODULE_1__["b"]
+);
+
+
+/***/ }),
+/* 1 */
+/*!******************************************!*\
+ !*** ./node_modules/big-module/index.js ***!
+ \******************************************/
+/*! exports provided: a, b, c */
+/***/ (function(module, __webpack_exports__, __webpack_require__) {
+
+"use strict";
+__webpack_require__.r(__webpack_exports__);
+/* harmony import */ var _a__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./a */ 2);
+/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _a__WEBPACK_IMPORTED_MODULE_0__["a"]; });
+
+/* harmony import */ var _b__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./b */ 3);
+/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "b", function() { return _b__WEBPACK_IMPORTED_MODULE_1__["b"]; });
+
+/* harmony import */ var _c__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./c */ 4);
+/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "c", function() { return _c__WEBPACK_IMPORTED_MODULE_2__["c"]; });
+
+
+
+
+
+
+/***/ }),
+/* 2 */
+/*!**************************************!*\
+ !*** ./node_modules/big-module/a.js ***!
+ \**************************************/
+/*! exports provided: a */
+/***/ (function(module, __webpack_exports__, __webpack_require__) {
+
+"use strict";
+__webpack_require__.r(__webpack_exports__);
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return a; });
+const a = "a";
+
+
+/***/ }),
+/* 3 */
+/*!**************************************!*\
+ !*** ./node_modules/big-module/b.js ***!
+ \**************************************/
+/*! exports provided: b */
+/***/ (function(module, __webpack_exports__, __webpack_require__) {
+
+"use strict";
+__webpack_require__.r(__webpack_exports__);
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return b; });
+const b = "b";
+
+
+/***/ }),
+/* 4 */
+/*!**************************************!*\
+ !*** ./node_modules/big-module/c.js ***!
+ \**************************************/
+/*! exports provided: c */
+/***/ (function(module, __webpack_exports__, __webpack_require__) {
+
+"use strict";
+__webpack_require__.r(__webpack_exports__);
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return c; });
+const c = "c";
+
+
+/***/ }),
+/* 5 */
+/*!****************************************************!*\
+ !*** ./node_modules/big-module-with-flag/index.js ***!
+ \****************************************************/
+/*! exports provided: a, b, c */
+/***/ (function(module, __webpack_exports__, __webpack_require__) {
+
+"use strict";
+__webpack_require__.r(__webpack_exports__);
+/* harmony import */ var _a__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./a */ 6);
+/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _a__WEBPACK_IMPORTED_MODULE_0__["a"]; });
+
+/* harmony import */ var _b__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./b */ 7);
+/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "b", function() { return _b__WEBPACK_IMPORTED_MODULE_1__["b"]; });
+
+/* harmony import */ var _c__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./c */ 8);
+/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "c", function() { return _c__WEBPACK_IMPORTED_MODULE_2__["c"]; });
+
+
+
+
+
+
+/***/ }),
+/* 6 */
+/*!************************************************!*\
+ !*** ./node_modules/big-module-with-flag/a.js ***!
+ \************************************************/
+/*! exports provided: a */
+/***/ (function(module, __webpack_exports__, __webpack_require__) {
+
+"use strict";
+__webpack_require__.r(__webpack_exports__);
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return a; });
+const a = "a";
+
+
+/***/ }),
+/* 7 */
+/*!************************************************!*\
+ !*** ./node_modules/big-module-with-flag/b.js ***!
+ \************************************************/
+/*! exports provided: b */
+/***/ (function(module, __webpack_exports__, __webpack_require__) {
+
+"use strict";
+__webpack_require__.r(__webpack_exports__);
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return b; });
+const b = "b";
+
+
+/***/ }),
+/* 8 */
+/*!************************************************!*\
+ !*** ./node_modules/big-module-with-flag/c.js ***!
+ \************************************************/
+/*! exports provided: c */
+/***/ (function(module, __webpack_exports__, __webpack_require__) {
+
+"use strict";
+__webpack_require__.r(__webpack_exports__);
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return c; });
+const c = "c";
+
+
+/***/ })
+/******/ ]);
+```
+
+# Info
+
+## Unoptimized
+
+```
+Hash: 0a1b2c3d4e5f6a7b8c9d
+Version: webpack 4.0.0-beta.2
+ Asset Size Chunks Chunk Names
+output.js 7.91 KiB 0 [emitted] main
+Entrypoint main = output.js
+chunk {0} output.js (main) 443 bytes [entry] [rendered]
+ > .\example.js main
+ [0] ./example.js 149 bytes {0} [built]
+ [no exports]
+ single entry .\example.js main
+ + 8 hidden modules
+```
+
+## Production mode
+
+```
+Hash: 0a1b2c3d4e5f6a7b8c9d
+Version: webpack 4.0.0-beta.2
+ Asset Size Chunks Chunk Names
+output.js 600 bytes 0 [emitted] main
+Entrypoint main = output.js
+chunk {0} output.js (main) 342 bytes [entry] [rendered]
+ > .\example.js main
+ [0] ./example.js + 6 modules 342 bytes {0} [built]
+ [no exports]
+ single entry .\example.js main
+ | ./example.js 149 bytes [built]
+ | [no exports]
+ | single entry .\example.js main
+ | + 6 hidden modules
+```
diff --git a/examples/css-bundle/build.js b/examples/side-effects/build.js
similarity index 100%
rename from examples/css-bundle/build.js
rename to examples/side-effects/build.js
diff --git a/examples/side-effects/example.js b/examples/side-effects/example.js
new file mode 100644
index 00000000..e4ed16e7
--- /dev/null
+++ b/examples/side-effects/example.js
@@ -0,0 +1,9 @@
+import { a as a1, b as b1 } from "big-module";
+import { a as a2, b as b2 } from "big-module-with-flag";
+
+console.log(
+ a1,
+ b1,
+ a2,
+ b2
+);
diff --git a/examples/side-effects/node_modules/big-module-with-flag/a.js b/examples/side-effects/node_modules/big-module-with-flag/a.js
new file mode 100644
index 00000000..9233cce2
--- /dev/null
+++ b/examples/side-effects/node_modules/big-module-with-flag/a.js
@@ -0,0 +1 @@
+export const a = "a";
diff --git a/examples/side-effects/node_modules/big-module-with-flag/b.js b/examples/side-effects/node_modules/big-module-with-flag/b.js
new file mode 100644
index 00000000..59d16899
--- /dev/null
+++ b/examples/side-effects/node_modules/big-module-with-flag/b.js
@@ -0,0 +1 @@
+export const b = "b";
diff --git a/examples/side-effects/node_modules/big-module-with-flag/c.js b/examples/side-effects/node_modules/big-module-with-flag/c.js
new file mode 100644
index 00000000..7f2cfac7
--- /dev/null
+++ b/examples/side-effects/node_modules/big-module-with-flag/c.js
@@ -0,0 +1 @@
+export const c = "c";
diff --git a/examples/side-effects/node_modules/big-module-with-flag/index.js b/examples/side-effects/node_modules/big-module-with-flag/index.js
new file mode 100644
index 00000000..4cf0c721
--- /dev/null
+++ b/examples/side-effects/node_modules/big-module-with-flag/index.js
@@ -0,0 +1,3 @@
+export { a } from "./a";
+export { b } from "./b";
+export { c } from "./c";
diff --git a/examples/side-effects/node_modules/big-module-with-flag/package.json b/examples/side-effects/node_modules/big-module-with-flag/package.json
new file mode 100644
index 00000000..5f16b9c5
--- /dev/null
+++ b/examples/side-effects/node_modules/big-module-with-flag/package.json
@@ -0,0 +1,4 @@
+{
+ "name": "big-module-with-flag",
+ "sideEffects": false
+}
diff --git a/examples/side-effects/node_modules/big-module/a.js b/examples/side-effects/node_modules/big-module/a.js
new file mode 100644
index 00000000..9233cce2
--- /dev/null
+++ b/examples/side-effects/node_modules/big-module/a.js
@@ -0,0 +1 @@
+export const a = "a";
diff --git a/examples/side-effects/node_modules/big-module/b.js b/examples/side-effects/node_modules/big-module/b.js
new file mode 100644
index 00000000..59d16899
--- /dev/null
+++ b/examples/side-effects/node_modules/big-module/b.js
@@ -0,0 +1 @@
+export const b = "b";
diff --git a/examples/side-effects/node_modules/big-module/c.js b/examples/side-effects/node_modules/big-module/c.js
new file mode 100644
index 00000000..7f2cfac7
--- /dev/null
+++ b/examples/side-effects/node_modules/big-module/c.js
@@ -0,0 +1 @@
+export const c = "c";
diff --git a/examples/side-effects/node_modules/big-module/index.js b/examples/side-effects/node_modules/big-module/index.js
new file mode 100644
index 00000000..4cf0c721
--- /dev/null
+++ b/examples/side-effects/node_modules/big-module/index.js
@@ -0,0 +1,3 @@
+export { a } from "./a";
+export { b } from "./b";
+export { c } from "./c";
diff --git a/examples/side-effects/node_modules/big-module/package.json b/examples/side-effects/node_modules/big-module/package.json
new file mode 100644
index 00000000..5a24f646
--- /dev/null
+++ b/examples/side-effects/node_modules/big-module/package.json
@@ -0,0 +1,3 @@
+{
+ "name": "big-module"
+}
diff --git a/examples/side-effects/template.md b/examples/side-effects/template.md
new file mode 100644
index 00000000..de9f3015
--- /dev/null
+++ b/examples/side-effects/template.md
@@ -0,0 +1,58 @@
+This example shows how the `sideEffects` flag for library authors works.
+
+The example contains a large library, `big-module`. `big-module` contains multiple child modules: `a`, `b` and `c`. The exports from the child modules are re-exported in the entry module (`index.js`) of the library. A consumer uses **some** of the exports, importing them from the library via `import { a, b } from "big-module"`. According to the EcmaScript spec, all child modules _must_ be evaluated because they could contain side effects.
+
+The `"sideEffects": false` flag in `big-module`'s `package.json` indicates that the package's modules have no side effects (on evaluation) and only expose exports. This allows tools like webpack to optimize re-exports. In the case `import { a, b } from "big-module-with-flag"` is rewritten to `import { a } from "big-module-with-flag/a"; import { b } from "big-module-with-flag/b"`.
+
+The example contains two variants of `big-module`. `big-module` has no `sideEffects` flag and `big-module-with-flag` has the `sideEffects` flag. The example client imports `a` and `b` from each of the variants.
+
+After being built by webpack, the output bundle contains `index.js` `a.js` `b.js` `c.js` from `big-module`, but only `a.js` and `b.js` from `big-module-with-flag`.
+
+Advantages:
+
+* Smaller bundles
+* Faster bootup
+
+# example.js
+
+``` javascript
+{{example.js}}
+```
+
+# node_modules/big-module/package.json
+
+``` javascript
+{{node_modules/big-module/package.json}}
+```
+
+# node_modules/big-module-with-flag/package.json
+
+``` javascript
+{{node_modules/big-module-with-flag/package.json}}
+```
+
+# node_modules/big-module(-with-flag)/index.js
+
+``` javascript
+{{node_modules/big-module-with-flag/index.js}}
+```
+
+# dist/output.js
+
+``` javascript
+{{dist/output.js}}
+```
+
+# Info
+
+## Unoptimized
+
+```
+{{stdout}}
+```
+
+## Production mode
+
+```
+{{production:stdout}}
+```
diff --git a/examples/source-map/README.md b/examples/source-map/README.md
index 5535de98..7b106ca0 100644
--- a/examples/source-map/README.md
+++ b/examples/source-map/README.md
@@ -20,7 +20,6 @@ race = (winner, runners...) ->
``` javascript
var path = require("path");
-var webpack = require("../../");
module.exports = [
"cheap-eval-source-map",
@@ -34,17 +33,18 @@ module.exports = [
"nosources-source-map",
"source-map",
].map(devtool => ({
+ mode: "development",
entry: {
bundle: "coffee-loader!./example.coffee",
},
output: {
- path: path.join(__dirname, "js"),
+ path: path.join(__dirname, "dist"),
filename: `./[name]-${devtool}.js`,
},
devtool,
- plugins: [
- new webpack.optimize.CommonsChunkPlugin(["manifest"]),
- ],
+ optimization: {
+ runtimeChunk: true
+ }
}));
```
@@ -52,13 +52,12 @@ module.exports = [
## source-map.js and source-map.js.map
``` javascript
-webpackJsonp([0],[
+(window["webpackJsonp"] = window["webpackJsonp"] || []).push([[0],[
/* 0 */
/*!*************************************************************!*\
!*** (webpack)/node_modules/coffee-loader!./example.coffee ***!
\*************************************************************/
/*! no static exports found */
-/*! all exports used */
/***/ (function(module, exports) {
var math, race,
@@ -80,23 +79,22 @@ race = function() {
/***/ })
-],[0]);
+],[[0,1]]]);
//# sourceMappingURL=bundle-source-map.js.map
```
``` javascript
-{"version":3,"sources":["webpack:///./example.coffee"],"names":[],"mappings":";;;;;;;;;AAGA;EAAA;;AAAA,OACE;EAAA,MAAQ,IAAI,CAAC,IAAb;EACA,QAAQ,MADR;EAEA,MAAQ,SAAC,CAAD;WAAO,IAAI,OAAO,CAAP;EAAX,CAFR;;;AAKF,OAAO;AACL;EADM,uBAAQ;SACd,MAAM,MAAN,EAAc,OAAd;AADK","file":"./bundle-source-map.js","sourcesContent":["# Taken from http://coffeescript.org/\r\n\r\n# Objects:\r\nmath =\r\n root: Math.sqrt\r\n square: square\r\n cube: (x) -> x * square x\r\n\r\n# Splats:\r\nrace = (winner, runners...) ->\r\n print winner, runners\r\n\n\n\n// WEBPACK FOOTER //\n// ./example.coffee"],"sourceRoot":""}
+{"version":3,"sources":["webpack:///./example.coffee"],"names":[],"mappings":";;;;;;;;AAGA;EAAA;;AAAA,OACE;EAAA,MAAQ,IAAI,CAAC,IAAb;EACA,QAAQ,MADR;EAEA,MAAQ,SAAC,CAAD;WAAO,IAAI,OAAO,CAAP;EAAX,CAFR;;;AAKF,OAAO;AACL;EADM,uBAAQ;SACd,MAAM,MAAN,EAAc,OAAd;AADK","file":"./bundle-source-map.js","sourcesContent":["# Taken from http://coffeescript.org/\r\n\r\n# Objects:\r\nmath =\r\n root: Math.sqrt\r\n square: square\r\n cube: (x) -> x * square x\r\n\r\n# Splats:\r\nrace = (winner, runners...) ->\r\n print winner, runners\r\n"],"sourceRoot":""}
```
## hidden-source-map.js and hidden-source-map.js.map
``` javascript
-webpackJsonp([0],[
+(window["webpackJsonp"] = window["webpackJsonp"] || []).push([[0],[
/* 0 */
/*!*************************************************************!*\
!*** (webpack)/node_modules/coffee-loader!./example.coffee ***!
\*************************************************************/
/*! no static exports found */
-/*! all exports used */
/***/ (function(module, exports) {
var math, race,
@@ -118,22 +116,21 @@ race = function() {
/***/ })
-],[0]);
+],[[0,1]]]);
```
``` javascript
-{"version":3,"sources":["webpack:///./example.coffee"],"names":[],"mappings":";;;;;;;;;AAGA;EAAA;;AAAA,OACE;EAAA,MAAQ,IAAI,CAAC,IAAb;EACA,QAAQ,MADR;EAEA,MAAQ,SAAC,CAAD;WAAO,IAAI,OAAO,CAAP;EAAX,CAFR;;;AAKF,OAAO;AACL;EADM,uBAAQ;SACd,MAAM,MAAN,EAAc,OAAd;AADK","file":"./bundle-hidden-source-map.js","sourcesContent":["# Taken from http://coffeescript.org/\r\n\r\n# Objects:\r\nmath =\r\n root: Math.sqrt\r\n square: square\r\n cube: (x) -> x * square x\r\n\r\n# Splats:\r\nrace = (winner, runners...) ->\r\n print winner, runners\r\n\n\n\n// WEBPACK FOOTER //\n// ./example.coffee"],"sourceRoot":""}
+{"version":3,"sources":["webpack:///./example.coffee"],"names":[],"mappings":";;;;;;;;AAGA;EAAA;;AAAA,OACE;EAAA,MAAQ,IAAI,CAAC,IAAb;EACA,QAAQ,MADR;EAEA,MAAQ,SAAC,CAAD;WAAO,IAAI,OAAO,CAAP;EAAX,CAFR;;;AAKF,OAAO;AACL;EADM,uBAAQ;SACd,MAAM,MAAN,EAAc,OAAd;AADK","file":"./bundle-hidden-source-map.js","sourcesContent":["# Taken from http://coffeescript.org/\r\n\r\n# Objects:\r\nmath =\r\n root: Math.sqrt\r\n square: square\r\n cube: (x) -> x * square x\r\n\r\n# Splats:\r\nrace = (winner, runners...) ->\r\n print winner, runners\r\n"],"sourceRoot":""}
```
## inline-source-map.js
``` javascript
-webpackJsonp([0],[
+(window["webpackJsonp"] = window["webpackJsonp"] || []).push([[0],[
/* 0 */
/*!*************************************************************!*\
!*** (webpack)/node_modules/coffee-loader!./example.coffee ***!
\*************************************************************/
/*! no static exports found */
-/*! all exports used */
/***/ (function(module, exports) {
var math, race,
@@ -155,206 +152,222 @@ race = function() {
/***/ })
-],[0]);
-//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly8vLi9leGFtcGxlLmNvZmZlZSJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7QUFHQTtFQUFBOztBQUFBLE9BQ0U7RUFBQSxNQUFRLElBQUksQ0FBQyxJQUFiO0VBQ0EsUUFBUSxNQURSO0VBRUEsTUFBUSxTQUFDLENBQUQ7V0FBTyxJQUFJLE9BQU8sQ0FBUDtFQUFYLENBRlI7OztBQUtGLE9BQU87QUFDTDtFQURNLHVCQUFRO1NBQ2QsTUFBTSxNQUFOLEVBQWMsT0FBZDtBQURLIiwiZmlsZSI6Ii4vYnVuZGxlLWlubGluZS1zb3VyY2UtbWFwLmpzIiwic291cmNlc0NvbnRlbnQiOlsiIyBUYWtlbiBmcm9tIGh0dHA6Ly9jb2ZmZWVzY3JpcHQub3JnL1xyXG5cclxuIyBPYmplY3RzOlxyXG5tYXRoID1cclxuICByb290OiAgIE1hdGguc3FydFxyXG4gIHNxdWFyZTogc3F1YXJlXHJcbiAgY3ViZTogICAoeCkgLT4geCAqIHNxdWFyZSB4XHJcblxyXG4jIFNwbGF0czpcclxucmFjZSA9ICh3aW5uZXIsIHJ1bm5lcnMuLi4pIC0+XHJcbiAgcHJpbnQgd2lubmVyLCBydW5uZXJzXHJcblxuXG5cbi8vIFdFQlBBQ0sgRk9PVEVSIC8vXG4vLyAuL2V4YW1wbGUuY29mZmVlIl0sInNvdXJjZVJvb3QiOiIifQ==
+],[[0,1]]]);
+//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly8vLi9leGFtcGxlLmNvZmZlZSJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7Ozs7OztBQUdBO0VBQUE7O0FBQUEsT0FDRTtFQUFBLE1BQVEsSUFBSSxDQUFDLElBQWI7RUFDQSxRQUFRLE1BRFI7RUFFQSxNQUFRLFNBQUMsQ0FBRDtXQUFPLElBQUksT0FBTyxDQUFQO0VBQVgsQ0FGUjs7O0FBS0YsT0FBTztBQUNMO0VBRE0sdUJBQVE7U0FDZCxNQUFNLE1BQU4sRUFBYyxPQUFkO0FBREsiLCJmaWxlIjoiLi9idW5kbGUtaW5saW5lLXNvdXJjZS1tYXAuanMiLCJzb3VyY2VzQ29udGVudCI6WyIjIFRha2VuIGZyb20gaHR0cDovL2NvZmZlZXNjcmlwdC5vcmcvXHJcblxyXG4jIE9iamVjdHM6XHJcbm1hdGggPVxyXG4gIHJvb3Q6ICAgTWF0aC5zcXJ0XHJcbiAgc3F1YXJlOiBzcXVhcmVcclxuICBjdWJlOiAgICh4KSAtPiB4ICogc3F1YXJlIHhcclxuXHJcbiMgU3BsYXRzOlxyXG5yYWNlID0gKHdpbm5lciwgcnVubmVycy4uLikgLT5cclxuICBwcmludCB3aW5uZXIsIHJ1bm5lcnNcclxuIl0sInNvdXJjZVJvb3QiOiIifQ==
```
## nosources-source-map.js.map
``` javascript
-{"version":3,"sources":["webpack:///./example.coffee"],"names":[],"mappings":";;;;;;;;;AAGA;EAAA;;AAAA,OACE;EAAA,MAAQ,IAAI,CAAC,IAAb;EACA,QAAQ,MADR;EAEA,MAAQ,SAAC,CAAD;WAAO,IAAI,OAAO,CAAP;EAAX,CAFR;;;AAKF,OAAO;AACL;EADM,uBAAQ;SACd,MAAM,MAAN,EAAc,OAAd;AADK","file":"./bundle-nosources-source-map.js","sourceRoot":""}
+{"version":3,"sources":["webpack:///./example.coffee"],"names":[],"mappings":";;;;;;;;AAGA;EAAA;;AAAA,OACE;EAAA,MAAQ,IAAI,CAAC,IAAb;EACA,QAAQ,MADR;EAEA,MAAQ,SAAC,CAAD;WAAO,IAAI,OAAO,CAAP;EAAX,CAFR;;;AAKF,OAAO;AACL;EADM,uBAAQ;SACd,MAAM,MAAN,EAAc,OAAd;AADK","file":"./bundle-nosources-source-map.js","sourceRoot":""}
```
## eval-source-map.js
``` javascript
-webpackJsonp([0],[
+(window["webpackJsonp"] = window["webpackJsonp"] || []).push([[0],[
/* 0 */
/*!*************************************************************!*\
!*** (webpack)/node_modules/coffee-loader!./example.coffee ***!
\*************************************************************/
/*! no static exports found */
-/*! all exports used */
/***/ (function(module, exports) {
-eval("var math, race,\n slice = [].slice;\n\nmath = {\n root: Math.sqrt,\n square: square,\n cube: function(x) {\n return x * square(x);\n }\n};\n\nrace = function() {\n var runners, winner;\n winner = arguments[0], runners = 2 <= arguments.length ? slice.call(arguments, 1) : [];\n return print(winner, runners);\n};\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly8vLi9leGFtcGxlLmNvZmZlZT85MWU1Il0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUdBO0VBQUE7O0FBQUEsT0FDRTtFQUFBLE1BQVEsSUFBSSxDQUFDLElBQWI7RUFDQSxRQUFRLE1BRFI7RUFFQSxNQUFRLFNBQUMsQ0FBRDtXQUFPLElBQUksT0FBTyxDQUFQO0VBQVgsQ0FGUjs7O0FBS0YsT0FBTztBQUNMO0VBRE0sdUJBQVE7U0FDZCxNQUFNLE1BQU4sRUFBYyxPQUFkO0FBREsiLCJmaWxlIjoiMC5qcyIsInNvdXJjZXNDb250ZW50IjpbIiMgVGFrZW4gZnJvbSBodHRwOi8vY29mZmVlc2NyaXB0Lm9yZy9cclxuXHJcbiMgT2JqZWN0czpcclxubWF0aCA9XHJcbiAgcm9vdDogICBNYXRoLnNxcnRcclxuICBzcXVhcmU6IHNxdWFyZVxyXG4gIGN1YmU6ICAgKHgpIC0+IHggKiBzcXVhcmUgeFxyXG5cclxuIyBTcGxhdHM6XHJcbnJhY2UgPSAod2lubmVyLCBydW5uZXJzLi4uKSAtPlxyXG4gIHByaW50IHdpbm5lciwgcnVubmVyc1xyXG5cblxuXG4vLyBXRUJQQUNLIEZPT1RFUiAvL1xuLy8gLi9leGFtcGxlLmNvZmZlZSJdLCJzb3VyY2VSb290IjoiIn0=\n//# sourceURL=webpack-internal:///0\n");
+eval("var math, race,\n slice = [].slice;\n\nmath = {\n root: Math.sqrt,\n square: square,\n cube: function(x) {\n return x * square(x);\n }\n};\n\nrace = function() {\n var runners, winner;\n winner = arguments[0], runners = 2 <= arguments.length ? slice.call(arguments, 1) : [];\n return print(winner, runners);\n};\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIndlYnBhY2s6Ly8vLi9leGFtcGxlLmNvZmZlZT85MWU1Il0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUdBO0VBQUE7O0FBQUEsT0FDRTtFQUFBLE1BQVEsSUFBSSxDQUFDLElBQWI7RUFDQSxRQUFRLE1BRFI7RUFFQSxNQUFRLFNBQUMsQ0FBRDtXQUFPLElBQUksT0FBTyxDQUFQO0VBQVgsQ0FGUjs7O0FBS0YsT0FBTztBQUNMO0VBRE0sdUJBQVE7U0FDZCxNQUFNLE1BQU4sRUFBYyxPQUFkO0FBREsiLCJmaWxlIjoiMC5qcyIsInNvdXJjZXNDb250ZW50IjpbIiMgVGFrZW4gZnJvbSBodHRwOi8vY29mZmVlc2NyaXB0Lm9yZy9cclxuXHJcbiMgT2JqZWN0czpcclxubWF0aCA9XHJcbiAgcm9vdDogICBNYXRoLnNxcnRcclxuICBzcXVhcmU6IHNxdWFyZVxyXG4gIGN1YmU6ICAgKHgpIC0+IHggKiBzcXVhcmUgeFxyXG5cclxuIyBTcGxhdHM6XHJcbnJhY2UgPSAod2lubmVyLCBydW5uZXJzLi4uKSAtPlxyXG4gIHByaW50IHdpbm5lciwgcnVubmVyc1xyXG4iXSwic291cmNlUm9vdCI6IiJ9\n//# sourceURL=webpack-internal:///0\n");
/***/ })
-],[0]);
+],[[0,1]]]);
```
## eval.js
``` javascript
-webpackJsonp([0],[
+(window["webpackJsonp"] = window["webpackJsonp"] || []).push([[0],[
/* 0 */
/*!*************************************************************!*\
!*** (webpack)/node_modules/coffee-loader!./example.coffee ***!
\*************************************************************/
/*! no static exports found */
-/*! all exports used */
/***/ (function(module, exports) {
-eval("var math, race,\n slice = [].slice;\n\nmath = {\n root: Math.sqrt,\n square: square,\n cube: function(x) {\n return x * square(x);\n }\n};\n\nrace = function() {\n var runners, winner;\n winner = arguments[0], runners = 2 <= arguments.length ? slice.call(arguments, 1) : [];\n return print(winner, runners);\n};\n\n\n//////////////////\n// WEBPACK FOOTER\n// (webpack)/node_modules/coffee-loader!./example.coffee\n// module id = 0\n// module chunks = 0\n\n//# sourceURL=webpack:///./example.coffee?(webpack)/node_modules/coffee-loader");
+eval("var math, race,\n slice = [].slice;\n\nmath = {\n root: Math.sqrt,\n square: square,\n cube: function(x) {\n return x * square(x);\n }\n};\n\nrace = function() {\n var runners, winner;\n winner = arguments[0], runners = 2 <= arguments.length ? slice.call(arguments, 1) : [];\n return print(winner, runners);\n};\n\n\n//# sourceURL=webpack:///./example.coffee?(webpack)/node_modules/coffee-loader");
/***/ })
-],[0]);
+],[[0,1]]]);
```
## cheap-eval-source-map.js
``` javascript
-webpackJsonp([0],[
+(window["webpackJsonp"] = window["webpackJsonp"] || []).push([[0],[
/* 0 */
/*!*************************************************************!*\
!*** (webpack)/node_modules/coffee-loader!./example.coffee ***!
\*************************************************************/
/*! no static exports found */
-/*! all exports used */
/***/ (function(module, exports) {
-eval("var math, race,\n slice = [].slice;\n\nmath = {\n root: Math.sqrt,\n square: square,\n cube: function(x) {\n return x * square(x);\n }\n};\n\nrace = function() {\n var runners, winner;\n winner = arguments[0], runners = 2 <= arguments.length ? slice.call(arguments, 1) : [];\n return print(winner, runners);\n};\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMC5qcyIsInNvdXJjZXMiOlsid2VicGFjazovLy8uL2V4YW1wbGUuY29mZmVlPzA5MjciXSwic291cmNlc0NvbnRlbnQiOlsidmFyIG1hdGgsIHJhY2UsXG4gIHNsaWNlID0gW10uc2xpY2U7XG5cbm1hdGggPSB7XG4gIHJvb3Q6IE1hdGguc3FydCxcbiAgc3F1YXJlOiBzcXVhcmUsXG4gIGN1YmU6IGZ1bmN0aW9uKHgpIHtcbiAgICByZXR1cm4geCAqIHNxdWFyZSh4KTtcbiAgfVxufTtcblxucmFjZSA9IGZ1bmN0aW9uKCkge1xuICB2YXIgcnVubmVycywgd2lubmVyO1xuICB3aW5uZXIgPSBhcmd1bWVudHNbMF0sIHJ1bm5lcnMgPSAyIDw9IGFyZ3VtZW50cy5sZW5ndGggPyBzbGljZS5jYWxsKGFyZ3VtZW50cywgMSkgOiBbXTtcbiAgcmV0dXJuIHByaW50KHdpbm5lciwgcnVubmVycyk7XG59O1xuXG5cblxuLy8vLy8vLy8vLy8vLy8vLy8vXG4vLyBXRUJQQUNLIEZPT1RFUlxuLy8gKHdlYnBhY2spL25vZGVfbW9kdWxlcy9jb2ZmZWUtbG9hZGVyIS4vZXhhbXBsZS5jb2ZmZWVcbi8vIG1vZHVsZSBpZCA9IDBcbi8vIG1vZHVsZSBjaHVua3MgPSAwIl0sIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTsiLCJzb3VyY2VSb290IjoiIn0=\n//# sourceURL=webpack-internal:///0\n");
+eval("var math, race,\n slice = [].slice;\n\nmath = {\n root: Math.sqrt,\n square: square,\n cube: function(x) {\n return x * square(x);\n }\n};\n\nrace = function() {\n var runners, winner;\n winner = arguments[0], runners = 2 <= arguments.length ? slice.call(arguments, 1) : [];\n return print(winner, runners);\n};\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMC5qcyIsInNvdXJjZXMiOlsid2VicGFjazovLy8uL2V4YW1wbGUuY29mZmVlPzA5MjciXSwic291cmNlc0NvbnRlbnQiOlsidmFyIG1hdGgsIHJhY2UsXG4gIHNsaWNlID0gW10uc2xpY2U7XG5cbm1hdGggPSB7XG4gIHJvb3Q6IE1hdGguc3FydCxcbiAgc3F1YXJlOiBzcXVhcmUsXG4gIGN1YmU6IGZ1bmN0aW9uKHgpIHtcbiAgICByZXR1cm4geCAqIHNxdWFyZSh4KTtcbiAgfVxufTtcblxucmFjZSA9IGZ1bmN0aW9uKCkge1xuICB2YXIgcnVubmVycywgd2lubmVyO1xuICB3aW5uZXIgPSBhcmd1bWVudHNbMF0sIHJ1bm5lcnMgPSAyIDw9IGFyZ3VtZW50cy5sZW5ndGggPyBzbGljZS5jYWxsKGFyZ3VtZW50cywgMSkgOiBbXTtcbiAgcmV0dXJuIHByaW50KHdpbm5lciwgcnVubmVycyk7XG59O1xuIl0sIm1hcHBpbmdzIjoiQUFBQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTsiLCJzb3VyY2VSb290IjoiIn0=\n//# sourceURL=webpack-internal:///0\n");
/***/ })
-],[0]);
+],[[0,1]]]);
```
## cheap-module-eval-source-map.js
``` javascript
-webpackJsonp([0],[
+(window["webpackJsonp"] = window["webpackJsonp"] || []).push([[0],[
/* 0 */
/*!*************************************************************!*\
!*** (webpack)/node_modules/coffee-loader!./example.coffee ***!
\*************************************************************/
/*! no static exports found */
-/*! all exports used */
/***/ (function(module, exports) {
-eval("var math, race,\n slice = [].slice;\n\nmath = {\n root: Math.sqrt,\n square: square,\n cube: function(x) {\n return x * square(x);\n }\n};\n\nrace = function() {\n var runners, winner;\n winner = arguments[0], runners = 2 <= arguments.length ? slice.call(arguments, 1) : [];\n return print(winner, runners);\n};\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMC5qcyIsInNvdXJjZXMiOlsid2VicGFjazovLy8uL2V4YW1wbGUuY29mZmVlPzkxZTUiXSwic291cmNlc0NvbnRlbnQiOlsiIyBUYWtlbiBmcm9tIGh0dHA6Ly9jb2ZmZWVzY3JpcHQub3JnL1xyXG5cclxuIyBPYmplY3RzOlxyXG5tYXRoID1cclxuICByb290OiAgIE1hdGguc3FydFxyXG4gIHNxdWFyZTogc3F1YXJlXHJcbiAgY3ViZTogICAoeCkgLT4geCAqIHNxdWFyZSB4XHJcblxyXG4jIFNwbGF0czpcclxucmFjZSA9ICh3aW5uZXIsIHJ1bm5lcnMuLi4pIC0+XHJcbiAgcHJpbnQgd2lubmVyLCBydW5uZXJzXHJcblxuXG5cbi8vIFdFQlBBQ0sgRk9PVEVSIC8vXG4vLyAuL2V4YW1wbGUuY29mZmVlIl0sIm1hcHBpbmdzIjoiQUFHQTtBQUFBO0FBQ0E7QUFEQTtBQUNBO0FBQ0E7QUFDQTtBQUFBO0FBQUE7OztBQUdBO0FBQ0E7QUFEQTtBQUNBO0FBREE7Iiwic291cmNlUm9vdCI6IiJ9\n//# sourceURL=webpack-internal:///0\n");
+eval("var math, race,\n slice = [].slice;\n\nmath = {\n root: Math.sqrt,\n square: square,\n cube: function(x) {\n return x * square(x);\n }\n};\n\nrace = function() {\n var runners, winner;\n winner = arguments[0], runners = 2 <= arguments.length ? slice.call(arguments, 1) : [];\n return print(winner, runners);\n};\n//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMC5qcyIsInNvdXJjZXMiOlsid2VicGFjazovLy8uL2V4YW1wbGUuY29mZmVlPzkxZTUiXSwic291cmNlc0NvbnRlbnQiOlsiIyBUYWtlbiBmcm9tIGh0dHA6Ly9jb2ZmZWVzY3JpcHQub3JnL1xyXG5cclxuIyBPYmplY3RzOlxyXG5tYXRoID1cclxuICByb290OiAgIE1hdGguc3FydFxyXG4gIHNxdWFyZTogc3F1YXJlXHJcbiAgY3ViZTogICAoeCkgLT4geCAqIHNxdWFyZSB4XHJcblxyXG4jIFNwbGF0czpcclxucmFjZSA9ICh3aW5uZXIsIHJ1bm5lcnMuLi4pIC0+XHJcbiAgcHJpbnQgd2lubmVyLCBydW5uZXJzXHJcbiJdLCJtYXBwaW5ncyI6IkFBR0E7QUFBQTtBQUNBO0FBREE7QUFDQTtBQUNBO0FBQ0E7QUFBQTtBQUFBOzs7QUFHQTtBQUNBO0FBREE7QUFDQTtBQURBOyIsInNvdXJjZVJvb3QiOiIifQ==\n//# sourceURL=webpack-internal:///0\n");
/***/ })
-],[0]);
+],[[0,1]]]);
```
## cheap-module-source-map.js.map
``` javascript
-{"version":3,"file":"./bundle-cheap-module-source-map.js","sources":["webpack:///./example.coffee"],"sourcesContent":["# Taken from http://coffeescript.org/\r\n\r\n# Objects:\r\nmath =\r\n root: Math.sqrt\r\n square: square\r\n cube: (x) -> x * square x\r\n\r\n# Splats:\r\nrace = (winner, runners...) ->\r\n print winner, runners\r\n\n\n\n// WEBPACK FOOTER //\n// ./example.coffee"],"mappings":";;;;;;;;;AAGA;AAAA;AACA;AADA;AACA;AACA;AACA;AAAA;AAAA;;;AAGA;AACA;AADA;AACA;AADA;;;;A","sourceRoot":""}
+{"version":3,"file":"./bundle-cheap-module-source-map.js","sources":["webpack:///./example.coffee"],"sourcesContent":["# Taken from http://coffeescript.org/\r\n\r\n# Objects:\r\nmath =\r\n root: Math.sqrt\r\n square: square\r\n cube: (x) -> x * square x\r\n\r\n# Splats:\r\nrace = (winner, runners...) ->\r\n print winner, runners\r\n"],"mappings":";;;;;;;;AAGA;AAAA;AACA;AADA;AACA;AACA;AACA;AAAA;AAAA;;;AAGA;AACA;AADA;AACA;AADA;;;;A","sourceRoot":""}
```
## cheap-source-map.js.map
``` javascript
-{"version":3,"file":"./bundle-cheap-source-map.js","sources":["webpack:///./example.coffee"],"sourcesContent":["var math, race,\n slice = [].slice;\n\nmath = {\n root: Math.sqrt,\n square: square,\n cube: function(x) {\n return x * square(x);\n }\n};\n\nrace = function() {\n var runners, winner;\n winner = arguments[0], runners = 2 <= arguments.length ? slice.call(arguments, 1) : [];\n return print(winner, runners);\n};\n\n\n\n//////////////////\n// WEBPACK FOOTER\n// (webpack)/node_modules/coffee-loader!./example.coffee\n// module id = 0\n// module chunks = 0"],"mappings":";;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;A","sourceRoot":""}
+{"version":3,"file":"./bundle-cheap-source-map.js","sources":["webpack:///./example.coffee"],"sourcesContent":["var math, race,\n slice = [].slice;\n\nmath = {\n root: Math.sqrt,\n square: square,\n cube: function(x) {\n return x * square(x);\n }\n};\n\nrace = function() {\n var runners, winner;\n winner = arguments[0], runners = 2 <= arguments.length ? slice.call(arguments, 1) : [];\n return print(winner, runners);\n};\n"],"mappings":";;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;A","sourceRoot":""}
```
# webpack output
```
-Hash: 6ee996e84863368c38e521284f8d1d322741045b5f9e187528736f9dd586ad053259eb9ee4cf69b5354b67e68d715d903c31515124d263f93c8aa7159d388dea6bd43ac605cdd4e103e888cf20eaf6f75dc2d2924e3fdc22d6889086c1479edc2c87f028
-Version: webpack 3.5.1
+Hash: 0a1b2c3d4e5f6a7b8c9d
+Version: webpack 4.0.0-beta.2
Child
- Hash: 6ee996e84863368c38e5
- Asset Size Chunks Chunk Names
- ./bundle-cheap-eval-source-map.js 1.69 kB 0 [emitted] bundle
- ./manifest-cheap-eval-source-map.js 5.8 kB 1 [emitted] manifest
- Entrypoint bundle = ./manifest-cheap-eval-source-map.js ./bundle-cheap-eval-source-map.js
- chunk {0} ./bundle-cheap-eval-source-map.js (bundle) 308 bytes {1} [initial] [rendered]
- > bundle [0] (webpack)/node_modules/coffee-loader!./example.coffee
+ Hash: 0a1b2c3d4e5f6a7b8c9d
+ Asset Size Chunks Chunk Names
+ ./bundle-cheap-eval-source-map.js 1.5 KiB 0 [emitted] bundle
+ ./runtime~bundle-cheap-eval-source-map.js 4.93 KiB 1 [emitted] runtime~bundle
+ Entrypoint bundle = ./runtime~bundle-cheap-eval-source-map.js ./bundle-cheap-eval-source-map.js
+ chunk {0} ./bundle-cheap-eval-source-map.js (bundle) 308 bytes ={1}= [initial] [rendered]
+ > coffee-loader!./example.coffee bundle
[0] (webpack)/node_modules/coffee-loader!./example.coffee 308 bytes {0} [built]
- chunk {1} ./manifest-cheap-eval-source-map.js (manifest) 0 bytes [entry] [rendered]
+ single entry coffee-loader!./example.coffee bundle
+ chunk {1} ./runtime~bundle-cheap-eval-source-map.js (runtime~bundle) 0 bytes ={0}= [entry] [rendered]
+ > coffee-loader!./example.coffee bundle
Child
- Hash: 21284f8d1d322741045b
- Asset Size Chunks Chunk Names
- ./bundle-cheap-module-eval-source-map.js 1.42 kB 0 [emitted] bundle
- ./manifest-cheap-module-eval-source-map.js 5.81 kB 1 [emitted] manifest
- Entrypoint bundle = ./manifest-cheap-module-eval-source-map.js ./bundle-cheap-module-eval-source-map.js
- chunk {0} ./bundle-cheap-module-eval-source-map.js (bundle) 308 bytes {1} [initial] [rendered]
- > bundle [0] (webpack)/node_modules/coffee-loader!./example.coffee
+ Hash: 0a1b2c3d4e5f6a7b8c9d
+ Asset Size Chunks Chunk Names
+ ./bundle-cheap-module-eval-source-map.js 1.36 KiB 0 [emitted] bundle
+ ./runtime~bundle-cheap-module-eval-source-map.js 4.93 KiB 1 [emitted] runtime~bundle
+ Entrypoint bundle = ./runtime~bundle-cheap-module-eval-source-map.js ./bundle-cheap-module-eval-source-map.js
+ chunk {0} ./bundle-cheap-module-eval-source-map.js (bundle) 308 bytes ={1}= [initial] [rendered]
+ > coffee-loader!./example.coffee bundle
[0] (webpack)/node_modules/coffee-loader!./example.coffee 308 bytes {0} [built]
- chunk {1} ./manifest-cheap-module-eval-source-map.js (manifest) 0 bytes [entry] [rendered]
+ single entry coffee-loader!./example.coffee bundle
+ chunk {1} ./runtime~bundle-cheap-module-eval-source-map.js (runtime~bundle) 0 bytes ={0}= [entry] [rendered]
+ > coffee-loader!./example.coffee bundle
Child
- Hash: 5f9e187528736f9dd586
- Asset Size Chunks Chunk Names
- ./bundle-cheap-module-source-map.js 703 bytes 0 [emitted] bundle
- ./manifest-cheap-module-source-map.js 5.87 kB 1 [emitted] manifest
- ./bundle-cheap-module-source-map.js.map 507 bytes 0 [emitted] bundle
- ./manifest-cheap-module-source-map.js.map 5.9 kB 1 [emitted] manifest
- Entrypoint bundle = ./manifest-cheap-module-source-map.js ./manifest-cheap-module-source-map.js.map ./bundle-cheap-module-source-map.js ./bundle-cheap-module-source-map.js.map
- chunk {0} ./bundle-cheap-module-source-map.js, ./bundle-cheap-module-source-map.js.map (bundle) 308 bytes {1} [initial] [rendered]
- > bundle [0] (webpack)/node_modules/coffee-loader!./example.coffee
+ Hash: 0a1b2c3d4e5f6a7b8c9d
+ Asset Size Chunks Chunk Names
+ ./bundle-cheap-module-source-map.js 733 bytes 0 [emitted] bundle
+ ./runtime~bundle-cheap-module-source-map.js 5 KiB 1 [emitted] runtime~bundle
+ ./bundle-cheap-module-source-map.js.map 459 bytes 0 [emitted] bundle
+ ./runtime~bundle-cheap-module-source-map.js.map 4.92 KiB 1 [emitted] runtime~bundle
+ Entrypoint bundle = ./runtime~bundle-cheap-module-source-map.js ./runtime~bundle-cheap-module-source-map.js.map ./bundle-cheap-module-source-map.js ./bundle-cheap-module-source-map.js.map
+ chunk {0} ./bundle-cheap-module-source-map.js, ./bundle-cheap-module-source-map.js.map (bundle) 308 bytes ={1}= [initial] [rendered]
+ > coffee-loader!./example.coffee bundle
[0] (webpack)/node_modules/coffee-loader!./example.coffee 308 bytes {0} [built]
- chunk {1} ./manifest-cheap-module-source-map.js, ./manifest-cheap-module-source-map.js.map (manifest) 0 bytes [entry] [rendered]
+ single entry coffee-loader!./example.coffee bundle
+ chunk {1} ./runtime~bundle-cheap-module-source-map.js, ./runtime~bundle-cheap-module-source-map.js.map (runtime~bundle) 0 bytes ={0}= [entry] [rendered]
+ > coffee-loader!./example.coffee bundle
Child
- Hash: ad053259eb9ee4cf69b5
- Asset Size Chunks Chunk Names
- ./bundle-cheap-source-map.js 696 bytes 0 [emitted] bundle
- ./manifest-cheap-source-map.js 5.85 kB 1 [emitted] manifest
- ./bundle-cheap-source-map.js.map 703 bytes 0 [emitted] bundle
- ./manifest-cheap-source-map.js.map 5.88 kB 1 [emitted] manifest
- Entrypoint bundle = ./manifest-cheap-source-map.js ./manifest-cheap-source-map.js.map ./bundle-cheap-source-map.js ./bundle-cheap-source-map.js.map
- chunk {0} ./bundle-cheap-source-map.js, ./bundle-cheap-source-map.js.map (bundle) 308 bytes {1} [initial] [rendered]
- > bundle [0] (webpack)/node_modules/coffee-loader!./example.coffee
+ Hash: 0a1b2c3d4e5f6a7b8c9d
+ Asset Size Chunks Chunk Names
+ ./bundle-cheap-source-map.js 726 bytes 0 [emitted] bundle
+ ./runtime~bundle-cheap-source-map.js 4.99 KiB 1 [emitted] runtime~bundle
+ ./bundle-cheap-source-map.js.map 561 bytes 0 [emitted] bundle
+ ./runtime~bundle-cheap-source-map.js.map 4.91 KiB 1 [emitted] runtime~bundle
+ Entrypoint bundle = ./runtime~bundle-cheap-source-map.js ./runtime~bundle-cheap-source-map.js.map ./bundle-cheap-source-map.js ./bundle-cheap-source-map.js.map
+ chunk {0} ./bundle-cheap-source-map.js, ./bundle-cheap-source-map.js.map (bundle) 308 bytes ={1}= [initial] [rendered]
+ > coffee-loader!./example.coffee bundle
[0] (webpack)/node_modules/coffee-loader!./example.coffee 308 bytes {0} [built]
- chunk {1} ./manifest-cheap-source-map.js, ./manifest-cheap-source-map.js.map (manifest) 0 bytes [entry] [rendered]
+ single entry coffee-loader!./example.coffee bundle
+ chunk {1} ./runtime~bundle-cheap-source-map.js, ./runtime~bundle-cheap-source-map.js.map (runtime~bundle) 0 bytes ={0}= [entry] [rendered]
+ > coffee-loader!./example.coffee bundle
Child
- Hash: 354b67e68d715d903c31
- Asset Size Chunks Chunk Names
- ./bundle-eval.js 890 bytes 0 [emitted] bundle
- ./manifest-eval.js 5.79 kB 1 [emitted] manifest
- Entrypoint bundle = ./manifest-eval.js ./bundle-eval.js
- chunk {0} ./bundle-eval.js (bundle) 308 bytes {1} [initial] [rendered]
- > bundle [0] (webpack)/node_modules/coffee-loader!./example.coffee
+ Hash: 0a1b2c3d4e5f6a7b8c9d
+ Asset Size Chunks Chunk Names
+ ./bundle-eval.js 781 bytes 0 [emitted] bundle
+ ./runtime~bundle-eval.js 4.93 KiB 1 [emitted] runtime~bundle
+ Entrypoint bundle = ./runtime~bundle-eval.js ./bundle-eval.js
+ chunk {0} ./bundle-eval.js (bundle) 308 bytes ={1}= [initial] [rendered]
+ > coffee-loader!./example.coffee bundle
[0] (webpack)/node_modules/coffee-loader!./example.coffee 308 bytes {0} [built]
- chunk {1} ./manifest-eval.js (manifest) 0 bytes [entry] [rendered]
+ single entry coffee-loader!./example.coffee bundle
+ chunk {1} ./runtime~bundle-eval.js (runtime~bundle) 0 bytes ={0}= [entry] [rendered]
+ > coffee-loader!./example.coffee bundle
Child
- Hash: 515124d263f93c8aa715
- Asset Size Chunks Chunk Names
- ./bundle-eval-source-map.js 1.56 kB 0 [emitted] bundle
- ./manifest-eval-source-map.js 5.8 kB 1 [emitted] manifest
- Entrypoint bundle = ./manifest-eval-source-map.js ./bundle-eval-source-map.js
- chunk {0} ./bundle-eval-source-map.js (bundle) 308 bytes {1} [initial] [rendered]
- > bundle [0] (webpack)/node_modules/coffee-loader!./example.coffee
+ Hash: 0a1b2c3d4e5f6a7b8c9d
+ Asset Size Chunks Chunk Names
+ ./bundle-eval-source-map.js 1.49 KiB 0 [emitted] bundle
+ ./runtime~bundle-eval-source-map.js 4.93 KiB 1 [emitted] runtime~bundle
+ Entrypoint bundle = ./runtime~bundle-eval-source-map.js ./bundle-eval-source-map.js
+ chunk {0} ./bundle-eval-source-map.js (bundle) 308 bytes ={1}= [initial] [rendered]
+ > coffee-loader!./example.coffee bundle
[0] (webpack)/node_modules/coffee-loader!./example.coffee 308 bytes {0} [built]
- chunk {1} ./manifest-eval-source-map.js (manifest) 0 bytes [entry] [rendered]
+ single entry coffee-loader!./example.coffee bundle
+ chunk {1} ./runtime~bundle-eval-source-map.js (runtime~bundle) 0 bytes ={0}= [entry] [rendered]
+ > coffee-loader!./example.coffee bundle
Child
- Hash: 9d388dea6bd43ac605cd
- Asset Size Chunks Chunk Names
- ./bundle-hidden-source-map.js 644 bytes 0 [emitted] bundle
- ./manifest-hidden-source-map.js 5.8 kB 1 [emitted] manifest
- ./bundle-hidden-source-map.js.map 604 bytes 0 [emitted] bundle
- ./manifest-hidden-source-map.js.map 5.93 kB 1 [emitted] manifest
- Entrypoint bundle = ./manifest-hidden-source-map.js ./manifest-hidden-source-map.js.map ./bundle-hidden-source-map.js ./bundle-hidden-source-map.js.map
- chunk {0} ./bundle-hidden-source-map.js, ./bundle-hidden-source-map.js.map (bundle) 308 bytes {1} [initial] [rendered]
- > bundle [0] (webpack)/node_modules/coffee-loader!./example.coffee
+ Hash: 0a1b2c3d4e5f6a7b8c9d
+ Asset Size Chunks Chunk Names
+ ./bundle-hidden-source-map.js 674 bytes 0 [emitted] bundle
+ ./runtime~bundle-hidden-source-map.js 4.93 KiB 1 [emitted] runtime~bundle
+ ./bundle-hidden-source-map.js.map 556 bytes 0 [emitted] bundle
+ ./runtime~bundle-hidden-source-map.js.map 4.96 KiB 1 [emitted] runtime~bundle
+ Entrypoint bundle = ./runtime~bundle-hidden-source-map.js ./runtime~bundle-hidden-source-map.js.map ./bundle-hidden-source-map.js ./bundle-hidden-source-map.js.map
+ chunk {0} ./bundle-hidden-source-map.js, ./bundle-hidden-source-map.js.map (bundle) 308 bytes ={1}= [initial] [rendered]
+ > coffee-loader!./example.coffee bundle
[0] (webpack)/node_modules/coffee-loader!./example.coffee 308 bytes {0} [built]
- chunk {1} ./manifest-hidden-source-map.js, ./manifest-hidden-source-map.js.map (manifest) 0 bytes [entry] [rendered]
+ single entry coffee-loader!./example.coffee bundle
+ chunk {1} ./runtime~bundle-hidden-source-map.js, ./runtime~bundle-hidden-source-map.js.map (runtime~bundle) 0 bytes ={0}= [entry] [rendered]
+ > coffee-loader!./example.coffee bundle
Child
- Hash: d4e103e888cf20eaf6f7
- Asset Size Chunks Chunk Names
- ./bundle-inline-source-map.js 1.52 kB 0 [emitted] bundle
- ./manifest-inline-source-map.js 13.8 kB 1 [emitted] manifest
- Entrypoint bundle = ./manifest-inline-source-map.js ./bundle-inline-source-map.js
- chunk {0} ./bundle-inline-source-map.js (bundle) 308 bytes {1} [initial] [rendered]
- > bundle [0] (webpack)/node_modules/coffee-loader!./example.coffee
+ Hash: 0a1b2c3d4e5f6a7b8c9d
+ Asset Size Chunks Chunk Names
+ ./bundle-inline-source-map.js 1.45 KiB 0 [emitted] bundle
+ ./runtime~bundle-inline-source-map.js 11.6 KiB 1 [emitted] runtime~bundle
+ Entrypoint bundle = ./runtime~bundle-inline-source-map.js ./bundle-inline-source-map.js
+ chunk {0} ./bundle-inline-source-map.js (bundle) 308 bytes ={1}= [initial] [rendered]
+ > coffee-loader!./example.coffee bundle
[0] (webpack)/node_modules/coffee-loader!./example.coffee 308 bytes {0} [built]
- chunk {1} ./manifest-inline-source-map.js (manifest) 0 bytes [entry] [rendered]
+ single entry coffee-loader!./example.coffee bundle
+ chunk {1} ./runtime~bundle-inline-source-map.js (runtime~bundle) 0 bytes ={0}= [entry] [rendered]
+ > coffee-loader!./example.coffee bundle
Child
- Hash: 5dc2d2924e3fdc22d688
- Asset Size Chunks Chunk Names
- ./bundle-nosources-source-map.js 700 bytes 0 [emitted] bundle
- ./manifest-nosources-source-map.js 5.86 kB 1 [emitted] manifest
- ./bundle-nosources-source-map.js.map 315 bytes 0 [emitted] bundle
- ./manifest-nosources-source-map.js.map 935 bytes 1 [emitted] manifest
- Entrypoint bundle = ./manifest-nosources-source-map.js ./manifest-nosources-source-map.js.map ./bundle-nosources-source-map.js ./bundle-nosources-source-map.js.map
- chunk {0} ./bundle-nosources-source-map.js, ./bundle-nosources-source-map.js.map (bundle) 308 bytes {1} [initial] [rendered]
- > bundle [0] (webpack)/node_modules/coffee-loader!./example.coffee
+ Hash: 0a1b2c3d4e5f6a7b8c9d
+ Asset Size Chunks Chunk Names
+ ./bundle-nosources-source-map.js 730 bytes 0 [emitted] bundle
+ ./runtime~bundle-nosources-source-map.js 5 KiB 1 [emitted] runtime~bundle
+ ./bundle-nosources-source-map.js.map 314 bytes 0 [emitted] bundle
+ ./runtime~bundle-nosources-source-map.js.map 838 bytes 1 [emitted] runtime~bundle
+ Entrypoint bundle = ./runtime~bundle-nosources-source-map.js ./runtime~bundle-nosources-source-map.js.map ./bundle-nosources-source-map.js ./bundle-nosources-source-map.js.map
+ chunk {0} ./bundle-nosources-source-map.js, ./bundle-nosources-source-map.js.map (bundle) 308 bytes ={1}= [initial] [rendered]
+ > coffee-loader!./example.coffee bundle
[0] (webpack)/node_modules/coffee-loader!./example.coffee 308 bytes {0} [built]
- chunk {1} ./manifest-nosources-source-map.js, ./manifest-nosources-source-map.js.map (manifest) 0 bytes [entry] [rendered]
+ single entry coffee-loader!./example.coffee bundle
+ chunk {1} ./runtime~bundle-nosources-source-map.js, ./runtime~bundle-nosources-source-map.js.map (runtime~bundle) 0 bytes ={0}= [entry] [rendered]
+ > coffee-loader!./example.coffee bundle
Child
- Hash: 9086c1479edc2c87f028
- Asset Size Chunks Chunk Names
- ./bundle-source-map.js 690 bytes 0 [emitted] bundle
- ./manifest-source-map.js 5.84 kB 1 [emitted] manifest
- ./bundle-source-map.js.map 597 bytes 0 [emitted] bundle
- ./manifest-source-map.js.map 5.92 kB 1 [emitted] manifest
- Entrypoint bundle = ./manifest-source-map.js ./manifest-source-map.js.map ./bundle-source-map.js ./bundle-source-map.js.map
- chunk {0} ./bundle-source-map.js, ./bundle-source-map.js.map (bundle) 308 bytes {1} [initial] [rendered]
- > bundle [0] (webpack)/node_modules/coffee-loader!./example.coffee
+ Hash: 0a1b2c3d4e5f6a7b8c9d
+ Asset Size Chunks Chunk Names
+ ./bundle-source-map.js 720 bytes 0 [emitted] bundle
+ ./runtime~bundle-source-map.js 4.99 KiB 1 [emitted] runtime~bundle
+ ./bundle-source-map.js.map 549 bytes 0 [emitted] bundle
+ ./runtime~bundle-source-map.js.map 4.95 KiB 1 [emitted] runtime~bundle
+ Entrypoint bundle = ./runtime~bundle-source-map.js ./runtime~bundle-source-map.js.map ./bundle-source-map.js ./bundle-source-map.js.map
+ chunk {0} ./bundle-source-map.js, ./bundle-source-map.js.map (bundle) 308 bytes ={1}= [initial] [rendered]
+ > coffee-loader!./example.coffee bundle
[0] (webpack)/node_modules/coffee-loader!./example.coffee 308 bytes {0} [built]
- chunk {1} ./manifest-source-map.js, ./manifest-source-map.js.map (manifest) 0 bytes [entry] [rendered]
+ single entry coffee-loader!./example.coffee bundle
+ chunk {1} ./runtime~bundle-source-map.js, ./runtime~bundle-source-map.js.map (runtime~bundle) 0 bytes ={0}= [entry] [rendered]
+ > coffee-loader!./example.coffee bundle
```
diff --git a/examples/source-map/template.md b/examples/source-map/template.md
index ea5a46f5..c28b09ed 100644
--- a/examples/source-map/template.md
+++ b/examples/source-map/template.md
@@ -16,60 +16,60 @@ This example demonstrates various types of source-maps.
## source-map.js and source-map.js.map
``` javascript
-{{js/bundle-source-map.js}}
+{{dist/bundle-source-map.js}}
```
``` javascript
-{{js/bundle-source-map.js.map}}
+{{dist/bundle-source-map.js.map}}
```
## hidden-source-map.js and hidden-source-map.js.map
``` javascript
-{{js/bundle-hidden-source-map.js}}
+{{dist/bundle-hidden-source-map.js}}
```
``` javascript
-{{js/bundle-hidden-source-map.js.map}}
+{{dist/bundle-hidden-source-map.js.map}}
```
## inline-source-map.js
``` javascript
-{{js/bundle-inline-source-map.js}}
+{{dist/bundle-inline-source-map.js}}
```
## nosources-source-map.js.map
``` javascript
-{{js/bundle-nosources-source-map.js.map}}
+{{dist/bundle-nosources-source-map.js.map}}
```
## eval-source-map.js
``` javascript
-{{js/bundle-eval-source-map.js}}
+{{dist/bundle-eval-source-map.js}}
```
## eval.js
``` javascript
-{{js/bundle-eval.js}}
+{{dist/bundle-eval.js}}
```
## cheap-eval-source-map.js
``` javascript
-{{js/bundle-cheap-eval-source-map.js}}
+{{dist/bundle-cheap-eval-source-map.js}}
```
## cheap-module-eval-source-map.js
``` javascript
-{{js/bundle-cheap-module-eval-source-map.js}}
+{{dist/bundle-cheap-module-eval-source-map.js}}
```
## cheap-module-source-map.js.map
``` javascript
-{{js/bundle-cheap-module-source-map.js.map}}
+{{dist/bundle-cheap-module-source-map.js.map}}
```
## cheap-source-map.js.map
``` javascript
-{{js/bundle-cheap-source-map.js.map}}
+{{dist/bundle-cheap-source-map.js.map}}
```
# webpack output
diff --git a/examples/source-map/webpack.config.js b/examples/source-map/webpack.config.js
index 7f0dac89..7e76cf81 100644
--- a/examples/source-map/webpack.config.js
+++ b/examples/source-map/webpack.config.js
@@ -1,5 +1,4 @@
var path = require("path");
-var webpack = require("../../");
module.exports = [
"cheap-eval-source-map",
@@ -11,17 +10,18 @@ module.exports = [
"hidden-source-map",
"inline-source-map",
"nosources-source-map",
- "source-map",
+ "source-map"
].map(devtool => ({
+ mode: "development",
entry: {
- bundle: "coffee-loader!./example.coffee",
+ bundle: "coffee-loader!./example.coffee"
},
output: {
- path: path.join(__dirname, "js"),
- filename: `./[name]-${devtool}.js`,
+ path: path.join(__dirname, "dist"),
+ filename: `./[name]-${devtool}.js`
},
devtool,
- plugins: [
- new webpack.optimize.CommonsChunkPlugin(["manifest"]),
- ],
+ optimization: {
+ runtimeChunk: true
+ }
}));
diff --git a/examples/template-common.js b/examples/template-common.js
index fb848b64..b67dbfce 100644
--- a/examples/template-common.js
+++ b/examples/template-common.js
@@ -9,14 +9,16 @@ const path = require("path");
function lessStrict(regExpStr) {
regExpStr = regExpStr
.replace(/node_modules/g, "(node_modules|~)")
- .replace(/(\\\/|\\\\)/g, "[\\/\\\\]")
+ .replace(/(\\\/|\\\\)/g, "[\\/\\\\]");
return regExpStr;
}
const runtimeRegexp = /(```\s*(?:js|javascript)\n)?(.*)(\/\*\*\*\*\*\*\/ \(function\(modules\) \{ \/\/ webpackBootstrap\n(?:.|\n)*?\n\/\*\*\*\*\*\*\/ \}\)\n\/\**\/\n)/;
const timeRegexp = /\s*Time: \d+ms/g;
+const buildAtRegexp = /\s*Built at: .+/mg;
+const hashRegexp = /Hash: [a-f0-9]+/g;
-exports.replaceBase = function replaceBase(template) {
+exports.replaceBase = (template) => {
let cwd = process.cwd();
let webpack = path.join(__dirname, "..");
@@ -35,6 +37,8 @@ exports.replaceBase = function replaceBase(template) {
.replace(webpack, "(webpack)")
.replace(webpackParent, "(webpack)/~")
.replace(timeRegexp, "")
+ .replace(buildAtRegexp, "")
+ .replace(hashRegexp, "Hash: 0a1b2c3d4e5f6a7b8c9d")
.replace(/\.chunkhash\./g, ".[chunkhash].")
.replace(runtimeRegexp, function(match) {
match = runtimeRegexp.exec(match);
@@ -42,16 +46,20 @@ exports.replaceBase = function replaceBase(template) {
const inner = match[1] ? match[1] : "``` js\n";
return prefix + "<details><summary><code>" + match[2] + "/******/ (function(modules) { /* webpackBootstrap */ })</code></summary>\n\n" + inner + match[2] + match[3] + "```\n\n</details>\n\n" + inner;
});
-}
+};
+
+exports.needResults = (template, prefix) => {
+ const regExp = prefix ? new RegExp(`\\{\\{${prefix}:`) : /\{\{/;
+ return regExp.test(template);
+};
-exports.replaceResults = function replaceResults(template, baseDir, stdout, prefix) {
- const regexp = new RegExp("\\{\\{" + (prefix ? prefix+":" : "") + "([^:\\}]+)\\}\\}", "g")
+exports.replaceResults = (template, baseDir, stdout, prefix) => {
+ const regexp = new RegExp("\\{\\{" + (prefix ? prefix + ":" : "") + "([^:\\}]+)\\}\\}", "g");
return template.replace(regexp, function(match) {
- match = match.substr(2 + (prefix ? prefix.length+1 : 0), match.length - 4 - (prefix ? prefix.length+1 : 0));
+ match = match.substr(2 + (prefix ? prefix.length + 1 : 0), match.length - 4 - (prefix ? prefix.length + 1 : 0));
if(match === "stdout")
return stdout;
return fs.readFileSync(path.join(baseDir, match), "utf-8").replace(/[\r\n]*$/, "");
});
-
-}
+};
diff --git a/examples/two-explicit-vendor-chunks/README.md b/examples/two-explicit-vendor-chunks/README.md
index 72fd9325..7db74836 100644
--- a/examples/two-explicit-vendor-chunks/README.md
+++ b/examples/two-explicit-vendor-chunks/README.md
@@ -2,8 +2,8 @@
``` javascript
var path = require("path");
-var CommonsChunkPlugin = require("../../lib/optimize/CommonsChunkPlugin");
module.exports = {
+ // mode: "development || "production",
entry: {
vendor1: ["./vendor1"],
vendor2: ["./vendor2"],
@@ -12,62 +12,37 @@ module.exports = {
pageC: "./pageC"
},
output: {
- path: path.join(__dirname, "js"),
+ path: path.join(__dirname, "dist"),
filename: "[name].js"
},
- plugins: [
- new CommonsChunkPlugin({
- names: ["vendor2", "vendor1"],
- minChunks: Infinity
- })
- ]
+ optimization: {
+ splitChunks: {
+ cacheGroups: {
+ vendor1: {
+ name: "vendor1",
+ test: "vendor1",
+ enforce: true
+ },
+ vendor2: {
+ name: "vendor2",
+ test: "vendor2",
+ enforce: true
+ }
+ }
+ }
+ }
};
```
-# js/vendor1.js
+# dist/vendor1.js
<details><summary><code>/******/ (function(modules) { /* webpackBootstrap */ })</code></summary>
``` javascript
/******/ (function(modules) { // webpackBootstrap
-/******/ // install a JSONP callback for chunk loading
-/******/ var parentJsonpFunction = window["webpackJsonp"];
-/******/ window["webpackJsonp"] = function webpackJsonpCallback(chunkIds, moreModules, executeModules) {
-/******/ // add "moreModules" to the modules object,
-/******/ // then flag all "chunkIds" as loaded and fire callback
-/******/ var moduleId, chunkId, i = 0, resolves = [], result;
-/******/ for(;i < chunkIds.length; i++) {
-/******/ chunkId = chunkIds[i];
-/******/ if(installedChunks[chunkId]) {
-/******/ resolves.push(installedChunks[chunkId][0]);
-/******/ }
-/******/ installedChunks[chunkId] = 0;
-/******/ }
-/******/ for(moduleId in moreModules) {
-/******/ if(Object.prototype.hasOwnProperty.call(moreModules, moduleId)) {
-/******/ modules[moduleId] = moreModules[moduleId];
-/******/ }
-/******/ }
-/******/ if(parentJsonpFunction) parentJsonpFunction(chunkIds, moreModules, executeModules);
-/******/ while(resolves.length) {
-/******/ resolves.shift()();
-/******/ }
-/******/ if(executeModules) {
-/******/ for(i=0; i < executeModules.length; i++) {
-/******/ result = __webpack_require__(__webpack_require__.s = executeModules[i]);
-/******/ }
-/******/ }
-/******/ return result;
-/******/ };
-/******/
/******/ // The module cache
/******/ var installedModules = {};
/******/
-/******/ // objects to store loaded and loading chunks
-/******/ var installedChunks = {
-/******/ 4: 0
-/******/ };
-/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
@@ -92,55 +67,110 @@ module.exports = {
/******/ return module.exports;
/******/ }
/******/
-/******/ // This file contains only the entry chunk.
-/******/ // The chunk loading function for additional chunks
-/******/ __webpack_require__.e = function requireEnsure(chunkId) {
-/******/ var installedChunkData = installedChunks[chunkId];
-/******/ if(installedChunkData === 0) {
-/******/ return new Promise(function(resolve) { resolve(); });
-/******/ }
/******/
-/******/ // a Promise means "currently loading".
-/******/ if(installedChunkData) {
-/******/ return installedChunkData[2];
+/******/ // expose the modules object (__webpack_modules__)
+/******/ __webpack_require__.m = modules;
+/******/
+/******/ // expose the module cache
+/******/ __webpack_require__.c = installedModules;
+/******/
+/******/ // define getter function for harmony exports
+/******/ __webpack_require__.d = function(exports, name, getter) {
+/******/ if(!__webpack_require__.o(exports, name)) {
+/******/ Object.defineProperty(exports, name, {
+/******/ configurable: false,
+/******/ enumerable: true,
+/******/ get: getter
+/******/ });
/******/ }
+/******/ };
+/******/
+/******/ // define __esModule on exports
+/******/ __webpack_require__.r = function(exports) {
+/******/ Object.defineProperty(exports, '__esModule', { value: true });
+/******/ };
/******/
-/******/ // setup Promise in chunk cache
-/******/ var promise = new Promise(function(resolve, reject) {
-/******/ installedChunkData = installedChunks[chunkId] = [resolve, reject];
-/******/ });
-/******/ installedChunkData[2] = promise;
-/******/
-/******/ // start chunk loading
-/******/ var head = document.getElementsByTagName('head')[0];
-/******/ var script = document.createElement('script');
-/******/ script.type = 'text/javascript';
-/******/ script.charset = 'utf-8';
-/******/ script.async = true;
-/******/ script.timeout = 120000;
-/******/
-/******/ if (__webpack_require__.nc) {
-/******/ script.setAttribute("nonce", __webpack_require__.nc);
+/******/ // getDefaultExport function for compatibility with non-harmony modules
+/******/ __webpack_require__.n = function(module) {
+/******/ var getter = module && module.__esModule ?
+/******/ function getDefault() { return module['default']; } :
+/******/ function getModuleExports() { return module; };
+/******/ __webpack_require__.d(getter, 'a', getter);
+/******/ return getter;
+/******/ };
+/******/
+/******/ // Object.prototype.hasOwnProperty.call
+/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
+/******/
+/******/ // __webpack_public_path__
+/******/ __webpack_require__.p = "dist/";
+/******/
+/******/
+/******/ // Load entry module and return exports
+/******/ return __webpack_require__(__webpack_require__.s = 0);
+/******/ })
+/************************************************************************/
+```
+
+</details>
+
+``` javascript
+/******/ ([
+/* 0 */
+/*!***********************!*\
+ !*** multi ./vendor1 ***!
+ \***********************/
+/*! no static exports found */
+/***/ (function(module, exports, __webpack_require__) {
+
+module.exports = __webpack_require__(/*! ./vendor1 */1);
+
+
+/***/ }),
+/* 1 */
+/*!********************!*\
+ !*** ./vendor1.js ***!
+ \********************/
+/*! no static exports found */
+/***/ (function(module, exports) {
+
+module.exports = "Vendor1";
+
+/***/ })
+/******/ ]);
+```
+
+# dist/vendor2.js
+
+``` javascript
+/******/ (function(modules) { // webpackBootstrap
+/******/ // The module cache
+/******/ var installedModules = {};
+/******/
+/******/ // The require function
+/******/ function __webpack_require__(moduleId) {
+/******/
+/******/ // Check if module is in cache
+/******/ if(installedModules[moduleId]) {
+/******/ return installedModules[moduleId].exports;
/******/ }
-/******/ script.src = __webpack_require__.p + "" + chunkId + ".js";
-/******/ var timeout = setTimeout(onScriptComplete, 120000);
-/******/ script.onerror = script.onload = onScriptComplete;
-/******/ function onScriptComplete() {
-/******/ // avoid mem leaks in IE.
-/******/ script.onerror = script.onload = null;
-/******/ clearTimeout(timeout);
-/******/ var chunk = installedChunks[chunkId];
-/******/ if(chunk !== 0) {
-/******/ if(chunk) {
-/******/ chunk[1](new Error('Loading chunk ' + chunkId + ' failed.'));
-/******/ }
-/******/ installedChunks[chunkId] = undefined;
-/******/ }
+/******/ // Create a new module (and put it into the cache)
+/******/ var module = installedModules[moduleId] = {
+/******/ i: moduleId,
+/******/ l: false,
+/******/ exports: {}
/******/ };
-/******/ head.appendChild(script);
/******/
-/******/ return promise;
-/******/ };
+/******/ // Execute the module function
+/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
+/******/
+/******/ // Flag the module as loaded
+/******/ module.l = true;
+/******/
+/******/ // Return the exports of the module
+/******/ return module.exports;
+/******/ }
+/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
@@ -159,6 +189,11 @@ module.exports = {
/******/ }
/******/ };
/******/
+/******/ // define __esModule on exports
+/******/ __webpack_require__.r = function(exports) {
+/******/ Object.defineProperty(exports, '__esModule', { value: true });
+/******/ };
+/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
@@ -172,183 +207,276 @@ module.exports = {
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
-/******/ __webpack_require__.p = "js/";
+/******/ __webpack_require__.p = "dist/";
/******/
-/******/ // on error function for async loading
-/******/ __webpack_require__.oe = function(err) { console.error(err); throw err; };
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 2);
/******/ })
/************************************************************************/
-```
-
-</details>
-
-``` javascript
/******/ ([
-/* 0 */
+/* 0 */,
+/* 1 */
/*!********************!*\
!*** ./vendor1.js ***!
\********************/
/*! no static exports found */
-/*! all exports used */
/***/ (function(module, exports) {
module.exports = "Vendor1";
/***/ }),
-/* 1 */,
/* 2 */
/*!***********************!*\
- !*** multi ./vendor1 ***!
+ !*** multi ./vendor2 ***!
\***********************/
/*! no static exports found */
-/*! all exports used */
/***/ (function(module, exports, __webpack_require__) {
-module.exports = __webpack_require__(/*! ./vendor1 */0);
+module.exports = __webpack_require__(/*! ./vendor2 */3);
+
+
+/***/ }),
+/* 3 */
+/*!********************!*\
+ !*** ./vendor2.js ***!
+ \********************/
+/*! no static exports found */
+/***/ (function(module, exports, __webpack_require__) {
+
+module.exports = "Vendor2";
+__webpack_require__(/*! ./vendor1 */ 1);
/***/ })
/******/ ]);
```
-# js/vendor2.js
+# dist/pageA.js
``` javascript
-webpackJsonp([0],[
+/******/ (function(modules) { // webpackBootstrap
+/******/ // The module cache
+/******/ var installedModules = {};
+/******/
+/******/ // The require function
+/******/ function __webpack_require__(moduleId) {
+/******/
+/******/ // Check if module is in cache
+/******/ if(installedModules[moduleId]) {
+/******/ return installedModules[moduleId].exports;
+/******/ }
+/******/ // Create a new module (and put it into the cache)
+/******/ var module = installedModules[moduleId] = {
+/******/ i: moduleId,
+/******/ l: false,
+/******/ exports: {}
+/******/ };
+/******/
+/******/ // Execute the module function
+/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
+/******/
+/******/ // Flag the module as loaded
+/******/ module.l = true;
+/******/
+/******/ // Return the exports of the module
+/******/ return module.exports;
+/******/ }
+/******/
+/******/
+/******/ // expose the modules object (__webpack_modules__)
+/******/ __webpack_require__.m = modules;
+/******/
+/******/ // expose the module cache
+/******/ __webpack_require__.c = installedModules;
+/******/
+/******/ // define getter function for harmony exports
+/******/ __webpack_require__.d = function(exports, name, getter) {
+/******/ if(!__webpack_require__.o(exports, name)) {
+/******/ Object.defineProperty(exports, name, {
+/******/ configurable: false,
+/******/ enumerable: true,
+/******/ get: getter
+/******/ });
+/******/ }
+/******/ };
+/******/
+/******/ // define __esModule on exports
+/******/ __webpack_require__.r = function(exports) {
+/******/ Object.defineProperty(exports, '__esModule', { value: true });
+/******/ };
+/******/
+/******/ // getDefaultExport function for compatibility with non-harmony modules
+/******/ __webpack_require__.n = function(module) {
+/******/ var getter = module && module.__esModule ?
+/******/ function getDefault() { return module['default']; } :
+/******/ function getModuleExports() { return module; };
+/******/ __webpack_require__.d(getter, 'a', getter);
+/******/ return getter;
+/******/ };
+/******/
+/******/ // Object.prototype.hasOwnProperty.call
+/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
+/******/
+/******/ // __webpack_public_path__
+/******/ __webpack_require__.p = "dist/";
+/******/
+/******/
+/******/ // Load entry module and return exports
+/******/ return __webpack_require__(__webpack_require__.s = 4);
+/******/ })
+/************************************************************************/
+/******/ ([
/* 0 */,
/* 1 */
/*!********************!*\
- !*** ./vendor2.js ***!
+ !*** ./vendor1.js ***!
\********************/
/*! no static exports found */
-/*! all exports used */
-/***/ (function(module, exports, __webpack_require__) {
-
-module.exports = "Vendor2";
-__webpack_require__(/*! ./vendor1 */ 0);
+/***/ (function(module, exports) {
+module.exports = "Vendor1";
/***/ }),
/* 2 */,
/* 3 */
-/*!***********************!*\
- !*** multi ./vendor2 ***!
- \***********************/
+/*!********************!*\
+ !*** ./vendor2.js ***!
+ \********************/
/*! no static exports found */
-/*! all exports used */
/***/ (function(module, exports, __webpack_require__) {
-module.exports = __webpack_require__(/*! ./vendor2 */1);
-
-
-/***/ })
-],[3]);
-```
-
-# js/pageA.js
+module.exports = "Vendor2";
+__webpack_require__(/*! ./vendor1 */ 1);
-``` javascript
-webpackJsonp([3],{
-/***/ 4:
+/***/ }),
+/* 4 */
/*!******************!*\
!*** ./pageA.js ***!
\******************/
/*! no static exports found */
-/*! all exports used */
/***/ (function(module, exports, __webpack_require__) {
module.exports = "pageA";
-__webpack_require__(/*! ./vendor1 */ 0);
-__webpack_require__(/*! ./vendor2 */ 1);
+__webpack_require__(/*! ./vendor1 */ 1);
+__webpack_require__(/*! ./vendor2 */ 3);
/***/ })
-
-},[4]);
+/******/ ]);
```
# Info
-## Uncompressed
+## Unoptimized
```
-Hash: 87020004ae57cbfa3361
-Version: webpack 3.5.1
- Asset Size Chunks Chunk Names
-vendor2.js 598 bytes 0 [emitted] vendor2
- pageC.js 235 bytes 1 [emitted] pageC
- pageB.js 235 bytes 2 [emitted] pageB
- pageA.js 342 bytes 3 [emitted] pageA
-vendor1.js 6.41 kB 4 [emitted] vendor1
+Hash: 0a1b2c3d4e5f6a7b8c9d
+Version: webpack 4.0.0-beta.2
+ Asset Size Chunks Chunk Names
+vendor1.js 2.99 KiB 0 [emitted] vendor1
+vendor2.js 3.25 KiB 1 [emitted] vendor2
+ pageA.js 3.3 KiB 2 [emitted] pageA
+ pageB.js 2.74 KiB 3 [emitted] pageB
+ pageC.js 2.74 KiB 4 [emitted] pageC
Entrypoint vendor1 = vendor1.js
-Entrypoint vendor2 = vendor1.js vendor2.js
-Entrypoint pageA = vendor1.js vendor2.js pageA.js
-Entrypoint pageB = vendor1.js vendor2.js pageB.js
-Entrypoint pageC = vendor1.js vendor2.js pageC.js
-chunk {0} vendor2.js (vendor2) 80 bytes {4} [initial] [rendered]
- > vendor2 [3] multi ./vendor2
- [1] ./vendor2.js 52 bytes {0} [built]
- single entry ./vendor2 [3] multi ./vendor2 vendor2:100000
+Entrypoint vendor2 = vendor2.js
+Entrypoint pageA = pageA.js
+Entrypoint pageB = pageB.js
+Entrypoint pageC = pageC.js
+chunk {0} vendor1.js (vendor1) 55 bytes [entry] [rendered]
+ > vendor1
+ [0] multi ./vendor1 28 bytes {0} [built]
+ multi entry
+ [1] ./vendor1.js 27 bytes {0} {1} {2} [built]
+ single entry ./vendor1 [0] multi ./vendor1 vendor1:100000
+ cjs require ./vendor1 [3] ./vendor2.js 2:0-20
+ cjs require ./vendor1 [4] ./pageA.js 2:0-20
+chunk {1} vendor2.js (vendor2) 107 bytes [entry] [rendered]
+ > vendor2
+ [1] ./vendor1.js 27 bytes {0} {1} {2} [built]
+ single entry ./vendor1 [0] multi ./vendor1 vendor1:100000
+ cjs require ./vendor1 [3] ./vendor2.js 2:0-20
+ cjs require ./vendor1 [4] ./pageA.js 2:0-20
+ [2] multi ./vendor2 28 bytes {1} [built]
+ multi entry
+ [3] ./vendor2.js 52 bytes {1} {2} [built]
+ single entry ./vendor2 [2] multi ./vendor2 vendor2:100000
cjs require ./vendor2 [4] ./pageA.js 3:0-20
- [3] multi ./vendor2 28 bytes {0} [built]
-chunk {1} pageC.js (pageC) 25 bytes {0} [initial] [rendered]
- > pageC [6] ./pageC.js
- [6] ./pageC.js 25 bytes {1} [built]
-chunk {2} pageB.js (pageB) 25 bytes {0} [initial] [rendered]
- > pageB [5] ./pageB.js
- [5] ./pageB.js 25 bytes {2} [built]
-chunk {3} pageA.js (pageA) 73 bytes {0} [initial] [rendered]
- > pageA [4] ./pageA.js
- [4] ./pageA.js 73 bytes {3} [built]
-chunk {4} vendor1.js (vendor1) 55 bytes [entry] [rendered]
- > vendor1 [2] multi ./vendor1
- [0] ./vendor1.js 27 bytes {4} [built]
- cjs require ./vendor1 [1] ./vendor2.js 2:0-20
- single entry ./vendor1 [2] multi ./vendor1 vendor1:100000
+chunk {2} pageA.js (pageA) 152 bytes [entry] [rendered]
+ > ./pageA pageA
+ [1] ./vendor1.js 27 bytes {0} {1} {2} [built]
+ single entry ./vendor1 [0] multi ./vendor1 vendor1:100000
+ cjs require ./vendor1 [3] ./vendor2.js 2:0-20
cjs require ./vendor1 [4] ./pageA.js 2:0-20
- [2] multi ./vendor1 28 bytes {4} [built]
+ [3] ./vendor2.js 52 bytes {1} {2} [built]
+ single entry ./vendor2 [2] multi ./vendor2 vendor2:100000
+ cjs require ./vendor2 [4] ./pageA.js 3:0-20
+ [4] ./pageA.js 73 bytes {2} [built]
+ single entry ./pageA pageA
+chunk {3} pageB.js (pageB) 25 bytes [entry] [rendered]
+ > ./pageB pageB
+ [5] ./pageB.js 25 bytes {3} [built]
+ single entry ./pageB pageB
+chunk {4} pageC.js (pageC) 25 bytes [entry] [rendered]
+ > ./pageC pageC
+ [6] ./pageC.js 25 bytes {4} [built]
+ single entry ./pageC pageC
```
-## Minimized (uglify-js, no zip)
+## Production mode
```
-Hash: 87020004ae57cbfa3361
-Version: webpack 3.5.1
+Hash: 0a1b2c3d4e5f6a7b8c9d
+Version: webpack 4.0.0-beta.2
Asset Size Chunks Chunk Names
-vendor2.js 100 bytes 0 [emitted] vendor2
- pageC.js 59 bytes 1 [emitted] pageC
- pageB.js 59 bytes 2 [emitted] pageB
- pageA.js 71 bytes 3 [emitted] pageA
-vendor1.js 1.44 kB 4 [emitted] vendor1
+ pageC.js 569 bytes 0 [emitted] pageC
+ pageB.js 569 bytes 1 [emitted] pageB
+ pageA.js 658 bytes 2 [emitted] pageA
+vendor2.js 646 bytes 3 [emitted] vendor2
+vendor1.js 605 bytes 4 [emitted] vendor1
Entrypoint vendor1 = vendor1.js
-Entrypoint vendor2 = vendor1.js vendor2.js
-Entrypoint pageA = vendor1.js vendor2.js pageA.js
-Entrypoint pageB = vendor1.js vendor2.js pageB.js
-Entrypoint pageC = vendor1.js vendor2.js pageC.js
-chunk {0} vendor2.js (vendor2) 80 bytes {4} [initial] [rendered]
- > vendor2 [3] multi ./vendor2
- [1] ./vendor2.js 52 bytes {0} [built]
- single entry ./vendor2 [3] multi ./vendor2 vendor2:100000
+Entrypoint vendor2 = vendor2.js
+Entrypoint pageA = pageA.js
+Entrypoint pageB = pageB.js
+Entrypoint pageC = pageC.js
+chunk {0} pageC.js (pageC) 25 bytes [entry] [rendered]
+ > ./pageC pageC
+ [2] ./pageC.js 25 bytes {0} [built]
+ single entry ./pageC pageC
+chunk {1} pageB.js (pageB) 25 bytes [entry] [rendered]
+ > ./pageB pageB
+ [3] ./pageB.js 25 bytes {1} [built]
+ single entry ./pageB pageB
+chunk {2} pageA.js (pageA) 152 bytes [entry] [rendered]
+ > ./pageA pageA
+ [0] ./vendor1.js 27 bytes {2} {3} {4} [built]
+ cjs require ./vendor1 [1] ./vendor2.js 2:0-20
+ cjs require ./vendor1 [4] ./pageA.js 2:0-20
+ single entry ./vendor1 [6] multi ./vendor1 vendor1:100000
+ [1] ./vendor2.js 52 bytes {2} {3} [built]
+ cjs require ./vendor2 [4] ./pageA.js 3:0-20
+ single entry ./vendor2 [5] multi ./vendor2 vendor2:100000
+ [4] ./pageA.js 73 bytes {2} [built]
+ single entry ./pageA pageA
+chunk {3} vendor2.js (vendor2) 107 bytes [entry] [rendered]
+ > vendor2
+ [0] ./vendor1.js 27 bytes {2} {3} {4} [built]
+ cjs require ./vendor1 [1] ./vendor2.js 2:0-20
+ cjs require ./vendor1 [4] ./pageA.js 2:0-20
+ single entry ./vendor1 [6] multi ./vendor1 vendor1:100000
+ [1] ./vendor2.js 52 bytes {2} {3} [built]
cjs require ./vendor2 [4] ./pageA.js 3:0-20
- [3] multi ./vendor2 28 bytes {0} [built]
-chunk {1} pageC.js (pageC) 25 bytes {0} [initial] [rendered]
- > pageC [6] ./pageC.js
- [6] ./pageC.js 25 bytes {1} [built]
-chunk {2} pageB.js (pageB) 25 bytes {0} [initial] [rendered]
- > pageB [5] ./pageB.js
- [5] ./pageB.js 25 bytes {2} [built]
-chunk {3} pageA.js (pageA) 73 bytes {0} [initial] [rendered]
- > pageA [4] ./pageA.js
- [4] ./pageA.js 73 bytes {3} [built]
+ single entry ./vendor2 [5] multi ./vendor2 vendor2:100000
+ [5] multi ./vendor2 28 bytes {3} [built]
+ multi entry
chunk {4} vendor1.js (vendor1) 55 bytes [entry] [rendered]
- > vendor1 [2] multi ./vendor1
- [0] ./vendor1.js 27 bytes {4} [built]
+ > vendor1
+ [0] ./vendor1.js 27 bytes {2} {3} {4} [built]
cjs require ./vendor1 [1] ./vendor2.js 2:0-20
- single entry ./vendor1 [2] multi ./vendor1 vendor1:100000
cjs require ./vendor1 [4] ./pageA.js 2:0-20
- [2] multi ./vendor1 28 bytes {4} [built]
+ single entry ./vendor1 [6] multi ./vendor1 vendor1:100000
+ [6] multi ./vendor1 28 bytes {4} [built]
+ multi entry
```
diff --git a/examples/two-explicit-vendor-chunks/template.md b/examples/two-explicit-vendor-chunks/template.md
index 6bc98f0a..dd246c14 100644
--- a/examples/two-explicit-vendor-chunks/template.md
+++ b/examples/two-explicit-vendor-chunks/template.md
@@ -4,34 +4,34 @@
{{webpack.config.js}}
```
-# js/vendor1.js
+# dist/vendor1.js
``` javascript
-{{js/vendor1.js}}
+{{dist/vendor1.js}}
```
-# js/vendor2.js
+# dist/vendor2.js
``` javascript
-{{js/vendor2.js}}
+{{dist/vendor2.js}}
```
-# js/pageA.js
+# dist/pageA.js
``` javascript
-{{js/pageA.js}}
+{{dist/pageA.js}}
```
# Info
-## Uncompressed
+## Unoptimized
```
{{stdout}}
```
-## Minimized (uglify-js, no zip)
+## Production mode
```
-{{min:stdout}}
+{{production:stdout}}
```
diff --git a/examples/two-explicit-vendor-chunks/webpack.config.js b/examples/two-explicit-vendor-chunks/webpack.config.js
index 3d7b5f8a..582fdd0d 100644
--- a/examples/two-explicit-vendor-chunks/webpack.config.js
+++ b/examples/two-explicit-vendor-chunks/webpack.config.js
@@ -1,6 +1,6 @@
var path = require("path");
-var CommonsChunkPlugin = require("../../lib/optimize/CommonsChunkPlugin");
module.exports = {
+ // mode: "development || "production",
entry: {
vendor1: ["./vendor1"],
vendor2: ["./vendor2"],
@@ -9,13 +9,23 @@ module.exports = {
pageC: "./pageC"
},
output: {
- path: path.join(__dirname, "js"),
+ path: path.join(__dirname, "dist"),
filename: "[name].js"
},
- plugins: [
- new CommonsChunkPlugin({
- names: ["vendor2", "vendor1"],
- minChunks: Infinity
- })
- ]
+ optimization: {
+ splitChunks: {
+ cacheGroups: {
+ vendor1: {
+ name: "vendor1",
+ test: "vendor1",
+ enforce: true
+ },
+ vendor2: {
+ name: "vendor2",
+ test: "vendor2",
+ enforce: true
+ }
+ }
+ }
+ }
};
diff --git a/examples/wasm-simple/README.md b/examples/wasm-simple/README.md
new file mode 100644
index 00000000..e41692c9
--- /dev/null
+++ b/examples/wasm-simple/README.md
@@ -0,0 +1,517 @@
+This very simple example shows usage of WebAssembly.
+
+WebAssembly modules can be imported like other modules. Their download and compilation happens in parallel to the download and evaluation of the javascript chunk.
+
+# example.js
+
+``` javascript
+import("./add.wasm").then(addModule => {
+ console.log(addModule.add(22, 2200));
+ import("./math").then(math => {
+ console.log(math.add(10, 101));
+ console.log(math.factorial(15));
+ console.log(math.factorialJavascript(15));
+ console.log(math.fibonacci(15));
+ console.log(math.fibonacciJavascript(15));
+ timed("wasm factorial", () => math.factorial(1500));
+ timed("js factorial", () => math.factorialJavascript(1500));
+ timed("wasm fibonacci", () => math.fibonacci(22));
+ timed("js fibonacci", () => math.fibonacciJavascript(22));
+ });
+});
+
+function timed(name, fn) {
+ if(!console.time || !console.timeEnd)
+ return fn();
+ // warmup
+ for(var i = 0; i < 10; i++)
+ fn();
+ console.time(name)
+ for(var i = 0; i < 5000; i++)
+ fn();
+ console.timeEnd(name)
+}
+```
+
+# math.js
+
+``` javascript
+import { add } from "./add.wasm";
+import { factorial } from "./factorial.wasm";
+import { fibonacci } from "./fibonacci.wasm";
+
+export { add, factorial, fibonacci };
+
+export function factorialJavascript(i) {
+ if(i < 1) return 1;
+ return i * factorialJavascript(i - 1);
+}
+
+export function fibonacciJavascript(i) {
+ if(i < 2) return 1;
+ return fibonacciJavascript(i - 1) + fibonacciJavascript(i - 2);
+}
+```
+
+# dist/output.js
+
+<details><summary><code>/******/ (function(modules) { /* webpackBootstrap */ })</code></summary>
+
+``` javascript
+/******/ (function(modules) { // webpackBootstrap
+/******/ // install a JSONP callback for chunk loading
+/******/ function webpackJsonpCallback(data) {
+/******/ var chunkIds = data[0];
+/******/ var moreModules = data[1]
+/******/
+/******/ // add "moreModules" to the modules object,
+/******/ // then flag all "chunkIds" as loaded and fire callback
+/******/ var moduleId, chunkId, i = 0, resolves = [];
+/******/ for(;i < chunkIds.length; i++) {
+/******/ chunkId = chunkIds[i];
+/******/ if(installedChunks[chunkId]) {
+/******/ resolves.push(installedChunks[chunkId][0]);
+/******/ }
+/******/ installedChunks[chunkId] = 0;
+/******/ }
+/******/ for(moduleId in moreModules) {
+/******/ if(Object.prototype.hasOwnProperty.call(moreModules, moduleId)) {
+/******/ modules[moduleId] = moreModules[moduleId];
+/******/ }
+/******/ }
+/******/ if(parentJsonpFunction) parentJsonpFunction(data);
+/******/ while(resolves.length) {
+/******/ resolves.shift()();
+/******/ }
+/******/
+/******/ };
+/******/
+/******/
+/******/ // The module cache
+/******/ var installedModules = {};
+/******/
+/******/ // object to store loaded and loading chunks
+/******/ var installedChunks = {
+/******/ 2: 0
+/******/ };
+/******/
+/******/
+/******/
+/******/ // object to store loaded and loading wasm modules
+/******/ var installedWasmModules = {};
+/******/
+/******/ // The require function
+/******/ function __webpack_require__(moduleId) {
+/******/
+/******/ // Check if module is in cache
+/******/ if(installedModules[moduleId]) {
+/******/ return installedModules[moduleId].exports;
+/******/ }
+/******/ // Create a new module (and put it into the cache)
+/******/ var module = installedModules[moduleId] = {
+/******/ i: moduleId,
+/******/ l: false,
+/******/ exports: {}
+/******/ };
+/******/
+/******/ // Execute the module function
+/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
+/******/
+/******/ // Flag the module as loaded
+/******/ module.l = true;
+/******/
+/******/ // Return the exports of the module
+/******/ return module.exports;
+/******/ }
+/******/
+/******/ // This file contains only the entry chunk.
+/******/ // The chunk loading function for additional chunks
+/******/ __webpack_require__.e = function requireEnsure(chunkId) {
+/******/ var promises = [];
+/******/
+/******/
+/******/ // JSONP chunk loading for javascript
+/******/
+/******/ var installedChunkData = installedChunks[chunkId];
+/******/ if(installedChunkData !== 0) { // 0 means "already installed".
+/******/
+/******/ // a Promise means "currently loading".
+/******/ if(installedChunkData) {
+/******/ promises.push(installedChunkData[2]);
+/******/ } else {
+/******/ // setup Promise in chunk cache
+/******/ var promise = new Promise(function(resolve, reject) {
+/******/ installedChunkData = installedChunks[chunkId] = [resolve, reject];
+/******/ });
+/******/ promises.push(installedChunkData[2] = promise);
+/******/
+/******/ // start chunk loading
+/******/ var head = document.getElementsByTagName('head')[0];
+/******/ var script = document.createElement('script');
+/******/
+/******/ script.charset = 'utf-8';
+/******/ script.timeout = 120000;
+/******/
+/******/ if (__webpack_require__.nc) {
+/******/ script.setAttribute("nonce", __webpack_require__.nc);
+/******/ }
+/******/ script.src = __webpack_require__.p + "" + chunkId + ".output.js";
+/******/ var timeout = setTimeout(function(){
+/******/ onScriptComplete({ type: 'timeout', target: script });
+/******/ }, 120000);
+/******/ script.onerror = script.onload = onScriptComplete;
+/******/ function onScriptComplete(event) {
+/******/ // avoid mem leaks in IE.
+/******/ script.onerror = script.onload = null;
+/******/ clearTimeout(timeout);
+/******/ var chunk = installedChunks[chunkId];
+/******/ if(chunk !== 0) {
+/******/ if(chunk) {
+/******/ var errorType = event && (event.type === 'load' ? 'missing' : event.type);
+/******/ var realSrc = event && event.target && event.target.src;
+/******/ var error = new Error('Loading chunk ' + chunkId + ' failed.\n(' + errorType + ': ' + realSrc + ')');
+/******/ error.type = errorType;
+/******/ error.request = realSrc;
+/******/ chunk[1](error);
+/******/ }
+/******/ installedChunks[chunkId] = undefined;
+/******/ }
+/******/ };
+/******/ head.appendChild(script);
+/******/ }
+/******/ }
+/******/
+/******/ // Fetch + compile chunk loading for webassembly
+/******/
+/******/ var wasmModules = {"0":[1,3,4],"1":[1]}[chunkId] || [];
+/******/
+/******/ wasmModules.forEach(function(wasmModuleId) {
+/******/ var installedWasmModuleData = installedWasmModules[wasmModuleId];
+/******/
+/******/ // a Promise means "currently loading" or "already loaded".
+/******/ promises.push(installedWasmModuleData ||
+/******/ (installedWasmModules[wasmModuleId] = fetch(__webpack_require__.p + "" + {"1":"9c8c5b45b5c12888e105","3":"62df68d96f4aa17e7b77","4":"e5003c8310987c008228"}[wasmModuleId] + ".wasm").then(function(response) {
+/******/ if(WebAssembly.compileStreaming) {
+/******/ return WebAssembly.compileStreaming(response);
+/******/ } else {
+/******/ return response.arrayBuffer().then(function(bytes) { return WebAssembly.compile(bytes); });
+/******/ }
+/******/ }).then(function(module) { __webpack_require__.w[wasmModuleId] = module; }))
+/******/ );
+/******/ });
+/******/ return Promise.all(promises);
+/******/ };
+/******/
+/******/ // expose the modules object (__webpack_modules__)
+/******/ __webpack_require__.m = modules;
+/******/
+/******/ // expose the module cache
+/******/ __webpack_require__.c = installedModules;
+/******/
+/******/ // define getter function for harmony exports
+/******/ __webpack_require__.d = function(exports, name, getter) {
+/******/ if(!__webpack_require__.o(exports, name)) {
+/******/ Object.defineProperty(exports, name, {
+/******/ configurable: false,
+/******/ enumerable: true,
+/******/ get: getter
+/******/ });
+/******/ }
+/******/ };
+/******/
+/******/ // define __esModule on exports
+/******/ __webpack_require__.r = function(exports) {
+/******/ Object.defineProperty(exports, '__esModule', { value: true });
+/******/ };
+/******/
+/******/ // getDefaultExport function for compatibility with non-harmony modules
+/******/ __webpack_require__.n = function(module) {
+/******/ var getter = module && module.__esModule ?
+/******/ function getDefault() { return module['default']; } :
+/******/ function getModuleExports() { return module; };
+/******/ __webpack_require__.d(getter, 'a', getter);
+/******/ return getter;
+/******/ };
+/******/
+/******/ // Object.prototype.hasOwnProperty.call
+/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
+/******/
+/******/ // __webpack_public_path__
+/******/ __webpack_require__.p = "dist/";
+/******/
+/******/ // on error function for async loading
+/******/ __webpack_require__.oe = function(err) { console.error(err); throw err; };
+/******/
+/******/ // object with all compiled WebAssmbly.Modules
+/******/ __webpack_require__.w = {};
+/******/
+/******/ var jsonpArray = window["webpackJsonp"] = window["webpackJsonp"] || [];
+/******/ var oldJsonpFunction = jsonpArray.push.bind(jsonpArray);
+/******/ jsonpArray.push = webpackJsonpCallback;
+/******/ jsonpArray = jsonpArray.slice();
+/******/ for(var i = 0; i < jsonpArray.length; i++) webpackJsonpCallback(jsonpArray[i]);
+/******/ var parentJsonpFunction = oldJsonpFunction;
+/******/
+/******/
+/******/ // Load entry module and return exports
+/******/ return __webpack_require__(__webpack_require__.s = 0);
+/******/ })
+/************************************************************************/
+```
+
+</details>
+
+``` javascript
+/******/ ([
+/* 0 */
+/*!********************!*\
+ !*** ./example.js ***!
+ \********************/
+/*! no static exports found */
+/***/ (function(module, exports, __webpack_require__) {
+
+__webpack_require__.e(/*! import() */ 1).then(__webpack_require__.bind(null, /*! ./add.wasm */ 1)).then(addModule => {
+ console.log(addModule.add(22, 2200));
+ __webpack_require__.e(/*! import() */ 0).then(__webpack_require__.bind(null, /*! ./math */ 2)).then(math => {
+ console.log(math.add(10, 101));
+ console.log(math.factorial(15));
+ console.log(math.factorialJavascript(15));
+ console.log(math.fibonacci(15));
+ console.log(math.fibonacciJavascript(15));
+ timed("wasm factorial", () => math.factorial(1500));
+ timed("js factorial", () => math.factorialJavascript(1500));
+ timed("wasm fibonacci", () => math.fibonacci(22));
+ timed("js fibonacci", () => math.fibonacciJavascript(22));
+ });
+});
+
+function timed(name, fn) {
+ if(!console.time || !console.timeEnd)
+ return fn();
+ // warmup
+ for(var i = 0; i < 10; i++)
+ fn();
+ console.time(name)
+ for(var i = 0; i < 5000; i++)
+ fn();
+ console.timeEnd(name)
+}
+
+
+/***/ })
+/******/ ]);
+```
+
+# dist/0.output.js
+
+``` javascript
+(window["webpackJsonp"] = window["webpackJsonp"] || []).push([[0],[
+/* 0 */,
+/* 1 */
+/*!******************!*\
+ !*** ./add.wasm ***!
+ \******************/
+/*! exports provided: add */
+/***/ (function(module, exports, __webpack_require__) {
+
+"use strict";
+
+// Instantiate WebAssembly module
+var instance = new WebAssembly.Instance(__webpack_require__.w[module.i], {
+});
+
+// export exports from WebAssembly module
+module.exports = instance.exports;
+
+/***/ }),
+/* 2 */
+/*!*****************!*\
+ !*** ./math.js ***!
+ \*****************/
+/*! exports provided: add, factorial, fibonacci, factorialJavascript, fibonacciJavascript */
+/***/ (function(module, __webpack_exports__, __webpack_require__) {
+
+"use strict";
+__webpack_require__.r(__webpack_exports__);
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "factorialJavascript", function() { return factorialJavascript; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fibonacciJavascript", function() { return fibonacciJavascript; });
+/* harmony import */ var _add_wasm__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./add.wasm */ 1);
+/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "add", function() { return _add_wasm__WEBPACK_IMPORTED_MODULE_0__["add"]; });
+
+/* harmony import */ var _factorial_wasm__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./factorial.wasm */ 4);
+/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "factorial", function() { return _factorial_wasm__WEBPACK_IMPORTED_MODULE_1__["factorial"]; });
+
+/* harmony import */ var _fibonacci_wasm__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./fibonacci.wasm */ 3);
+/* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "fibonacci", function() { return _fibonacci_wasm__WEBPACK_IMPORTED_MODULE_2__["fibonacci"]; });
+
+
+
+
+
+
+
+function factorialJavascript(i) {
+ if(i < 1) return 1;
+ return i * factorialJavascript(i - 1);
+}
+
+function fibonacciJavascript(i) {
+ if(i < 2) return 1;
+ return fibonacciJavascript(i - 1) + fibonacciJavascript(i - 2);
+}
+
+
+/***/ }),
+/* 3 */
+/*!************************!*\
+ !*** ./fibonacci.wasm ***!
+ \************************/
+/*! exports provided: fibonacci */
+/***/ (function(module, exports, __webpack_require__) {
+
+"use strict";
+
+// Instantiate WebAssembly module
+var instance = new WebAssembly.Instance(__webpack_require__.w[module.i], {
+});
+
+// export exports from WebAssembly module
+module.exports = instance.exports;
+
+/***/ }),
+/* 4 */
+/*!************************!*\
+ !*** ./factorial.wasm ***!
+ \************************/
+/*! exports provided: factorial */
+/***/ (function(module, exports, __webpack_require__) {
+
+"use strict";
+
+// Instantiate WebAssembly module
+var instance = new WebAssembly.Instance(__webpack_require__.w[module.i], {
+});
+
+// export exports from WebAssembly module
+module.exports = instance.exports;
+
+/***/ })
+]]);
+```
+
+# dist/1.output.js
+
+``` javascript
+(window["webpackJsonp"] = window["webpackJsonp"] || []).push([[1],[
+/* 0 */,
+/* 1 */
+/*!******************!*\
+ !*** ./add.wasm ***!
+ \******************/
+/*! exports provided: add */
+/***/ (function(module, exports, __webpack_require__) {
+
+"use strict";
+
+// Instantiate WebAssembly module
+var instance = new WebAssembly.Instance(__webpack_require__.w[module.i], {
+});
+
+// export exports from WebAssembly module
+module.exports = instance.exports;
+
+/***/ })
+]]);
+```
+
+# Info
+
+## Unoptimized
+
+```
+Hash: 0a1b2c3d4e5f6a7b8c9d
+Version: webpack 4.0.0-beta.2
+ Asset Size Chunks Chunk Names
+ 0.output.js 2.88 KiB 0 [emitted]
+9c8c5b45b5c12888e105.wasm 41 bytes 0, 1 [emitted]
+62df68d96f4aa17e7b77.wasm 67 bytes 0 [emitted]
+e5003c8310987c008228.wasm 62 bytes 0 [emitted]
+ 1.output.js 462 bytes 1 [emitted]
+ output.js 8.91 KiB 2 [emitted] main
+Entrypoint main = output.js
+chunk {0} 0.output.js, 9c8c5b45b5c12888e105.wasm, 62df68d96f4aa17e7b77.wasm, e5003c8310987c008228.wasm 585 bytes <{2}> [rendered]
+ > ./math [0] ./example.js 3:1-17
+ [1] ./add.wasm 41 bytes {0} {1} [built]
+ [exports: add]
+ import() ./add.wasm [0] ./example.js 1:0-20
+ harmony side effect evaluation ./add.wasm [2] ./math.js 1:0-33
+ harmony export imported specifier ./add.wasm [2] ./math.js 5:0-37
+ [2] ./math.js 415 bytes {0} [built]
+ [exports: add, factorial, fibonacci, factorialJavascript, fibonacciJavascript]
+ import() ./math [0] ./example.js 3:1-17
+ [3] ./fibonacci.wasm 67 bytes {0} [built]
+ [exports: fibonacci]
+ harmony side effect evaluation ./fibonacci.wasm [2] ./math.js 3:0-45
+ harmony export imported specifier ./fibonacci.wasm [2] ./math.js 5:0-37
+ [4] ./factorial.wasm 62 bytes {0} [built]
+ [exports: factorial]
+ harmony side effect evaluation ./factorial.wasm [2] ./math.js 2:0-45
+ harmony export imported specifier ./factorial.wasm [2] ./math.js 5:0-37
+chunk {1} 1.output.js, 9c8c5b45b5c12888e105.wasm 41 bytes <{2}> [rendered]
+ > ./add.wasm [0] ./example.js 1:0-20
+ [1] ./add.wasm 41 bytes {0} {1} [built]
+ [exports: add]
+ import() ./add.wasm [0] ./example.js 1:0-20
+ harmony side effect evaluation ./add.wasm [2] ./math.js 1:0-33
+ harmony export imported specifier ./add.wasm [2] ./math.js 5:0-37
+chunk {2} output.js (main) 788 bytes >{0}< >{1}< [entry] [rendered]
+ > .\example.js main
+ [0] ./example.js 788 bytes {2} [built]
+ single entry .\example.js main
+```
+
+## Production mode
+
+```
+Hash: 0a1b2c3d4e5f6a7b8c9d
+Version: webpack 4.0.0-beta.2
+ Asset Size Chunks Chunk Names
+ 0.output.js 722 bytes 0, 1 [emitted]
+fb3978ee17c3b5162f77.wasm 41 bytes 0, 1, 1 [emitted]
+11be07941949e929b309.wasm 67 bytes 0, 1 [emitted]
+e231a41fda9732bd5556.wasm 62 bytes 0, 1 [emitted]
+ 1.output.js 155 bytes 1 [emitted]
+ output.js 2.52 KiB 2 [emitted] main
+Entrypoint main = output.js
+chunk {0} 0.output.js, fb3978ee17c3b5162f77.wasm, 11be07941949e929b309.wasm, e231a41fda9732bd5556.wasm 585 bytes <{2}> [rendered]
+ > ./math [0] ./example.js 3:1-17
+ [1] ./add.wasm 41 bytes {0} {1} [built]
+ [exports: add]
+ import() ./add.wasm [0] ./example.js 1:0-20
+ harmony side effect evaluation ./add.wasm [2] ./math.js 1:0-33
+ harmony export imported specifier ./add.wasm [2] ./math.js 5:0-37
+ [2] ./math.js 415 bytes {0} [built]
+ [exports: add, factorial, fibonacci, factorialJavascript, fibonacciJavascript]
+ import() ./math [0] ./example.js 3:1-17
+ [3] ./fibonacci.wasm 67 bytes {0} [built]
+ [exports: fibonacci]
+ [only some exports used: fibonacci]
+ harmony side effect evaluation ./fibonacci.wasm [2] ./math.js 3:0-45
+ harmony export imported specifier ./fibonacci.wasm [2] ./math.js 5:0-37
+ [4] ./factorial.wasm 62 bytes {0} [built]
+ [exports: factorial]
+ [only some exports used: factorial]
+ harmony side effect evaluation ./factorial.wasm [2] ./math.js 2:0-45
+ harmony export imported specifier ./factorial.wasm [2] ./math.js 5:0-37
+chunk {1} 1.output.js, fb3978ee17c3b5162f77.wasm 41 bytes <{2}> [rendered]
+ > ./add.wasm [0] ./example.js 1:0-20
+ [1] ./add.wasm 41 bytes {0} {1} [built]
+ [exports: add]
+ import() ./add.wasm [0] ./example.js 1:0-20
+ harmony side effect evaluation ./add.wasm [2] ./math.js 1:0-33
+ harmony export imported specifier ./add.wasm [2] ./math.js 5:0-37
+chunk {2} output.js (main) 788 bytes >{0}< >{1}< [entry] [rendered]
+ > .\example.js main
+ [0] ./example.js 788 bytes {2} [built]
+ single entry .\example.js main
+```
diff --git a/examples/wasm-simple/add.wasm b/examples/wasm-simple/add.wasm
new file mode 100644
index 00000000..357f72da
Binary files /dev/null and b/examples/wasm-simple/add.wasm differ
diff --git a/examples/wasm-simple/build.js b/examples/wasm-simple/build.js
new file mode 100644
index 00000000..41c29c9d
--- /dev/null
+++ b/examples/wasm-simple/build.js
@@ -0,0 +1 @@
+require("../build-common");
\ No newline at end of file
diff --git a/examples/wasm-simple/example.js b/examples/wasm-simple/example.js
new file mode 100644
index 00000000..25c1fd16
--- /dev/null
+++ b/examples/wasm-simple/example.js
@@ -0,0 +1,26 @@
+import("./add.wasm").then(addModule => {
+ console.log(addModule.add(22, 2200));
+ import("./math").then(math => {
+ console.log(math.add(10, 101));
+ console.log(math.factorial(15));
+ console.log(math.factorialJavascript(15));
+ console.log(math.fibonacci(15));
+ console.log(math.fibonacciJavascript(15));
+ timed("wasm factorial", () => math.factorial(1500));
+ timed("js factorial", () => math.factorialJavascript(1500));
+ timed("wasm fibonacci", () => math.fibonacci(22));
+ timed("js fibonacci", () => math.fibonacciJavascript(22));
+ });
+});
+
+function timed(name, fn) {
+ if(!console.time || !console.timeEnd)
+ return fn();
+ // warmup
+ for(var i = 0; i < 10; i++)
+ fn();
+ console.time(name)
+ for(var i = 0; i < 5000; i++)
+ fn();
+ console.timeEnd(name)
+}
diff --git a/examples/wasm-simple/factorial.wasm b/examples/wasm-simple/factorial.wasm
new file mode 100644
index 00000000..0e0d759d
Binary files /dev/null and b/examples/wasm-simple/factorial.wasm differ
diff --git a/examples/wasm-simple/fibonacci.wasm b/examples/wasm-simple/fibonacci.wasm
new file mode 100644
index 00000000..cffb563b
Binary files /dev/null and b/examples/wasm-simple/fibonacci.wasm differ
diff --git a/examples/wasm-simple/index.html b/examples/wasm-simple/index.html
new file mode 100644
index 00000000..22a4cefe
--- /dev/null
+++ b/examples/wasm-simple/index.html
@@ -0,0 +1,5 @@
+<html>
+ <body>
+ <script src="js/output.js"></script>
+ </body>
+</html>
diff --git a/examples/wasm-simple/math.js b/examples/wasm-simple/math.js
new file mode 100644
index 00000000..761a57a4
--- /dev/null
+++ b/examples/wasm-simple/math.js
@@ -0,0 +1,15 @@
+import { add } from "./add.wasm";
+import { factorial } from "./factorial.wasm";
+import { fibonacci } from "./fibonacci.wasm";
+
+export { add, factorial, fibonacci };
+
+export function factorialJavascript(i) {
+ if(i < 1) return 1;
+ return i * factorialJavascript(i - 1);
+}
+
+export function fibonacciJavascript(i) {
+ if(i < 2) return 1;
+ return fibonacciJavascript(i - 1) + fibonacciJavascript(i - 2);
+}
diff --git a/examples/wasm-simple/template.md b/examples/wasm-simple/template.md
new file mode 100644
index 00000000..882ae226
--- /dev/null
+++ b/examples/wasm-simple/template.md
@@ -0,0 +1,47 @@
+This very simple example shows usage of WebAssembly.
+
+WebAssembly modules can be imported like other modules. Their download and compilation happens in parallel to the download and evaluation of the javascript chunk.
+
+# example.js
+
+``` javascript
+{{example.js}}
+```
+
+# math.js
+
+``` javascript
+{{math.js}}
+```
+
+# dist/output.js
+
+``` javascript
+{{dist/output.js}}
+```
+
+# dist/0.output.js
+
+``` javascript
+{{dist/0.output.js}}
+```
+
+# dist/1.output.js
+
+``` javascript
+{{dist/1.output.js}}
+```
+
+# Info
+
+## Unoptimized
+
+```
+{{stdout}}
+```
+
+## Production mode
+
+```
+{{production:stdout}}
+```
diff --git a/examples/wasm-simple/test.filter.js b/examples/wasm-simple/test.filter.js
new file mode 100644
index 00000000..9872d9c8
--- /dev/null
+++ b/examples/wasm-simple/test.filter.js
@@ -0,0 +1,5 @@
+var supportsWebAssembly = require("../../test/helpers/supportsWebAssembly");
+
+module.exports = function(config) {
+ return supportsWebAssembly();
+};
diff --git a/examples/wasm-simple/webpack.config.js b/examples/wasm-simple/webpack.config.js
new file mode 100644
index 00000000..df7a7e90
--- /dev/null
+++ b/examples/wasm-simple/webpack.config.js
@@ -0,0 +1,18 @@
+module.exports = {
+ // mode: "development || "production",
+ output: {
+ webassemblyModuleFilename: "[modulehash].wasm",
+ publicPath: "js/"
+ },
+ module: {
+ rules: [
+ {
+ test: /\.wasm$/,
+ type: "webassembly/experimental"
+ }
+ ]
+ },
+ optimization: {
+ occurrenceOrder: true // To keep filename consistent between different modes (for example building only)
+ }
+};
diff --git a/examples/web-worker/README.md b/examples/web-worker/README.md
index 3473f86e..3e80483c 100644
--- a/examples/web-worker/README.md
+++ b/examples/web-worker/README.md
@@ -2,7 +2,7 @@
# example.js
``` javascript
-var Worker = require("worker-loader!./worker");
+var Worker = require("worker-loader?name=hash.worker.js!./worker");
var worker = new Worker;
worker.postMessage("b");
worker.onmessage = function(event) {
@@ -21,7 +21,7 @@ onmessage = function(event) {
}
```
-# js/output.js
+# dist/output.js
<details><summary><code>/******/ (function(modules) { /* webpackBootstrap */ })</code></summary>
@@ -72,6 +72,11 @@ onmessage = function(event) {
/******/ }
/******/ };
/******/
+/******/ // define __esModule on exports
+/******/ __webpack_require__.r = function(exports) {
+/******/ Object.defineProperty(exports, '__esModule', { value: true });
+/******/ };
+/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
@@ -85,10 +90,11 @@ onmessage = function(event) {
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
-/******/ __webpack_require__.p = "js/";
+/******/ __webpack_require__.p = "dist/";
+/******/
/******/
/******/ // Load entry module and return exports
-/******/ return __webpack_require__(__webpack_require__.s = 0);
+/******/ return __webpack_require__(__webpack_require__.s = 1);
/******/ })
/************************************************************************/
```
@@ -98,14 +104,25 @@ onmessage = function(event) {
``` javascript
/******/ ([
/* 0 */
+/*!****************************************************************************************!*\
+ !*** (webpack)/node_modules/worker-loader/dist/cjs.js?name=hash.worker.js!./worker.js ***!
+ \****************************************************************************************/
+/*! no static exports found */
+/***/ (function(module, exports, __webpack_require__) {
+
+module.exports = function() {
+ return new Worker(__webpack_require__.p + "hash.worker.js");
+};
+
+/***/ }),
+/* 1 */
/*!********************!*\
!*** ./example.js ***!
\********************/
/*! no static exports found */
-/*! all exports used */
/***/ (function(module, exports, __webpack_require__) {
-var Worker = __webpack_require__(/*! worker-loader!./worker */ 1);
+var Worker = __webpack_require__(/*! worker-loader?name=hash.worker.js!./worker */ 0);
var worker = new Worker;
worker.postMessage("b");
worker.onmessage = function(event) {
@@ -113,28 +130,15 @@ worker.onmessage = function(event) {
}
-/***/ }),
-/* 1 */
-/*!********************************************************!*\
- !*** (webpack)/node_modules/worker-loader!./worker.js ***!
- \********************************************************/
-/*! no static exports found */
-/*! all exports used */
-/***/ (function(module, exports, __webpack_require__) {
-
-module.exports = function() {
- return new Worker(__webpack_require__.p + "hash.worker.js");
-};
-
/***/ })
/******/ ]);
```
-# js/[hash].worker.js
+# dist/[hash].worker.js
``` javascript
/******/ (function(modules) { // webpackBootstrap
-/******/ this["webpackChunk"] = function webpackChunkCallback(chunkIds, moreModules) {
+/******/ window["webpackChunk"] = function webpackChunkCallback(chunkIds, moreModules) {
/******/ for(var moduleId in moreModules) {
/******/ modules[moduleId] = moreModules[moduleId];
/******/ }
@@ -178,13 +182,14 @@ module.exports = function() {
/******/ // This file contains only the entry chunk.
/******/ // The chunk loading function for additional chunks
/******/ __webpack_require__.e = function requireEnsure(chunkId) {
-/******/ return new Promise(function(resolve) {
+/******/ var promises = [];
+/******/ promises.push(Promise.resolve().then(function() {
/******/ // "1" is the signal for "already loaded"
/******/ if(!installedChunks[chunkId]) {
/******/ importScripts("" + chunkId + ".hash.worker.js");
/******/ }
-/******/ resolve();
-/******/ });
+/******/ }));
+/******/ return Promise.all(promises);
/******/ };
/******/
/******/ // expose the modules object (__webpack_modules__)
@@ -204,6 +209,11 @@ module.exports = function() {
/******/ }
/******/ };
/******/
+/******/ // define __esModule on exports
+/******/ __webpack_require__.r = function(exports) {
+/******/ Object.defineProperty(exports, '__esModule', { value: true });
+/******/ };
+/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
@@ -217,7 +227,8 @@ module.exports = function() {
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
-/******/ __webpack_require__.p = "js/";
+/******/ __webpack_require__.p = "dist/";
+/******/
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 0);
@@ -229,14 +240,13 @@ module.exports = function() {
!*** ./worker.js ***!
\*******************/
/*! no static exports found */
-/*! all exports used */
/***/ (function(module, exports, __webpack_require__) {
onmessage = function(event) {
var template = event.data;
- __webpack_require__.e/* require */(0).then(function() { var __WEBPACK_AMD_REQUIRE_ARRAY__ = [__webpack_require__(/*! ../require.context/templates */ 1)("./" + event.data)]; (function(tmpl) {
+ __webpack_require__.e(/*! AMD require */ 0).then(function() { var __WEBPACK_AMD_REQUIRE_ARRAY__ = [__webpack_require__(1)("./" + event.data)]; (function(tmpl) {
postMessage(tmpl());
- }.apply(null, __WEBPACK_AMD_REQUIRE_ARRAY__));}).catch(__webpack_require__.oe);
+ }).apply(null, __WEBPACK_AMD_REQUIRE_ARRAY__);}).catch(__webpack_require__.oe);
}
@@ -244,36 +254,42 @@ onmessage = function(event) {
/******/ ]);
```
-# js/0.[hash].worker.js
+# dist/0.[hash].worker.js
``` javascript
-webpackChunk([0],[
+window["webpackChunk"]([0],[
/* 0 */,
/* 1 */
-/*!*********************************************!*\
- !*** ../require.context/templates ^\.\/.*$ ***!
- \*********************************************/
+/*!**************************************************!*\
+ !*** ../require.context/templates sync ^\.\/.*$ ***!
+ \**************************************************/
/*! no static exports found */
-/*! all exports used */
/***/ (function(module, exports, __webpack_require__) {
var map = {
- "./a": 2,
- "./a.js": 2,
+ "./a": 4,
+ "./a.js": 4,
"./b": 3,
"./b.js": 3,
- "./c": 4,
- "./c.js": 4
+ "./c": 2,
+ "./c.js": 2
};
+
+
function webpackContext(req) {
- return __webpack_require__(webpackContextResolve(req));
-};
+ var id = webpackContextResolve(req);
+ var module = __webpack_require__(id);
+ return module;
+}
function webpackContextResolve(req) {
var id = map[req];
- if(!(id + 1)) // check for number or string
- throw new Error("Cannot find module '" + req + "'.");
+ if(!(id + 1)) { // check for number or string
+ var e = new Error('Cannot find module "' + req + '".');
+ e.code = 'MODULE_NOT_FOUND';
+ throw e;
+ }
return id;
-};
+}
webpackContext.keys = function webpackContextKeys() {
return Object.keys(map);
};
@@ -284,14 +300,13 @@ webpackContext.id = 1;
/***/ }),
/* 2 */
/*!*****************************************!*\
- !*** ../require.context/templates/a.js ***!
+ !*** ../require.context/templates/c.js ***!
\*****************************************/
/*! no static exports found */
-/*! all exports used */
/***/ (function(module, exports) {
module.exports = function() {
- return "This text was generated by template A";
+ return "This text was generated by template C";
}
/***/ }),
@@ -300,7 +315,6 @@ module.exports = function() {
!*** ../require.context/templates/b.js ***!
\*****************************************/
/*! no static exports found */
-/*! all exports used */
/***/ (function(module, exports) {
module.exports = function() {
@@ -310,14 +324,13 @@ module.exports = function() {
/***/ }),
/* 4 */
/*!*****************************************!*\
- !*** ../require.context/templates/c.js ***!
+ !*** ../require.context/templates/a.js ***!
\*****************************************/
/*! no static exports found */
-/*! all exports used */
/***/ (function(module, exports) {
module.exports = function() {
- return "This text was generated by template C";
+ return "This text was generated by template A";
}
/***/ })
@@ -326,78 +339,82 @@ module.exports = function() {
# Info
-## Uncompressed
+## Unoptimized
```
-Hash: de5e6c34dad6f90c6640
-Version: webpack 3.5.1
- Asset Size Chunks Chunk Names
-0.hash.worker.js 1.85 kB [emitted]
- hash.worker.js 3.91 kB [emitted]
- output.js 3.27 kB 0 [emitted] main
+Hash: 0a1b2c3d4e5f6a7b8c9d
+Version: webpack 4.0.0-beta.2
+ Asset Size Chunks Chunk Names
+0.hash.worker.js 1.82 KiB [emitted]
+ hash.worker.js 4.02 KiB [emitted]
+ output.js 3.46 KiB 0 [emitted] main
Entrypoint main = output.js
-chunk {0} output.js (main) 311 bytes [entry] [rendered]
- > main [0] ./example.js
- [0] ./example.js 215 bytes {0} [built]
- [1] (webpack)/node_modules/worker-loader!./worker.js 96 bytes {0} [not cacheable] [built]
- cjs require worker-loader!./worker [0] ./example.js 1:13-46
+chunk {0} output.js (main) 332 bytes [entry] [rendered]
+ > .\example.js main
+ [0] (webpack)/node_modules/worker-loader/dist/cjs.js?name=hash.worker.js!./worker.js 97 bytes {0} [not cacheable] [built]
+ cjs require worker-loader?name=hash.worker.js!./worker [1] ./example.js 1:13-66
+ [1] ./example.js 235 bytes {0} [built]
+ single entry .\example.js main
Child worker:
- Asset Size Chunks Chunk Names
- 0.hash.worker.js 1.85 kB 0 [emitted]
- hash.worker.js 3.91 kB 1 [emitted] main
+ Asset Size Chunks Chunk Names
+ 0.hash.worker.js 1.82 KiB 0 [emitted]
+ hash.worker.js 4.02 KiB 1 [emitted] main
Entrypoint main = hash.worker.js
- chunk {0} 0.hash.worker.js 463 bytes {1} [rendered]
+ chunk {0} 0.hash.worker.js 463 bytes <{1}> [rendered]
> [0] ./worker.js 3:1-5:3
- [1] ../require.context/templates ^\.\/.*$ 217 bytes {0} [built]
+ [1] ../require.context/templates sync ^\.\/.*$ 217 bytes {0} [built]
amd require context ../require.context/templates [0] ./worker.js 3:1-5:3
- [2] ../require.context/templates/a.js 82 bytes {0} [optional] [built]
- context element ./a.js [1] ../require.context/templates ^\.\/.*$ ./a.js
- context element ./a [1] ../require.context/templates ^\.\/.*$ ./a
+ [2] ../require.context/templates/c.js 82 bytes {0} [optional] [built]
+ context element ./c.js [1] ../require.context/templates sync ^\.\/.*$ ./c.js
+ context element ./c [1] ../require.context/templates sync ^\.\/.*$ ./c
[3] ../require.context/templates/b.js 82 bytes {0} [optional] [built]
- context element ./b.js [1] ../require.context/templates ^\.\/.*$ ./b.js
- context element ./b [1] ../require.context/templates ^\.\/.*$ ./b
- [4] ../require.context/templates/c.js 82 bytes {0} [optional] [built]
- context element ./c.js [1] ../require.context/templates ^\.\/.*$ ./c.js
- context element ./c [1] ../require.context/templates ^\.\/.*$ ./c
- chunk {1} hash.worker.js (main) 168 bytes [entry] [rendered]
- > main [0] ./worker.js
+ context element ./b.js [1] ../require.context/templates sync ^\.\/.*$ ./b.js
+ context element ./b [1] ../require.context/templates sync ^\.\/.*$ ./b
+ [4] ../require.context/templates/a.js 82 bytes {0} [optional] [built]
+ context element ./a.js [1] ../require.context/templates sync ^\.\/.*$ ./a.js
+ context element ./a [1] ../require.context/templates sync ^\.\/.*$ ./a
+ chunk {1} hash.worker.js (main) 168 bytes >{0}< [entry] [rendered]
+ > !!.\worker.js main
[0] ./worker.js 168 bytes {1} [built]
+ single entry !!.\worker.js main
```
-## Minimized (uglify-js, no zip)
+## Production mode
```
-Hash: de5e6c34dad6f90c6640
-Version: webpack 3.5.1
+Hash: 0a1b2c3d4e5f6a7b8c9d
+Version: webpack 4.0.0-beta.2
Asset Size Chunks Chunk Names
-0.hash.worker.js 544 bytes [emitted]
- hash.worker.js 811 bytes [emitted]
- output.js 632 bytes 0 [emitted] main
+0.hash.worker.js 594 bytes [emitted]
+ hash.worker.js 919 bytes [emitted]
+ output.js 697 bytes 0 [emitted] main
Entrypoint main = output.js
-chunk {0} output.js (main) 311 bytes [entry] [rendered]
- > main [0] ./example.js
- [0] ./example.js 215 bytes {0} [built]
- [1] (webpack)/node_modules/worker-loader!./worker.js 96 bytes {0} [not cacheable] [built]
- cjs require worker-loader!./worker [0] ./example.js 1:13-46
+chunk {0} output.js (main) 332 bytes [entry] [rendered]
+ > .\example.js main
+ [0] (webpack)/node_modules/worker-loader/dist/cjs.js?name=hash.worker.js!./worker.js 97 bytes {0} [not cacheable] [built]
+ cjs require worker-loader?name=hash.worker.js!./worker [1] ./example.js 1:13-66
+ [1] ./example.js 235 bytes {0} [built]
+ single entry .\example.js main
Child worker:
Asset Size Chunks Chunk Names
- 0.hash.worker.js 544 bytes 0 [emitted]
- hash.worker.js 811 bytes 1 [emitted] main
+ 0.hash.worker.js 594 bytes 0 [emitted]
+ hash.worker.js 919 bytes 1 [emitted] main
Entrypoint main = hash.worker.js
- chunk {0} 0.hash.worker.js 463 bytes {1} [rendered]
+ chunk {0} 0.hash.worker.js 463 bytes <{1}> [rendered]
> [0] ./worker.js 3:1-5:3
- [1] ../require.context/templates ^\.\/.*$ 217 bytes {0} [built]
+ [1] ../require.context/templates sync ^\.\/.*$ 217 bytes {0} [built]
amd require context ../require.context/templates [0] ./worker.js 3:1-5:3
- [2] ../require.context/templates/a.js 82 bytes {0} [optional] [built]
- context element ./a.js [1] ../require.context/templates ^\.\/.*$ ./a.js
- context element ./a [1] ../require.context/templates ^\.\/.*$ ./a
+ [2] ../require.context/templates/c.js 82 bytes {0} [optional] [built]
+ context element ./c.js [1] ../require.context/templates sync ^\.\/.*$ ./c.js
+ context element ./c [1] ../require.context/templates sync ^\.\/.*$ ./c
[3] ../require.context/templates/b.js 82 bytes {0} [optional] [built]
- context element ./b.js [1] ../require.context/templates ^\.\/.*$ ./b.js
- context element ./b [1] ../require.context/templates ^\.\/.*$ ./b
- [4] ../require.context/templates/c.js 82 bytes {0} [optional] [built]
- context element ./c.js [1] ../require.context/templates ^\.\/.*$ ./c.js
- context element ./c [1] ../require.context/templates ^\.\/.*$ ./c
- chunk {1} hash.worker.js (main) 168 bytes [entry] [rendered]
- > main [0] ./worker.js
+ context element ./b.js [1] ../require.context/templates sync ^\.\/.*$ ./b.js
+ context element ./b [1] ../require.context/templates sync ^\.\/.*$ ./b
+ [4] ../require.context/templates/a.js 82 bytes {0} [optional] [built]
+ context element ./a.js [1] ../require.context/templates sync ^\.\/.*$ ./a.js
+ context element ./a [1] ../require.context/templates sync ^\.\/.*$ ./a
+ chunk {1} hash.worker.js (main) 168 bytes >{0}< [entry] [rendered]
+ > !!.\worker.js main
[0] ./worker.js 168 bytes {1} [built]
+ single entry !!.\worker.js main
```
diff --git a/examples/web-worker/example.js b/examples/web-worker/example.js
index 902c1208..68002e75 100644
--- a/examples/web-worker/example.js
+++ b/examples/web-worker/example.js
@@ -1,4 +1,4 @@
-var Worker = require("worker-loader!./worker");
+var Worker = require("worker-loader?name=hash.worker.js!./worker");
var worker = new Worker;
worker.postMessage("b");
worker.onmessage = function(event) {
diff --git a/examples/web-worker/template.md b/examples/web-worker/template.md
index f980eb3c..40477fbd 100644
--- a/examples/web-worker/template.md
+++ b/examples/web-worker/template.md
@@ -11,34 +11,34 @@
{{worker.js}}
```
-# js/output.js
+# dist/output.js
``` javascript
-{{js/output.js}}
+{{dist/output.js}}
```
-# js/[hash].worker.js
+# dist/[hash].worker.js
``` javascript
-{{js/hash.worker.js}}
+{{dist/hash.worker.js}}
```
-# js/0.[hash].worker.js
+# dist/0.[hash].worker.js
``` javascript
-{{js/0.hash.worker.js}}
+{{dist/0.hash.worker.js}}
```
# Info
-## Uncompressed
+## Unoptimized
```
{{stdout}}
```
-## Minimized (uglify-js, no zip)
+## Production mode
```
-{{min:stdout}}
+{{production:stdout}}
```
diff --git a/examples/web-worker/webpack.config.js b/examples/web-worker/webpack.config.js
index 279ff068..5a2ab29f 100644
--- a/examples/web-worker/webpack.config.js
+++ b/examples/web-worker/webpack.config.js
@@ -1,5 +1,6 @@
var webpack = require("../../");
module.exports = {
+ // mode: "development" || "production",
plugins: [
new webpack.LoaderOptionsPlugin({
options: {
@@ -11,5 +12,8 @@ module.exports = {
}
}
})
- ]
+ ],
+ optimization: {
+ occurrenceOrder: true // To keep filename consistent between different modes (for example building only)
+ }
};
diff --git a/hot/.eslintrc b/hot/.eslintrc
index 78758832..e35b431d 100644
--- a/hot/.eslintrc
+++ b/hot/.eslintrc
@@ -5,5 +5,4 @@
"rules": {
"node/exports-style": ["off"]
}
-
}
diff --git a/hot/dev-server.js b/hot/dev-server.js
index 54c6eed2..a4cb0f50 100644
--- a/hot/dev-server.js
+++ b/hot/dev-server.js
@@ -3,46 +3,54 @@
Author Tobias Koppers @sokra
*/
/*globals window __webpack_hash__ */
-if(module.hot) {
+if (module.hot) {
var lastHash;
var upToDate = function upToDate() {
return lastHash.indexOf(__webpack_hash__) >= 0;
};
var log = require("./log");
var check = function check() {
- module.hot.check(true).then(function(updatedModules) {
- if(!updatedModules) {
- log("warning", "[HMR] Cannot find update. Need to do a full reload!");
- log("warning", "[HMR] (Probably because of restarting the webpack-dev-server)");
- window.location.reload();
- return;
- }
+ module.hot
+ .check(true)
+ .then(function(updatedModules) {
+ if (!updatedModules) {
+ log("warning", "[HMR] Cannot find update. Need to do a full reload!");
+ log(
+ "warning",
+ "[HMR] (Probably because of restarting the webpack-dev-server)"
+ );
+ window.location.reload();
+ return;
+ }
- if(!upToDate()) {
- check();
- }
+ if (!upToDate()) {
+ check();
+ }
- require("./log-apply-result")(updatedModules, updatedModules);
+ require("./log-apply-result")(updatedModules, updatedModules);
- if(upToDate()) {
- log("info", "[HMR] App is up to date.");
- }
-
- }).catch(function(err) {
- var status = module.hot.status();
- if(["abort", "fail"].indexOf(status) >= 0) {
- log("warning", "[HMR] Cannot apply update. Need to do a full reload!");
- log("warning", "[HMR] " + err.stack || err.message);
- window.location.reload();
- } else {
- log("warning", "[HMR] Update failed: " + err.stack || err.message);
- }
- });
+ if (upToDate()) {
+ log("info", "[HMR] App is up to date.");
+ }
+ })
+ .catch(function(err) {
+ var status = module.hot.status();
+ if (["abort", "fail"].indexOf(status) >= 0) {
+ log(
+ "warning",
+ "[HMR] Cannot apply update. Need to do a full reload!"
+ );
+ log("warning", "[HMR] " + err.stack || err.message);
+ window.location.reload();
+ } else {
+ log("warning", "[HMR] Update failed: " + err.stack || err.message);
+ }
+ });
};
var hotEmitter = require("./emitter");
hotEmitter.on("webpackHotUpdate", function(currentHash) {
lastHash = currentHash;
- if(!upToDate() && module.hot.status() === "idle") {
+ if (!upToDate() && module.hot.status() === "idle") {
log("info", "[HMR] Checking for updates on the server...");
check();
}
diff --git a/hot/log-apply-result.js b/hot/log-apply-result.js
index a795cc59..b63e7574 100644
--- a/hot/log-apply-result.js
+++ b/hot/log-apply-result.js
@@ -8,19 +8,22 @@ module.exports = function(updatedModules, renewedModules) {
});
var log = require("./log");
- if(unacceptedModules.length > 0) {
- log("warning", "[HMR] The following modules couldn't be hot updated: (They would need a full reload!)");
+ if (unacceptedModules.length > 0) {
+ log(
+ "warning",
+ "[HMR] The following modules couldn't be hot updated: (They would need a full reload!)"
+ );
unacceptedModules.forEach(function(moduleId) {
log("warning", "[HMR] - " + moduleId);
});
}
- if(!renewedModules || renewedModules.length === 0) {
+ if (!renewedModules || renewedModules.length === 0) {
log("info", "[HMR] Nothing hot updated.");
} else {
log("info", "[HMR] Updated modules:");
renewedModules.forEach(function(moduleId) {
- if(typeof moduleId === "string" && moduleId.indexOf("!") !== -1) {
+ if (typeof moduleId === "string" && moduleId.indexOf("!") !== -1) {
var parts = moduleId.split("!");
log.groupCollapsed("info", "[HMR] - " + parts.pop());
log("info", "[HMR] - " + moduleId);
@@ -32,7 +35,10 @@ module.exports = function(updatedModules, renewedModules) {
var numberIds = renewedModules.every(function(moduleId) {
return typeof moduleId === "number";
});
- if(numberIds)
- log("info", "[HMR] Consider using the NamedModulesPlugin for module names.");
+ if (numberIds)
+ log(
+ "info",
+ "[HMR] Consider using the NamedModulesPlugin for module names."
+ );
}
};
diff --git a/hot/log.js b/hot/log.js
index 2baf6cce..d9e09b22 100644
--- a/hot/log.js
+++ b/hot/log.js
@@ -3,7 +3,8 @@ var logLevel = "info";
function dummy() {}
function shouldLog(level) {
- var shouldLog = (logLevel === "info" && level === "info") ||
+ var shouldLog =
+ (logLevel === "info" && level === "info") ||
(["info", "warning"].indexOf(logLevel) >= 0 && level === "warning") ||
(["info", "warning", "error"].indexOf(logLevel) >= 0 && level === "error");
return shouldLog;
@@ -11,19 +12,19 @@ function shouldLog(level) {
function logGroup(logFn) {
return function(level, msg) {
- if(shouldLog(level)) {
+ if (shouldLog(level)) {
logFn(msg);
}
};
}
module.exports = function(level, msg) {
- if(shouldLog(level)) {
- if(level === "info") {
+ if (shouldLog(level)) {
+ if (level === "info") {
console.log(msg);
- } else if(level === "warning") {
+ } else if (level === "warning") {
console.warn(msg);
- } else if(level === "error") {
+ } else if (level === "error") {
console.error(msg);
}
}
diff --git a/hot/only-dev-server.js b/hot/only-dev-server.js
index 0ad41eee..cf452dc6 100644
--- a/hot/only-dev-server.js
+++ b/hot/only-dev-server.js
@@ -3,65 +3,99 @@
Author Tobias Koppers @sokra
*/
/*globals __webpack_hash__ */
-if(module.hot) {
+if (module.hot) {
var lastHash;
var upToDate = function upToDate() {
return lastHash.indexOf(__webpack_hash__) >= 0;
};
var log = require("./log");
var check = function check() {
- module.hot.check().then(function(updatedModules) {
- if(!updatedModules) {
- log("warning", "[HMR] Cannot find update. Need to do a full reload!");
- log("warning", "[HMR] (Probably because of restarting the webpack-dev-server)");
- return;
- }
-
- return module.hot.apply({
- ignoreUnaccepted: true,
- ignoreDeclined: true,
- ignoreErrored: true,
- onUnaccepted: function(data) {
- log("warning", "Ignored an update to unaccepted module " + data.chain.join(" -> "));
- },
- onDeclined: function(data) {
- log("warning", "Ignored an update to declined module " + data.chain.join(" -> "));
- },
- onErrored: function(data) {
- log("error", data.error);
- log("warning", "Ignored an error while updating module " + data.moduleId + " (" + data.type + ")");
- }
- }).then(function(renewedModules) {
- if(!upToDate()) {
- check();
+ module.hot
+ .check()
+ .then(function(updatedModules) {
+ if (!updatedModules) {
+ log("warning", "[HMR] Cannot find update. Need to do a full reload!");
+ log(
+ "warning",
+ "[HMR] (Probably because of restarting the webpack-dev-server)"
+ );
+ return;
}
- require("./log-apply-result")(updatedModules, renewedModules);
+ return module.hot
+ .apply({
+ ignoreUnaccepted: true,
+ ignoreDeclined: true,
+ ignoreErrored: true,
+ onUnaccepted: function(data) {
+ log(
+ "warning",
+ "Ignored an update to unaccepted module " +
+ data.chain.join(" -> ")
+ );
+ },
+ onDeclined: function(data) {
+ log(
+ "warning",
+ "Ignored an update to declined module " +
+ data.chain.join(" -> ")
+ );
+ },
+ onErrored: function(data) {
+ log("error", data.error);
+ log(
+ "warning",
+ "Ignored an error while updating module " +
+ data.moduleId +
+ " (" +
+ data.type +
+ ")"
+ );
+ }
+ })
+ .then(function(renewedModules) {
+ if (!upToDate()) {
+ check();
+ }
- if(upToDate()) {
- log("info", "[HMR] App is up to date.");
+ require("./log-apply-result")(updatedModules, renewedModules);
+
+ if (upToDate()) {
+ log("info", "[HMR] App is up to date.");
+ }
+ });
+ })
+ .catch(function(err) {
+ var status = module.hot.status();
+ if (["abort", "fail"].indexOf(status) >= 0) {
+ log(
+ "warning",
+ "[HMR] Cannot check for update. Need to do a full reload!"
+ );
+ log("warning", "[HMR] " + err.stack || err.message);
+ } else {
+ log(
+ "warning",
+ "[HMR] Update check failed: " + err.stack || err.message
+ );
}
});
- }).catch(function(err) {
- var status = module.hot.status();
- if(["abort", "fail"].indexOf(status) >= 0) {
- log("warning", "[HMR] Cannot check for update. Need to do a full reload!");
- log("warning", "[HMR] " + err.stack || err.message);
- } else {
- log("warning", "[HMR] Update check failed: " + err.stack || err.message);
- }
- });
};
var hotEmitter = require("./emitter");
hotEmitter.on("webpackHotUpdate", function(currentHash) {
lastHash = currentHash;
- if(!upToDate()) {
+ if (!upToDate()) {
var status = module.hot.status();
- if(status === "idle") {
+ if (status === "idle") {
log("info", "[HMR] Checking for updates on the server...");
check();
- } else if(["abort", "fail"].indexOf(status) >= 0) {
- log("warning", "[HMR] Cannot apply update as a previous update " + status + "ed. Need to do a full reload!");
+ } else if (["abort", "fail"].indexOf(status) >= 0) {
+ log(
+ "warning",
+ "[HMR] Cannot apply update as a previous update " +
+ status +
+ "ed. Need to do a full reload!"
+ );
}
}
});
diff --git a/hot/poll.js b/hot/poll.js
index 5a075f67..f615acce 100644
--- a/hot/poll.js
+++ b/hot/poll.js
@@ -3,29 +3,32 @@
Author Tobias Koppers @sokra
*/
/*globals __resourceQuery */
-if(module.hot) {
- var hotPollInterval = +(__resourceQuery.substr(1)) || (10 * 60 * 1000);
+if (module.hot) {
+ var hotPollInterval = +__resourceQuery.substr(1) || 10 * 60 * 1000;
var log = require("./log");
var checkForUpdate = function checkForUpdate(fromUpdate) {
- if(module.hot.status() === "idle") {
- module.hot.check(true).then(function(updatedModules) {
- if(!updatedModules) {
- if(fromUpdate) log("info", "[HMR] Update applied.");
- return;
- }
- require("./log-apply-result")(updatedModules, updatedModules);
- checkForUpdate(true);
- }).catch(function(err) {
- var status = module.hot.status();
- if(["abort", "fail"].indexOf(status) >= 0) {
- log("warning", "[HMR] Cannot apply update.");
- log("warning", "[HMR] " + err.stack || err.message);
- log("warning", "[HMR] You need to restart the application!");
- } else {
- log("warning", "[HMR] Update failed: " + err.stack || err.message);
- }
- });
+ if (module.hot.status() === "idle") {
+ module.hot
+ .check(true)
+ .then(function(updatedModules) {
+ if (!updatedModules) {
+ if (fromUpdate) log("info", "[HMR] Update applied.");
+ return;
+ }
+ require("./log-apply-result")(updatedModules, updatedModules);
+ checkForUpdate(true);
+ })
+ .catch(function(err) {
+ var status = module.hot.status();
+ if (["abort", "fail"].indexOf(status) >= 0) {
+ log("warning", "[HMR] Cannot apply update.");
+ log("warning", "[HMR] " + err.stack || err.message);
+ log("warning", "[HMR] You need to restart the application!");
+ } else {
+ log("warning", "[HMR] Update failed: " + err.stack || err.message);
+ }
+ });
}
};
setInterval(checkForUpdate, hotPollInterval);
diff --git a/hot/signal.js b/hot/signal.js
index 2dfa8867..d3ce50e8 100644
--- a/hot/signal.js
+++ b/hot/signal.js
@@ -3,44 +3,54 @@
Author Tobias Koppers @sokra
*/
/*globals __resourceQuery */
-if(module.hot) {
+if (module.hot) {
var log = require("./log");
var checkForUpdate = function checkForUpdate(fromUpdate) {
- module.hot.check().then(function(updatedModules) {
- if(!updatedModules) {
- if(fromUpdate)
- log("info", "[HMR] Update applied.");
- else
- log("warning", "[HMR] Cannot find update.");
- return;
- }
+ module.hot
+ .check()
+ .then(function(updatedModules) {
+ if (!updatedModules) {
+ if (fromUpdate) log("info", "[HMR] Update applied.");
+ else log("warning", "[HMR] Cannot find update.");
+ return;
+ }
- return module.hot.apply({
- ignoreUnaccepted: true,
- onUnaccepted: function(data) {
- log("warning", "Ignored an update to unaccepted module " + data.chain.join(" -> "));
- },
- }).then(function(renewedModules) {
- require("./log-apply-result")(updatedModules, renewedModules);
+ return module.hot
+ .apply({
+ ignoreUnaccepted: true,
+ onUnaccepted: function(data) {
+ log(
+ "warning",
+ "Ignored an update to unaccepted module " +
+ data.chain.join(" -> ")
+ );
+ }
+ })
+ .then(function(renewedModules) {
+ require("./log-apply-result")(updatedModules, renewedModules);
- checkForUpdate(true);
- return null;
+ checkForUpdate(true);
+ return null;
+ });
+ })
+ .catch(function(err) {
+ var status = module.hot.status();
+ if (["abort", "fail"].indexOf(status) >= 0) {
+ log("warning", "[HMR] Cannot apply update.");
+ log("warning", "[HMR] " + err.stack || err.message);
+ log("warning", "[HMR] You need to restart the application!");
+ } else {
+ log("warning", "[HMR] Update failed: " + err.stack || err.message);
+ }
});
- }).catch(function(err) {
- var status = module.hot.status();
- if(["abort", "fail"].indexOf(status) >= 0) {
- log("warning", "[HMR] Cannot apply update.");
- log("warning", "[HMR] " + err.stack || err.message);
- log("warning", "[HMR] You need to restart the application!");
- } else {
- log("warning", "[HMR] Update failed: " + err.stack || err.message);
- }
- });
};
process.on(__resourceQuery.substr(1) || "SIGUSR2", function() {
- if(module.hot.status() !== "idle") {
- log("warning", "[HMR] Got signal but currently in " + module.hot.status() + " state.");
+ if (module.hot.status() !== "idle") {
+ log(
+ "warning",
+ "[HMR] Got signal but currently in " + module.hot.status() + " state."
+ );
log("warning", "[HMR] Need to be in idle state to start hot update.");
return;
}
diff --git a/lib/APIPlugin.js b/lib/APIPlugin.js
index 6456ad85..ad8980cb 100644
--- a/lib/APIPlugin.js
+++ b/lib/APIPlugin.js
@@ -9,36 +9,75 @@ const ParserHelpers = require("./ParserHelpers");
const NullFactory = require("./NullFactory");
+/* eslint-disable camelcase */
const REPLACEMENTS = {
- __webpack_require__: "__webpack_require__", // eslint-disable-line camelcase
- __webpack_public_path__: "__webpack_require__.p", // eslint-disable-line camelcase
- __webpack_modules__: "__webpack_require__.m", // eslint-disable-line camelcase
- __webpack_chunk_load__: "__webpack_require__.e", // eslint-disable-line camelcase
- __non_webpack_require__: "require", // eslint-disable-line camelcase
- __webpack_nonce__: "__webpack_require__.nc", // eslint-disable-line camelcase
- "require.onError": "__webpack_require__.oe" // eslint-disable-line camelcase
+ __webpack_require__: "__webpack_require__",
+ __webpack_public_path__: "__webpack_require__.p",
+ __webpack_modules__: "__webpack_require__.m",
+ __webpack_chunk_load__: "__webpack_require__.e",
+ __non_webpack_require__: "require",
+ __webpack_nonce__: "__webpack_require__.nc",
+ "require.onError": "__webpack_require__.oe"
+};
+const NO_WEBPACK_REQUIRE = {
+ __non_webpack_require__: true
};
const REPLACEMENT_TYPES = {
- __webpack_public_path__: "string", // eslint-disable-line camelcase
- __webpack_require__: "function", // eslint-disable-line camelcase
- __webpack_modules__: "object", // eslint-disable-line camelcase
- __webpack_chunk_load__: "function", // eslint-disable-line camelcase
- __webpack_nonce__: "string" // eslint-disable-line camelcase
+ __webpack_public_path__: "string",
+ __webpack_require__: "function",
+ __webpack_modules__: "object",
+ __webpack_chunk_load__: "function",
+ __webpack_nonce__: "string"
};
+/* eslint-enable camelcase */
class APIPlugin {
apply(compiler) {
- compiler.plugin("compilation", (compilation, params) => {
- compilation.dependencyFactories.set(ConstDependency, new NullFactory());
- compilation.dependencyTemplates.set(ConstDependency, new ConstDependency.Template());
+ compiler.hooks.compilation.tap(
+ "APIPlugin",
+ (compilation, { normalModuleFactory }) => {
+ compilation.dependencyFactories.set(ConstDependency, new NullFactory());
+ compilation.dependencyTemplates.set(
+ ConstDependency,
+ new ConstDependency.Template()
+ );
+
+ const handler = parser => {
+ Object.keys(REPLACEMENTS).forEach(key => {
+ parser.hooks.expression
+ .for(key)
+ .tap(
+ "APIPlugin",
+ NO_WEBPACK_REQUIRE[key]
+ ? ParserHelpers.toConstantDependency(
+ parser,
+ REPLACEMENTS[key]
+ )
+ : ParserHelpers.toConstantDependencyWithWebpackRequire(
+ parser,
+ REPLACEMENTS[key]
+ )
+ );
+ parser.hooks.evaluateTypeof
+ .for(key)
+ .tap(
+ "APIPlugin",
+ ParserHelpers.evaluateToString(REPLACEMENT_TYPES[key])
+ );
+ });
+ };
- params.normalModuleFactory.plugin("parser", parser => {
- Object.keys(REPLACEMENTS).forEach(key => {
- parser.plugin(`expression ${key}`, ParserHelpers.toConstantDependency(REPLACEMENTS[key]));
- parser.plugin(`evaluate typeof ${key}`, ParserHelpers.evaluateToString(REPLACEMENT_TYPES[key]));
- });
- });
- });
+ normalModuleFactory.hooks.parser
+ .for("javascript/auto")
+ .tap("APIPlugin", handler);
+ normalModuleFactory.hooks.parser
+ .for("javascript/dynamic")
+ .tap("APIPlugin", handler);
+ normalModuleFactory.hooks.parser
+ .for("javascript/esm")
+ .tap("APIPlugin", handler);
+ }
+ );
}
}
diff --git a/lib/AmdMainTemplatePlugin.js b/lib/AmdMainTemplatePlugin.js
index 9e2e6b67..fe63c23b 100644
--- a/lib/AmdMainTemplatePlugin.js
+++ b/lib/AmdMainTemplatePlugin.js
@@ -14,39 +14,60 @@ class AmdMainTemplatePlugin {
}
apply(compilation) {
- const mainTemplate = compilation.mainTemplate;
-
- compilation.templatesPlugin("render-with-entry", (source, chunk, hash) => {
- const externals = chunk.getModules().filter((m) => m.external);
- const externalsDepsArray = JSON.stringify(externals.map((m) =>
- typeof m.request === "object" ? m.request.amd : m.request
- ));
- const externalsArguments = externals.map((m) =>
- Template.toIdentifier(`__WEBPACK_EXTERNAL_MODULE_${m.id}__`)
- ).join(", ");
-
- if(this.name) {
- const name = mainTemplate.applyPluginsWaterfall("asset-path", this.name, {
+ const { mainTemplate, chunkTemplate } = compilation;
+
+ const onRenderWithEntry = (source, chunk, hash) => {
+ const externals = chunk.getModules().filter(m => m.external);
+ const externalsDepsArray = JSON.stringify(
+ externals.map(
+ m => (typeof m.request === "object" ? m.request.amd : m.request)
+ )
+ );
+ const externalsArguments = externals
+ .map(
+ m => `__WEBPACK_EXTERNAL_MODULE_${Template.toIdentifier(`${m.id}`)}__`
+ )
+ .join(", ");
+
+ if (this.name) {
+ const name = mainTemplate.getAssetPath(this.name, {
hash,
chunk
});
return new ConcatSource(
- `define(${JSON.stringify(name)}, ${externalsDepsArray}, function(${externalsArguments}) { return `, source, "});"
+ `define(${JSON.stringify(name)}, ${externalsDepsArray}, function(${
+ externalsArguments
+ }) { return `,
+ source,
+ "});"
+ );
+ } else if (externalsArguments) {
+ return new ConcatSource(
+ `define(${externalsDepsArray}, function(${
+ externalsArguments
+ }) { return `,
+ source,
+ "});"
);
- } else if(externalsArguments) {
- return new ConcatSource(`define(${externalsDepsArray}, function(${externalsArguments}) { return `, source, "});");
} else {
return new ConcatSource("define(function() { return ", source, "});");
}
- });
+ };
+
+ for (const template of [mainTemplate, chunkTemplate]) {
+ template.hooks.renderWithEntry.tap(
+ "AmdMainTemplatePlugin",
+ onRenderWithEntry
+ );
+ }
- mainTemplate.plugin("global-hash-paths", (paths) => {
- if(this.name) paths.push(this.name);
+ mainTemplate.hooks.globalHashPaths.tap("AmdMainTemplatePlugin", paths => {
+ if (this.name) paths.push(this.name);
return paths;
});
- mainTemplate.plugin("hash", (hash) => {
+ mainTemplate.hooks.hash.tap("AmdMainTemplatePlugin", hash => {
hash.update("exports amd");
hash.update(this.name);
});
diff --git a/lib/AsyncDependenciesBlock.js b/lib/AsyncDependenciesBlock.js
index e8ff2daa..806d8497 100644
--- a/lib/AsyncDependenciesBlock.js
+++ b/lib/AsyncDependenciesBlock.js
@@ -6,38 +6,48 @@
const DependenciesBlock = require("./DependenciesBlock");
module.exports = class AsyncDependenciesBlock extends DependenciesBlock {
- constructor(name, module, loc) {
+ constructor(name, module, loc, request) {
super();
this.chunkName = name;
- this.chunks = null;
+ this.chunkGroup = undefined;
this.module = module;
this.loc = loc;
+ this.request = request;
}
- get chunk() {
- throw new Error("`chunk` was been renamed to `chunks` and is now an array");
+
+ get chunks() {
+ throw new Error("Moved to AsyncDependenciesBlock.chunkGroup");
}
- set chunk(chunk) {
- throw new Error("`chunk` was been renamed to `chunks` and is now an array");
+
+ set chunks(value) {
+ throw new Error("Moved to AsyncDependenciesBlock.chunkGroup");
}
+
updateHash(hash) {
hash.update(this.chunkName || "");
- hash.update(this.chunks && this.chunks.map((chunk) => {
- return chunk.id !== null ? chunk.id : "";
- }).join(",") || "");
+ hash.update(
+ (this.chunkGroup &&
+ this.chunkGroup.chunks
+ .map(chunk => {
+ return chunk.id !== null ? chunk.id : "";
+ })
+ .join(",")) ||
+ ""
+ );
super.updateHash(hash);
}
+
disconnect() {
- this.chunks = null;
+ this.chunkGroup = undefined;
super.disconnect();
}
+
unseal() {
- this.chunks = null;
+ this.chunkGroup = undefined;
super.unseal();
}
+
sortItems() {
super.sortItems();
- if(this.chunks) {
- this.chunks.sort((a, b) => a.compareTo(b));
- }
}
};
diff --git a/lib/AsyncDependencyToInitialChunkWarning.js b/lib/AsyncDependencyToInitialChunkError.js
similarity index 65%
rename from lib/AsyncDependencyToInitialChunkWarning.js
rename to lib/AsyncDependencyToInitialChunkError.js
index f9d223b6..168123f1 100644
--- a/lib/AsyncDependencyToInitialChunkWarning.js
+++ b/lib/AsyncDependencyToInitialChunkError.js
@@ -6,12 +6,14 @@
const WebpackError = require("./WebpackError");
-module.exports = class AsyncDependencyToInitialChunkWarning extends WebpackError {
+module.exports = class AsyncDependencyToInitialChunkError extends WebpackError {
constructor(chunkName, module, loc) {
super();
- this.name = "AsyncDependencyToInitialChunkWarning";
- this.message = `It's not allowed to load an initial chunk on demand. The chunk name "${chunkName}" is already used by an entrypoint.`;
+ this.name = "AsyncDependencyToInitialChunkError";
+ this.message = `It's not allowed to load an initial chunk on demand. The chunk name "${
+ chunkName
+ }" is already used by an entrypoint.`;
this.module = module;
this.origin = module;
this.originLoc = loc;
diff --git a/lib/AutomaticPrefetchPlugin.js b/lib/AutomaticPrefetchPlugin.js
index 9aabe17c..4efb350c 100644
--- a/lib/AutomaticPrefetchPlugin.js
+++ b/lib/AutomaticPrefetchPlugin.js
@@ -4,33 +4,47 @@
*/
"use strict";
-const asyncLib = require("async");
+const asyncLib = require("neo-async");
const PrefetchDependency = require("./dependencies/PrefetchDependency");
const NormalModule = require("./NormalModule");
class AutomaticPrefetchPlugin {
apply(compiler) {
- compiler.plugin("compilation", (compilation, params) => {
- const normalModuleFactory = params.normalModuleFactory;
-
- compilation.dependencyFactories.set(PrefetchDependency, normalModuleFactory);
- });
+ compiler.hooks.compilation.tap(
+ "AutomaticPrefetchPlugin",
+ (compilation, { normalModuleFactory }) => {
+ compilation.dependencyFactories.set(
+ PrefetchDependency,
+ normalModuleFactory
+ );
+ }
+ );
let lastModules = null;
- compiler.plugin("after-compile", (compilation, callback) => {
+ compiler.hooks.afterCompile.tap("AutomaticPrefetchPlugin", compilation => {
lastModules = compilation.modules
.filter(m => m instanceof NormalModule)
.map(m => ({
context: m.context,
request: m.request
}));
- callback();
- });
- compiler.plugin("make", (compilation, callback) => {
- if(!lastModules) return callback();
- asyncLib.forEach(lastModules, (m, callback) => {
- compilation.prefetch(m.context || compiler.context, new PrefetchDependency(m.request), callback);
- }, callback);
});
+ compiler.hooks.make.tapAsync(
+ "AutomaticPrefetchPlugin",
+ (compilation, callback) => {
+ if (!lastModules) return callback();
+ asyncLib.forEach(
+ lastModules,
+ (m, callback) => {
+ compilation.prefetch(
+ m.context || compiler.context,
+ new PrefetchDependency(m.request),
+ callback
+ );
+ },
+ callback
+ );
+ }
+ );
}
}
module.exports = AutomaticPrefetchPlugin;
diff --git a/lib/BannerPlugin.js b/lib/BannerPlugin.js
index d3a3afb1..97e383ce 100644
--- a/lib/BannerPlugin.js
+++ b/lib/BannerPlugin.js
@@ -7,66 +7,92 @@
const ConcatSource = require("webpack-sources").ConcatSource;
const ModuleFilenameHelpers = require("./ModuleFilenameHelpers");
+const Template = require("./Template");
-const wrapComment = (str) => {
- if(!str.includes("\n")) return `/*! ${str} */`;
- return `/*!\n * ${str.split("\n").join("\n * ")}\n */`;
+const validateOptions = require("schema-utils");
+const schema = require("../schemas/plugins/BannerPlugin.json");
+
+const wrapComment = str => {
+ if (!str.includes("\n")) return Template.toComment(str);
+ return `/*!\n * ${str
+ .replace(/\*\//g, "* /")
+ .split("\n")
+ .join("\n * ")}\n */`;
};
class BannerPlugin {
constructor(options) {
- if(arguments.length > 1)
- throw new Error("BannerPlugin only takes one argument (pass an options object)");
- if(typeof options === "string")
+ if (arguments.length > 1)
+ throw new Error(
+ "BannerPlugin only takes one argument (pass an options object)"
+ );
+
+ validateOptions(schema, options, "Banner Plugin");
+
+ if (typeof options === "string")
options = {
banner: options
};
this.options = options || {};
- this.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment