commit
6db94536ad
|
@ -0,0 +1 @@
|
||||||
|
[Code of Conduct](https://js.foundation/community/code-of-conduct)
|
|
@ -59,7 +59,7 @@ declare module "neo-async" {
|
||||||
}
|
}
|
||||||
|
|
||||||
export type AsyncAutoTasks<R extends Dictionary<any>, E> = {
|
export type AsyncAutoTasks<R extends Dictionary<any>, E> = {
|
||||||
[K in keyof R]: AsyncAutoTask<R[K], R, E>
|
[K in keyof R]: AsyncAutoTask<R[K], R, E>;
|
||||||
};
|
};
|
||||||
export type AsyncAutoTask<R1, R extends Dictionary<any>, E> =
|
export type AsyncAutoTask<R1, R extends Dictionary<any>, E> =
|
||||||
| AsyncAutoTaskFunctionWithoutDependencies<R1, E>
|
| AsyncAutoTaskFunctionWithoutDependencies<R1, E>
|
||||||
|
|
|
@ -40,10 +40,10 @@ if (module.hot) {
|
||||||
"warning",
|
"warning",
|
||||||
"[HMR] Cannot apply update. Need to do a full reload!"
|
"[HMR] Cannot apply update. Need to do a full reload!"
|
||||||
);
|
);
|
||||||
log("warning", "[HMR] " + (err.stack || err.message));
|
log("warning", "[HMR] " + log.formatError(err));
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
} else {
|
} else {
|
||||||
log("warning", "[HMR] Update failed: " + (err.stack || err.message));
|
log("warning", "[HMR] Update failed: " + log.formatError(err));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
12
hot/log.js
12
hot/log.js
|
@ -45,3 +45,15 @@ module.exports.groupEnd = logGroup(groupEnd);
|
||||||
module.exports.setLogLevel = function(level) {
|
module.exports.setLogLevel = function(level) {
|
||||||
logLevel = level;
|
logLevel = level;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
module.exports.formatError = function(err) {
|
||||||
|
var message = err.message;
|
||||||
|
var stack = err.stack;
|
||||||
|
if (!stack) {
|
||||||
|
return message;
|
||||||
|
} else if (stack.indexOf(message) < 0) {
|
||||||
|
return message + "\n" + stack;
|
||||||
|
} else {
|
||||||
|
return stack;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
|
@ -72,12 +72,9 @@ if (module.hot) {
|
||||||
"warning",
|
"warning",
|
||||||
"[HMR] Cannot check for update. Need to do a full reload!"
|
"[HMR] Cannot check for update. Need to do a full reload!"
|
||||||
);
|
);
|
||||||
log("warning", "[HMR] " + (err.stack || err.message));
|
log("warning", "[HMR] " + log.formatError(err));
|
||||||
} else {
|
} else {
|
||||||
log(
|
log("warning", "[HMR] Update check failed: " + log.formatError(err));
|
||||||
"warning",
|
|
||||||
"[HMR] Update check failed: " + (err.stack || err.message)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -23,13 +23,10 @@ if (module.hot) {
|
||||||
var status = module.hot.status();
|
var status = module.hot.status();
|
||||||
if (["abort", "fail"].indexOf(status) >= 0) {
|
if (["abort", "fail"].indexOf(status) >= 0) {
|
||||||
log("warning", "[HMR] Cannot apply update.");
|
log("warning", "[HMR] Cannot apply update.");
|
||||||
log("warning", "[HMR] " + (err.stack || err.message));
|
log("warning", "[HMR] " + log.formatError(err));
|
||||||
log("warning", "[HMR] You need to restart the application!");
|
log("warning", "[HMR] You need to restart the application!");
|
||||||
} else {
|
} else {
|
||||||
log(
|
log("warning", "[HMR] Update failed: " + log.formatError(err));
|
||||||
"warning",
|
|
||||||
"[HMR] Update failed: " + (err.stack || err.message)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ if (module.hot) {
|
||||||
var status = module.hot.status();
|
var status = module.hot.status();
|
||||||
if (["abort", "fail"].indexOf(status) >= 0) {
|
if (["abort", "fail"].indexOf(status) >= 0) {
|
||||||
log("warning", "[HMR] Cannot apply update.");
|
log("warning", "[HMR] Cannot apply update.");
|
||||||
log("warning", "[HMR] " + (err.stack || err.message));
|
log("warning", "[HMR] " + log.formatError(err));
|
||||||
log("warning", "[HMR] You need to restart the application!");
|
log("warning", "[HMR] You need to restart the application!");
|
||||||
} else {
|
} else {
|
||||||
log("warning", "[HMR] Update failed: " + (err.stack || err.message));
|
log("warning", "[HMR] Update failed: " + (err.stack || err.message));
|
||||||
|
|
|
@ -527,18 +527,14 @@ class ChunkGroup {
|
||||||
for (const child of chunk._children) {
|
for (const child of chunk._children) {
|
||||||
if (!child._parents.has(chunk)) {
|
if (!child._parents.has(chunk)) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`checkConstraints: child missing parent ${chunk.debugId} -> ${
|
`checkConstraints: child missing parent ${chunk.debugId} -> ${child.debugId}`
|
||||||
child.debugId
|
|
||||||
}`
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (const parentChunk of chunk._parents) {
|
for (const parentChunk of chunk._parents) {
|
||||||
if (!parentChunk._children.has(chunk)) {
|
if (!parentChunk._children.has(chunk)) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`checkConstraints: parent missing child ${parentChunk.debugId} <- ${
|
`checkConstraints: parent missing child ${parentChunk.debugId} <- ${chunk.debugId}`
|
||||||
chunk.debugId
|
|
||||||
}`
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,9 +86,7 @@ class CommonJsStuffPlugin {
|
||||||
"CommonJsStuffPlugin",
|
"CommonJsStuffPlugin",
|
||||||
toConstantDependency(
|
toConstantDependency(
|
||||||
parser,
|
parser,
|
||||||
`${RuntimeGlobals.moduleCache}[${
|
`${RuntimeGlobals.moduleCache}[${RuntimeGlobals.entryModuleId}]`,
|
||||||
RuntimeGlobals.entryModuleId
|
|
||||||
}]`,
|
|
||||||
[RuntimeGlobals.moduleCache, RuntimeGlobals.entryModuleId]
|
[RuntimeGlobals.moduleCache, RuntimeGlobals.entryModuleId]
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
|
@ -770,9 +770,7 @@ class Compilation {
|
||||||
const factory = this.dependencyFactories.get(dep.constructor);
|
const factory = this.dependencyFactories.get(dep.constructor);
|
||||||
if (factory === undefined) {
|
if (factory === undefined) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`No module factory available for dependency type: ${
|
`No module factory available for dependency type: ${dep.constructor.name}`
|
||||||
dep.constructor.name
|
|
||||||
}`
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
let innerMap = dependencies.get(factory);
|
let innerMap = dependencies.get(factory);
|
||||||
|
@ -1059,9 +1057,7 @@ class Compilation {
|
||||||
if (!moduleFactory) {
|
if (!moduleFactory) {
|
||||||
return callback(
|
return callback(
|
||||||
new WebpackError(
|
new WebpackError(
|
||||||
`No dependency factory available for this dependency type: ${
|
`No dependency factory available for this dependency type: ${dependency.constructor.name}`
|
||||||
dependency.constructor.name
|
|
||||||
}`
|
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -465,9 +465,7 @@ class ContextModule extends Module {
|
||||||
if (typeof fakeMap === "number") {
|
if (typeof fakeMap === "number") {
|
||||||
return `return ${this.getReturn(fakeMap)};`;
|
return `return ${this.getReturn(fakeMap)};`;
|
||||||
}
|
}
|
||||||
return `return ${
|
return `return ${RuntimeGlobals.createFakeNamespaceObject}(id, ${fakeMapDataExpression})`;
|
||||||
RuntimeGlobals.createFakeNamespaceObject
|
|
||||||
}(id, ${fakeMapDataExpression})`;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -741,9 +739,7 @@ module.exports = webpackAsyncContext;`;
|
||||||
const requestPrefix = hasNoChunk
|
const requestPrefix = hasNoChunk
|
||||||
? "Promise.resolve()"
|
? "Promise.resolve()"
|
||||||
: hasMultipleOrNoChunks
|
: hasMultipleOrNoChunks
|
||||||
? `Promise.all(ids.slice(${chunksStartPosition}).map(${
|
? `Promise.all(ids.slice(${chunksStartPosition}).map(${RuntimeGlobals.ensureChunk}))`
|
||||||
RuntimeGlobals.ensureChunk
|
|
||||||
}))`
|
|
||||||
: `${RuntimeGlobals.ensureChunk}(ids[${chunksStartPosition}])`;
|
: `${RuntimeGlobals.ensureChunk}(ids[${chunksStartPosition}])`;
|
||||||
const returnModuleObject = this.getReturnModuleObjectSource(
|
const returnModuleObject = this.getReturnModuleObjectSource(
|
||||||
fakeMap,
|
fakeMap,
|
||||||
|
|
|
@ -10,7 +10,6 @@ const { SyncBailHook, HookMap } = require("tapable");
|
||||||
const vm = require("vm");
|
const vm = require("vm");
|
||||||
const BasicEvaluatedExpression = require("./BasicEvaluatedExpression");
|
const BasicEvaluatedExpression = require("./BasicEvaluatedExpression");
|
||||||
const StackedSetMap = require("./util/StackedSetMap");
|
const StackedSetMap = require("./util/StackedSetMap");
|
||||||
const TrackingSet = require("./util/TrackingSet");
|
|
||||||
|
|
||||||
// Syntax: https://developer.mozilla.org/en/SpiderMonkey/Parser_API
|
// Syntax: https://developer.mozilla.org/en/SpiderMonkey/Parser_API
|
||||||
|
|
||||||
|
@ -37,8 +36,6 @@ const defaultParserOptions = {
|
||||||
// regexp to match at lease one "magic comment"
|
// regexp to match at lease one "magic comment"
|
||||||
const webpackCommentRegExp = new RegExp(/(^|\W)webpack[A-Z]{1,}[A-Za-z]{1,}:/);
|
const webpackCommentRegExp = new RegExp(/(^|\W)webpack[A-Z]{1,}[A-Za-z]{1,}:/);
|
||||||
|
|
||||||
const EMPTY_ARRAY = [];
|
|
||||||
|
|
||||||
const EMPTY_COMMENT_OPTIONS = {
|
const EMPTY_COMMENT_OPTIONS = {
|
||||||
options: null,
|
options: null,
|
||||||
errors: null
|
errors: null
|
||||||
|
@ -855,6 +852,14 @@ class JavascriptParser {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Block-Prewalking iterates the scope for block variable declarations
|
||||||
|
blockPrewalkStatements(statements) {
|
||||||
|
for (let index = 0, len = statements.length; index < len; index++) {
|
||||||
|
const statement = statements[index];
|
||||||
|
this.blockPrewalkStatement(statement);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Walking iterates the statements and expressions and processes them
|
// Walking iterates the statements and expressions and processes them
|
||||||
walkStatements(statements) {
|
walkStatements(statements) {
|
||||||
for (let index = 0, len = statements.length; index < len; index++) {
|
for (let index = 0, len = statements.length; index < len; index++) {
|
||||||
|
@ -868,9 +873,6 @@ class JavascriptParser {
|
||||||
case "BlockStatement":
|
case "BlockStatement":
|
||||||
this.prewalkBlockStatement(statement);
|
this.prewalkBlockStatement(statement);
|
||||||
break;
|
break;
|
||||||
case "ClassDeclaration":
|
|
||||||
this.prewalkClassDeclaration(statement);
|
|
||||||
break;
|
|
||||||
case "DoWhileStatement":
|
case "DoWhileStatement":
|
||||||
this.prewalkDoWhileStatement(statement);
|
this.prewalkDoWhileStatement(statement);
|
||||||
break;
|
break;
|
||||||
|
@ -922,6 +924,23 @@ class JavascriptParser {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
blockPrewalkStatement(statement) {
|
||||||
|
switch (statement.type) {
|
||||||
|
case "VariableDeclaration":
|
||||||
|
this.blockPrewalkVariableDeclaration(statement);
|
||||||
|
break;
|
||||||
|
case "ExportDefaultDeclaration":
|
||||||
|
this.blockPrewalkExportDefaultDeclaration(statement);
|
||||||
|
break;
|
||||||
|
case "ExportNamedDeclaration":
|
||||||
|
this.blockPrewalkExportNamedDeclaration(statement);
|
||||||
|
break;
|
||||||
|
case "ClassDeclaration":
|
||||||
|
this.blockPrewalkClassDeclaration(statement);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
walkStatement(statement) {
|
walkStatement(statement) {
|
||||||
if (this.hooks.statement.call(statement) !== undefined) return;
|
if (this.hooks.statement.call(statement) !== undefined) return;
|
||||||
switch (statement.type) {
|
switch (statement.type) {
|
||||||
|
@ -991,7 +1010,11 @@ class JavascriptParser {
|
||||||
}
|
}
|
||||||
|
|
||||||
walkBlockStatement(statement) {
|
walkBlockStatement(statement) {
|
||||||
this.walkStatements(statement.body);
|
this.inBlockScope(() => {
|
||||||
|
const body = statement.body;
|
||||||
|
this.blockPrewalkStatements(body);
|
||||||
|
this.walkStatements(body);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
walkExpressionStatement(statement) {
|
walkExpressionStatement(statement) {
|
||||||
|
@ -1109,20 +1132,30 @@ class JavascriptParser {
|
||||||
}
|
}
|
||||||
|
|
||||||
walkForStatement(statement) {
|
walkForStatement(statement) {
|
||||||
if (statement.init) {
|
this.inBlockScope(() => {
|
||||||
if (statement.init.type === "VariableDeclaration") {
|
if (statement.init) {
|
||||||
this.walkStatement(statement.init);
|
if (statement.init.type === "VariableDeclaration") {
|
||||||
} else {
|
this.blockPrewalkVariableDeclaration(statement.init);
|
||||||
this.walkExpression(statement.init);
|
this.walkStatement(statement.init);
|
||||||
|
} else {
|
||||||
|
this.walkExpression(statement.init);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
if (statement.test) {
|
||||||
if (statement.test) {
|
this.walkExpression(statement.test);
|
||||||
this.walkExpression(statement.test);
|
}
|
||||||
}
|
if (statement.update) {
|
||||||
if (statement.update) {
|
this.walkExpression(statement.update);
|
||||||
this.walkExpression(statement.update);
|
}
|
||||||
}
|
const body = statement.body;
|
||||||
this.walkStatement(statement.body);
|
if (body.type === "BlockStatement") {
|
||||||
|
// no need to add additional scope
|
||||||
|
this.blockPrewalkStatements(body.body);
|
||||||
|
this.walkStatements(body.body);
|
||||||
|
} else {
|
||||||
|
this.walkStatement(body);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
prewalkForInStatement(statement) {
|
prewalkForInStatement(statement) {
|
||||||
|
@ -1133,13 +1166,23 @@ class JavascriptParser {
|
||||||
}
|
}
|
||||||
|
|
||||||
walkForInStatement(statement) {
|
walkForInStatement(statement) {
|
||||||
if (statement.left.type === "VariableDeclaration") {
|
this.inBlockScope(() => {
|
||||||
this.walkVariableDeclaration(statement.left);
|
if (statement.left.type === "VariableDeclaration") {
|
||||||
} else {
|
this.blockPrewalkVariableDeclaration(statement.left);
|
||||||
this.walkPattern(statement.left);
|
this.walkVariableDeclaration(statement.left);
|
||||||
}
|
} else {
|
||||||
this.walkExpression(statement.right);
|
this.walkPattern(statement.left);
|
||||||
this.walkStatement(statement.body);
|
}
|
||||||
|
this.walkExpression(statement.right);
|
||||||
|
const body = statement.body;
|
||||||
|
if (body.type === "BlockStatement") {
|
||||||
|
// no need to add additional scope
|
||||||
|
this.blockPrewalkStatements(body.body);
|
||||||
|
this.walkStatements(body.body);
|
||||||
|
} else {
|
||||||
|
this.walkStatement(body);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
prewalkForOfStatement(statement) {
|
prewalkForOfStatement(statement) {
|
||||||
|
@ -1153,13 +1196,23 @@ class JavascriptParser {
|
||||||
}
|
}
|
||||||
|
|
||||||
walkForOfStatement(statement) {
|
walkForOfStatement(statement) {
|
||||||
if (statement.left.type === "VariableDeclaration") {
|
this.inBlockScope(() => {
|
||||||
this.walkVariableDeclaration(statement.left);
|
if (statement.left.type === "VariableDeclaration") {
|
||||||
} else {
|
this.blockPrewalkVariableDeclaration(statement.left);
|
||||||
this.walkPattern(statement.left);
|
this.walkVariableDeclaration(statement.left);
|
||||||
}
|
} else {
|
||||||
this.walkExpression(statement.right);
|
this.walkPattern(statement.left);
|
||||||
this.walkStatement(statement.body);
|
}
|
||||||
|
this.walkExpression(statement.right);
|
||||||
|
const body = statement.body;
|
||||||
|
if (body.type === "BlockStatement") {
|
||||||
|
// no need to add additional scope
|
||||||
|
this.blockPrewalkStatements(body.body);
|
||||||
|
this.walkStatements(body.body);
|
||||||
|
} else {
|
||||||
|
this.walkStatement(body);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Declarations
|
// Declarations
|
||||||
|
@ -1173,7 +1226,7 @@ class JavascriptParser {
|
||||||
walkFunctionDeclaration(statement) {
|
walkFunctionDeclaration(statement) {
|
||||||
const wasTopLevel = this.scope.topLevelScope;
|
const wasTopLevel = this.scope.topLevelScope;
|
||||||
this.scope.topLevelScope = false;
|
this.scope.topLevelScope = false;
|
||||||
this.inScope(statement.params, () => {
|
this.inFunctionScope(true, statement.params, () => {
|
||||||
for (const param of statement.params) {
|
for (const param of statement.params) {
|
||||||
this.walkPattern(param);
|
this.walkPattern(param);
|
||||||
}
|
}
|
||||||
|
@ -1214,6 +1267,33 @@ class JavascriptParser {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enterDeclaration(declaration, onIdent) {
|
||||||
|
switch (declaration.type) {
|
||||||
|
case "VariableDeclaration":
|
||||||
|
for (const declarator of declaration.declarations) {
|
||||||
|
switch (declarator.type) {
|
||||||
|
case "VariableDeclarator": {
|
||||||
|
this.enterPattern(declarator.id, onIdent);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "FunctionDeclaration":
|
||||||
|
this.enterPattern(declaration.id, onIdent);
|
||||||
|
break;
|
||||||
|
case "ClassDeclaration":
|
||||||
|
this.enterPattern(declaration.id, onIdent);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
blockPrewalkExportNamedDeclaration(statement) {
|
||||||
|
if (statement.declaration) {
|
||||||
|
this.blockPrewalkStatement(statement.declaration);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
prewalkExportNamedDeclaration(statement) {
|
prewalkExportNamedDeclaration(statement) {
|
||||||
let source;
|
let source;
|
||||||
if (statement.source) {
|
if (statement.source) {
|
||||||
|
@ -1226,16 +1306,11 @@ class JavascriptParser {
|
||||||
if (
|
if (
|
||||||
!this.hooks.exportDeclaration.call(statement, statement.declaration)
|
!this.hooks.exportDeclaration.call(statement, statement.declaration)
|
||||||
) {
|
) {
|
||||||
const originalDefinitions = this.scope.definitions;
|
|
||||||
const tracker = new TrackingSet(this.scope.definitions);
|
|
||||||
this.scope.definitions = tracker;
|
|
||||||
this.prewalkStatement(statement.declaration);
|
this.prewalkStatement(statement.declaration);
|
||||||
const newDefs = Array.from(tracker.getAddedItems());
|
let index = 0;
|
||||||
this.scope.definitions = originalDefinitions;
|
this.enterDeclaration(statement.declaration, def => {
|
||||||
for (let index = newDefs.length - 1; index >= 0; index--) {
|
this.hooks.exportSpecifier.call(statement, def, def, index++);
|
||||||
const def = newDefs[index];
|
});
|
||||||
this.hooks.exportSpecifier.call(statement, def, def, index);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (statement.specifiers) {
|
if (statement.specifiers) {
|
||||||
|
@ -1277,18 +1352,24 @@ class JavascriptParser {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
blockPrewalkExportDefaultDeclaration(statement) {
|
||||||
|
if (statement.declaration.type === "ClassDeclaration") {
|
||||||
|
this.blockPrewalkClassDeclaration(statement.declaration);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
prewalkExportDefaultDeclaration(statement) {
|
prewalkExportDefaultDeclaration(statement) {
|
||||||
if (statement.declaration.id) {
|
this.prewalkStatement(statement.declaration);
|
||||||
const originalDefinitions = this.scope.definitions;
|
if (
|
||||||
const tracker = new TrackingSet(this.scope.definitions);
|
statement.declaration.id &&
|
||||||
this.scope.definitions = tracker;
|
statement.declaration.type !== "FunctionExpression" &&
|
||||||
this.prewalkStatement(statement.declaration);
|
statement.declaration.type !== "ClassExpression"
|
||||||
const newDefs = Array.from(tracker.getAddedItems());
|
) {
|
||||||
this.scope.definitions = originalDefinitions;
|
this.hooks.exportSpecifier.call(
|
||||||
for (let index = 0, len = newDefs.length; index < len; index++) {
|
statement,
|
||||||
const def = newDefs[index];
|
statement.declaration.id.name,
|
||||||
this.hooks.exportSpecifier.call(statement, def, "default");
|
"default"
|
||||||
}
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1332,12 +1413,20 @@ class JavascriptParser {
|
||||||
}
|
}
|
||||||
|
|
||||||
prewalkVariableDeclaration(statement) {
|
prewalkVariableDeclaration(statement) {
|
||||||
|
if (statement.kind !== "var") return;
|
||||||
|
this._prewalkVariableDeclaration(statement, this.hooks.varDeclarationVar);
|
||||||
|
}
|
||||||
|
|
||||||
|
blockPrewalkVariableDeclaration(statement) {
|
||||||
|
if (statement.kind === "var") return;
|
||||||
const hookMap =
|
const hookMap =
|
||||||
statement.kind === "const"
|
statement.kind === "const"
|
||||||
? this.hooks.varDeclarationConst
|
? this.hooks.varDeclarationConst
|
||||||
: statement.kind === "let"
|
: this.hooks.varDeclarationLet;
|
||||||
? this.hooks.varDeclarationLet
|
this._prewalkVariableDeclaration(statement, hookMap);
|
||||||
: this.hooks.varDeclarationVar;
|
}
|
||||||
|
|
||||||
|
_prewalkVariableDeclaration(statement, hookMap) {
|
||||||
for (const declarator of statement.declarations) {
|
for (const declarator of statement.declarations) {
|
||||||
switch (declarator.type) {
|
switch (declarator.type) {
|
||||||
case "VariableDeclarator": {
|
case "VariableDeclarator": {
|
||||||
|
@ -1386,7 +1475,7 @@ class JavascriptParser {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
prewalkClassDeclaration(statement) {
|
blockPrewalkClassDeclaration(statement) {
|
||||||
if (statement.id) {
|
if (statement.id) {
|
||||||
this.scope.renames.set(statement.id.name, null);
|
this.scope.renames.set(statement.id.name, null);
|
||||||
this.scope.definitions.add(statement.id.name);
|
this.scope.definitions.add(statement.id.name);
|
||||||
|
@ -1416,11 +1505,15 @@ class JavascriptParser {
|
||||||
}
|
}
|
||||||
|
|
||||||
walkCatchClause(catchClause) {
|
walkCatchClause(catchClause) {
|
||||||
// Error binding is optional in catch clause since ECMAScript 2019
|
this.inBlockScope(() => {
|
||||||
const errorBinding =
|
// Error binding is optional in catch clause since ECMAScript 2019
|
||||||
catchClause.param === null ? EMPTY_ARRAY : [catchClause.param];
|
if (catchClause.param !== null) {
|
||||||
|
this.enterPattern(catchClause.param, ident => {
|
||||||
this.inScope(errorBinding, () => {
|
this.scope.renames.set(ident, null);
|
||||||
|
this.scope.definitions.add(ident);
|
||||||
|
});
|
||||||
|
this.walkPattern(catchClause.param);
|
||||||
|
}
|
||||||
this.prewalkStatement(catchClause.body);
|
this.prewalkStatement(catchClause.body);
|
||||||
this.walkStatement(catchClause.body);
|
this.walkStatement(catchClause.body);
|
||||||
});
|
});
|
||||||
|
@ -1603,7 +1696,7 @@ class JavascriptParser {
|
||||||
scopeParams.push(expression.id.name);
|
scopeParams.push(expression.id.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.inScope(scopeParams, () => {
|
this.inFunctionScope(true, scopeParams, () => {
|
||||||
for (const param of expression.params) {
|
for (const param of expression.params) {
|
||||||
this.walkPattern(param);
|
this.walkPattern(param);
|
||||||
}
|
}
|
||||||
|
@ -1621,7 +1714,7 @@ class JavascriptParser {
|
||||||
walkArrowFunctionExpression(expression) {
|
walkArrowFunctionExpression(expression) {
|
||||||
const wasTopLevel = this.scope.topLevelScope;
|
const wasTopLevel = this.scope.topLevelScope;
|
||||||
this.scope.topLevelScope = wasTopLevel ? "arrow" : false;
|
this.scope.topLevelScope = wasTopLevel ? "arrow" : false;
|
||||||
this.inScope(expression.params, () => {
|
this.inFunctionScope(false, expression.params, () => {
|
||||||
for (const param of expression.params) {
|
for (const param of expression.params) {
|
||||||
this.walkPattern(param);
|
this.walkPattern(param);
|
||||||
}
|
}
|
||||||
|
@ -1797,7 +1890,7 @@ class JavascriptParser {
|
||||||
scopeParams.push(functionExpression.id.name);
|
scopeParams.push(functionExpression.id.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.inScope(scopeParams, () => {
|
this.inFunctionScope(true, scopeParams, () => {
|
||||||
if (renameThis) {
|
if (renameThis) {
|
||||||
this.scope.renames.set("this", renameThis);
|
this.scope.renames.set("this", renameThis);
|
||||||
}
|
}
|
||||||
|
@ -1912,6 +2005,12 @@ class JavascriptParser {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
* @param {any} params scope params
|
||||||
|
* @param {function(): void} fn inner function
|
||||||
|
* @returns {void}
|
||||||
|
*/
|
||||||
inScope(params, fn) {
|
inScope(params, fn) {
|
||||||
const oldScope = this.scope;
|
const oldScope = this.scope;
|
||||||
this.scope = {
|
this.scope = {
|
||||||
|
@ -1925,22 +2024,60 @@ class JavascriptParser {
|
||||||
|
|
||||||
this.scope.renames.set("this", null);
|
this.scope.renames.set("this", null);
|
||||||
|
|
||||||
for (const param of params) {
|
this.enterPatterns(params, (ident, pattern) => {
|
||||||
if (typeof param !== "string") {
|
const hook = pattern && this.hooks.pattern.get(ident);
|
||||||
this.enterPattern(param, (param, pattern) => {
|
if (!hook || hook.call(pattern) !== true) {
|
||||||
const hook = this.hooks.pattern.get(param);
|
this.scope.renames.set(ident, null);
|
||||||
if (!hook || hook.call(pattern) !== true) {
|
this.scope.definitions.add(ident);
|
||||||
this.scope.renames.set(param, null);
|
|
||||||
this.scope.definitions.add(param);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else if (param) {
|
|
||||||
this.scope.renames.set(param, null);
|
|
||||||
this.scope.definitions.add(param);
|
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
|
|
||||||
fn();
|
fn();
|
||||||
|
|
||||||
|
this.scope = oldScope;
|
||||||
|
}
|
||||||
|
|
||||||
|
inFunctionScope(hasThis, params, fn) {
|
||||||
|
const oldScope = this.scope;
|
||||||
|
this.scope = {
|
||||||
|
topLevelScope: oldScope.topLevelScope,
|
||||||
|
inTry: false,
|
||||||
|
inShorthand: false,
|
||||||
|
isStrict: oldScope.isStrict,
|
||||||
|
definitions: oldScope.definitions.createChild(),
|
||||||
|
renames: oldScope.renames.createChild()
|
||||||
|
};
|
||||||
|
|
||||||
|
if (hasThis) {
|
||||||
|
this.scope.renames.set("this", null);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.enterPatterns(params, (ident, pattern) => {
|
||||||
|
const hook = pattern && this.hooks.pattern.get(ident);
|
||||||
|
if (!hook || hook.call(pattern) !== true) {
|
||||||
|
this.scope.renames.set(ident, null);
|
||||||
|
this.scope.definitions.add(ident);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
fn();
|
||||||
|
|
||||||
|
this.scope = oldScope;
|
||||||
|
}
|
||||||
|
|
||||||
|
inBlockScope(fn) {
|
||||||
|
const oldScope = this.scope;
|
||||||
|
this.scope = {
|
||||||
|
topLevelScope: oldScope.topLevelScope,
|
||||||
|
inTry: oldScope.inTry,
|
||||||
|
inShorthand: false,
|
||||||
|
isStrict: oldScope.isStrict,
|
||||||
|
definitions: oldScope.definitions.createChild(),
|
||||||
|
renames: oldScope.renames.createChild()
|
||||||
|
};
|
||||||
|
|
||||||
|
fn();
|
||||||
|
|
||||||
this.scope = oldScope;
|
this.scope = oldScope;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1955,6 +2092,16 @@ class JavascriptParser {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enterPatterns(patterns, onIdent) {
|
||||||
|
for (const pattern of patterns) {
|
||||||
|
if (typeof pattern !== "string") {
|
||||||
|
this.enterPattern(pattern, onIdent);
|
||||||
|
} else if (pattern) {
|
||||||
|
onIdent(pattern);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
enterPattern(pattern, onIdent) {
|
enterPattern(pattern, onIdent) {
|
||||||
if (!pattern) return;
|
if (!pattern) return;
|
||||||
switch (pattern.type) {
|
switch (pattern.type) {
|
||||||
|
@ -2156,6 +2303,7 @@ class JavascriptParser {
|
||||||
if (this.hooks.program.call(ast, comments) === undefined) {
|
if (this.hooks.program.call(ast, comments) === undefined) {
|
||||||
this.detectStrictMode(ast.body);
|
this.detectStrictMode(ast.body);
|
||||||
this.prewalkStatements(ast.body);
|
this.prewalkStatements(ast.body);
|
||||||
|
this.blockPrewalkStatements(ast.body);
|
||||||
this.walkStatements(ast.body);
|
this.walkStatements(ast.body);
|
||||||
}
|
}
|
||||||
this.scope = oldScope;
|
this.scope = oldScope;
|
||||||
|
|
|
@ -136,9 +136,7 @@ module.exports = class MainTemplate {
|
||||||
const moduleId = chunkGraph.getModuleId(entryModule);
|
const moduleId = chunkGraph.getModuleId(entryModule);
|
||||||
let moduleIdExpr = JSON.stringify(moduleId);
|
let moduleIdExpr = JSON.stringify(moduleId);
|
||||||
if (runtimeRequirements.has(RuntimeGlobals.entryModuleId)) {
|
if (runtimeRequirements.has(RuntimeGlobals.entryModuleId)) {
|
||||||
moduleIdExpr = `${
|
moduleIdExpr = `${RuntimeGlobals.entryModuleId} = ${moduleIdExpr}`;
|
||||||
RuntimeGlobals.entryModuleId
|
|
||||||
} = ${moduleIdExpr}`;
|
|
||||||
}
|
}
|
||||||
buf.push(`${mayReturn}__webpack_require__(${moduleIdExpr});`);
|
buf.push(`${mayReturn}__webpack_require__(${moduleIdExpr});`);
|
||||||
}
|
}
|
||||||
|
@ -230,9 +228,7 @@ module.exports = class MainTemplate {
|
||||||
)
|
)
|
||||||
? Template.asString([
|
? Template.asString([
|
||||||
"var execOptions = { id: moduleId, module: module, factory: modules[moduleId], require: __webpack_require__ };",
|
"var execOptions = { id: moduleId, module: module, factory: modules[moduleId], require: __webpack_require__ };",
|
||||||
`${
|
`${RuntimeGlobals.interceptModuleExecution}.forEach(function(handler) { handler(execOptions); });`,
|
||||||
RuntimeGlobals.interceptModuleExecution
|
|
||||||
}.forEach(function(handler) { handler(execOptions); });`,
|
|
||||||
"module = execOptions.module;",
|
"module = execOptions.module;",
|
||||||
"execOptions.factory.call(module.exports, module, module.exports, execOptions.require);"
|
"execOptions.factory.call(module.exports, module, module.exports, execOptions.require);"
|
||||||
])
|
])
|
||||||
|
|
|
@ -464,9 +464,7 @@ class ExportInfo {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Unexpected flags for canMangle ${this.canMangleProvide} ${
|
`Unexpected flags for canMangle ${this.canMangleProvide} ${this.canMangleUse}`
|
||||||
this.canMangleUse
|
|
||||||
}`
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -541,9 +539,7 @@ class ExportInfo {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Unexpected flags for getRenameInfo ${this.canMangleProvide} ${
|
`Unexpected flags for getRenameInfo ${this.canMangleProvide} ${this.canMangleUse}`
|
||||||
this.canMangleUse
|
|
||||||
}`
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,12 +12,22 @@ class ModuleParseError extends WebpackError {
|
||||||
/**
|
/**
|
||||||
* @param {string} source source code
|
* @param {string} source source code
|
||||||
* @param {Error&any} err the parse error
|
* @param {Error&any} err the parse error
|
||||||
|
* @param {string[]} loaders the loaders used
|
||||||
*/
|
*/
|
||||||
constructor(source, err) {
|
constructor(source, err, loaders) {
|
||||||
let message = "Module parse failed: " + (err && err.message);
|
let message = "Module parse failed: " + (err && err.message);
|
||||||
let loc = undefined;
|
let loc = undefined;
|
||||||
|
|
||||||
message += "\nYou may need an appropriate loader to handle this file type.";
|
if (loaders.length >= 1) {
|
||||||
|
message += `\nFile was processed with these loaders:${loaders
|
||||||
|
.map(loader => `\n * ${loader}`)
|
||||||
|
.join("")}`;
|
||||||
|
message +=
|
||||||
|
"\nYou may need an additional loader to handle the result of these loaders.";
|
||||||
|
} else {
|
||||||
|
message +=
|
||||||
|
"\nYou may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders";
|
||||||
|
}
|
||||||
|
|
||||||
if (
|
if (
|
||||||
err &&
|
err &&
|
||||||
|
@ -31,7 +41,7 @@ class ModuleParseError extends WebpackError {
|
||||||
// binary file
|
// binary file
|
||||||
message += "\n(Source code omitted for this binary file)";
|
message += "\n(Source code omitted for this binary file)";
|
||||||
} else {
|
} else {
|
||||||
const sourceLines = source.split("\n");
|
const sourceLines = source.split(/\r?\n/);
|
||||||
const start = Math.max(0, lineNumber - 3);
|
const start = Math.max(0, lineNumber - 3);
|
||||||
const linesBefore = sourceLines.slice(start, lineNumber - 1);
|
const linesBefore = sourceLines.slice(start, lineNumber - 1);
|
||||||
const theLine = sourceLines[lineNumber - 1];
|
const theLine = sourceLines[lineNumber - 1];
|
||||||
|
|
|
@ -469,7 +469,6 @@ class NormalModule extends Module {
|
||||||
markModuleAsErrored(error) {
|
markModuleAsErrored(error) {
|
||||||
// Restore build meta from successful build to keep importing state
|
// Restore build meta from successful build to keep importing state
|
||||||
this.buildMeta = Object.assign({}, this._lastSuccessfulBuildMeta);
|
this.buildMeta = Object.assign({}, this._lastSuccessfulBuildMeta);
|
||||||
|
|
||||||
this.error = error;
|
this.error = error;
|
||||||
this.errors.push(error);
|
this.errors.push(error);
|
||||||
}
|
}
|
||||||
|
@ -576,7 +575,10 @@ class NormalModule extends Module {
|
||||||
|
|
||||||
const handleParseError = e => {
|
const handleParseError = e => {
|
||||||
const source = /** @type {string} */ (this._source.source());
|
const source = /** @type {string} */ (this._source.source());
|
||||||
const error = new ModuleParseError(source, e);
|
const loaders = this.loaders.map(item =>
|
||||||
|
contextify(options.context, item.loader)
|
||||||
|
);
|
||||||
|
const error = new ModuleParseError(source, e, loaders);
|
||||||
this.markModuleAsErrored(error);
|
this.markModuleAsErrored(error);
|
||||||
this._initBuildHash(compilation);
|
this._initBuildHash(compilation);
|
||||||
return callback();
|
return callback();
|
||||||
|
|
|
@ -578,9 +578,7 @@ class NormalModuleFactory extends ModuleFactory {
|
||||||
err.message +
|
err.message +
|
||||||
"\n" +
|
"\n" +
|
||||||
"BREAKING CHANGE: It's no longer allowed to omit the '-loader' suffix when using loaders.\n" +
|
"BREAKING CHANGE: It's no longer allowed to omit the '-loader' suffix when using loaders.\n" +
|
||||||
` You need to specify '${
|
` You need to specify '${item.loader}-loader' instead of '${item.loader}',\n` +
|
||||||
item.loader
|
|
||||||
}-loader' instead of '${item.loader}',\n` +
|
|
||||||
" see https://webpack.js.org/migrate/3/#automatic-loader-module-name-extension-removed";
|
" see https://webpack.js.org/migrate/3/#automatic-loader-module-name-extension-removed";
|
||||||
}
|
}
|
||||||
callback(err);
|
callback(err);
|
||||||
|
|
|
@ -399,35 +399,23 @@ class RuntimeTemplate {
|
||||||
} else if (exportsType === "named") {
|
} else if (exportsType === "named") {
|
||||||
runtimeRequirements.add(RuntimeGlobals.createFakeNamespaceObject);
|
runtimeRequirements.add(RuntimeGlobals.createFakeNamespaceObject);
|
||||||
if (header) {
|
if (header) {
|
||||||
getModuleFunction = `function() { ${header}return ${
|
getModuleFunction = `function() { ${header}return ${RuntimeGlobals.createFakeNamespaceObject}(${moduleIdExpr}, 3); }`;
|
||||||
RuntimeGlobals.createFakeNamespaceObject
|
|
||||||
}(${moduleIdExpr}, 3); }`;
|
|
||||||
} else {
|
} else {
|
||||||
getModuleFunction = `${
|
getModuleFunction = `${RuntimeGlobals.createFakeNamespaceObject}.bind(__webpack_require__, ${comment}${idExpr}, 3)`;
|
||||||
RuntimeGlobals.createFakeNamespaceObject
|
|
||||||
}.bind(__webpack_require__, ${comment}${idExpr}, 3)`;
|
|
||||||
}
|
}
|
||||||
} else if (strict) {
|
} else if (strict) {
|
||||||
runtimeRequirements.add(RuntimeGlobals.createFakeNamespaceObject);
|
runtimeRequirements.add(RuntimeGlobals.createFakeNamespaceObject);
|
||||||
if (header) {
|
if (header) {
|
||||||
getModuleFunction = `function() { ${header}return ${
|
getModuleFunction = `function() { ${header}return ${RuntimeGlobals.createFakeNamespaceObject}(${moduleIdExpr}, 1); }`;
|
||||||
RuntimeGlobals.createFakeNamespaceObject
|
|
||||||
}(${moduleIdExpr}, 1); }`;
|
|
||||||
} else {
|
} else {
|
||||||
getModuleFunction = `${
|
getModuleFunction = `${RuntimeGlobals.createFakeNamespaceObject}.bind(__webpack_require__, ${comment}${idExpr}, 1)`;
|
||||||
RuntimeGlobals.createFakeNamespaceObject
|
|
||||||
}.bind(__webpack_require__, ${comment}${idExpr}, 1)`;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
runtimeRequirements.add(RuntimeGlobals.createFakeNamespaceObject);
|
runtimeRequirements.add(RuntimeGlobals.createFakeNamespaceObject);
|
||||||
if (header) {
|
if (header) {
|
||||||
getModuleFunction = `function() { ${header}return ${
|
getModuleFunction = `function() { ${header}return ${RuntimeGlobals.createFakeNamespaceObject}(${moduleIdExpr}, 7); }`;
|
||||||
RuntimeGlobals.createFakeNamespaceObject
|
|
||||||
}(${moduleIdExpr}, 7); }`;
|
|
||||||
} else {
|
} else {
|
||||||
getModuleFunction = `${
|
getModuleFunction = `${RuntimeGlobals.createFakeNamespaceObject}.bind(__webpack_require__, ${comment}${idExpr}, 7)`;
|
||||||
RuntimeGlobals.createFakeNamespaceObject
|
|
||||||
}.bind(__webpack_require__, ${comment}${idExpr}, 7)`;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -491,20 +479,14 @@ class RuntimeTemplate {
|
||||||
|
|
||||||
if (!exportsType && !originModule.buildMeta.strictHarmonyModule) {
|
if (!exportsType && !originModule.buildMeta.strictHarmonyModule) {
|
||||||
runtimeRequirements.add(RuntimeGlobals.compatGetDefaultExport);
|
runtimeRequirements.add(RuntimeGlobals.compatGetDefaultExport);
|
||||||
content += `/* harmony import */ ${optDeclaration}${importVar}_default = /*#__PURE__*/${
|
content += `/* harmony import */ ${optDeclaration}${importVar}_default = /*#__PURE__*/${RuntimeGlobals.compatGetDefaultExport}(${importVar});\n`;
|
||||||
RuntimeGlobals.compatGetDefaultExport
|
|
||||||
}(${importVar});\n`;
|
|
||||||
}
|
}
|
||||||
if (exportsType === "named") {
|
if (exportsType === "named") {
|
||||||
runtimeRequirements.add(RuntimeGlobals.createFakeNamespaceObject);
|
runtimeRequirements.add(RuntimeGlobals.createFakeNamespaceObject);
|
||||||
if (Array.isArray(chunkGraph.moduleGraph.getProvidedExports(module))) {
|
if (Array.isArray(chunkGraph.moduleGraph.getProvidedExports(module))) {
|
||||||
content += `${optDeclaration}${importVar}_namespace = /*#__PURE__*/${
|
content += `${optDeclaration}${importVar}_namespace = /*#__PURE__*/${RuntimeGlobals.createFakeNamespaceObject}(${moduleId}, 1);\n`;
|
||||||
RuntimeGlobals.createFakeNamespaceObject
|
|
||||||
}(${moduleId}, 1);\n`;
|
|
||||||
} else {
|
} else {
|
||||||
content += `${optDeclaration}${importVar}_namespace = /*#__PURE__*/${
|
content += `${optDeclaration}${importVar}_namespace = /*#__PURE__*/${RuntimeGlobals.createFakeNamespaceObject}(${moduleId});\n`;
|
||||||
RuntimeGlobals.createFakeNamespaceObject
|
|
||||||
}(${moduleId});\n`;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return content;
|
return content;
|
||||||
|
@ -567,9 +549,7 @@ class RuntimeTemplate {
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
runtimeRequirements.add(RuntimeGlobals.createFakeNamespaceObject);
|
runtimeRequirements.add(RuntimeGlobals.createFakeNamespaceObject);
|
||||||
return `/*#__PURE__*/${
|
return `/*#__PURE__*/${RuntimeGlobals.createFakeNamespaceObject}(${importVar})`;
|
||||||
RuntimeGlobals.createFakeNamespaceObject
|
|
||||||
}(${importVar})`;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,9 +97,7 @@ AMDRequireDependency.Template = class AMDRequireDependencyTemplate extends NullD
|
||||||
// has function range but no array range
|
// has function range but no array range
|
||||||
if (dep.functionRange && !dep.arrayRange) {
|
if (dep.functionRange && !dep.arrayRange) {
|
||||||
const startBlock = `${promise}.then((`;
|
const startBlock = `${promise}.then((`;
|
||||||
const endBlock = `).bind(exports, __webpack_require__, exports, module)).catch(${
|
const endBlock = `).bind(exports, __webpack_require__, exports, module)).catch(${RuntimeGlobals.uncaughtErrorHandler})`;
|
||||||
RuntimeGlobals.uncaughtErrorHandler
|
|
||||||
})`;
|
|
||||||
runtimeRequirements.add(RuntimeGlobals.uncaughtErrorHandler);
|
runtimeRequirements.add(RuntimeGlobals.uncaughtErrorHandler);
|
||||||
|
|
||||||
source.replace(dep.outerRange[0], dep.functionRange[0] - 1, startBlock);
|
source.replace(dep.outerRange[0], dep.functionRange[0] - 1, startBlock);
|
||||||
|
|
|
@ -835,9 +835,7 @@ HarmonyExportImportedSpecifierDependency.Template = class HarmonyExportImportedS
|
||||||
initFragments.push(
|
initFragments.push(
|
||||||
new InitFragment(
|
new InitFragment(
|
||||||
content +
|
content +
|
||||||
`${
|
`${RuntimeGlobals.definePropertyGetter}(${exportsName}, __WEBPACK_IMPORT_KEY__, function(key) { return ${importVar}[key]; }.bind(0, __WEBPACK_IMPORT_KEY__));\n`,
|
||||||
RuntimeGlobals.definePropertyGetter
|
|
||||||
}(${exportsName}, __WEBPACK_IMPORT_KEY__, function(key) { return ${importVar}[key]; }.bind(0, __WEBPACK_IMPORT_KEY__));\n`,
|
|
||||||
InitFragment.STAGE_HARMONY_IMPORTS,
|
InitFragment.STAGE_HARMONY_IMPORTS,
|
||||||
dep.sourceOrder
|
dep.sourceOrder
|
||||||
)
|
)
|
||||||
|
|
|
@ -107,16 +107,16 @@ class HarmonyImportDependency extends ModuleDependency {
|
||||||
// It's not an harmony module
|
// It's not an harmony module
|
||||||
if (
|
if (
|
||||||
moduleGraph.getParentModule(this).buildMeta.strictHarmonyModule &&
|
moduleGraph.getParentModule(this).buildMeta.strictHarmonyModule &&
|
||||||
(ids.length === 0 || ids[0] !== "default")
|
(ids.length > 0 && ids[0] !== "default")
|
||||||
) {
|
) {
|
||||||
// In strict harmony modules we only support the default export
|
// In strict harmony modules we only support the default export
|
||||||
const exportName =
|
|
||||||
ids.length > 0
|
|
||||||
? `the named export ${ids.map(id => `'${id}'`).join(".")}`
|
|
||||||
: "the namespace object";
|
|
||||||
return [
|
return [
|
||||||
new HarmonyLinkingError(
|
new HarmonyLinkingError(
|
||||||
`Can't import ${exportName} ${additionalMessage} from non EcmaScript module (only default export is available)`
|
`Can't import the named export ${ids
|
||||||
|
.map(id => `'${id}'`)
|
||||||
|
.join(
|
||||||
|
"."
|
||||||
|
)} ${additionalMessage} from non EcmaScript module (only default export is available)`
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,9 +45,7 @@ class ImportParserPlugin {
|
||||||
const { comment } = e;
|
const { comment } = e;
|
||||||
parser.state.module.warnings.push(
|
parser.state.module.warnings.push(
|
||||||
new CommentCompilationWarning(
|
new CommentCompilationWarning(
|
||||||
`Compilation error while processing magic comment(-s): /*${
|
`Compilation error while processing magic comment(-s): /*${comment.value}*/: ${e.message}`,
|
||||||
comment.value
|
|
||||||
}*/: ${e.message}`,
|
|
||||||
comment.loc
|
comment.loc
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
@ -59,9 +57,7 @@ class ImportParserPlugin {
|
||||||
if (typeof importOptions.webpackIgnore !== "boolean") {
|
if (typeof importOptions.webpackIgnore !== "boolean") {
|
||||||
parser.state.module.warnings.push(
|
parser.state.module.warnings.push(
|
||||||
new UnsupportedFeatureWarning(
|
new UnsupportedFeatureWarning(
|
||||||
`\`webpackIgnore\` expected a boolean, but received: ${
|
`\`webpackIgnore\` expected a boolean, but received: ${importOptions.webpackIgnore}.`,
|
||||||
importOptions.webpackIgnore
|
|
||||||
}.`,
|
|
||||||
expr.loc
|
expr.loc
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
@ -76,9 +72,7 @@ class ImportParserPlugin {
|
||||||
if (typeof importOptions.webpackChunkName !== "string") {
|
if (typeof importOptions.webpackChunkName !== "string") {
|
||||||
parser.state.module.warnings.push(
|
parser.state.module.warnings.push(
|
||||||
new UnsupportedFeatureWarning(
|
new UnsupportedFeatureWarning(
|
||||||
`\`webpackChunkName\` expected a string, but received: ${
|
`\`webpackChunkName\` expected a string, but received: ${importOptions.webpackChunkName}.`,
|
||||||
importOptions.webpackChunkName
|
|
||||||
}.`,
|
|
||||||
expr.loc
|
expr.loc
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
@ -90,9 +84,7 @@ class ImportParserPlugin {
|
||||||
if (typeof importOptions.webpackMode !== "string") {
|
if (typeof importOptions.webpackMode !== "string") {
|
||||||
parser.state.module.warnings.push(
|
parser.state.module.warnings.push(
|
||||||
new UnsupportedFeatureWarning(
|
new UnsupportedFeatureWarning(
|
||||||
`\`webpackMode\` expected a string, but received: ${
|
`\`webpackMode\` expected a string, but received: ${importOptions.webpackMode}.`,
|
||||||
importOptions.webpackMode
|
|
||||||
}.`,
|
|
||||||
expr.loc
|
expr.loc
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
@ -108,9 +100,7 @@ class ImportParserPlugin {
|
||||||
} else {
|
} else {
|
||||||
parser.state.module.warnings.push(
|
parser.state.module.warnings.push(
|
||||||
new UnsupportedFeatureWarning(
|
new UnsupportedFeatureWarning(
|
||||||
`\`webpackPrefetch\` expected true or a number, but received: ${
|
`\`webpackPrefetch\` expected true or a number, but received: ${importOptions.webpackPrefetch}.`,
|
||||||
importOptions.webpackPrefetch
|
|
||||||
}.`,
|
|
||||||
expr.loc
|
expr.loc
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
@ -124,9 +114,7 @@ class ImportParserPlugin {
|
||||||
} else {
|
} else {
|
||||||
parser.state.module.warnings.push(
|
parser.state.module.warnings.push(
|
||||||
new UnsupportedFeatureWarning(
|
new UnsupportedFeatureWarning(
|
||||||
`\`webpackPreload\` expected true or a number, but received: ${
|
`\`webpackPreload\` expected true or a number, but received: ${importOptions.webpackPreload}.`,
|
||||||
importOptions.webpackPreload
|
|
||||||
}.`,
|
|
||||||
expr.loc
|
expr.loc
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
@ -139,9 +127,7 @@ class ImportParserPlugin {
|
||||||
) {
|
) {
|
||||||
parser.state.module.warnings.push(
|
parser.state.module.warnings.push(
|
||||||
new UnsupportedFeatureWarning(
|
new UnsupportedFeatureWarning(
|
||||||
`\`webpackInclude\` expected a regular expression, but received: ${
|
`\`webpackInclude\` expected a regular expression, but received: ${importOptions.webpackInclude}.`,
|
||||||
importOptions.webpackInclude
|
|
||||||
}.`,
|
|
||||||
expr.loc
|
expr.loc
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
@ -156,9 +142,7 @@ class ImportParserPlugin {
|
||||||
) {
|
) {
|
||||||
parser.state.module.warnings.push(
|
parser.state.module.warnings.push(
|
||||||
new UnsupportedFeatureWarning(
|
new UnsupportedFeatureWarning(
|
||||||
`\`webpackExclude\` expected a regular expression, but received: ${
|
`\`webpackExclude\` expected a regular expression, but received: ${importOptions.webpackExclude}.`,
|
||||||
importOptions.webpackExclude
|
|
||||||
}.`,
|
|
||||||
expr.loc
|
expr.loc
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
|
@ -51,9 +51,7 @@ class LoaderPlugin {
|
||||||
if (factory === undefined) {
|
if (factory === undefined) {
|
||||||
return callback(
|
return callback(
|
||||||
new Error(
|
new Error(
|
||||||
`No module factory available for dependency type: ${
|
`No module factory available for dependency type: ${dep.constructor.name}`
|
||||||
dep.constructor.name
|
|
||||||
}`
|
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,9 +80,7 @@ ModuleDecoratorDependency.Template = class ModuleDecoratorDependencyTemplate ext
|
||||||
runtimeRequirements.add(dep.decorator);
|
runtimeRequirements.add(dep.decorator);
|
||||||
initFragments.push(
|
initFragments.push(
|
||||||
new InitFragment(
|
new InitFragment(
|
||||||
`/* module decorator */ ${module.moduleArgument} = ${dep.decorator}(${
|
`/* module decorator */ ${module.moduleArgument} = ${dep.decorator}(${module.moduleArgument});\n`,
|
||||||
module.moduleArgument
|
|
||||||
});\n`,
|
|
||||||
InitFragment.STAGE_PROVIDES,
|
InitFragment.STAGE_PROVIDES,
|
||||||
0,
|
0,
|
||||||
`module decorator ${chunkGraph.getModuleId(module)}`
|
`module decorator ${chunkGraph.getModuleId(module)}`
|
||||||
|
|
|
@ -90,9 +90,7 @@ RequireEnsureDependency.Template = class RequireEnsureDependencyTemplate extends
|
||||||
source.replace(
|
source.replace(
|
||||||
contentRange[1],
|
contentRange[1],
|
||||||
range[1] - 1,
|
range[1] - 1,
|
||||||
`).bind(null, __webpack_require__)).catch(${
|
`).bind(null, __webpack_require__)).catch(${RuntimeGlobals.uncaughtErrorHandler})`
|
||||||
RuntimeGlobals.uncaughtErrorHandler
|
|
||||||
})`
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,9 +63,7 @@ class WebAssemblyImportDependency extends ModuleDependency {
|
||||||
) {
|
) {
|
||||||
return [
|
return [
|
||||||
new UnsupportedWebAssemblyFeatureError(
|
new UnsupportedWebAssemblyFeatureError(
|
||||||
`Import "${this.name}" from "${this.request}" with ${
|
`Import "${this.name}" from "${this.request}" with ${this.onlyDirectImport} can only be used for direct wasm to wasm dependencies`
|
||||||
this.onlyDirectImport
|
|
||||||
} can only be used for direct wasm to wasm dependencies`
|
|
||||||
)
|
)
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,9 +34,7 @@ class ChunkModuleIdRangePlugin {
|
||||||
);
|
);
|
||||||
if (!chunk) {
|
if (!chunk) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`ChunkModuleIdRangePlugin: Chunk with name '${
|
`ChunkModuleIdRangePlugin: Chunk with name '${options.name}"' was not found`
|
||||||
options.name
|
|
||||||
}"' was not found`
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -68,9 +68,7 @@ class ReadFileChunkLoadingRuntimeModule extends RuntimeModule {
|
||||||
"var promise = new Promise(function(resolve, reject) {",
|
"var promise = new Promise(function(resolve, reject) {",
|
||||||
Template.indent([
|
Template.indent([
|
||||||
"installedChunkData = installedChunks[chunkId] = [resolve, reject];",
|
"installedChunkData = installedChunks[chunkId] = [resolve, reject];",
|
||||||
`var filename = require('path').join(__dirname, ${
|
`var filename = require('path').join(__dirname, ${RuntimeGlobals.getChunkScriptFilename}(chunkId));`,
|
||||||
RuntimeGlobals.getChunkScriptFilename
|
|
||||||
}(chunkId));`,
|
|
||||||
"require('fs').readFile(filename, 'utf-8', function(err, content) {",
|
"require('fs').readFile(filename, 'utf-8', function(err, content) {",
|
||||||
Template.indent([
|
Template.indent([
|
||||||
"if(err) return reject(err);",
|
"if(err) return reject(err);",
|
||||||
|
@ -82,9 +80,7 @@ class ReadFileChunkLoadingRuntimeModule extends RuntimeModule {
|
||||||
Template.indent([
|
Template.indent([
|
||||||
"if(Object.prototype.hasOwnProperty.call(moreModules, moduleId)) {",
|
"if(Object.prototype.hasOwnProperty.call(moreModules, moduleId)) {",
|
||||||
Template.indent([
|
Template.indent([
|
||||||
`${
|
`${RuntimeGlobals.moduleFactories}[moduleId] = moreModules[moduleId];`
|
||||||
RuntimeGlobals.moduleFactories
|
|
||||||
}[moduleId] = moreModules[moduleId];`
|
|
||||||
]),
|
]),
|
||||||
"}"
|
"}"
|
||||||
]),
|
]),
|
||||||
|
@ -142,9 +138,7 @@ class ReadFileChunkLoadingRuntimeModule extends RuntimeModule {
|
||||||
Template.indent([
|
Template.indent([
|
||||||
"return new Promise(function(resolve, reject) {",
|
"return new Promise(function(resolve, reject) {",
|
||||||
Template.indent([
|
Template.indent([
|
||||||
`var filename = require('path').join(__dirname, ${
|
`var filename = require('path').join(__dirname, ${RuntimeGlobals.getChunkUpdateScriptFilename}(chunkId));`,
|
||||||
RuntimeGlobals.getChunkUpdateScriptFilename
|
|
||||||
}(chunkId));`,
|
|
||||||
"require('fs').readFile(filename, 'utf-8', function(err, content) {",
|
"require('fs').readFile(filename, 'utf-8', function(err, content) {",
|
||||||
Template.indent([
|
Template.indent([
|
||||||
"if(err) return reject(err);",
|
"if(err) return reject(err);",
|
||||||
|
@ -172,9 +166,7 @@ class ReadFileChunkLoadingRuntimeModule extends RuntimeModule {
|
||||||
]),
|
]),
|
||||||
"}",
|
"}",
|
||||||
"",
|
"",
|
||||||
`${
|
`${RuntimeGlobals.hmrDownloadUpdateHandlers}.readFileVm = function(chunkIds, removedChunks, removedModules, promises, applyHandlers, updatedModulesList) {`,
|
||||||
RuntimeGlobals.hmrDownloadUpdateHandlers
|
|
||||||
}.readFileVm = function(chunkIds, removedChunks, removedModules, promises, applyHandlers, updatedModulesList) {`,
|
|
||||||
Template.indent([
|
Template.indent([
|
||||||
"applyHandlers.push(function(options) {",
|
"applyHandlers.push(function(options) {",
|
||||||
Template.indent([
|
Template.indent([
|
||||||
|
@ -223,9 +215,7 @@ class ReadFileChunkLoadingRuntimeModule extends RuntimeModule {
|
||||||
Template.indent([
|
Template.indent([
|
||||||
"return new Promise(function(resolve, reject) {",
|
"return new Promise(function(resolve, reject) {",
|
||||||
Template.indent([
|
Template.indent([
|
||||||
`var filename = require('path').join(__dirname, ${
|
`var filename = require('path').join(__dirname, ${RuntimeGlobals.getUpdateManifestFilename}());`,
|
||||||
RuntimeGlobals.getUpdateManifestFilename
|
|
||||||
}());`,
|
|
||||||
"require('fs').readFile(filename, 'utf-8', function(err, content) {",
|
"require('fs').readFile(filename, 'utf-8', function(err, content) {",
|
||||||
Template.indent([
|
Template.indent([
|
||||||
"if(err) {",
|
"if(err) {",
|
||||||
|
|
|
@ -59,17 +59,13 @@ class RequireChunkLoadingRuntimeModule extends RuntimeModule {
|
||||||
? "if(true) { // all chunks have JS"
|
? "if(true) { // all chunks have JS"
|
||||||
: `if(${hasJsMatcher("chunkId")}) {`,
|
: `if(${hasJsMatcher("chunkId")}) {`,
|
||||||
Template.indent([
|
Template.indent([
|
||||||
`var chunk = require("./" + ${
|
`var chunk = require("./" + ${RuntimeGlobals.getChunkScriptFilename}(chunkId));`,
|
||||||
RuntimeGlobals.getChunkScriptFilename
|
|
||||||
}(chunkId));`,
|
|
||||||
"var moreModules = chunk.modules, chunkIds = chunk.ids, runtime = chunk.runtime;",
|
"var moreModules = chunk.modules, chunkIds = chunk.ids, runtime = chunk.runtime;",
|
||||||
"for(var moduleId in moreModules) {",
|
"for(var moduleId in moreModules) {",
|
||||||
Template.indent([
|
Template.indent([
|
||||||
"if(Object.prototype.hasOwnProperty.call(moreModules, moduleId)) {",
|
"if(Object.prototype.hasOwnProperty.call(moreModules, moduleId)) {",
|
||||||
Template.indent([
|
Template.indent([
|
||||||
`${
|
`${RuntimeGlobals.moduleFactories}[moduleId] = moreModules[moduleId];`
|
||||||
RuntimeGlobals.moduleFactories
|
|
||||||
}[moduleId] = moreModules[moduleId];`
|
|
||||||
]),
|
]),
|
||||||
"}"
|
"}"
|
||||||
]),
|
]),
|
||||||
|
@ -107,9 +103,7 @@ class RequireChunkLoadingRuntimeModule extends RuntimeModule {
|
||||||
"var currentUpdateRuntime;",
|
"var currentUpdateRuntime;",
|
||||||
"function loadUpdateChunk(chunkId, updatedModulesList) {",
|
"function loadUpdateChunk(chunkId, updatedModulesList) {",
|
||||||
Template.indent([
|
Template.indent([
|
||||||
`var update = require("./" + ${
|
`var update = require("./" + ${RuntimeGlobals.getChunkUpdateScriptFilename}(chunkId));`,
|
||||||
RuntimeGlobals.getChunkUpdateScriptFilename
|
|
||||||
}(chunkId));`,
|
|
||||||
"var updatedModules = update.modules;",
|
"var updatedModules = update.modules;",
|
||||||
"var runtime = update.runtime;",
|
"var runtime = update.runtime;",
|
||||||
"for(var moduleId in updatedModules) {",
|
"for(var moduleId in updatedModules) {",
|
||||||
|
@ -126,9 +120,7 @@ class RequireChunkLoadingRuntimeModule extends RuntimeModule {
|
||||||
]),
|
]),
|
||||||
"}",
|
"}",
|
||||||
"",
|
"",
|
||||||
`${
|
`${RuntimeGlobals.hmrDownloadUpdateHandlers}.require = function(chunkIds, removedChunks, removedModules, promises, applyHandlers, updatedModulesList) {`,
|
||||||
RuntimeGlobals.hmrDownloadUpdateHandlers
|
|
||||||
}.require = function(chunkIds, removedChunks, removedModules, promises, applyHandlers, updatedModulesList) {`,
|
|
||||||
Template.indent([
|
Template.indent([
|
||||||
"applyHandlers.push(function(options) {",
|
"applyHandlers.push(function(options) {",
|
||||||
Template.indent([
|
Template.indent([
|
||||||
|
@ -177,9 +169,7 @@ class RequireChunkLoadingRuntimeModule extends RuntimeModule {
|
||||||
Template.indent([
|
Template.indent([
|
||||||
"return Promise.resolve().then(function() {",
|
"return Promise.resolve().then(function() {",
|
||||||
Template.indent([
|
Template.indent([
|
||||||
`return require("./" + ${
|
`return require("./" + ${RuntimeGlobals.getUpdateManifestFilename}());`
|
||||||
RuntimeGlobals.getUpdateManifestFilename
|
|
||||||
}());`
|
|
||||||
]),
|
]),
|
||||||
'}).catch(function(err) { if(err.code !== "MODULE_NOT_FOUND") throw err; });'
|
'}).catch(function(err) { if(err.code !== "MODULE_NOT_FOUND") throw err; });'
|
||||||
]),
|
]),
|
||||||
|
|
|
@ -946,23 +946,17 @@ class ConcatenatedModule extends Module {
|
||||||
if (info.interopNamespaceObjectUsed) {
|
if (info.interopNamespaceObjectUsed) {
|
||||||
if (info.module.buildMeta.exportsType === "named") {
|
if (info.module.buildMeta.exportsType === "named") {
|
||||||
result.add(
|
result.add(
|
||||||
`var ${info.interopNamespaceObjectName} = /*#__PURE__*/${
|
`var ${info.interopNamespaceObjectName} = /*#__PURE__*/${RuntimeGlobals.createFakeNamespaceObject}(${info.name}, 2);\n`
|
||||||
RuntimeGlobals.createFakeNamespaceObject
|
|
||||||
}(${info.name}, 2);\n`
|
|
||||||
);
|
);
|
||||||
} else if (!info.module.buildMeta.exportsType) {
|
} else if (!info.module.buildMeta.exportsType) {
|
||||||
result.add(
|
result.add(
|
||||||
`var ${info.interopNamespaceObjectName} = /*#__PURE__*/${
|
`var ${info.interopNamespaceObjectName} = /*#__PURE__*/${RuntimeGlobals.createFakeNamespaceObject}(${info.name});\n`
|
||||||
RuntimeGlobals.createFakeNamespaceObject
|
|
||||||
}(${info.name});\n`
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (info.interopDefaultAccessUsed) {
|
if (info.interopDefaultAccessUsed) {
|
||||||
result.add(
|
result.add(
|
||||||
`var ${info.interopDefaultAccessName} = /*#__PURE__*/${
|
`var ${info.interopDefaultAccessName} = /*#__PURE__*/${RuntimeGlobals.compatGetDefaultExport}(${info.name});\n`
|
||||||
RuntimeGlobals.compatGetDefaultExport
|
|
||||||
}(${info.name});\n`
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -1328,9 +1322,7 @@ class HarmonyImportSpecifierDependencyConcatenatedTemplate extends DependencyTem
|
||||||
const exportData = Buffer.from(JSON.stringify(ids), "utf-8").toString(
|
const exportData = Buffer.from(JSON.stringify(ids), "utf-8").toString(
|
||||||
"hex"
|
"hex"
|
||||||
);
|
);
|
||||||
content = `__WEBPACK_MODULE_REFERENCE__${
|
content = `__WEBPACK_MODULE_REFERENCE__${info.index}_${exportData}${callFlag}${strictFlag}__`;
|
||||||
info.index
|
|
||||||
}_${exportData}${callFlag}${strictFlag}__`;
|
|
||||||
}
|
}
|
||||||
if (dep.shorthand) {
|
if (dep.shorthand) {
|
||||||
content = dep.name + ": " + content;
|
content = dep.name + ": " + content;
|
||||||
|
@ -1527,23 +1519,17 @@ class HarmonyExportImportedSpecifierDependencyConcatenatedTemplate extends Depen
|
||||||
? "_strict"
|
? "_strict"
|
||||||
: "";
|
: "";
|
||||||
if (def.ids.length === 0) {
|
if (def.ids.length === 0) {
|
||||||
finalName = `__WEBPACK_MODULE_REFERENCE__${
|
finalName = `__WEBPACK_MODULE_REFERENCE__${info.index}_ns${strictFlag}__`;
|
||||||
info.index
|
|
||||||
}_ns${strictFlag}__`;
|
|
||||||
} else {
|
} else {
|
||||||
const exportData = Buffer.from(
|
const exportData = Buffer.from(
|
||||||
JSON.stringify(def.ids),
|
JSON.stringify(def.ids),
|
||||||
"utf-8"
|
"utf-8"
|
||||||
).toString("hex");
|
).toString("hex");
|
||||||
finalName = `__WEBPACK_MODULE_REFERENCE__${
|
finalName = `__WEBPACK_MODULE_REFERENCE__${info.index}_${exportData}${strictFlag}__`;
|
||||||
info.index
|
|
||||||
}_${exportData}${strictFlag}__`;
|
|
||||||
}
|
}
|
||||||
const exportsName = this.rootModule.exportsArgument;
|
const exportsName = this.rootModule.exportsArgument;
|
||||||
const content =
|
const content =
|
||||||
`/* concated harmony reexport */ ${
|
`/* concated harmony reexport */ ${RuntimeGlobals.definePropertyGetter}(` +
|
||||||
RuntimeGlobals.definePropertyGetter
|
|
||||||
}(` +
|
|
||||||
`${exportsName}, ${JSON.stringify(used)}, ` +
|
`${exportsName}, ${JSON.stringify(used)}, ` +
|
||||||
`function() { return ${finalName}; });\n`;
|
`function() { return ${finalName}; });\n`;
|
||||||
initFragments.push(
|
initFragments.push(
|
||||||
|
|
|
@ -682,9 +682,7 @@ module.exports = class SplitChunksPlugin {
|
||||||
compilation.errors.push(
|
compilation.errors.push(
|
||||||
new WebpackError(
|
new WebpackError(
|
||||||
"SplitChunksPlugin\n" +
|
"SplitChunksPlugin\n" +
|
||||||
`Cache group "${
|
`Cache group "${cacheGroup.key}" conflicts with existing chunk.\n` +
|
||||||
cacheGroup.key
|
|
||||||
}" conflicts with existing chunk.\n` +
|
|
||||||
`Both have the same name "${name}".\n` +
|
`Both have the same name "${name}".\n` +
|
||||||
"Use a different name for the cache group.\n" +
|
"Use a different name for the cache group.\n" +
|
||||||
'HINT: You can omit "name" to automatically create a name.\n' +
|
'HINT: You can omit "name" to automatically create a name.\n' +
|
||||||
|
|
|
@ -159,9 +159,7 @@ class ObjectMiddleware extends SerializerMiddleware {
|
||||||
|
|
||||||
if (serializers.has(Constructor)) {
|
if (serializers.has(Constructor)) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`ObjectMiddleware.register: serializer for ${
|
`ObjectMiddleware.register: serializer for ${Constructor.name} is already registered`
|
||||||
Constructor.name
|
|
||||||
} is already registered`
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -187,9 +185,7 @@ class ObjectMiddleware extends SerializerMiddleware {
|
||||||
static registerNotSerializable(Constructor) {
|
static registerNotSerializable(Constructor) {
|
||||||
if (serializers.has(Constructor)) {
|
if (serializers.has(Constructor)) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`ObjectMiddleware.registerNotSerializable: serializer for ${
|
`ObjectMiddleware.registerNotSerializable: serializer for ${Constructor.name} is already registered`
|
||||||
Constructor.name
|
|
||||||
} is already registered`
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -134,7 +134,7 @@ const DEFAULTS = {
|
||||||
publicPath: OFF_FOR_TO_STRING,
|
publicPath: OFF_FOR_TO_STRING,
|
||||||
excludeModules: () => [],
|
excludeModules: () => [],
|
||||||
excludeAssets: () => [],
|
excludeAssets: () => [],
|
||||||
maxModules: (o, { forToString }) => (forToString ? 15 : Infinity),
|
maxModules: (o, { forToString }) => ((forToString ? 15 : Infinity)),
|
||||||
modulesSort: () => "id",
|
modulesSort: () => "id",
|
||||||
chunksSort: () => "id",
|
chunksSort: () => "id",
|
||||||
assetsSort: () => "name",
|
assetsSort: () => "name",
|
||||||
|
|
|
@ -135,7 +135,7 @@ const SIMPLE_PRINTERS = {
|
||||||
"asset.size": (
|
"asset.size": (
|
||||||
size,
|
size,
|
||||||
{ asset: { isOverSizeLimit }, yellow, green, formatSize }
|
{ asset: { isOverSizeLimit }, yellow, green, formatSize }
|
||||||
) => (isOverSizeLimit ? yellow(formatSize(size)) : formatSize(size)),
|
) => ((isOverSizeLimit ? yellow(formatSize(size)) : formatSize(size))),
|
||||||
"asset.emitted": (emitted, { green, formatFlag }) =>
|
"asset.emitted": (emitted, { green, formatFlag }) =>
|
||||||
emitted ? green(formatFlag("emitted")) : undefined,
|
emitted ? green(formatFlag("emitted")) : undefined,
|
||||||
"asset.isOverSizeLimit": (isOverSizeLimit, { yellow, formatFlag }) =>
|
"asset.isOverSizeLimit": (isOverSizeLimit, { yellow, formatFlag }) =>
|
||||||
|
@ -317,7 +317,8 @@ const SIMPLE_PRINTERS = {
|
||||||
rendered ? green(formatFlag("rendered")) : undefined,
|
rendered ? green(formatFlag("rendered")) : undefined,
|
||||||
"chunk.recorded": (recorded, { formatFlag, green }) =>
|
"chunk.recorded": (recorded, { formatFlag, green }) =>
|
||||||
recorded ? green(formatFlag("recorded")) : undefined,
|
recorded ? green(formatFlag("recorded")) : undefined,
|
||||||
"chunk.reason": (reason, { yellow }) => (reason ? yellow(reason) : undefined),
|
"chunk.reason": (reason, { yellow }) =>
|
||||||
|
(reason ? yellow(reason) : undefined),
|
||||||
"chunk.rootModules": (modules, context) => {
|
"chunk.rootModules": (modules, context) => {
|
||||||
let maxModuleId = 0;
|
let maxModuleId = 0;
|
||||||
for (const module of modules) {
|
for (const module of modules) {
|
||||||
|
@ -707,7 +708,7 @@ const SIMPLE_ELEMENT_JOINERS = {
|
||||||
if (maxModuleId >= 10) prefix += " ";
|
if (maxModuleId >= 10) prefix += " ";
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
prefix +
|
(prefix +
|
||||||
joinExplicitNewLine(
|
joinExplicitNewLine(
|
||||||
items.filter(item => {
|
items.filter(item => {
|
||||||
switch (item.element) {
|
switch (item.element) {
|
||||||
|
@ -726,13 +727,13 @@ const SIMPLE_ELEMENT_JOINERS = {
|
||||||
return true;
|
return true;
|
||||||
}),
|
}),
|
||||||
indenter
|
indenter
|
||||||
)
|
))
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
chunk: items => {
|
chunk: items => {
|
||||||
let hasEntry = false;
|
let hasEntry = false;
|
||||||
return (
|
return (
|
||||||
"chunk " +
|
("chunk " +
|
||||||
joinExplicitNewLine(
|
joinExplicitNewLine(
|
||||||
items.filter(item => {
|
items.filter(item => {
|
||||||
switch (item.element) {
|
switch (item.element) {
|
||||||
|
@ -746,7 +747,7 @@ const SIMPLE_ELEMENT_JOINERS = {
|
||||||
return true;
|
return true;
|
||||||
}),
|
}),
|
||||||
" "
|
" "
|
||||||
)
|
))
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
"chunk.childrenByOrder[]": items => `(${joinOneLine(items)})`,
|
"chunk.childrenByOrder[]": items => `(${joinOneLine(items)})`,
|
||||||
|
@ -766,8 +767,8 @@ const SIMPLE_ELEMENT_JOINERS = {
|
||||||
break;
|
break;
|
||||||
case "resolvedModule":
|
case "resolvedModule":
|
||||||
return (
|
return (
|
||||||
moduleReason.module !== moduleReason.resolvedModule &&
|
(moduleReason.module !== moduleReason.resolvedModule &&
|
||||||
item.content
|
item.content)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -50,9 +50,7 @@ class ClassSerializer {
|
||||||
const hash = context.read();
|
const hash = context.read();
|
||||||
if (this.hash !== hash)
|
if (this.hash !== hash)
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Version mismatch for ${this.Constructor.name}: ${hash} !== ${
|
`Version mismatch for ${this.Constructor.name}: ${hash} !== ${this.hash}`
|
||||||
this.hash
|
|
||||||
}`
|
|
||||||
);
|
);
|
||||||
if (typeof this.Constructor.deserialize === "function") {
|
if (typeof this.Constructor.deserialize === "function") {
|
||||||
return this.Constructor.deserialize(context);
|
return this.Constructor.deserialize(context);
|
||||||
|
|
|
@ -30,7 +30,7 @@ register(
|
||||||
CachedSource,
|
CachedSource,
|
||||||
CURRENT_MODULE,
|
CURRENT_MODULE,
|
||||||
"webpack-sources/CachedSource",
|
"webpack-sources/CachedSource",
|
||||||
new class CachedSourceSerializer {
|
new (class CachedSourceSerializer {
|
||||||
/**
|
/**
|
||||||
* @param {CachedSource} source the cached source to be serialized
|
* @param {CachedSource} source the cached source to be serialized
|
||||||
* @param {ObjectSerializerContext} context context
|
* @param {ObjectSerializerContext} context context
|
||||||
|
@ -56,14 +56,14 @@ register(
|
||||||
source._cachedMaps = read();
|
source._cachedMaps = read();
|
||||||
return source;
|
return source;
|
||||||
}
|
}
|
||||||
}()
|
})()
|
||||||
);
|
);
|
||||||
|
|
||||||
register(
|
register(
|
||||||
RawSource,
|
RawSource,
|
||||||
CURRENT_MODULE,
|
CURRENT_MODULE,
|
||||||
"webpack-sources/RawSource",
|
"webpack-sources/RawSource",
|
||||||
new class RawSourceSerializer {
|
new (class RawSourceSerializer {
|
||||||
/**
|
/**
|
||||||
* @param {RawSource} source the raw source to be serialized
|
* @param {RawSource} source the raw source to be serialized
|
||||||
* @param {ObjectSerializerContext} context context
|
* @param {ObjectSerializerContext} context context
|
||||||
|
@ -82,14 +82,14 @@ register(
|
||||||
const source = read();
|
const source = read();
|
||||||
return new RawSource(source);
|
return new RawSource(source);
|
||||||
}
|
}
|
||||||
}()
|
})()
|
||||||
);
|
);
|
||||||
|
|
||||||
register(
|
register(
|
||||||
ConcatSource,
|
ConcatSource,
|
||||||
CURRENT_MODULE,
|
CURRENT_MODULE,
|
||||||
"webpack-sources/ConcatSource",
|
"webpack-sources/ConcatSource",
|
||||||
new class ConcatSourceSerializer {
|
new (class ConcatSourceSerializer {
|
||||||
/**
|
/**
|
||||||
* @param {ConcatSource} source the concat source to be serialized
|
* @param {ConcatSource} source the concat source to be serialized
|
||||||
* @param {ObjectSerializerContext} context context
|
* @param {ObjectSerializerContext} context context
|
||||||
|
@ -109,14 +109,14 @@ register(
|
||||||
source.children = children;
|
source.children = children;
|
||||||
return source;
|
return source;
|
||||||
}
|
}
|
||||||
}()
|
})()
|
||||||
);
|
);
|
||||||
|
|
||||||
register(
|
register(
|
||||||
PrefixSource,
|
PrefixSource,
|
||||||
CURRENT_MODULE,
|
CURRENT_MODULE,
|
||||||
"webpack-sources/PrefixSource",
|
"webpack-sources/PrefixSource",
|
||||||
new class PrefixSourceSerializer {
|
new (class PrefixSourceSerializer {
|
||||||
/**
|
/**
|
||||||
* @param {PrefixSource} source the prefix source to be serialized
|
* @param {PrefixSource} source the prefix source to be serialized
|
||||||
* @param {ObjectSerializerContext} context context
|
* @param {ObjectSerializerContext} context context
|
||||||
|
@ -134,14 +134,14 @@ register(
|
||||||
deserialize({ read }) {
|
deserialize({ read }) {
|
||||||
return new PrefixSource(read(), read());
|
return new PrefixSource(read(), read());
|
||||||
}
|
}
|
||||||
}()
|
})()
|
||||||
);
|
);
|
||||||
|
|
||||||
register(
|
register(
|
||||||
ReplaceSource,
|
ReplaceSource,
|
||||||
CURRENT_MODULE,
|
CURRENT_MODULE,
|
||||||
"webpack-sources/ReplaceSource",
|
"webpack-sources/ReplaceSource",
|
||||||
new class ReplaceSourceSerializer {
|
new (class ReplaceSourceSerializer {
|
||||||
/**
|
/**
|
||||||
* @param {ReplaceSource} source the replace source to be serialized
|
* @param {ReplaceSource} source the replace source to be serialized
|
||||||
* @param {ObjectSerializerContext} context context
|
* @param {ObjectSerializerContext} context context
|
||||||
|
@ -175,14 +175,14 @@ register(
|
||||||
}
|
}
|
||||||
return source;
|
return source;
|
||||||
}
|
}
|
||||||
}()
|
})()
|
||||||
);
|
);
|
||||||
|
|
||||||
register(
|
register(
|
||||||
OriginalSource,
|
OriginalSource,
|
||||||
CURRENT_MODULE,
|
CURRENT_MODULE,
|
||||||
"webpack-sources/OriginalSource",
|
"webpack-sources/OriginalSource",
|
||||||
new class OriginalSourceSerializer {
|
new (class OriginalSourceSerializer {
|
||||||
/**
|
/**
|
||||||
* @param {OriginalSource} source the original source to be serialized
|
* @param {OriginalSource} source the original source to be serialized
|
||||||
* @param {ObjectSerializerContext} context context
|
* @param {ObjectSerializerContext} context context
|
||||||
|
@ -200,14 +200,14 @@ register(
|
||||||
deserialize({ read }) {
|
deserialize({ read }) {
|
||||||
return new OriginalSource(read(), read());
|
return new OriginalSource(read(), read());
|
||||||
}
|
}
|
||||||
}()
|
})()
|
||||||
);
|
);
|
||||||
|
|
||||||
register(
|
register(
|
||||||
SourceLocation,
|
SourceLocation,
|
||||||
CURRENT_MODULE,
|
CURRENT_MODULE,
|
||||||
"acorn/SourceLocation",
|
"acorn/SourceLocation",
|
||||||
new class SourceLocationSerializer {
|
new (class SourceLocationSerializer {
|
||||||
/**
|
/**
|
||||||
* @param {SourceLocation} loc the location to be serialized
|
* @param {SourceLocation} loc the location to be serialized
|
||||||
* @param {ObjectSerializerContext} context context
|
* @param {ObjectSerializerContext} context context
|
||||||
|
@ -236,14 +236,14 @@ register(
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}()
|
})()
|
||||||
);
|
);
|
||||||
|
|
||||||
register(
|
register(
|
||||||
Position,
|
Position,
|
||||||
CURRENT_MODULE,
|
CURRENT_MODULE,
|
||||||
"acorn/Position",
|
"acorn/Position",
|
||||||
new class PositionSerializer {
|
new (class PositionSerializer {
|
||||||
/**
|
/**
|
||||||
* @param {Position} pos the position to be serialized
|
* @param {Position} pos the position to be serialized
|
||||||
* @param {ObjectSerializerContext} context context
|
* @param {ObjectSerializerContext} context context
|
||||||
|
@ -264,14 +264,14 @@ register(
|
||||||
column: read()
|
column: read()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}()
|
})()
|
||||||
);
|
);
|
||||||
|
|
||||||
register(
|
register(
|
||||||
SourceMapSource,
|
SourceMapSource,
|
||||||
CURRENT_MODULE,
|
CURRENT_MODULE,
|
||||||
"webpack-sources/SourceMapSource",
|
"webpack-sources/SourceMapSource",
|
||||||
new class SourceMapSourceSerializer {
|
new (class SourceMapSourceSerializer {
|
||||||
/**
|
/**
|
||||||
* @param {SourceMapSource} source the source map source to be serialized
|
* @param {SourceMapSource} source the source map source to be serialized
|
||||||
* @param {ObjectSerializerContext} context context
|
* @param {ObjectSerializerContext} context context
|
||||||
|
@ -292,5 +292,5 @@ register(
|
||||||
const map = read();
|
const map = read();
|
||||||
return new SourceMapSource(source, "unknown", map);
|
return new SourceMapSource(source, "unknown", map);
|
||||||
}
|
}
|
||||||
}()
|
})()
|
||||||
);
|
);
|
||||||
|
|
|
@ -134,9 +134,8 @@ class AsyncWebAssemblyJavascriptGenerator extends Generator {
|
||||||
: undefined;
|
: undefined;
|
||||||
|
|
||||||
const instantiateCall =
|
const instantiateCall =
|
||||||
`${RuntimeGlobals.instantiateWasm}(${module.exportsArgument}, ${
|
`${RuntimeGlobals.instantiateWasm}(${module.exportsArgument}, ${module.moduleArgument}.i` +
|
||||||
module.moduleArgument
|
(importsObj ? `, ${importsObj})` : `)`);
|
||||||
}.i` + (importsObj ? `, ${importsObj})` : `)`);
|
|
||||||
|
|
||||||
return new RawSource(
|
return new RawSource(
|
||||||
Template.asString([
|
Template.asString([
|
||||||
|
|
|
@ -335,9 +335,7 @@ class WasmChunkLoadingRuntimeModule extends RuntimeModule {
|
||||||
"}",
|
"}",
|
||||||
"promises.push(installedWasmModules[wasmModuleId] = promise.then(function(res) {",
|
"promises.push(installedWasmModules[wasmModuleId] = promise.then(function(res) {",
|
||||||
Template.indent([
|
Template.indent([
|
||||||
`return ${
|
`return ${RuntimeGlobals.wasmInstances}[wasmModuleId] = (res.instance || res).exports;`
|
||||||
RuntimeGlobals.wasmInstances
|
|
||||||
}[wasmModuleId] = (res.instance || res).exports;`
|
|
||||||
]),
|
]),
|
||||||
"}));"
|
"}));"
|
||||||
]),
|
]),
|
||||||
|
|
|
@ -60,9 +60,7 @@ class WasmFinalizeExportsPlugin {
|
||||||
// 4. error
|
// 4. error
|
||||||
/** @type {TODO} */
|
/** @type {TODO} */
|
||||||
const error = new UnsupportedWebAssemblyFeatureError(
|
const error = new UnsupportedWebAssemblyFeatureError(
|
||||||
`Export "${name}" with ${
|
`Export "${name}" with ${jsIncompatibleExports[name]} can only be used for direct wasm to wasm dependencies\n` +
|
||||||
jsIncompatibleExports[name]
|
|
||||||
} can only be used for direct wasm to wasm dependencies\n` +
|
|
||||||
`It's used from ${connection.originModule.readableIdentifier(
|
`It's used from ${connection.originModule.readableIdentifier(
|
||||||
compilation.requestShortener
|
compilation.requestShortener
|
||||||
)} at ${formatLocation(connection.dependency.loc)}.`
|
)} at ${formatLocation(connection.dependency.loc)}.`
|
||||||
|
|
|
@ -168,9 +168,7 @@ class WebAssemblyJavascriptGenerator extends Generator {
|
||||||
[
|
[
|
||||||
'"use strict";',
|
'"use strict";',
|
||||||
"// Instantiate WebAssembly module",
|
"// Instantiate WebAssembly module",
|
||||||
`var wasmExports = ${RuntimeGlobals.wasmInstances}[${
|
`var wasmExports = ${RuntimeGlobals.wasmInstances}[${module.moduleArgument}.i];`,
|
||||||
module.moduleArgument
|
|
||||||
}.i];`,
|
|
||||||
|
|
||||||
exportsInfo.otherExportsInfo.used !== UsageState.Unused
|
exportsInfo.otherExportsInfo.used !== UsageState.Unused
|
||||||
? `${RuntimeGlobals.makeNamespaceObject}(${module.exportsArgument});`
|
? `${RuntimeGlobals.makeNamespaceObject}(${module.exportsArgument});`
|
||||||
|
|
|
@ -153,9 +153,7 @@ class JsonpChunkLoadingRuntimeModule extends RuntimeModule {
|
||||||
"promises.push(installedChunkData[2] = promise);",
|
"promises.push(installedChunkData[2] = promise);",
|
||||||
"",
|
"",
|
||||||
"// start chunk loading",
|
"// start chunk loading",
|
||||||
`var url = ${RuntimeGlobals.publicPath} + ${
|
`var url = ${RuntimeGlobals.publicPath} + ${RuntimeGlobals.getChunkScriptFilename}(chunkId);`,
|
||||||
RuntimeGlobals.getChunkScriptFilename
|
|
||||||
}(chunkId);`,
|
|
||||||
"var loadingEnded = function() { if(installedChunks[chunkId]) return installedChunks[chunkId][1]; if(installedChunks[chunkId] !== 0) installedChunks[chunkId] = undefined; };",
|
"var loadingEnded = function() { if(installedChunks[chunkId]) return installedChunks[chunkId][1]; if(installedChunks[chunkId] !== 0) installedChunks[chunkId] = undefined; };",
|
||||||
jsonpScript.call("", chunk),
|
jsonpScript.call("", chunk),
|
||||||
"document.head.appendChild(script);"
|
"document.head.appendChild(script);"
|
||||||
|
@ -232,9 +230,7 @@ class JsonpChunkLoadingRuntimeModule extends RuntimeModule {
|
||||||
Template.indent([
|
Template.indent([
|
||||||
"waitingUpdateResolves[chunkId] = resolve;",
|
"waitingUpdateResolves[chunkId] = resolve;",
|
||||||
"// start update chunk loading",
|
"// start update chunk loading",
|
||||||
`var url = ${RuntimeGlobals.publicPath} + ${
|
`var url = ${RuntimeGlobals.publicPath} + ${RuntimeGlobals.getChunkUpdateScriptFilename}(chunkId);`,
|
||||||
RuntimeGlobals.getChunkUpdateScriptFilename
|
|
||||||
}(chunkId);`,
|
|
||||||
"var loadingEnded = function() {",
|
"var loadingEnded = function() {",
|
||||||
Template.indent([
|
Template.indent([
|
||||||
"if(waitingUpdateResolves[chunkId]) {",
|
"if(waitingUpdateResolves[chunkId]) {",
|
||||||
|
@ -276,9 +272,7 @@ class JsonpChunkLoadingRuntimeModule extends RuntimeModule {
|
||||||
]),
|
]),
|
||||||
"};",
|
"};",
|
||||||
"",
|
"",
|
||||||
`${
|
`${RuntimeGlobals.hmrDownloadUpdateHandlers}.jsonp = function(chunkIds, removedChunks, removedModules, promises, applyHandlers, updatedModulesList) {`,
|
||||||
RuntimeGlobals.hmrDownloadUpdateHandlers
|
|
||||||
}.jsonp = function(chunkIds, removedChunks, removedModules, promises, applyHandlers, updatedModulesList) {`,
|
|
||||||
Template.indent([
|
Template.indent([
|
||||||
"applyHandlers.push(function(options) {",
|
"applyHandlers.push(function(options) {",
|
||||||
Template.indent([
|
Template.indent([
|
||||||
|
@ -325,9 +319,7 @@ class JsonpChunkLoadingRuntimeModule extends RuntimeModule {
|
||||||
`${RuntimeGlobals.hmrDownloadManifest} = function() {`,
|
`${RuntimeGlobals.hmrDownloadManifest} = function() {`,
|
||||||
Template.indent([
|
Template.indent([
|
||||||
'if (typeof fetch === "undefined") throw new Error("No browser support: need fetch API");',
|
'if (typeof fetch === "undefined") throw new Error("No browser support: need fetch API");',
|
||||||
`return fetch(${RuntimeGlobals.publicPath} + ${
|
`return fetch(${RuntimeGlobals.publicPath} + ${RuntimeGlobals.getUpdateManifestFilename}()).then(function(response) {`,
|
||||||
RuntimeGlobals.getUpdateManifestFilename
|
|
||||||
}()).then(function(response) {`,
|
|
||||||
Template.indent([
|
Template.indent([
|
||||||
"if(response.status === 404) return; // no update available",
|
"if(response.status === 404) return; // no update available",
|
||||||
'if(!response.ok) throw new Error("Failed to fetch update manifest " + response.statusText);',
|
'if(!response.ok) throw new Error("Failed to fetch update manifest " + response.statusText);',
|
||||||
|
@ -427,9 +419,7 @@ class JsonpChunkLoadingRuntimeModule extends RuntimeModule {
|
||||||
Template.indent([
|
Template.indent([
|
||||||
"if(Object.prototype.hasOwnProperty.call(moreModules, moduleId)) {",
|
"if(Object.prototype.hasOwnProperty.call(moreModules, moduleId)) {",
|
||||||
Template.indent(
|
Template.indent(
|
||||||
`${
|
`${RuntimeGlobals.moduleFactories}[moduleId] = moreModules[moduleId];`
|
||||||
RuntimeGlobals.moduleFactories
|
|
||||||
}[moduleId] = moreModules[moduleId];`
|
|
||||||
),
|
),
|
||||||
"}"
|
"}"
|
||||||
]),
|
]),
|
||||||
|
|
|
@ -121,6 +121,7 @@ class JsonpTemplatePlugin {
|
||||||
"var errorType = event && (event.type === 'load' ? 'missing' : event.type);",
|
"var errorType = event && (event.type === 'load' ? 'missing' : event.type);",
|
||||||
"var realSrc = event && event.target && event.target.src;",
|
"var realSrc = event && event.target && event.target.src;",
|
||||||
"error.message = 'Loading chunk ' + chunkId + ' failed.\\n(' + errorType + ': ' + realSrc + ')';",
|
"error.message = 'Loading chunk ' + chunkId + ' failed.\\n(' + errorType + ': ' + realSrc + ')';",
|
||||||
|
"error.name = 'ChunkLoadError';",
|
||||||
"error.type = errorType;",
|
"error.type = errorType;",
|
||||||
"error.request = realSrc;",
|
"error.request = realSrc;",
|
||||||
"reportError(error);"
|
"reportError(error);"
|
||||||
|
@ -154,9 +155,7 @@ class JsonpTemplatePlugin {
|
||||||
"}",
|
"}",
|
||||||
'link.rel = "preload";',
|
'link.rel = "preload";',
|
||||||
'link.as = "script";',
|
'link.as = "script";',
|
||||||
`link.href = ${RuntimeGlobals.publicPath} + ${
|
`link.href = ${RuntimeGlobals.publicPath} + ${RuntimeGlobals.getChunkScriptFilename}(chunkId);`,
|
||||||
RuntimeGlobals.getChunkScriptFilename
|
|
||||||
}(chunkId);`,
|
|
||||||
crossOriginLoading
|
crossOriginLoading
|
||||||
? Template.asString([
|
? Template.asString([
|
||||||
"if (link.href.indexOf(window.location.origin + '/') !== 0) {",
|
"if (link.href.indexOf(window.location.origin + '/') !== 0) {",
|
||||||
|
@ -184,9 +183,7 @@ class JsonpTemplatePlugin {
|
||||||
"}",
|
"}",
|
||||||
'link.rel = "prefetch";',
|
'link.rel = "prefetch";',
|
||||||
'link.as = "script";',
|
'link.as = "script";',
|
||||||
`link.href = ${RuntimeGlobals.publicPath} + ${
|
`link.href = ${RuntimeGlobals.publicPath} + ${RuntimeGlobals.getChunkScriptFilename}(chunkId);`
|
||||||
RuntimeGlobals.getChunkScriptFilename
|
|
||||||
}(chunkId);`
|
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -57,9 +57,7 @@ class ImportScriptsChunkLoadingRuntimeModule extends RuntimeModule {
|
||||||
Template.indent([
|
Template.indent([
|
||||||
"if(Object.prototype.hasOwnProperty.call(moreModules, moduleId)) {",
|
"if(Object.prototype.hasOwnProperty.call(moreModules, moduleId)) {",
|
||||||
Template.indent(
|
Template.indent(
|
||||||
`${
|
`${RuntimeGlobals.moduleFactories}[moduleId] = moreModules[moduleId];`
|
||||||
RuntimeGlobals.moduleFactories
|
|
||||||
}[moduleId] = moreModules[moduleId];`
|
|
||||||
),
|
),
|
||||||
"}"
|
"}"
|
||||||
]),
|
]),
|
||||||
|
@ -69,9 +67,7 @@ class ImportScriptsChunkLoadingRuntimeModule extends RuntimeModule {
|
||||||
Template.indent("installedChunks[chunkIds.pop()] = 1;")
|
Template.indent("installedChunks[chunkIds.pop()] = 1;")
|
||||||
]),
|
]),
|
||||||
"};",
|
"};",
|
||||||
`importScripts(${
|
`importScripts(${RuntimeGlobals.getChunkScriptFilename}(chunkId));`,
|
||||||
RuntimeGlobals.getChunkScriptFilename
|
|
||||||
}(chunkId));`,
|
|
||||||
"",
|
"",
|
||||||
withHmr
|
withHmr
|
||||||
? "if(currentUpdateChunks && currentUpdateChunks[chunkId]) loadUpdateChunk(chunkId);"
|
? "if(currentUpdateChunks && currentUpdateChunks[chunkId]) loadUpdateChunk(chunkId);"
|
||||||
|
@ -110,16 +106,12 @@ class ImportScriptsChunkLoadingRuntimeModule extends RuntimeModule {
|
||||||
]),
|
]),
|
||||||
"};",
|
"};",
|
||||||
"// start update chunk loading",
|
"// start update chunk loading",
|
||||||
`importScripts(${RuntimeGlobals.publicPath} + ${
|
`importScripts(${RuntimeGlobals.publicPath} + ${RuntimeGlobals.getChunkUpdateScriptFilename}(chunkId));`,
|
||||||
RuntimeGlobals.getChunkUpdateScriptFilename
|
|
||||||
}(chunkId));`,
|
|
||||||
'if(!success) throw new Error("Loading update chunk failed for unknown reason");'
|
'if(!success) throw new Error("Loading update chunk failed for unknown reason");'
|
||||||
]),
|
]),
|
||||||
"}",
|
"}",
|
||||||
"",
|
"",
|
||||||
`${
|
`${RuntimeGlobals.hmrDownloadUpdateHandlers}.jsonp = function(chunkIds, removedChunks, removedModules, promises, applyHandlers, updatedModulesList) {`,
|
||||||
RuntimeGlobals.hmrDownloadUpdateHandlers
|
|
||||||
}.jsonp = function(chunkIds, removedChunks, removedModules, promises, applyHandlers, updatedModulesList) {`,
|
|
||||||
Template.indent([
|
Template.indent([
|
||||||
"applyHandlers.push(function(options) {",
|
"applyHandlers.push(function(options) {",
|
||||||
Template.indent([
|
Template.indent([
|
||||||
|
@ -167,9 +159,7 @@ class ImportScriptsChunkLoadingRuntimeModule extends RuntimeModule {
|
||||||
`${RuntimeGlobals.hmrDownloadManifest} = function() {`,
|
`${RuntimeGlobals.hmrDownloadManifest} = function() {`,
|
||||||
Template.indent([
|
Template.indent([
|
||||||
'if (typeof fetch === "undefined") throw new Error("No browser support: need fetch API");',
|
'if (typeof fetch === "undefined") throw new Error("No browser support: need fetch API");',
|
||||||
`return fetch(${RuntimeGlobals.publicPath} + ${
|
`return fetch(${RuntimeGlobals.publicPath} + ${RuntimeGlobals.getUpdateManifestFilename}()).then(function(response) {`,
|
||||||
RuntimeGlobals.getUpdateManifestFilename
|
|
||||||
}()).then(function(response) {`,
|
|
||||||
Template.indent([
|
Template.indent([
|
||||||
"if(response.status === 404) return; // no update available",
|
"if(response.status === 404) return; // no update available",
|
||||||
'if(!response.ok) throw new Error("Failed to fetch update manifest " + response.statusText);',
|
'if(!response.ok) throw new Error("Failed to fetch update manifest " + response.statusText);',
|
||||||
|
|
|
@ -279,9 +279,7 @@ describe("BenchmarkTestCases", function() {
|
||||||
describe(`${testName} create benchmarks`, function() {
|
describe(`${testName} create benchmarks`, function() {
|
||||||
baselines.forEach(baseline => {
|
baselines.forEach(baseline => {
|
||||||
let baselineStats = null;
|
let baselineStats = null;
|
||||||
it(`should benchmark ${baseline.name} (${
|
it(`should benchmark ${baseline.name} (${baseline.rev})`, function(done) {
|
||||||
baseline.rev
|
|
||||||
})`, function(done) {
|
|
||||||
const outputDirectory = path.join(
|
const outputDirectory = path.join(
|
||||||
__dirname,
|
__dirname,
|
||||||
"js",
|
"js",
|
||||||
|
@ -332,14 +330,10 @@ describe("BenchmarkTestCases", function() {
|
||||||
}, 180000);
|
}, 180000);
|
||||||
|
|
||||||
if (baseline.name !== "HEAD") {
|
if (baseline.name !== "HEAD") {
|
||||||
it(`HEAD should not be slower than ${baseline.name} (${
|
it(`HEAD should not be slower than ${baseline.name} (${baseline.rev})`, function() {
|
||||||
baseline.rev
|
|
||||||
})`, function() {
|
|
||||||
if (baselineStats.maxConfidence < headStats.minConfidence) {
|
if (baselineStats.maxConfidence < headStats.minConfidence) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`HEAD (${headStats.text}) is slower than ${baseline.name} (${
|
`HEAD (${headStats.text}) is slower than ${baseline.name} (${baselineStats.text}) (90% confidence)`
|
||||||
baselineStats.text
|
|
||||||
}) (90% confidence)`
|
|
||||||
);
|
);
|
||||||
} else if (
|
} else if (
|
||||||
baselineStats.minConfidence > headStats.maxConfidence
|
baselineStats.minConfidence > headStats.maxConfidence
|
||||||
|
|
|
@ -332,7 +332,7 @@ Object {
|
||||||
"errors": Array [
|
"errors": Array [
|
||||||
Object {
|
Object {
|
||||||
"loc": "2:12",
|
"loc": "2:12",
|
||||||
"message": "Module parse failed: Unexpected token (2:12)\\nYou may need an appropriate loader to handle this file type.\\n| window.foo = {\\n> bar: true,;\\n| };\\n| ",
|
"message": "Module parse failed: Unexpected token (2:12)\\nYou may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders\\n| window.foo = {\\n> bar: true,;\\n| };\\n| ",
|
||||||
"moduleId": 0,
|
"moduleId": 0,
|
||||||
"moduleIdentifier": "<cwd>/test/fixtures/errors/has-syntax-error.js",
|
"moduleIdentifier": "<cwd>/test/fixtures/errors/has-syntax-error.js",
|
||||||
"moduleName": "./has-syntax-error.js",
|
"moduleName": "./has-syntax-error.js",
|
||||||
|
@ -682,6 +682,155 @@ Object {
|
||||||
],
|
],
|
||||||
"warnings": Array [],
|
"warnings": Array [],
|
||||||
}
|
}
|
||||||
|
`);
|
||||||
|
});
|
||||||
|
|
||||||
|
const identityLoader = path.resolve(
|
||||||
|
__dirname,
|
||||||
|
"fixtures/errors/identity-loader.js"
|
||||||
|
);
|
||||||
|
const addCommentLoader = path.resolve(
|
||||||
|
__dirname,
|
||||||
|
"fixtures/errors/add-comment-loader.js"
|
||||||
|
);
|
||||||
|
|
||||||
|
it("should show loader used if it is present when module parsing fails", async () => {
|
||||||
|
await expect(
|
||||||
|
compile({
|
||||||
|
mode: "development",
|
||||||
|
entry: "./abc.html",
|
||||||
|
module: {
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
test: /\.html$/,
|
||||||
|
use: [{ loader: identityLoader }]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
})
|
||||||
|
).resolves.toMatchInlineSnapshot(`
|
||||||
|
Object {
|
||||||
|
"errors": Array [
|
||||||
|
Object {
|
||||||
|
"loc": "1:0",
|
||||||
|
"message": "Module parse failed: Unexpected token (1:0)\\nFile was processed with these loaders:\\n * ./identity-loader.js\\nYou may need an additional loader to handle the result of these loaders.\\n> <!DOCTYPE html>\\n| <html>\\n| <body>",
|
||||||
|
"moduleId": "./abc.html",
|
||||||
|
"moduleIdentifier": "<cwd>/test/fixtures/errors/identity-loader.js!<cwd>/test/fixtures/errors/abc.html",
|
||||||
|
"moduleName": "./abc.html",
|
||||||
|
"moduleTrace": Array [],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
"warnings": Array [],
|
||||||
|
}
|
||||||
|
`);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should show all loaders used if they are in config when module parsing fails", async () => {
|
||||||
|
await expect(
|
||||||
|
compile({
|
||||||
|
mode: "development",
|
||||||
|
entry: "./abc.html",
|
||||||
|
module: {
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
test: /\.html$/,
|
||||||
|
use: [{ loader: identityLoader }, { loader: addCommentLoader }]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
})
|
||||||
|
).resolves.toMatchInlineSnapshot(`
|
||||||
|
Object {
|
||||||
|
"errors": Array [
|
||||||
|
Object {
|
||||||
|
"loc": "1:0",
|
||||||
|
"message": "Module parse failed: Unexpected token (1:0)\\nFile was processed with these loaders:\\n * ./identity-loader.js\\n * ./add-comment-loader.js\\nYou may need an additional loader to handle the result of these loaders.\\n> <!DOCTYPE html>\\n| <html>\\n| <body>",
|
||||||
|
"moduleId": "./abc.html",
|
||||||
|
"moduleIdentifier": "<cwd>/test/fixtures/errors/identity-loader.js!<cwd>/test/fixtures/errors/add-comment-loader.js!<cwd>/test/fixtures/errors/abc.html",
|
||||||
|
"moduleName": "./abc.html",
|
||||||
|
"moduleTrace": Array [],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
"warnings": Array [],
|
||||||
|
}
|
||||||
|
`);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should show all loaders used if use is a string", async () => {
|
||||||
|
await expect(
|
||||||
|
compile({
|
||||||
|
mode: "development",
|
||||||
|
entry: "./abc.html",
|
||||||
|
module: {
|
||||||
|
rules: [
|
||||||
|
{ test: /\.html$/, use: identityLoader },
|
||||||
|
{ test: /\.html$/, use: addCommentLoader }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
})
|
||||||
|
).resolves.toMatchInlineSnapshot(`
|
||||||
|
Object {
|
||||||
|
"errors": Array [
|
||||||
|
Object {
|
||||||
|
"loc": "1:0",
|
||||||
|
"message": "Module parse failed: Unexpected token (1:0)\\nFile was processed with these loaders:\\n * ./identity-loader.js\\n * ./add-comment-loader.js\\nYou may need an additional loader to handle the result of these loaders.\\n> <!DOCTYPE html>\\n| <html>\\n| <body>",
|
||||||
|
"moduleId": "./abc.html",
|
||||||
|
"moduleIdentifier": "<cwd>/test/fixtures/errors/identity-loader.js!<cwd>/test/fixtures/errors/add-comment-loader.js!<cwd>/test/fixtures/errors/abc.html",
|
||||||
|
"moduleName": "./abc.html",
|
||||||
|
"moduleTrace": Array [],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
"warnings": Array [],
|
||||||
|
}
|
||||||
|
`);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should show 'no loaders are configured to process this file' if loaders are not included in config when module parsing fails", async () => {
|
||||||
|
await expect(
|
||||||
|
compile({
|
||||||
|
mode: "development",
|
||||||
|
entry: "./abc.html",
|
||||||
|
module: {}
|
||||||
|
})
|
||||||
|
).resolves.toMatchInlineSnapshot(`
|
||||||
|
Object {
|
||||||
|
"errors": Array [
|
||||||
|
Object {
|
||||||
|
"loc": "1:0",
|
||||||
|
"message": "Module parse failed: Unexpected token (1:0)\\nYou may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders\\n> <!DOCTYPE html>\\n| <html>\\n| <body>",
|
||||||
|
"moduleId": "./abc.html",
|
||||||
|
"moduleIdentifier": "<cwd>/test/fixtures/errors/abc.html",
|
||||||
|
"moduleName": "./abc.html",
|
||||||
|
"moduleTrace": Array [],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
"warnings": Array [],
|
||||||
|
}
|
||||||
|
`);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should show 'source code omitted for this binary file' when module parsing fails for binary files", async () => {
|
||||||
|
const folder = path.join(__dirname, "/fixtures");
|
||||||
|
await expect(
|
||||||
|
compile({
|
||||||
|
mode: "development",
|
||||||
|
entry: path.resolve(folder, "./font.ttf"),
|
||||||
|
module: {}
|
||||||
|
})
|
||||||
|
).resolves.toMatchInlineSnapshot(`
|
||||||
|
Object {
|
||||||
|
"errors": Array [
|
||||||
|
Object {
|
||||||
|
"loc": "1:0",
|
||||||
|
"message": "Module parse failed: Unexpected character ' |