webpack
Advanced tools
Comparing version 5.70.0 to 5.71.0
@@ -7,3 +7,3 @@ /* | ||
if (module.hot) { | ||
var hotPollInterval = +__resourceQuery.substr(1) || 10 * 60 * 1000; | ||
var hotPollInterval = +__resourceQuery.slice(1) || 10 * 60 * 1000; | ||
var log = require("./log"); | ||
@@ -10,0 +10,0 @@ |
@@ -48,3 +48,3 @@ /* | ||
process.on(__resourceQuery.substr(1) || "SIGUSR2", function () { | ||
process.on(__resourceQuery.slice(1) || "SIGUSR2", function () { | ||
if (module.hot.status() !== "idle") { | ||
@@ -51,0 +51,0 @@ log( |
@@ -693,3 +693,3 @@ /* | ||
if (key.endsWith("Order")) { | ||
const name = key.substr(0, key.length - "Order".length); | ||
const name = key.slice(0, key.length - "Order".length); | ||
let list = lists.get(name); | ||
@@ -696,0 +696,0 @@ if (list === undefined) { |
@@ -489,3 +489,3 @@ /* | ||
if (key.endsWith("Order")) { | ||
const name = key.substr(0, key.length - "Order".length); | ||
const name = key.slice(0, key.length - "Order".length); | ||
let list = lists.get(name); | ||
@@ -492,0 +492,0 @@ if (list === undefined) { |
@@ -548,4 +548,17 @@ /* | ||
const startTime = Date.now(); | ||
const finalCallback = (err, entries, compilation) => { | ||
try { | ||
callback(err, entries, compilation); | ||
} catch (e) { | ||
const err = new WebpackError( | ||
`compiler.runAsChild callback error: ${e}` | ||
); | ||
err.details = e.stack; | ||
this.parentCompilation.errors.push(err); | ||
} | ||
}; | ||
this.compile((err, compilation) => { | ||
if (err) return callback(err); | ||
if (err) return finalCallback(err); | ||
@@ -565,3 +578,3 @@ this.parentCompilation.children.push(compilation); | ||
return callback(null, entries, compilation); | ||
return finalCallback(null, entries, compilation); | ||
}); | ||
@@ -601,3 +614,3 @@ } | ||
if (queryStringIdx >= 0) { | ||
targetFile = targetFile.substr(0, queryStringIdx); | ||
targetFile = targetFile.slice(0, queryStringIdx); | ||
// We may remove the hash, which is in the query string | ||
@@ -604,0 +617,0 @@ // So we recheck if the file is immutable |
@@ -718,3 +718,11 @@ /* | ||
F(output, "uniqueName", () => { | ||
const libraryName = getLibraryName(output.library); | ||
const libraryName = getLibraryName(output.library).replace( | ||
/^\[(\\*[\w:]+\\*)\](\.)|(\.)\[(\\*[\w:]+\\*)\](?=\.|$)|\[(\\*[\w:]+\\*)\]/g, | ||
(m, a, d1, d2, b, c) => { | ||
const content = a || b || c; | ||
return content.startsWith("\\") && content.endsWith("\\") | ||
? `${d2 || ""}[${content.slice(1, -1)}]${d1 || ""}` | ||
: ""; | ||
} | ||
); | ||
if (libraryName) return libraryName; | ||
@@ -721,0 +729,0 @@ const pkgPath = path.resolve(context, "package.json"); |
@@ -327,3 +327,3 @@ /* | ||
const param = parser.evaluateExpression(expression.left); | ||
const keepRight = param && param.asNullish(); | ||
const keepRight = param.asNullish(); | ||
if (typeof keepRight === "boolean") { | ||
@@ -411,3 +411,3 @@ // ------------------------------------------ | ||
if (evaluated && evaluated.asNullish()) { | ||
if (evaluated.asNullish()) { | ||
// ------------------------------------------ | ||
@@ -414,0 +414,0 @@ // |
@@ -22,3 +22,7 @@ /* | ||
} = require("./util/comparators"); | ||
const { contextify, parseResource } = require("./util/identifier"); | ||
const { | ||
contextify, | ||
parseResource, | ||
makePathsRelative | ||
} = require("./util/identifier"); | ||
const makeSerializable = require("./util/makeSerializable"); | ||
@@ -1070,5 +1074,17 @@ | ||
getSource(sourceString) { | ||
/** | ||
* @param {string} sourceString source content | ||
* @param {Compilation=} compilation the compilation | ||
* @returns {Source} generated source | ||
*/ | ||
getSource(sourceString, compilation) { | ||
if (this.useSourceMap || this.useSimpleSourceMap) { | ||
return new OriginalSource(sourceString, this.identifier()); | ||
return new OriginalSource( | ||
sourceString, | ||
`webpack://${makePathsRelative( | ||
(compilation && compilation.compiler.context) || "", | ||
this.identifier(), | ||
compilation && compilation.compiler.root | ||
)}` | ||
); | ||
} | ||
@@ -1083,12 +1099,19 @@ return new RawSource(sourceString); | ||
codeGeneration(context) { | ||
const { chunkGraph } = context; | ||
const { chunkGraph, compilation } = context; | ||
const sources = new Map(); | ||
sources.set( | ||
"javascript", | ||
this.getSource(this.getSourceString(this.options.mode, context)) | ||
this.getSource( | ||
this.getSourceString(this.options.mode, context), | ||
compilation | ||
) | ||
); | ||
const set = new Set(); | ||
const allDeps = /** @type {ContextElementDependency[]} */ ( | ||
this.dependencies.concat(this.blocks.map(b => b.dependencies[0])) | ||
); | ||
const allDeps = | ||
this.dependencies.length > 0 | ||
? /** @type {ContextElementDependency[]} */ (this.dependencies).slice() | ||
: []; | ||
for (const block of this.blocks) | ||
for (const dep of block.dependencies) | ||
allDeps.push(/** @type {ContextElementDependency} */ (dep)); | ||
set.add(RuntimeGlobals.module); | ||
@@ -1095,0 +1118,0 @@ set.add(RuntimeGlobals.hasOwnProperty); |
@@ -131,3 +131,3 @@ /* | ||
if (idx >= 0) { | ||
let loadersRequest = request.substr(0, idx + 1); | ||
let loadersRequest = request.slice(0, idx + 1); | ||
let i; | ||
@@ -142,3 +142,3 @@ for ( | ||
loadersRequest = loadersRequest | ||
.substr(i) | ||
.slice(i) | ||
.replace(/!+$/, "") | ||
@@ -151,3 +151,3 @@ .replace(/!!+/g, "!"); | ||
} | ||
resource = request.substr(idx + 1); | ||
resource = request.slice(idx + 1); | ||
} else { | ||
@@ -298,3 +298,2 @@ loaders = []; | ||
let severalContexts = false; | ||
const addDirectoryChecked = (ctx, directory, visited, callback) => { | ||
@@ -355,3 +354,3 @@ fs.realpath(directory, (err, realPath) => { | ||
request: | ||
"." + subResource.substr(ctx.length).replace(/\\/g, "/") | ||
"." + subResource.slice(ctx.length).replace(/\\/g, "/") | ||
}; | ||
@@ -367,11 +366,9 @@ | ||
.map(obj => { | ||
const request = severalContexts | ||
? join(fs, obj.context, obj.request) | ||
: obj.request; | ||
const dep = new ContextElementDependency( | ||
request + resourceQuery + resourceFragment, | ||
`${obj.request}${resourceQuery}${resourceFragment}`, | ||
obj.request, | ||
typePrefix, | ||
category, | ||
referencedExports | ||
referencedExports, | ||
obj.context | ||
); | ||
@@ -423,3 +420,2 @@ dep.optional = true; | ||
} else { | ||
severalContexts = true; | ||
asyncLib.map(resource, visitResource, (err, result) => { | ||
@@ -426,0 +422,0 @@ if (err) return callback(err); |
@@ -32,3 +32,3 @@ /* | ||
if (request && request.startsWith(`${scope}/`)) { | ||
const innerRequest = "." + request.substr(scope.length); | ||
const innerRequest = "." + request.slice(scope.length); | ||
let resolved; | ||
@@ -35,0 +35,0 @@ if (innerRequest in this.options.content) { |
@@ -204,3 +204,3 @@ /* | ||
const exportsArg = parser.evaluateExpression(expr.arguments[0]); | ||
if (!exportsArg || !exportsArg.isIdentifier()) return; | ||
if (!exportsArg.isIdentifier()) return; | ||
if ( | ||
@@ -214,3 +214,2 @@ exportsArg.identifier !== "exports" && | ||
const propertyArg = parser.evaluateExpression(expr.arguments[1]); | ||
if (!propertyArg) return; | ||
const property = propertyArg.asString(); | ||
@@ -217,0 +216,0 @@ if (typeof property !== "string") return; |
@@ -31,4 +31,4 @@ /* | ||
if (idx >= 0) { | ||
context = prefix.substr(0, idx); | ||
prefix = `.${prefix.substr(idx)}`; | ||
context = prefix.slice(0, idx); | ||
prefix = `.${prefix.slice(idx)}`; | ||
} | ||
@@ -35,0 +35,0 @@ return { |
@@ -17,3 +17,18 @@ /* | ||
class ContextElementDependency extends ModuleDependency { | ||
constructor(request, userRequest, typePrefix, category, referencedExports) { | ||
/** | ||
* @param {string} request request | ||
* @param {string|undefined} userRequest user request | ||
* @param {string} typePrefix type prefix | ||
* @param {string} category category | ||
* @param {string[][]=} referencedExports referenced exports | ||
* @param {string=} context context | ||
*/ | ||
constructor( | ||
request, | ||
userRequest, | ||
typePrefix, | ||
category, | ||
referencedExports, | ||
context | ||
) { | ||
super(request); | ||
@@ -23,2 +38,3 @@ this.referencedExports = referencedExports; | ||
this._category = category; | ||
this._context = context || undefined; | ||
@@ -38,2 +54,16 @@ if (userRequest) { | ||
/** | ||
* @returns {string | undefined} a request context | ||
*/ | ||
getContext() { | ||
return this._context; | ||
} | ||
/** | ||
* @returns {string | null} an identifier to merge equal requests | ||
*/ | ||
getResourceIdentifier() { | ||
return `context${this._context || ""}|${super.getResourceIdentifier()}`; | ||
} | ||
get category() { | ||
@@ -62,2 +92,3 @@ return this._category; | ||
write(this._category); | ||
write(this._context); | ||
write(this.referencedExports); | ||
@@ -71,2 +102,3 @@ super.serialize(context); | ||
this._category = read(); | ||
this._context = read(); | ||
this.referencedExports = read(); | ||
@@ -73,0 +105,0 @@ super.deserialize(context); |
@@ -13,2 +13,3 @@ /* | ||
const HarmonyAcceptImportDependency = require("./HarmonyAcceptImportDependency"); | ||
const HarmonyEvaluatedImportSpecifierDependency = require("./HarmonyEvaluatedImportSpecifierDependency"); | ||
const HarmonyExports = require("./HarmonyExports"); | ||
@@ -87,2 +88,14 @@ const { ExportPresenceModes } = require("./HarmonyImportDependency"); | ||
const { exportPresenceMode } = this; | ||
function getNonOptionalPart(members, membersOptionals) { | ||
let i = 0; | ||
while (i < members.length && membersOptionals[i] === false) i++; | ||
return i !== members.length ? members.slice(0, i) : members; | ||
} | ||
function getNonOptionalMemberChain(node, count) { | ||
while (count--) node = node.object; | ||
return node; | ||
} | ||
parser.hooks.isPure | ||
@@ -136,2 +149,41 @@ .for("Identifier") | ||
); | ||
parser.hooks.binaryExpression.tap( | ||
"HarmonyImportDependencyParserPlugin", | ||
expression => { | ||
if (expression.operator !== "in") return; | ||
const leftPartEvaluated = parser.evaluateExpression(expression.left); | ||
if (leftPartEvaluated.couldHaveSideEffects()) return; | ||
const leftPart = leftPartEvaluated.asString(); | ||
if (!leftPart) return; | ||
const rightPart = parser.evaluateExpression(expression.right); | ||
if (!rightPart.isIdentifier()) return; | ||
const rootInfo = rightPart.rootInfo; | ||
if ( | ||
!rootInfo || | ||
!rootInfo.tagInfo || | ||
rootInfo.tagInfo.tag !== harmonySpecifierTag | ||
) | ||
return; | ||
const settings = rootInfo.tagInfo.data; | ||
const members = rightPart.getMembers(); | ||
const dep = new HarmonyEvaluatedImportSpecifierDependency( | ||
settings.source, | ||
settings.sourceOrder, | ||
settings.ids.concat(members).concat([leftPart]), | ||
settings.name, | ||
expression.range, | ||
settings.assertions, | ||
"in" | ||
); | ||
dep.directImport = members.length === 0; | ||
dep.asiSafe = !parser.isAsiPosition(expression.range[0]); | ||
dep.loc = expression.loc; | ||
parser.state.module.addDependency(dep); | ||
InnerGraph.onUsage(parser.state, e => (dep.usedByExports = e)); | ||
return true; | ||
} | ||
); | ||
parser.hooks.expression | ||
@@ -160,47 +212,79 @@ .for(harmonySpecifierTag) | ||
.for(harmonySpecifierTag) | ||
.tap("HarmonyImportDependencyParserPlugin", (expr, members) => { | ||
const settings = /** @type {HarmonySettings} */ (parser.currentTagData); | ||
const ids = settings.ids.concat(members); | ||
const dep = new HarmonyImportSpecifierDependency( | ||
settings.source, | ||
settings.sourceOrder, | ||
ids, | ||
settings.name, | ||
expr.range, | ||
exportPresenceMode, | ||
settings.assertions | ||
); | ||
dep.asiSafe = !parser.isAsiPosition(expr.range[0]); | ||
dep.loc = expr.loc; | ||
parser.state.module.addDependency(dep); | ||
InnerGraph.onUsage(parser.state, e => (dep.usedByExports = e)); | ||
return true; | ||
}); | ||
.tap( | ||
"HarmonyImportDependencyParserPlugin", | ||
(expression, members, membersOptionals) => { | ||
const settings = /** @type {HarmonySettings} */ ( | ||
parser.currentTagData | ||
); | ||
const nonOptionalMembers = getNonOptionalPart( | ||
members, | ||
membersOptionals | ||
); | ||
const expr = | ||
nonOptionalMembers !== members | ||
? getNonOptionalMemberChain( | ||
expression, | ||
members.length - nonOptionalMembers.length | ||
) | ||
: expression; | ||
const ids = settings.ids.concat(nonOptionalMembers); | ||
const dep = new HarmonyImportSpecifierDependency( | ||
settings.source, | ||
settings.sourceOrder, | ||
ids, | ||
settings.name, | ||
expr.range, | ||
exportPresenceMode, | ||
settings.assertions | ||
); | ||
dep.asiSafe = !parser.isAsiPosition(expr.range[0]); | ||
dep.loc = expr.loc; | ||
parser.state.module.addDependency(dep); | ||
InnerGraph.onUsage(parser.state, e => (dep.usedByExports = e)); | ||
return true; | ||
} | ||
); | ||
parser.hooks.callMemberChain | ||
.for(harmonySpecifierTag) | ||
.tap("HarmonyImportDependencyParserPlugin", (expr, members) => { | ||
const { arguments: args, callee } = expr; | ||
const settings = /** @type {HarmonySettings} */ (parser.currentTagData); | ||
const ids = settings.ids.concat(members); | ||
const dep = new HarmonyImportSpecifierDependency( | ||
settings.source, | ||
settings.sourceOrder, | ||
ids, | ||
settings.name, | ||
callee.range, | ||
exportPresenceMode, | ||
settings.assertions | ||
); | ||
dep.directImport = members.length === 0; | ||
dep.call = true; | ||
dep.asiSafe = !parser.isAsiPosition(callee.range[0]); | ||
// only in case when we strictly follow the spec we need a special case here | ||
dep.namespaceObjectAsContext = | ||
members.length > 0 && this.strictThisContextOnImports; | ||
dep.loc = callee.loc; | ||
parser.state.module.addDependency(dep); | ||
if (args) parser.walkExpressions(args); | ||
InnerGraph.onUsage(parser.state, e => (dep.usedByExports = e)); | ||
return true; | ||
}); | ||
.tap( | ||
"HarmonyImportDependencyParserPlugin", | ||
(expression, members, membersOptionals) => { | ||
const { arguments: args, callee } = expression; | ||
const settings = /** @type {HarmonySettings} */ ( | ||
parser.currentTagData | ||
); | ||
const nonOptionalMembers = getNonOptionalPart( | ||
members, | ||
membersOptionals | ||
); | ||
const expr = | ||
nonOptionalMembers !== members | ||
? getNonOptionalMemberChain( | ||
callee, | ||
members.length - nonOptionalMembers.length | ||
) | ||
: callee; | ||
const ids = settings.ids.concat(nonOptionalMembers); | ||
const dep = new HarmonyImportSpecifierDependency( | ||
settings.source, | ||
settings.sourceOrder, | ||
ids, | ||
settings.name, | ||
expr.range, | ||
exportPresenceMode, | ||
settings.assertions | ||
); | ||
dep.directImport = members.length === 0; | ||
dep.call = true; | ||
dep.asiSafe = !parser.isAsiPosition(expr.range[0]); | ||
// only in case when we strictly follow the spec we need a special case here | ||
dep.namespaceObjectAsContext = | ||
members.length > 0 && this.strictThisContextOnImports; | ||
dep.loc = expr.loc; | ||
parser.state.module.addDependency(dep); | ||
if (args) parser.walkExpressions(args); | ||
InnerGraph.onUsage(parser.state, e => (dep.usedByExports = e)); | ||
return true; | ||
} | ||
); | ||
const { hotAcceptCallback, hotAcceptWithoutCallback } = | ||
@@ -207,0 +291,0 @@ HotModuleReplacementPlugin.getParserHooks(parser); |
@@ -264,4 +264,3 @@ /* | ||
const dep = /** @type {HarmonyImportSpecifierDependency} */ (dependency); | ||
const { moduleGraph, module, runtime, concatenationScope } = | ||
templateContext; | ||
const { moduleGraph, runtime } = templateContext; | ||
const connection = moduleGraph.getConnection(dep); | ||
@@ -272,3 +271,22 @@ // Skip rendering depending when dependency is conditional | ||
const ids = dep.getIds(moduleGraph); | ||
const exportExpr = this._getCodeForIds(dep, source, templateContext, ids); | ||
const range = dep.range; | ||
if (dep.shorthand) { | ||
source.insert(range[1], `: ${exportExpr}`); | ||
} else { | ||
source.replace(range[0], range[1] - 1, exportExpr); | ||
} | ||
} | ||
/** | ||
* @param {HarmonyImportSpecifierDependency} dep dependency | ||
* @param {ReplaceSource} source source | ||
* @param {DependencyTemplateContext} templateContext context | ||
* @param {string[]} ids ids | ||
* @returns {string} generated code | ||
*/ | ||
_getCodeForIds(dep, source, templateContext, ids) { | ||
const { moduleGraph, module, runtime, concatenationScope } = | ||
templateContext; | ||
const connection = moduleGraph.getConnection(dep); | ||
let exportExpr; | ||
@@ -304,3 +322,3 @@ if ( | ||
} else { | ||
super.apply(dependency, source, templateContext); | ||
super.apply(dep, source, templateContext); | ||
@@ -326,7 +344,3 @@ const { runtimeTemplate, initFragments, runtimeRequirements } = | ||
} | ||
if (dep.shorthand) { | ||
source.insert(dep.range[1], `: ${exportExpr}`); | ||
} else { | ||
source.replace(dep.range[0], dep.range[1] - 1, exportExpr); | ||
} | ||
return exportExpr; | ||
} | ||
@@ -333,0 +347,0 @@ }; |
@@ -11,2 +11,3 @@ /* | ||
const HarmonyCompatibilityDependency = require("./HarmonyCompatibilityDependency"); | ||
const HarmonyEvaluatedImportSpecifierDependency = require("./HarmonyEvaluatedImportSpecifierDependency"); | ||
const HarmonyExportExpressionDependency = require("./HarmonyExportExpressionDependency"); | ||
@@ -63,3 +64,12 @@ const HarmonyExportHeaderDependency = require("./HarmonyExportHeaderDependency"); | ||
compilation.dependencyFactories.set( | ||
HarmonyEvaluatedImportSpecifierDependency, | ||
normalModuleFactory | ||
); | ||
compilation.dependencyTemplates.set( | ||
HarmonyEvaluatedImportSpecifierDependency, | ||
new HarmonyEvaluatedImportSpecifierDependency.Template() | ||
); | ||
compilation.dependencyTemplates.set( | ||
HarmonyExportHeaderDependency, | ||
@@ -66,0 +76,0 @@ new HarmonyExportHeaderDependency.Template() |
@@ -186,2 +186,9 @@ /* | ||
/** | ||
* @returns {string | undefined} a request context | ||
*/ | ||
getContext() { | ||
return undefined; | ||
} | ||
/** | ||
* @returns {string | null} an identifier to merge equal requests | ||
@@ -188,0 +195,0 @@ */ |
@@ -46,4 +46,4 @@ /* | ||
} else { | ||
const firstLine = stack.substr(0, nextLine); | ||
return firstLine === message ? stack.substr(nextLine + 1) : stack; | ||
const firstLine = stack.slice(0, nextLine); | ||
return firstLine === message ? stack.slice(nextLine + 1) : stack; | ||
} | ||
@@ -50,0 +50,0 @@ }; |
@@ -28,3 +28,5 @@ /* | ||
const chunkLoading = | ||
(options && options.chunkLoading) || globalChunkLoading; | ||
options && options.chunkLoading !== undefined | ||
? options.chunkLoading | ||
: globalChunkLoading; | ||
return chunkLoading === "import"; | ||
@@ -31,0 +33,0 @@ }; |
@@ -92,4 +92,4 @@ /* | ||
const idx = externalConfig.indexOf(" "); | ||
type = externalConfig.substr(0, idx); | ||
externalConfig = externalConfig.substr(idx + 1); | ||
type = externalConfig.slice(0, idx); | ||
externalConfig = externalConfig.slice(idx + 1); | ||
} else if ( | ||
@@ -102,5 +102,5 @@ Array.isArray(externalConfig) && | ||
const idx = firstItem.indexOf(" "); | ||
type = firstItem.substr(0, idx); | ||
type = firstItem.slice(0, idx); | ||
externalConfig = [ | ||
firstItem.substr(idx + 1), | ||
firstItem.slice(idx + 1), | ||
...externalConfig.slice(1) | ||
@@ -107,0 +107,0 @@ ]; |
@@ -31,3 +31,4 @@ /* | ||
// while downloading | ||
var blockingPromises; | ||
var blockingPromises = 0; | ||
var blockingPromisesWaiting = []; | ||
@@ -222,2 +223,16 @@ // The update info | ||
function unblock() { | ||
if (--blockingPromises === 0) { | ||
setStatus("ready").then(function () { | ||
if (blockingPromises === 0) { | ||
var list = blockingPromisesWaiting; | ||
blockingPromisesWaiting = []; | ||
for (var i = 0; i < list.length; i++) { | ||
list[i](); | ||
} | ||
} | ||
}); | ||
} | ||
} | ||
function trackBlockingPromise(promise) { | ||
@@ -227,9 +242,6 @@ switch (currentStatus) { | ||
setStatus("prepare"); | ||
blockingPromises.push(promise); | ||
waitForBlockingPromises(function () { | ||
return setStatus("ready"); | ||
}); | ||
return promise; | ||
/* fallthrough */ | ||
case "prepare": | ||
blockingPromises.push(promise); | ||
blockingPromises++; | ||
promise.then(unblock, unblock); | ||
return promise; | ||
@@ -242,7 +254,7 @@ default: | ||
function waitForBlockingPromises(fn) { | ||
if (blockingPromises.length === 0) return fn(); | ||
var blocker = blockingPromises; | ||
blockingPromises = []; | ||
return Promise.all(blocker).then(function () { | ||
return waitForBlockingPromises(fn); | ||
if (blockingPromises === 0) return fn(); | ||
return new Promise(function (resolve) { | ||
blockingPromisesWaiting.push(function () { | ||
resolve(fn()); | ||
}); | ||
}); | ||
@@ -268,3 +280,2 @@ } | ||
var updatedModules = []; | ||
blockingPromises = []; | ||
currentUpdateApplyHandlers = []; | ||
@@ -306,3 +317,7 @@ | ||
return Promise.resolve().then(function () { | ||
throw new Error("apply() is only allowed in ready status"); | ||
throw new Error( | ||
"apply() is only allowed in ready status (state: " + | ||
currentStatus + | ||
")" | ||
); | ||
}); | ||
@@ -309,0 +324,0 @@ } |
@@ -446,2 +446,4 @@ /* | ||
currentUpdateChunks[chunkId] = true; | ||
} else { | ||
currentUpdateChunks[chunkId] = false; | ||
} | ||
@@ -453,5 +455,4 @@ }); | ||
currentUpdateChunks && | ||
!$hasOwnProperty$(currentUpdateChunks, chunkId) && | ||
$hasOwnProperty$($installedChunks$, chunkId) && | ||
$installedChunks$[chunkId] !== undefined | ||
$hasOwnProperty$(currentUpdateChunks, chunkId) && | ||
!currentUpdateChunks[chunkId] | ||
) { | ||
@@ -458,0 +459,0 @@ promises.push($loadUpdateChunk$(chunkId)); |
@@ -67,4 +67,4 @@ /* | ||
let len = options.hashDigestLength; | ||
while (usedIds.has(hashId.substr(0, len))) len++; | ||
const moduleId = hashId.substr(0, len); | ||
while (usedIds.has(hashId.slice(0, len))) len++; | ||
const moduleId = hashId.slice(0, len); | ||
chunkGraph.setModuleId(module, moduleId); | ||
@@ -71,0 +71,0 @@ usedIds.add(moduleId); |
@@ -28,3 +28,3 @@ /* | ||
const digest = /** @type {string} */ (hash.digest("hex")); | ||
return digest.substr(0, len); | ||
return digest.slice(0, len); | ||
}; | ||
@@ -31,0 +31,0 @@ |
@@ -64,3 +64,3 @@ /* | ||
this.wrappedInnerExpressions = undefined; | ||
/** @type {string | undefined} */ | ||
/** @type {string | VariableInfoInterface | undefined} */ | ||
this.identifier = undefined; | ||
@@ -71,2 +71,4 @@ /** @type {VariableInfoInterface} */ | ||
this.getMembers = undefined; | ||
/** @type {() => boolean[]} */ | ||
this.getMembersOptionals = undefined; | ||
/** @type {EsTreeNode} */ | ||
@@ -347,3 +349,3 @@ this.expression = undefined; | ||
setIdentifier(identifier, rootInfo, getMembers) { | ||
setIdentifier(identifier, rootInfo, getMembers, getMembersOptionals) { | ||
this.type = TypeIdentifier; | ||
@@ -353,2 +355,3 @@ this.identifier = identifier; | ||
this.getMembers = getMembers; | ||
this.getMembersOptionals = getMembersOptionals; | ||
this.sideEffects = true; | ||
@@ -355,0 +358,0 @@ return this; |
@@ -313,5 +313,7 @@ /* | ||
" }\n") + | ||
`})(${ | ||
runtimeTemplate.outputOptions.globalObject | ||
}, function(${externalsArguments(externals)}) {\nreturn `, | ||
`})(${runtimeTemplate.outputOptions.globalObject}, ${ | ||
runtimeTemplate.supportsArrowFunction() | ||
? `(${externalsArguments(externals)}) =>` | ||
: `function(${externalsArguments(externals)})` | ||
} {\nreturn `, | ||
"webpack/universalModuleDefinition" | ||
@@ -318,0 +320,0 @@ ), |
@@ -55,3 +55,3 @@ /* | ||
options, | ||
i < 0 ? resource : resource.substr(0, i) | ||
i < 0 ? resource : resource.slice(0, i) | ||
) | ||
@@ -58,0 +58,0 @@ ) { |
@@ -52,2 +52,3 @@ /* | ||
// TODO webpack 6: compilation will be required in CodeGenerationContext | ||
/** | ||
@@ -62,2 +63,3 @@ * @typedef {Object} CodeGenerationContext | ||
* @property {CodeGenerationResults} codeGenerationResults code generation results of other modules (need to have a codeGenerationDependency to use that) | ||
* @property {Compilation=} compilation the compilation | ||
*/ | ||
@@ -64,0 +66,0 @@ |
@@ -50,3 +50,3 @@ /* | ||
const idx = str.indexOf(token); | ||
return idx < 0 ? "" : str.substr(idx); | ||
return idx < 0 ? "" : str.slice(idx); | ||
}; | ||
@@ -59,3 +59,3 @@ }; | ||
const idx = str.lastIndexOf(token); | ||
return idx < 0 ? "" : str.substr(0, idx); | ||
return idx < 0 ? "" : str.slice(0, idx); | ||
}; | ||
@@ -69,3 +69,3 @@ }; | ||
const digest = /** @type {string} */ (hash.digest("hex")); | ||
return digest.substr(0, 4); | ||
return digest.slice(0, 4); | ||
}; | ||
@@ -72,0 +72,0 @@ }; |
@@ -378,3 +378,3 @@ /* | ||
const idx = resource.indexOf("?"); | ||
if (idx >= 0) return resource.substr(0, idx); | ||
if (idx >= 0) return resource.slice(0, idx); | ||
return resource; | ||
@@ -562,3 +562,3 @@ } | ||
if (typeof options === "string") { | ||
if (options.substr(0, 1) === "{" && options.substr(-1) === "}") { | ||
if (options.startsWith("{") && options.endsWith("}")) { | ||
try { | ||
@@ -565,0 +565,0 @@ options = parseJson(options); |
@@ -382,3 +382,3 @@ /* | ||
}; | ||
requestWithoutMatchResource = request.substr( | ||
requestWithoutMatchResource = request.slice( | ||
matchResourceMatch[0].length | ||
@@ -441,3 +441,3 @@ ); | ||
if (typeof item.options === "string" && item.options[0] === "?") { | ||
const ident = item.options.substr(1); | ||
const ident = item.options.slice(1); | ||
if (ident === "[[missing ident]]") { | ||
@@ -444,0 +444,0 @@ throw new Error( |
@@ -14,2 +14,3 @@ /* | ||
const AutoPublicPathRuntimeModule = require("./runtime/AutoPublicPathRuntimeModule"); | ||
const BaseUriRuntimeModule = require("./runtime/BaseUriRuntimeModule"); | ||
const CompatGetDefaultExportRuntimeModule = require("./runtime/CompatGetDefaultExportRuntimeModule"); | ||
@@ -100,2 +101,11 @@ const CompatRuntimeModule = require("./runtime/CompatRuntimeModule"); | ||
compiler.hooks.compilation.tap("RuntimePlugin", compilation => { | ||
const globalChunkLoading = compilation.outputOptions.chunkLoading; | ||
const isChunkLoadingDisabledForChunk = chunk => { | ||
const options = chunk.getEntryOptions(); | ||
const chunkLoading = | ||
options && options.chunkLoading !== undefined | ||
? options.chunkLoading | ||
: globalChunkLoading; | ||
return chunkLoading === false; | ||
}; | ||
compilation.dependencyTemplates.set( | ||
@@ -418,2 +428,10 @@ RuntimeRequirementsDependency, | ||
}); | ||
compilation.hooks.runtimeRequirementInTree | ||
.for(RuntimeGlobals.baseURI) | ||
.tap("RuntimePlugin", chunk => { | ||
if (isChunkLoadingDisabledForChunk(chunk)) { | ||
compilation.addRuntimeModule(chunk, new BaseUriRuntimeModule()); | ||
return true; | ||
} | ||
}); | ||
// TODO webpack 6: remove CompatRuntimeModule | ||
@@ -420,0 +438,0 @@ compilation.hooks.additionalTreeRuntimeRequirements.tap( |
@@ -106,2 +106,4 @@ /* | ||
require("../dependencies/HarmonyImportSpecifierDependency"), | ||
"dependencies/HarmonyEvaluatedImportSpecifierDependency": () => | ||
require("../dependencies/HarmonyEvaluatedImportSpecifierDependency"), | ||
"dependencies/ImportContextDependency": () => | ||
@@ -108,0 +110,0 @@ require("../dependencies/ImportContextDependency"), |
@@ -289,4 +289,5 @@ /* | ||
"var waitingUpdateResolves = {};", | ||
"function loadUpdateChunk(chunkId) {", | ||
"function loadUpdateChunk(chunkId, updatedModulesList) {", | ||
Template.indent([ | ||
"currentUpdatedModulesList = updatedModulesList;", | ||
`return new Promise(${runtimeTemplate.basicFunction( | ||
@@ -293,0 +294,0 @@ "resolve, reject", |
{ | ||
"name": "webpack", | ||
"version": "5.70.0", | ||
"version": "5.71.0", | ||
"author": "Tobias Koppers @sokra", | ||
@@ -5,0 +5,0 @@ "description": "Packs CommonJs/AMD modules for the browser. Allows to split your codebase into multiple bundles, which can be loaded on demand. Support loaders to preprocess files, i.e. json, jsx, es7, css, less, ... and your custom stuff.", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
4373093
647
127002
24