Files

Return to Package Diff Home.
Brought to you by Intrinsic.

Package Diff: webpack @ 4.30.0 .. 4.32.0

bin/webpack.js

@@ -109,7 +109,7 @@
)}".`
);
- let question = `Do you want to install 'webpack-cli' (yes/no): `;
+ const question = `Do you want to install 'webpack-cli' (yes/no): `;
const questionInterface = readLine.createInterface({
input: process.stdin,

declarations/WebpackOptions.d.ts

@@ -369,7 +369,14 @@
stats?:
| StatsOptions
| boolean
- | ("none" | "errors-only" | "minimal" | "normal" | "detailed" | "verbose");
+ | (
+ | "none"
+ | "errors-only"
+ | "minimal"
+ | "normal"
+ | "detailed"
+ | "verbose"
+ | "errors-warnings");
/**
* Environment to build for
*/
@@ -1054,7 +1061,7 @@
*/
filename?: string | Function;
/**
- * Use the future version of asset emitting logic, which is allows freeing memory of assets after emitting. It could break plugins which assume that assets are still readable after emitting. Will be the new default in the next major version.
+ * Use the future version of asset emitting logic, which allows freeing memory of assets after emitting. It could break plugins which assume that assets are still readable after emitting. Will be the new default in the next major version.
*/
futureEmitAssets?: boolean;
/**

lib/Chunk.js

@@ -688,7 +688,15 @@
};
if (includeDirectChildren) {
- addChildIdsByOrdersToMap(this);
+ const chunks = new Set();
+ for (const chunkGroup of this.groupsIterable) {
+ for (const chunk of chunkGroup.chunks) {
+ chunks.add(chunk);
+ }
+ }
+ for (const chunk of chunks) {
+ addChildIdsByOrdersToMap(chunk);
+ }
}
for (const chunk of this.getAllAsyncChunks()) {

lib/dependencies/HarmonyExportImportedSpecifierDependency.js

@@ -50,6 +50,7 @@
) {
super(request, originModule, sourceOrder, parserScope);
this.id = id;
+ this.redirectedId = undefined;
this.name = name;
this.activeExports = activeExports;
this.otherStarExports = otherStarExports;
@@ -60,9 +61,13 @@
return "harmony export imported specifier";
}
+ get _id() {
+ return this.redirectedId || this.id;
+ }
+
getMode(ignoreUnused) {
const name = this.name;
- const id = this.id;
+ const id = this._id;
const used = this.originModule.isUsed(name);
const importedModule = this._module;
@@ -288,7 +293,7 @@
};
}
- const importedModule = this.module;
+ const importedModule = this._module;
if (!importedModule) {
// no imported module available
@@ -350,11 +355,11 @@
// It's not an harmony module
if (
this.originModule.buildMeta.strictHarmonyModule &&
- this.id !== "default"
+ this._id !== "default"
) {
// In strict harmony modules we only support the default export
- const exportName = this.id
- ? `the named export '${this.id}'`
+ const exportName = this._id
+ ? `the named export '${this._id}'`
: "the namespace object";
return [
new HarmonyLinkingError(
@@ -365,20 +370,20 @@
return;
}
- if (!this.id) {
+ if (!this._id) {
return;
}
- if (importedModule.isProvided(this.id) !== false) {
+ if (importedModule.isProvided(this._id) !== false) {
// It's provided or we are not sure
return;
}
// We are sure that it's not provided
const idIsNotNameMessage =
- this.id !== this.name ? ` (reexported as '${this.name}')` : "";
+ this._id !== this.name ? ` (reexported as '${this.name}')` : "";
const errorMessage = `"export '${
- this.id
+ this._id
}'${idIsNotNameMessage} was not found in '${this.userRequest}'`;
return [new HarmonyLinkingError(errorMessage)];
}
@@ -402,6 +407,11 @@
importedModule.used + stringifiedUsedExport + stringifiedProvidedExport
);
}
+
+ disconnect() {
+ super.disconnect();
+ this.redirectedId = undefined;
+ }
}
module.exports = HarmonyExportImportedSpecifierDependency;

lib/MainTemplate.js

@@ -98,6 +98,8 @@
beforeStartup: new SyncWaterfallHook(["source", "chunk", "hash"]),
/** @type {SyncWaterfallHook<string, Chunk, string>} */
startup: new SyncWaterfallHook(["source", "chunk", "hash"]),
+ /** @type {SyncWaterfallHook<string, Chunk, string>} */
+ afterStartup: new SyncWaterfallHook(["source", "chunk", "hash"]),
render: new SyncWaterfallHook([
"source",
"chunk",
@@ -404,7 +406,20 @@
);
buf.push("");
buf.push(Template.asString(this.hooks.beforeStartup.call("", chunk, hash)));
+ const afterStartupCode = Template.asString(
+ this.hooks.afterStartup.call("", chunk, hash)
+ );
+ if (afterStartupCode) {
+ // TODO webpack 5: this is a bit hacky to avoid a breaking change
+ // change it to a better way
+ buf.push("var startupResult = (function() {");
+ }
buf.push(Template.asString(this.hooks.startup.call("", chunk, hash)));
+ if (afterStartupCode) {
+ buf.push("})();");
+ buf.push(afterStartupCode);
+ buf.push("return startupResult;");
+ }
return buf;
}

lib/NodeStuffPlugin.js

@@ -58,9 +58,10 @@
});
};
const context = compiler.context;
+ if (localOptions.__filename) {
if (localOptions.__filename === "mock") {
setConstant("__filename", "/index.js");
- } else if (localOptions.__filename) {
+ } else {
setModuleConstant("__filename", module =>
path.relative(context, module.resource)
);
@@ -75,9 +76,11 @@
i < 0 ? resource : resource.substr(0, i)
)(expr);
});
+ }
+ if (localOptions.__dirname) {
if (localOptions.__dirname === "mock") {
setConstant("__dirname", "/");
- } else if (localOptions.__dirname) {
+ } else {
setModuleConstant("__dirname", module =>
path.relative(context, module.context)
);
@@ -90,6 +93,7 @@
parser.state.module.context
)(expr);
});
+ }
parser.hooks.expression
.for("require.main")
.tap(

lib/NoModeWarning.js

@@ -16,7 +16,7 @@
"The 'mode' option has not been set, webpack will fallback to 'production' for this value. " +
"Set 'mode' option to 'development' or 'production' to enable defaults for each environment.\n" +
"You can also set it to 'none' to disable any default behavior. " +
- "Learn more: https://webpack.js.org/concepts/mode/";
+ "Learn more: https://webpack.js.org/configuration/mode/";
Error.captureStackTrace(this, this.constructor);
}

lib/NormalModule.js

@@ -212,6 +212,7 @@
rootContext: options.context,
webpack: true,
sourceMap: !!this.useSourceMap,
+ mode: options.mode || "production",
_module: this,
_compilation: compilation,
_compiler: compilation.compiler,

lib/optimize/SideEffectsFlagPlugin.js

@@ -111,8 +111,9 @@
const reason = module.reasons[i];
const dep = reason.dependency;
if (
- dep instanceof HarmonyImportSpecifierDependency &&
- !dep.namespaceObjectAsContext
+ dep instanceof HarmonyExportImportedSpecifierDependency ||
+ (dep instanceof HarmonyImportSpecifierDependency &&
+ !dep.namespaceObjectAsContext)
) {
const mapping = map.get(dep.id);
if (mapping) {

lib/Parser.js

@@ -1954,6 +1954,9 @@
case "RestElement":
this.enterRestElement(pattern, onIdent);
break;
+ case "Property":
+ this.enterPattern(pattern.value, onIdent);
+ break;
}
}
@@ -1968,7 +1971,7 @@
propIndex++
) {
const prop = pattern.properties[propIndex];
- this.enterPattern(prop.value, onIdent);
+ this.enterPattern(prop, onIdent);
}
}
@@ -2238,6 +2241,8 @@
if (type === "auto") {
parserOptions.sourceType = "module";
+ } else if (parserOptions.sourceType === "script") {
+ parserOptions.allowReturnOutsideFunction = true;
}
let ast;
@@ -2252,6 +2257,7 @@
if (threw && type === "auto") {
parserOptions.sourceType = "script";
+ parserOptions.allowReturnOutsideFunction = true;
if (Array.isArray(parserOptions.onComment)) {
parserOptions.onComment.length = 0;
}

lib/Stats.js

@@ -1408,6 +1408,12 @@
errors: true,
moduleTrace: true
};
+ case "errors-warnings":
+ return {
+ all: false,
+ errors: true,
+ warnings: true
+ };
default:
return {};
}

lib/web/JsonpMainTemplatePlugin.js

@@ -115,7 +115,11 @@
),
"};",
"",
- needEntryDeferringCode(chunk) ? "var deferredModules = [];" : ""
+ needEntryDeferringCode(chunk)
+ ? needPrefetchingCode(chunk)
+ ? "var deferredModules = [], deferredPrefetch = [];"
+ : "var deferredModules = [];"
+ : ""
);
}
if (needChunkOnDemandLoadingCode(chunk)) {
@@ -169,6 +173,8 @@
"}"
])
: "",
+ "// create error before stack unwound to get useful stacktrace later",
+ "var error = new Error();",
"onScriptComplete = function (event) {",
Template.indent([
"// avoid mem leaks in IE.",
@@ -181,7 +187,7 @@
Template.indent([
"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.message = 'Loading chunk ' + chunkId + ' failed.\\n(' + errorType + ': ' + realSrc + ')';",
"error.type = errorType;",
"error.request = realSrc;",
"chunk[1](error);"
@@ -384,7 +390,9 @@
"}",
"if(parentJsonpFunction) parentJsonpFunction(data);",
withPrefetch
- ? Template.asString([
+ ? withDefer
+ ? "deferredPrefetch.push.apply(deferredPrefetch, prefetchChunks);"
+ : Template.asString([
"// chunk prefetching for javascript",
"prefetchChunks.forEach(function(chunkId) {",
Template.indent([
@@ -441,6 +449,31 @@
"}"
]),
"}",
+ withPrefetch
+ ? Template.asString([
+ "if(deferredModules.length === 0) {",
+ Template.indent([
+ "// chunk prefetching for javascript",
+ "deferredPrefetch.forEach(function(chunkId) {",
+ Template.indent([
+ "if(installedChunks[chunkId] === undefined) {",
+ Template.indent([
+ "installedChunks[chunkId] = null;",
+ mainTemplate.hooks.linkPrefetch.call(
+ "",
+ chunk,
+ hash
+ ),
+ "document.head.appendChild(link);"
+ ]),
+ "}"
+ ]),
+ "});",
+ "deferredPrefetch.length = 0;"
+ ]),
+ "}"
+ ])
+ : "",
"return result;"
]),
"}"
@@ -473,7 +506,7 @@
return source;
}
);
- mainTemplate.hooks.beforeStartup.tap(
+ mainTemplate.hooks.afterStartup.tap(
"JsonpMainTemplatePlugin",
(source, chunk, hash) => {
const prefetchChunks = chunk.getChildIdsByOrders().prefetch;

lib/WebpackOptionsApply.js

@@ -21,7 +21,6 @@
const APIPlugin = require("./APIPlugin");
const ConstPlugin = require("./ConstPlugin");
-const NodeStuffPlugin = require("./NodeStuffPlugin");
const CompatibilityPlugin = require("./CompatibilityPlugin");
const TemplatedPathPlugin = require("./TemplatedPathPlugin");
@@ -290,7 +289,10 @@
}
new CommonJsPlugin(options.module).apply(compiler);
new LoaderPlugin().apply(compiler);
+ if (options.node !== false) {
+ const NodeStuffPlugin = require("./NodeStuffPlugin");
new NodeStuffPlugin(options.node).apply(compiler);
+ }
new APIPlugin().apply(compiler);
new ConstPlugin().apply(compiler);
new UseStrictPlugin().apply(compiler);

package.json

@@ -1,6 +1,6 @@
{
"name": "webpack",
- "version": "4.30.0",
+ "version": "4.32.0",
"author": "Tobias Koppers @sokra",
"description": "Packs CommonJs/AMD modules for the browser. Allows to split your codebase into multiple bundles, which can be loaded on demand. Support loaders to preprocess files, i.e. json, jsx, es7, css, less, ... and your custom stuff.",
"license": "MIT",

README.md

@@ -90,7 +90,7 @@
### Get Started
-Check out webpack's quick [**Get Started**](https://webpack.js.org/get-started/) guide and the [other guides](https://webpack.js.org/guides/).
+Check out webpack's quick [**Get Started**](https://webpack.js.org/guides/getting-started) guide and the [other guides](https://webpack.js.org/guides/).
### Browser Compatibility

schemas/WebpackOptions.json

@@ -868,7 +868,7 @@
]
},
"futureEmitAssets": {
- "description": "Use the future version of asset emitting logic, which is allows freeing memory of assets after emitting. It could break plugins which assume that assets are still readable after emitting. Will be the new default in the next major version.",
+ "description": "Use the future version of asset emitting logic, which allows freeing memory of assets after emitting. It could break plugins which assume that assets are still readable after emitting. Will be the new default in the next major version.",
"type": "boolean"
},
"globalObject": {
@@ -2110,7 +2110,8 @@
"minimal",
"normal",
"detailed",
- "verbose"
+ "verbose",
+ "errors-warnings"
]
}
]