Unverified Commit 54dbeb30 authored by Tobias Koppers's avatar Tobias Koppers Committed by GitHub
parent 9b38ffe5
......@@ -19047,6 +19047,7 @@ const compareModuleIterables = compareIterables(compareModulesByIdentifier);
/** @typedef {(c: Chunk, chunkGraph: ChunkGraph) => boolean} ChunkFilterPredicate */
/** @typedef {(m: Module) => boolean} ModuleFilterPredicate */
/** @typedef {[Module, Entrypoint | undefined]} EntryModuleWithChunkGroup */
/**
* @typedef {Object} ChunkSizeOptions
......@@ -20181,8 +20182,6 @@ class ChunkGraph {
return cgc.dependentHashModules;
}
/** @typedef {[Module, Entrypoint | undefined]} EntryModuleWithChunkGroup */
/**
* @param {Chunk} chunk the chunk
* @returns {Iterable<EntryModuleWithChunkGroup>} iterable of modules (do not modify)
......@@ -22479,6 +22478,7 @@ const { isSourceEqual } = __webpack_require__(41245);
/**
* @typedef {Object} ChunkHashContext
* @property {CodeGenerationResults} codeGenerationResults results of code generation
* @property {RuntimeTemplate} runtimeTemplate the runtime template
* @property {ModuleGraph} moduleGraph the module graph
* @property {ChunkGraph} chunkGraph the chunk graph
......@@ -26434,6 +26434,7 @@ This prevents using hashes of each other and should be avoided.`);
chunk.updateHash(chunkHash, chunkGraph);
this.hooks.chunkHash.call(chunk, chunkHash, {
chunkGraph,
codeGenerationResults: this.codeGenerationResults,
moduleGraph: this.moduleGraph,
runtimeTemplate: this.runtimeTemplate
});
......@@ -27267,7 +27268,7 @@ This prevents using hashes of each other and should be avoided.`);
strictModuleErrorHandling,
strictModuleExceptionHandling
} = this.outputOptions;
const __nested_webpack_require_152290__ = id => {
const __nested_webpack_require_152432__ = id => {
const cached = moduleCache[id];
if (cached !== undefined) {
if (cached.error) throw cached.error;
......@@ -27276,20 +27277,20 @@ This prevents using hashes of each other and should be avoided.`);
const moduleArgument = moduleArgumentsById.get(id);
return __webpack_require_module__(moduleArgument, id);
};
const interceptModuleExecution = (__nested_webpack_require_152290__[
const interceptModuleExecution = (__nested_webpack_require_152432__[
RuntimeGlobals.interceptModuleExecution.replace(
"__webpack_require__.",
""
)
] = []);
const moduleCache = (__nested_webpack_require_152290__[
const moduleCache = (__nested_webpack_require_152432__[
RuntimeGlobals.moduleCache.replace(
"__webpack_require__.",
""
)
] = {});
context.__webpack_require__ = __nested_webpack_require_152290__;
context.__webpack_require__ = __nested_webpack_require_152432__;
/**
* @param {ExecuteModuleArgument} moduleArgument the module argument
......@@ -27305,7 +27306,7 @@ This prevents using hashes of each other and should be avoided.`);
loaded: false,
error: undefined
},
require: __nested_webpack_require_152290__
require: __nested_webpack_require_152432__
};
interceptModuleExecution.forEach(handler =>
handler(execOptions)
......@@ -27345,7 +27346,7 @@ This prevents using hashes of each other and should be avoided.`);
moduleArgumentsMap.get(runtimeModule)
);
}
exports = __nested_webpack_require_152290__(module.identifier());
exports = __nested_webpack_require_152432__(module.identifier());
} catch (e) {
const err = new WebpackError(
`Execution of module code from module graph (${module.readableIdentifier(
......@@ -29715,7 +29716,7 @@ const makeSerializable = __webpack_require__(33032);
/**
* @typedef {Object} ContextModuleOptionsExtras
* @property {string} resource
* @property {string|string[]} resource
* @property {string=} resourceQuery
* @property {string=} resourceFragment
* @property {TODO} resolveOptions
......@@ -29746,23 +29747,36 @@ class ContextModule extends Module {
* @param {ContextModuleOptions} options options object
*/
constructor(resolveDependencies, options) {
const parsed = parseResource(options ? options.resource : "");
const resource = parsed.path;
const resourceQuery = (options && options.resourceQuery) || parsed.query;
const resourceFragment =
(options && options.resourceFragment) || parsed.fragment;
super("javascript/dynamic", resource);
if (!options || typeof options.resource === "string") {
const parsed = parseResource(
options ? /** @type {string} */ (options.resource) : ""
);
const resource = parsed.path;
const resourceQuery = (options && options.resourceQuery) || parsed.query;
const resourceFragment =
(options && options.resourceFragment) || parsed.fragment;
super("javascript/dynamic", resource);
/** @type {ContextModuleOptions} */
this.options = {
...options,
resource,
resourceQuery,
resourceFragment
};
} else {
super("javascript/dynamic");
/** @type {ContextModuleOptions} */
this.options = {
...options,
resource: options.resource,
resourceQuery: options.resourceQuery || "",
resourceFragment: options.resourceFragment || ""
};
}
// Info from Factory
this.resolveDependencies = resolveDependencies;
/** @type {ContextModuleOptions} */
this.options = {
...options,
resource,
resourceQuery,
resourceFragment
};
if (options && options.resolveOptions !== undefined) {
this.resolveOptions = options.resolveOptions;
}
......@@ -29809,7 +29823,11 @@ class ContextModule extends Module {
}
_createIdentifier() {
let identifier = this.context;
let identifier =
this.context ||
(typeof this.options.resource === "string"
? this.options.resource
: this.options.resource.join("|"));
if (this.options.resourceQuery) {
identifier += `|${this.options.resourceQuery}`;
}
......@@ -29874,7 +29892,16 @@ class ContextModule extends Module {
* @returns {string} a user readable identifier of the module
*/
readableIdentifier(requestShortener) {
let identifier = requestShortener.shorten(this.context) + "/";
let identifier;
if (this.context) {
identifier = requestShortener.shorten(this.context) + "/";
} else if (typeof this.options.resource === "string") {
identifier = requestShortener.shorten(this.options.resource) + "/";
} else {
identifier = this.options.resource
.map(r => requestShortener.shorten(r) + "/")
.join(" ");
}
if (this.options.resourceQuery) {
identifier += ` ${this.options.resourceQuery}`;
}
......@@ -29924,11 +29951,30 @@ class ContextModule extends Module {
* @returns {string | null} an identifier for library inclusion
*/
libIdent(options) {
let identifier = contextify(
options.context,
this.context,
options.associatedObjectForCache
);
let identifier;
if (this.context) {
identifier = contextify(
options.context,
this.context,
options.associatedObjectForCache
);
} else if (typeof this.options.resource === "string") {
identifier = contextify(
options.context,
this.options.resource,
options.associatedObjectForCache
);
} else {
const arr = [];
for (const res of this.options.resource) {
arr.push(
contextify(options.context, res, options.associatedObjectForCache)
);
}
identifier = arr.join(" ");
}
if (this.layer) identifier = `(${this.layer})/${identifier}`;
if (this.options.mode) {
identifier += ` ${this.options.mode}`;
......@@ -30096,7 +30142,11 @@ class ContextModule extends Module {
compilation.fileSystemInfo.createSnapshot(
startTime,
null,
[this.context],
this.context
? [this.context]
: typeof this.options.resource === "string"
? [this.options.resource]
: this.options.resource,
null,
SNAPSHOT_OPTIONS,
(err, snapshot) => {
......@@ -30120,7 +30170,13 @@ class ContextModule extends Module {
missingDependencies,
buildDependencies
) {
contextDependencies.add(this.context);
if (this.context) {
contextDependencies.add(this.context);
} else if (typeof this.options.resource === "string") {
contextDependencies.add(this.options.resource);
} else {
for (const res of this.options.resource) contextDependencies.add(res);
}
}
/**
......@@ -30912,6 +30968,9 @@ module.exports = class ContextModuleFactory extends ModuleFactory {
asyncLib.parallel(
[
callback => {
const results = [];
const yield_ = obj => results.push(obj);
contextResolver.resolve(
{},
context,
......@@ -30919,11 +30978,12 @@ module.exports = class ContextModuleFactory extends ModuleFactory {
{
fileDependencies,
missingDependencies,
contextDependencies
contextDependencies,
yield: yield_
},
(err, result) => {
err => {
if (err) return callback(err);
callback(null, result);
callback(null, results);
}
);
},
......@@ -30958,15 +31018,20 @@ module.exports = class ContextModuleFactory extends ModuleFactory {
contextDependencies
});
}
const [contextResult, loaderResult] = result;
this.hooks.afterResolve.callAsync(
{
addon:
loadersPrefix +
result[1].join("!") +
(result[1].length > 0 ? "!" : ""),
resource: result[0],
loaderResult.join("!") +
(loaderResult.length > 0 ? "!" : ""),
resource:
contextResult.length > 1
? contextResult.map(r => r.path)
: contextResult[0].path,
resolveDependencies: this.resolveDependencies.bind(this),
resourceQuery: contextResult[0].query,
resourceFragment: contextResult[0].fragment,
...beforeResolveResult
},
(err, result) => {
......@@ -31023,26 +31088,28 @@ module.exports = class ContextModuleFactory extends ModuleFactory {
} = options;
if (!regExp || !resource) return callback(null, []);
const addDirectoryChecked = (directory, visited, callback) => {
let severalContexts = false;
const addDirectoryChecked = (ctx, directory, visited, callback) => {
fs.realpath(directory, (err, realPath) => {
if (err) return callback(err);
if (visited.has(realPath)) return callback(null, []);
let recursionStack;
addDirectory(
ctx,
directory,
(dir, callback) => {
(_, dir, callback) => {
if (recursionStack === undefined) {
recursionStack = new Set(visited);
recursionStack.add(realPath);
}
addDirectoryChecked(dir, recursionStack, callback);
addDirectoryChecked(ctx, dir, recursionStack, callback);
},
callback
);
});
};
const addDirectory = (directory, addSubDirectory, callback) => {
const addDirectory = (ctx, directory, addSubDirectory, callback) => {
fs.readdir(directory, (err, files) => {
if (err) return callback(err);
const processedFiles = cmf.hooks.contextModuleFiles.call(
......@@ -31069,16 +31136,15 @@ module.exports = class ContextModuleFactory extends ModuleFactory {
if (stat.isDirectory()) {
if (!recursive) return callback();
addSubDirectory(subResource, callback);
addSubDirectory(ctx, subResource, callback);
} else if (
stat.isFile() &&
(!include || subResource.match(include))
) {
const obj = {
context: resource,
context: ctx,
request:
"." +
subResource.substr(resource.length).replace(/\\/g, "/")
"." + subResource.substr(ctx.length).replace(/\\/g, "/")
};
this.hooks.alternativeRequests.callAsync(
......@@ -31089,8 +31155,11 @@ module.exports = class ContextModuleFactory extends ModuleFactory {
alternatives = alternatives
.filter(obj => regExp.test(obj.request))
.map(obj => {
const request = severalContexts
? join(fs, obj.context, obj.request)
: obj.request;
const dep = new ContextElementDependency(
obj.request + resourceQuery + resourceFragment,
request + resourceQuery + resourceFragment,
obj.request,
typePrefix,
category,
......@@ -31127,12 +31196,38 @@ module.exports = class ContextModuleFactory extends ModuleFactory {
});
};
if (typeof fs.realpath === "function") {
addDirectoryChecked(resource, new Set(), callback);
const addSubDirectory = (ctx, dir, callback) =>
addDirectory(ctx, dir, addSubDirectory, callback);
const visitResource = (resource, callback) => {
if (typeof fs.realpath === "function") {
addDirectoryChecked(resource, resource, new Set(), callback);
} else {
addDirectory(resource, resource, addSubDirectory, callback);
}
};
if (typeof resource === "string") {
visitResource(resource, callback);
} else {
const addSubDirectory = (dir, callback) =>
addDirectory(dir, addSubDirectory, callback);
addDirectory(resource, addSubDirectory, callback);
severalContexts = true;
asyncLib.map(resource, visitResource, (err, result) => {
if (err) return callback(err);
// result dependencies should have unique userRequest
// ordered by resolve result
const temp = new Set();
const res = [];
for (let i = 0; i < result.length; i++) {
const inner = result[i];
for (const el of inner) {
if (temp.has(el.userRequest)) continue;
res.push(el);
temp.add(el.userRequest);
}
}
callback(null, res);
});
}
}
};
......@@ -34588,15 +34683,15 @@ class ExportsInfo {
}
}
for (const exportInfo of this._exports.values()) {
if (!canMangle && exportInfo.canMangleProvide !== false) {
exportInfo.canMangleProvide = false;
changed = true;
}
if (excludeExports && excludeExports.has(exportInfo.name)) continue;
if (exportInfo.provided !== true && exportInfo.provided !== null) {
exportInfo.provided = null;
changed = true;
}
if (!canMangle && exportInfo.canMangleProvide !== false) {
exportInfo.canMangleProvide = false;
changed = true;
}
if (targetKey) {
exportInfo.setTarget(targetKey, targetModule, [exportInfo.name], -1);
}
......@@ -49902,7 +49997,10 @@ const LazySet = __webpack_require__(38938);
const { getScheme } = __webpack_require__(54500);
const { cachedCleverMerge, cachedSetProperty } = __webpack_require__(60839);
const { join } = __webpack_require__(17139);
const { parseResource } = __webpack_require__(82186);
const {
parseResource,
parseResourceWithoutFragment
} = __webpack_require__(82186);
/** @typedef {import("../declarations/WebpackOptions").ModuleOptionsNormalized} ModuleOptions */
/** @typedef {import("./Generator")} Generator */
......@@ -49940,6 +50038,11 @@ const { parseResource } = __webpack_require__(82186);
/** @typedef {ResourceData & { data: Record<string, any> }} ResourceDataWithData */
/** @typedef {Object} ParsedLoaderRequest
* @property {string} loader loader
* @property {string|undefined} options options
*/
const EMPTY_RESOLVE_OPTIONS = {};
const EMPTY_PARSER_OPTIONS = {};
const EMPTY_GENERATOR_OPTIONS = {};
......@@ -49971,27 +50074,6 @@ const stringifyLoadersAndResource = (loaders, resource) => {
return str + resource;
};
/**
* @param {string} resultString resultString
* @returns {{loader: string, options: string|undefined}} parsed loader request
*/
const identToLoaderRequest = resultString => {
const idx = resultString.indexOf("?");
if (idx >= 0) {
const loader = resultString.substr(0, idx);
const options = resultString.substr(idx + 1);
return {
loader,
options
};
} else {
return {
loader: resultString,
options: undefined
};
}
};
const needCalls = (times, callback) => {
return err => {
if (--times === 0) {
......@@ -50138,6 +50220,9 @@ class NormalModuleFactory extends ModuleFactory {
const cacheParseResource = parseResource.bindCache(
associatedObjectForCache
);
const cachedParseResourceWithoutFragment =
parseResourceWithoutFragment.bindCache(associatedObjectForCache);
this._parseResourceWithoutFragment = cachedParseResourceWithoutFragment;
this.hooks.factorize.tapAsync(
{
......@@ -50225,7 +50310,7 @@ class NormalModuleFactory extends ModuleFactory {
let matchResourceData = undefined;
/** @type {string} */
let unresolvedResource;
/** @type {{loader: string, options: string|undefined}[]} */
/** @type {ParsedLoaderRequest[]} */
let elements;
let noPreAutoLoaders = false;
let noAutoLoaders = false;
......@@ -50279,7 +50364,13 @@ class NormalModuleFactory extends ModuleFactory {
)
.split(/!+/);
unresolvedResource = rawElements.pop();
elements = rawElements.map(identToLoaderRequest);
elements = rawElements.map(el => {
const { path, query } = cachedParseResourceWithoutFragment(el);
return {
loader: path,
options: query ? query.slice(1) : undefined
};
});
scheme = getScheme(unresolvedResource);
} else {
unresolvedResource = requestWithoutMatchResource;
......@@ -50891,12 +50982,14 @@ If changing the source code is not an option there is also a resolve options cal
}
if (err) return callback(err);
const parsedResult = identToLoaderRequest(result);
const parsedResult = this._parseResourceWithoutFragment(result);
const resolved = {
loader: parsedResult.loader,
loader: parsedResult.path,
options:
item.options === undefined
? parsedResult.options
? parsedResult.query
? parsedResult.query.slice(1)
: undefined
: item.options,
ident: item.options === undefined ? undefined : item.ident
};
......@@ -51311,7 +51404,7 @@ const createDefaultHandler = (profile, logger) => {
/**
* @callback ReportProgress
* @param {number} p
* @param {...string[]} [args]
* @param {...string} [args]
* @returns {void}
*/
......@@ -55963,6 +56056,7 @@ module.exports.NUMBER_OF_IDENTIFIER_CONTINUATION_CHARS =
const mime = __webpack_require__(78585);
const { basename, extname } = __webpack_require__(71017);
const util = __webpack_require__(73837);
const Chunk = __webpack_require__(39385);
......@@ -56075,29 +56169,53 @@ const replacePathVariables = (path, data, assetInfo) => {
// [name] - file
// [ext] - .js
if (typeof data.filename === "string") {
const { path: file, query, fragment } = parseResource(data.filename);
const ext = extname(file);
const base = basename(file);
const name = base.slice(0, base.length - ext.length);
const path = file.slice(0, file.length - base.length);
replacements.set("file", replacer(file));
replacements.set("query", replacer(query, true));
replacements.set("fragment", replacer(fragment, true));
replacements.set("path", replacer(path, true));
replacements.set("base", replacer(base));
replacements.set("name", replacer(name));
replacements.set("ext", replacer(ext, true));
// Legacy
replacements.set(
"filebase",
deprecated(
replacer(base),
"[filebase] is now [base]",
"DEP_WEBPACK_TEMPLATE_PATH_PLUGIN_REPLACE_PATH_VARIABLES_FILENAME"
)
);
// check that filename is data uri
let match = data.filename.match(/^data:([^;,]+)/);
if (match) {
const ext = mime.extension(match[1]);
const emptyReplacer = replacer("", true);
replacements.set("file", emptyReplacer);
replacements.set("query", emptyReplacer);
replacements.set("fragment", emptyReplacer);
replacements.set("path", emptyReplacer);
replacements.set("base", emptyReplacer);
replacements.set("name", emptyReplacer);
replacements.set("ext", replacer(ext ? `.${ext}` : "", true));
// Legacy
replacements.set(
"filebase",
deprecated(
emptyReplacer,
"[filebase] is now [base]",
"DEP_WEBPACK_TEMPLATE_PATH_PLUGIN_REPLACE_PATH_VARIABLES_FILENAME"
)
);
} else {
const { path: file, query, fragment } = parseResource(data.filename);
const ext = extname(file);
const base = basename(file);
const name = base.slice(0, base.length - ext.length);
const path = file.slice(0, file.length - base.length);
replacements.set("file", replacer(file));
replacements.set("query", replacer(query, true));
replacements.set("fragment", replacer(fragment, true));
replacements.set("path", replacer(path, true));
replacements.set("base", replacer(base));
replacements.set("name", replacer(name));
replacements.set("ext", replacer(ext, true));
// Legacy
replacements.set(
"filebase",
deprecated(
replacer(base),
"[filebase] is now [base]",
"DEP_WEBPACK_TEMPLATE_PATH_PLUGIN_REPLACE_PATH_VARIABLES_FILENAME"
)
);
}
}
// Compilation context
......@@ -58118,6 +58236,7 @@ const Generator = __webpack_require__(93401);
const RuntimeGlobals = __webpack_require__(16475);
const createHash = __webpack_require__(49835);
const { makePathsRelative } = __webpack_require__(82186);
const nonNumericOnlyHash = __webpack_require__(55668);
/** @typedef {import("webpack-sources").Source} Source */
/** @typedef {import("../../declarations/WebpackOptions").AssetGeneratorOptions} AssetGeneratorOptions */
......@@ -58338,8 +58457,8 @@ class AssetGenerator extends Generator {
const fullHash = /** @type {string} */ (
hash.digest(runtimeTemplate.outputOptions.hashDigest)
);
const contentHash = fullHash.slice(
0,
const contentHash = nonNumericOnlyHash(
fullHash,
runtimeTemplate.outputOptions.hashDigestLength
);
module.buildInfo.fullContentHash = fullHash;
......@@ -60103,7 +60222,7 @@ const visitModules = (
const module = it.value;
if (
availableModules.has(module) ||
availableModules.plus.has(m)
availableModules.plus.has(module)
) {
cachedMinAvailableModules.add(module);
}
......@@ -62690,6 +62809,11 @@ class ResolverCachePlugin {
fileDependencies: new LazySet(),
contextDependencies: new LazySet()
};
let yieldResult;
if (typeof newResolveContext.yield === "function") {
yieldResult = [];
newResolveContext.yield = obj => yieldResult.push(obj);
}
const propagate = key => {
if (resolveContext[key]) {
addAllToSet(resolveContext[key], newResolveContext[key]);
......@@ -62717,15 +62841,19 @@ class ResolverCachePlugin {
snapshotOptions,
(err, snapshot) => {
if (err) return callback(err);
const resolveResult = result || yieldResult;
if (!snapshot) {
if (result) return callback(null, result);
if (resolveResult) return callback(null, resolveResult);
return callback();
}
itemCache.store(new CacheEntry(result, snapshot), storeErr => {
if (storeErr) return callback(storeErr);
if (result) return callback(null, result);
callback();
});
itemCache.store(
new CacheEntry(resolveResult, snapshot),
storeErr => {
if (storeErr) return callback(storeErr);
if (resolveResult) return callback(null, resolveResult);
callback();
}
);
}
);
}
......@@ -62735,6 +62863,8 @@ class ResolverCachePlugin {
factory(type, hook) {
/** @type {Map<string, (function(Error=, Object=): void)[]>} */
const activeRequests = new Map();
/** @type {Map<string, [function(Error=, Object=): void, function(Error=, Object=): void][]>} */
const activeRequestsWithYield = new Map();
hook.tap(
"ResolverCachePlugin",
/**
......@@ -62759,29 +62889,63 @@ class ResolverCachePlugin {
if (request._ResolverCachePluginCacheMiss || !fileSystemInfo) {
return callback();
}
const identifier = `${type}${optionsIdent}${objectToString(
request,
!cacheWithContext
)}`;
const activeRequest = activeRequests.get(identifier);
if (activeRequest) {
activeRequest.push(callback);
return;
const withYield = typeof resolveContext.yield === "function";
const identifier = `${type}${
withYield ? "|yield" : "|default"
}${optionsIdent}${objectToString(request, !cacheWithContext)}`;
if (withYield) {
const activeRequest = activeRequestsWithYield.get(identifier);
if (activeRequest) {
activeRequest[0].push(callback);
activeRequest[1].push(resolveContext.yield);
return;
}
} else {
const activeRequest = activeRequests.get(identifier);
if (activeRequest) {
activeRequest.push(callback);
return;
}
}
const itemCache = cache.getItemCache(identifier, null);
let callbacks;
const done = (err, result) => {
if (callbacks === undefined) {
callback(err, result);
callbacks = false;
} else {
for (const callback of callbacks) {
callback(err, result);
}
activeRequests.delete(identifier);
callbacks = false;
}
};
let callbacks, yields;
const done = withYield
? (err, result) => {
if (callbacks === undefined) {
if (err) {
callback(err);
} else {
if (result)
for (const r of result) resolveContext.yield(r);
callback(null, null);
}
yields = undefined;
callbacks = false;
} else {
for (let i = 0; i < callbacks.length; i++) {
const cb = callbacks[i];
const yield_ = yields[i];
if (result) for (const r of result) yield_(r);
cb(null, null);
}
activeRequestsWithYield.delete(identifier);
yields = undefined;
callbacks = false;
}
}
: (err, result) => {
if (callbacks === undefined) {
callback(err, result);
callbacks = false;
} else {
for (const callback of callbacks) {
callback(err, result);
}
activeRequests.delete(identifier);
callbacks = false;
}
};
/**
* @param {Error=} err error if any
* @param {CacheEntry=} cacheEntry cache entry
......@@ -62838,7 +63002,14 @@ class ResolverCachePlugin {
}
};
itemCache.get(processCacheResult);
if (callbacks === undefined) {
if (withYield && callbacks === undefined) {
callbacks = [callback];
yields = [resolveContext.yield];
activeRequestsWithYield.set(
identifier,
/** @type {[any, any]} */ ([callbacks, yields])
);
} else if (callbacks === undefined) {
callbacks = [callback];
activeRequests.set(identifier, callbacks);
}
......@@ -64946,6 +65117,7 @@ const applyOutputDefaults = (
D(output, "strictModuleExceptionHandling", false);
const optimistic = v => v || v === undefined;
const conditionallyOptimistic = (v, c) => (v === undefined && c) || v;
F(
output.environment,
"arrowFunction",
......@@ -64959,8 +65131,12 @@ const applyOutputDefaults = (
);
F(output.environment, "forOf", () => tp && optimistic(tp.forOf));
F(output.environment, "bigIntLiteral", () => tp && tp.bigIntLiteral);
F(output.environment, "dynamicImport", () => tp && tp.dynamicImport);
F(output.environment, "module", () => tp && tp.module);
F(output.environment, "dynamicImport", () =>
conditionallyOptimistic(tp && tp.dynamicImport, output.module)
);
F(output.environment, "module", () =>
conditionallyOptimistic(tp && tp.module, output.module)
);
const { trustedTypes } = output;
if (trustedTypes) {
......@@ -68350,78 +68526,71 @@ class CssLoadingRuntimeModule extends RuntimeModule {
"",
withLoading
? Template.asString([
`${fn}.css = ${runtimeTemplate.basicFunction(
"chunkId, promises",
hasCssMatcher !== false
? [
"// css chunk loading",
`var installedChunkData = ${RuntimeGlobals.hasOwnProperty}(installedChunks, chunkId) ? installedChunks[chunkId] : undefined;`,
'if(installedChunkData !== 0) { // 0 means "already installed".',
Template.indent([
"",
'// a Promise means "currently loading".',
"if(installedChunkData) {",
Template.indent([
"promises.push(installedChunkData[2]);"
]),
"} else {",
Template.indent([
hasCssMatcher === true
? "if(true) { // all chunks have CSS"
: `if(${hasCssMatcher("chunkId")}) {`,
`${fn}.css = ${runtimeTemplate.basicFunction("chunkId, promises", [
"// css chunk loading",
`var installedChunkData = ${RuntimeGlobals.hasOwnProperty}(installedChunks, chunkId) ? installedChunks[chunkId] : undefined;`,
'if(installedChunkData !== 0) { // 0 means "already installed".',
Template.indent([
"",
'// a Promise means "currently loading".',
"if(installedChunkData) {",
Template.indent(["promises.push(installedChunkData[2]);"]),
"} else {",
Template.indent([
hasCssMatcher === true
? "if(true) { // all chunks have CSS"
: `if(${hasCssMatcher("chunkId")}) {`,
Template.indent([
"// setup Promise in chunk cache",
`var promise = new Promise(${runtimeTemplate.expressionFunction(
`installedChunkData = installedChunks[chunkId] = [resolve, reject]`,
"resolve, reject"
)});`,
"promises.push(installedChunkData[2] = promise);",
"",
"// start chunk loading",
`var url = ${RuntimeGlobals.publicPath} + ${RuntimeGlobals.getChunkCssFilename}(chunkId);`,
"// create error before stack unwound to get useful stacktrace later",
"var error = new Error();",
`var loadingEnded = ${runtimeTemplate.basicFunction(
"event",
[
`if(${RuntimeGlobals.hasOwnProperty}(installedChunks, chunkId)) {`,
Template.indent([
"// setup Promise in chunk cache",
`var promise = new Promise(${runtimeTemplate.expressionFunction(
`installedChunkData = installedChunks[chunkId] = [resolve, reject]`,
"resolve, reject"
)});`,
"promises.push(installedChunkData[2] = promise);",
"",
"// start chunk loading",
`var url = ${RuntimeGlobals.publicPath} + ${RuntimeGlobals.getChunkCssFilename}(chunkId);`,
"// create error before stack unwound to get useful stacktrace later",
"var error = new Error();",
`var loadingEnded = ${runtimeTemplate.basicFunction(
"event",
[
`if(${RuntimeGlobals.hasOwnProperty}(installedChunks, chunkId)) {`,
Template.indent([
"installedChunkData = installedChunks[chunkId];",
"if(installedChunkData !== 0) installedChunks[chunkId] = undefined;",
"if(installedChunkData) {",
Template.indent([
'if(event.type !== "load") {',
Template.indent([
"var errorType = event && event.type;",
"var realSrc = event && event.target && event.target.src;",
"error.message = 'Loading css chunk ' + chunkId + ' failed.\\n(' + errorType + ': ' + realSrc + ')';",
"error.name = 'ChunkLoadError';",
"error.type = errorType;",
"error.request = realSrc;",
"installedChunkData[1](error);"
]),
"} else {",
Template.indent([
`loadCssChunkData(${RuntimeGlobals.moduleFactories}, link, chunkId);`,
"installedChunkData[0]();"
]),
"}"
]),
"}"
]),
"}"
]
)};`,
"var link = loadStylesheet(chunkId, url, loadingEnded);"
"installedChunkData = installedChunks[chunkId];",
"if(installedChunkData !== 0) installedChunks[chunkId] = undefined;",
"if(installedChunkData) {",
Template.indent([
'if(event.type !== "load") {',
Template.indent([
"var errorType = event && event.type;",
"var realSrc = event && event.target && event.target.src;",
"error.message = 'Loading css chunk ' + chunkId + ' failed.\\n(' + errorType + ': ' + realSrc + ')';",
"error.name = 'ChunkLoadError';",
"error.type = errorType;",
"error.request = realSrc;",
"installedChunkData[1](error);"
]),
"} else {",
Template.indent([
`loadCssChunkData(${RuntimeGlobals.moduleFactories}, link, chunkId);`,
"installedChunkData[0]();"
]),
"}"
]),
"}"
]),
"} else installedChunks[chunkId] = 0;"
]),
"}"
]),
"}"
]
: "installedChunks[chunkId] = 0;"
)};`
"}"
]
)};`,
"var link = loadStylesheet(chunkId, url, loadingEnded);"
]),
"} else installedChunks[chunkId] = 0;"
]),
"}"
]),
"}"
])};`
])
: "// no chunk loading",
"",
......@@ -68550,6 +68719,7 @@ const { compareModulesByIdentifier } = __webpack_require__(29579);
const createSchemaValidation = __webpack_require__(32540);
const createHash = __webpack_require__(49835);
const memoize = __webpack_require__(78676);
const nonNumericOnlyHash = __webpack_require__(55668);
const CssExportsGenerator = __webpack_require__(91254);
const CssGenerator = __webpack_require__(46061);
const CssParser = __webpack_require__(98305);
......@@ -68732,7 +68902,7 @@ class CssModulesPlugin {
hash.update(chunkGraph.getModuleHash(module, chunk.runtime));
}
const digest = /** @type {string} */ (hash.digest(hashDigest));
chunk.contentHash.css = digest.substr(0, hashDigestLength);
chunk.contentHash.css = nonNumericOnlyHash(digest, hashDigestLength);
});
compilation.hooks.renderManifest.tap(plugin, (result, options) => {
const { chunkGraph } = compilation;
......@@ -70636,7 +70806,8 @@ const interceptAllJavascriptModulesPluginHooks = (compilation, tracer) => {
};
const makeInterceptorFor = (instance, tracer) => hookName => ({
register: ({ name, type, context, fn }) => {
register: tapInfo => {
const { name, type, fn } = tapInfo;
const newFn =
// Don't tap our own hooks to ensure stream can close cleanly
name === pluginName
......@@ -70647,9 +70818,7 @@ const makeInterceptorFor = (instance, tracer) => hookName => ({
fn
});
return {
name,
type,
context,
...tapInfo,
fn: newFn
};
}
......@@ -75184,12 +75353,18 @@ class ContextElementDependency extends ModuleDependency {
}
serialize(context) {
context.write(this.referencedExports);
const { write } = context;
write(this._typePrefix);
write(this._category);
write(this.referencedExports);
super.serialize(context);
}
deserialize(context) {
this.referencedExports = context.read();
const { read } = context;
this._typePrefix = read();
this._category = read();
this.referencedExports = read();
super.deserialize(context);
}
}
......@@ -76123,6 +76298,12 @@ const getProperty = (moduleGraph, module, exportName, property, runtime) => {
}
}
switch (property) {
case "canMangle": {
const exportsInfo = moduleGraph.getExportsInfo(module);
const exportInfo = exportsInfo.getExportInfo(exportName);
if (exportInfo) return exportInfo.canMangle;
return exportsInfo.otherExportsInfo.canMangle;
}
case "used":
return (
moduleGraph.getExportsInfo(module).getUsed(exportName, runtime) !==
......@@ -87945,6 +88126,7 @@ const memoize = __webpack_require__(78676);
/** @typedef {import("../declarations/WebpackOptions").Entry} Entry */
/** @typedef {import("../declarations/WebpackOptions").EntryNormalized} EntryNormalized */
/** @typedef {import("../declarations/WebpackOptions").EntryObject} EntryObject */
/** @typedef {import("../declarations/WebpackOptions").FileCacheOptions} FileCacheOptions */
/** @typedef {import("../declarations/WebpackOptions").LibraryOptions} LibraryOptions */
/** @typedef {import("../declarations/WebpackOptions").ModuleOptions} ModuleOptions */
/** @typedef {import("../declarations/WebpackOptions").ResolveOptions} ResolveOptions */
......@@ -87960,11 +88142,15 @@ const memoize = __webpack_require__(78676);
/** @typedef {import("../declarations/WebpackOptions").WebpackPluginInstance} WebpackPluginInstance */
/** @typedef {import("./Compilation").Asset} Asset */
/** @typedef {import("./Compilation").AssetInfo} AssetInfo */
/** @typedef {import("./Compilation").EntryOptions} EntryOptions */
/** @typedef {import("./Compiler").AssetEmittedInfo} AssetEmittedInfo */
/** @typedef {import("./MultiStats")} MultiStats */
/** @typedef {import("./Parser").ParserState} ParserState */
/** @typedef {import("./ResolverFactory").ResolvePluginInstance} ResolvePluginInstance */
/** @typedef {import("./ResolverFactory").Resolver} Resolver */
/** @typedef {import("./Watching")} Watching */
/** @typedef {import("./cli").Argument} Argument */
/** @typedef {import("./cli").Problem} Problem */
/** @typedef {import("./stats/DefaultStatsFactoryPlugin").StatsAsset} StatsAsset */
/** @typedef {import("./stats/DefaultStatsFactoryPlugin").StatsChunk} StatsChunk */
/** @typedef {import("./stats/DefaultStatsFactoryPlugin").StatsChunkGroup} StatsChunkGroup */
......@@ -89770,6 +89956,7 @@ const { last, someInIterable } = __webpack_require__(39104);
const StringXor = __webpack_require__(40293);
const { compareModulesByIdentifier } = __webpack_require__(29579);
const createHash = __webpack_require__(49835);
const nonNumericOnlyHash = __webpack_require__(55668);
const { intersectRuntime } = __webpack_require__(17156);
const JavascriptGenerator = __webpack_require__(77106);
const JavascriptParser = __webpack_require__(29050);
......@@ -89848,6 +90035,7 @@ const printGeneratedCodeForStack = (module, code) => {
/**
* @typedef {Object} RenderBootstrapContext
* @property {Chunk} chunk the chunk
* @property {CodeGenerationResults} codeGenerationResults results of code generation
* @property {RuntimeTemplate} runtimeTemplate the runtime template
* @property {ModuleGraph} moduleGraph the module graph
* @property {ChunkGraph} chunkGraph the chunk graph
......@@ -90077,6 +90265,7 @@ class JavascriptModulesPlugin {
{
hash: "0000",
chunk,
codeGenerationResults: context.codeGenerationResults,
chunkGraph: context.chunkGraph,
moduleGraph: context.moduleGraph,
runtimeTemplate: context.runtimeTemplate
......@@ -90089,6 +90278,7 @@ class JavascriptModulesPlugin {
compilation.hooks.contentHash.tap("JavascriptModulesPlugin", chunk => {
const {
chunkGraph,
codeGenerationResults,
moduleGraph,
runtimeTemplate,
outputOptions: {
......@@ -90106,6 +90296,7 @@ class JavascriptModulesPlugin {
{
hash: "0000",
chunk,
codeGenerationResults,
chunkGraph: compilation.chunkGraph,
moduleGraph: compilation.moduleGraph,
runtimeTemplate: compilation.runtimeTemplate
......@@ -90118,6 +90309,7 @@ class JavascriptModulesPlugin {
}
hooks.chunkHash.call(chunk, hash, {
chunkGraph,
codeGenerationResults,
moduleGraph,
runtimeTemplate
});
......@@ -90144,7 +90336,10 @@ class JavascriptModulesPlugin {
xor.updateHash(hash);
}
const digest = /** @type {string} */ (hash.digest(hashDigest));
chunk.contentHash.javascript = digest.substr(0, hashDigestLength);
chunk.contentHash.javascript = nonNumericOnlyHash(
digest,
hashDigestLength
);
});
compilation.hooks.additionalTreeRuntimeRequirements.tap(
"JavascriptModulesPlugin",
......@@ -90720,7 +90915,13 @@ class JavascriptModulesPlugin {
* @returns {{ header: string[], beforeStartup: string[], startup: string[], afterStartup: string[], allowInlineStartup: boolean }} the generated source of the bootstrap code
*/
renderBootstrap(renderContext, hooks) {
const { chunkGraph, moduleGraph, chunk, runtimeTemplate } = renderContext;
const {
chunkGraph,
codeGenerationResults,
moduleGraph,
chunk,
runtimeTemplate
} = renderContext;
const runtimeRequirements = chunkGraph.getTreeRuntimeRequirements(chunk);
......@@ -90844,8 +91045,18 @@ class JavascriptModulesPlugin {
);
result.allowInlineStartup = false;
}
let data;
if (codeGenerationResults.has(entryModule, chunk.runtime)) {
const result = codeGenerationResults.get(
entryModule,
chunk.runtime
);
data = result.data;
}
if (
result.allowInlineStartup &&
(!data || !data.get("topLevelDeclarations")) &&
(!entryModule.buildInfo ||
!entryModule.buildInfo.topLevelDeclarations)
) {
......@@ -95012,6 +95223,7 @@ const { getAllChunks } = __webpack_require__(91145);
/** @typedef {import("../Chunk")} Chunk */
/** @typedef {import("../Compilation")} Compilation */
/** @typedef {import("../ChunkGraph")} ChunkGraph */
/** @typedef {import("../ChunkGraph").EntryModuleWithChunkGroup} EntryModuleWithChunkGroup */
/** @typedef {import("../ChunkGroup")} ChunkGroup */
/** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */
/** @typedef {(string|number)[]} EntryItem */
......@@ -95021,7 +95233,7 @@ const EXPORT_PREFIX = "var __webpack_exports__ = ";
/**
* @param {ChunkGraph} chunkGraph chunkGraph
* @param {RuntimeTemplate} runtimeTemplate runtimeTemplate
* @param {import("../ChunkGraph").EntryModuleWithChunkGroup[]} entries entries
* @param {EntryModuleWithChunkGroup[]} entries entries
* @param {Chunk} chunk chunk
* @param {boolean} passive true: passive startup with on chunks loaded
* @returns {string} runtime code
......@@ -95099,7 +95311,7 @@ exports.generateEntryStartup = (
/**
* @param {Hash} hash the hash to update
* @param {ChunkGraph} chunkGraph chunkGraph
* @param {import("../ChunkGraph").EntryModuleWithChunkGroup[]} entries entries
* @param {EntryModuleWithChunkGroup[]} entries entries
* @param {Chunk} chunk chunk
* @returns {void}
*/
......@@ -96205,9 +96417,15 @@ class AssignLibraryPlugin extends AbstractLibraryPlugin {
* @param {LibraryContext<T>} libraryContext context
* @returns {string | undefined} bailout reason
*/
embedInRuntimeBailout(module, { chunk }, { options, compilation }) {
embedInRuntimeBailout(
module,
{ chunk, codeGenerationResults },
{ options, compilation }
) {
const { data } = codeGenerationResults.get(module, chunk.runtime);
const topLevelDeclarations =
module.buildInfo && module.buildInfo.topLevelDeclarations;
(data && data.get("topLevelDeclarations")) ||
(module.buildInfo && module.buildInfo.topLevelDeclarations);
if (!topLevelDeclarations)
return "it doesn't tell about top level declarations.";
const fullNameResolved = this._getResolvedFullName(
......@@ -98277,6 +98495,7 @@ const builtins = [
"tty",
"url",
"util",
"util/types",
"v8",
"vm",
"wasi",
......@@ -100695,10 +100914,6 @@ class ConcatenatedModule extends Module {
const topLevelDeclarations = this.buildInfo.topLevelDeclarations;
if (topLevelDeclarations !== undefined) {
for (const decl of m.buildInfo.topLevelDeclarations) {
// reserved names will always be renamed
if (RESERVED_NAMES.has(decl)) continue;
// TODO actually this is incorrect since with renaming there could be more
// We should do the renaming during build
topLevelDeclarations.add(decl);
}
}
......@@ -100986,6 +101201,8 @@ class ConcatenatedModule extends Module {
// List of all used names to avoid conflicts
const allUsedNames = new Set(RESERVED_NAMES);
// Updated Top level declarations are created by renaming
const topLevelDeclarations = new Set();
// List of additional names in scope for module references
/** @type {Map<string, { usedNames: Set<string>, alreadyCheckedScopes: Set<TODO> }>} */
......@@ -101130,6 +101347,7 @@ class ConcatenatedModule extends Module {
);
allUsedNames.add(newName);
info.internalNames.set(name, newName);
topLevelDeclarations.add(newName);
const source = info.source;
const allIdentifiers = new Set(
references.map(r => r.identifier).concat(variable.identifiers)
......@@ -101156,6 +101374,7 @@ class ConcatenatedModule extends Module {
} else {
allUsedNames.add(name);
info.internalNames.set(name, name);
topLevelDeclarations.add(name);
}
}
let namespaceObjectName;
......@@ -101173,6 +101392,7 @@ class ConcatenatedModule extends Module {
allUsedNames.add(namespaceObjectName);
}
info.namespaceObjectName = namespaceObjectName;
topLevelDeclarations.add(namespaceObjectName);
break;
}
case "external": {
......@@ -101184,6 +101404,7 @@ class ConcatenatedModule extends Module {
);
allUsedNames.add(externalName);
info.name = externalName;
topLevelDeclarations.add(externalName);
break;
}
}
......@@ -101196,6 +101417,7 @@ class ConcatenatedModule extends Module {
);
allUsedNames.add(externalNameInterop);
info.interopNamespaceObjectName = externalNameInterop;
topLevelDeclarations.add(externalNameInterop);
}
if (
info.module.buildMeta.exportsType === "default" &&
......@@ -101209,6 +101431,7 @@ class ConcatenatedModule extends Module {
);
allUsedNames.add(externalNameInterop);
info.interopNamespaceObject2Name = externalNameInterop;
topLevelDeclarations.add(externalNameInterop);
}
if (
info.module.buildMeta.exportsType === "dynamic" ||
......@@ -101222,6 +101445,7 @@ class ConcatenatedModule extends Module {
);
allUsedNames.add(externalNameInterop);
info.interopDefaultAccessName = externalNameInterop;
topLevelDeclarations.add(externalNameInterop);
}
}
......@@ -101491,6 +101715,7 @@ ${defineGetters}`
const data = new Map();
if (chunkInitFragments.length > 0)
data.set("chunkInitFragments", chunkInitFragments);
data.set("topLevelDeclarations", topLevelDeclarations);
/** @type {CodeGenerationResult} */
const resultEntry = {
......@@ -110956,7 +111181,7 @@ class HttpUriPlugin {
/**
* @param {string} url URL
* @param {FetchResult} cachedResult result from cache
* @param {FetchResult | RedirectFetchResult} cachedResult result from cache
* @param {function((Error | null)=, FetchResult=): void} callback callback
* @returns {void}
*/
......@@ -111050,9 +111275,30 @@ class HttpUriPlugin {
res.statusCode >= 301 &&
res.statusCode <= 308
) {
return finishWith({
const result = {
location: new URL(location, url).href
});
};
if (
!cachedResult ||
!("location" in cachedResult) ||
cachedResult.location !== result.location ||
cachedResult.validUntil < validUntil ||
cachedResult.storeLock !== storeLock ||
cachedResult.storeCache !== storeCache ||
cachedResult.etag !== etag
) {
return finishWith(result);
} else {
logger.debug(`GET ${url} [${res.statusCode}] (unchanged)`);
return callback(null, {
...result,
fresh: true,
storeLock,
storeCache,
validUntil,
etag
});
}
}
const contentType = res.headers["content-type"] || "";
const bufferArr = [];
......@@ -112598,6 +112844,8 @@ Section -> Buffer
// "wpc" + 1 in little-endian
const VERSION = 0x01637077;
const WRITE_LIMIT_TOTAL = 0x7fff0000;
const WRITE_LIMIT_CHUNK = 511 * 1024 * 1024;
/**
* @param {Buffer[]} buffers buffers
......@@ -112645,7 +112893,7 @@ const readUInt64LE = Buffer.prototype.readBigUInt64LE
* @param {FileMiddleware} middleware this
* @param {BufferSerializableType[] | Promise<BufferSerializableType[]>} data data to be serialized
* @param {string | boolean} name file base name
* @param {function(string | false, Buffer[]): Promise<void>} writeFile writes a file
* @param {function(string | false, Buffer[], number): Promise<void>} writeFile writes a file
* @param {string | Hash} hashFunction hash function to use
* @returns {Promise<SerializeResult>} resulting file pointer and promise
*/
......@@ -112770,9 +113018,9 @@ const serialize = async (
if (name === true) {
name = hashForName(buf, hashFunction);
}
backgroundJobs.push(writeFile(name, buf));
let size = 0;
for (const b of buf) size += b.length;
backgroundJobs.push(writeFile(name, buf, size));
return {
size,
name,
......@@ -112980,7 +113228,7 @@ class FileMiddleware extends SerializerMiddleware {
// It's important that we don't touch existing files during serialization
// because serialize may read existing files (when deserializing)
const allWrittenFiles = new Set();
const writeFile = async (name, content) => {
const writeFile = async (name, content, size) => {
const file = name
? join(this.fs, filename, `../${name}${extension}`)
: filename;
......@@ -112999,10 +113247,7 @@ class FileMiddleware extends SerializerMiddleware {
[zConstants.BROTLI_PARAM_MODE]: zConstants.BROTLI_MODE_TEXT,
[zConstants.BROTLI_PARAM_QUALITY]: 2,
[zConstants.BROTLI_PARAM_DISABLE_LITERAL_CONTEXT_MODELING]: true,
[zConstants.BROTLI_PARAM_SIZE_HINT]: content.reduce(
(size, b) => size + b.length,
0
)
[zConstants.BROTLI_PARAM_SIZE_HINT]: size
}
});
}
......@@ -113014,8 +113259,44 @@ class FileMiddleware extends SerializerMiddleware {
stream.on("error", err => reject(err));
stream.on("finish", () => resolve());
}
for (const b of content) stream.write(b);
stream.end();
// split into chunks for WRITE_LIMIT_CHUNK size
const chunks = [];
for (const b of content) {
if (b.length < WRITE_LIMIT_CHUNK) {
chunks.push(b);
} else {
for (let i = 0; i < b.length; i += WRITE_LIMIT_CHUNK) {
chunks.push(b.slice(i, i + WRITE_LIMIT_CHUNK));
}
}
}
const len = chunks.length;
let i = 0;
const batchWrite = err => {
// will be handled in "on" error handler
if (err) return;
if (i === len) {
stream.end();
return;
}
// queue up a batch of chunks up to the write limit
// end is exclusive
let end = i;
let sum = chunks[end++].length;
while (end < len) {
sum += chunks[end].length;
if (sum > WRITE_LIMIT_TOTAL) break;
end++;
}
while (i < end - 1) {
stream.write(chunks[i++]);
}
stream.write(chunks[i++], batchWrite);
};
batchWrite();
});
if (name) allWrittenFiles.add(file);
};
......@@ -124682,7 +124963,7 @@ const toSimpleString = str => {
/**
* @param {Record<string|number, boolean>} map value map
* @returns {true|false|function(string): string} true/false, when unconditionally true/false, or a template function to determine the value at runtime
* @returns {boolean|(function(string): string)} true/false, when unconditionally true/false, or a template function to determine the value at runtime
*/
const compileBooleanMatcher = map => {
const positiveItems = Object.keys(map).filter(i => map[i]);
......@@ -125863,7 +126144,7 @@ module.exports = ({ maxSize, minSize, items, getSize, getKey }) => {
// return the results
return result.map(group => {
/** @type {GroupedItems} */
/** @type {GroupedItems<T>} */
return {
key: group.key,
items: group.nodes.map(node => node.item),
......@@ -126873,7 +127154,49 @@ const requestToAbsolute = (context, relativePath) => {
return relativePath;
};
const makeCacheable = fn => {
const makeCacheable = realFn => {
/** @type {WeakMap<object, Map<string, ParsedResource>>} */
const cache = new WeakMap();
const getCache = associatedObjectForCache => {
const entry = cache.get(associatedObjectForCache);
if (entry !== undefined) return entry;
/** @type {Map<string, ParsedResource>} */
const map = new Map();
cache.set(associatedObjectForCache, map);
return map;
};
/**
* @param {string} str the path with query and fragment
* @param {Object=} associatedObjectForCache an object to which the cache will be attached
* @returns {ParsedResource} parsed parts
*/
const fn = (str, associatedObjectForCache) => {
if (!associatedObjectForCache) return realFn(str);
const cache = getCache(associatedObjectForCache);
const entry = cache.get(str);
if (entry !== undefined) return entry;
const result = realFn(str);
cache.set(str, result);
return result;
};
fn.bindCache = associatedObjectForCache => {
const cache = getCache(associatedObjectForCache);
return str => {
const entry = cache.get(str);
if (entry !== undefined) return entry;
const result = realFn(str);
cache.set(str, result);
return result;
};
};
return fn;
};
const makeCacheableWithContext = fn => {
/** @type {WeakMap<object, Map<string, Map<string, string>>>} */
const cache = new WeakMap();
......@@ -127007,7 +127330,7 @@ const _makePathsRelative = (context, identifier) => {
.join("");
};
exports.makePathsRelative = makeCacheable(_makePathsRelative);
exports.makePathsRelative = makeCacheableWithContext(_makePathsRelative);
/**
*
......@@ -127022,7 +127345,7 @@ const _makePathsAbsolute = (context, identifier) => {
.join("");
};
exports.makePathsAbsolute = makeCacheable(_makePathsAbsolute);
exports.makePathsAbsolute = makeCacheableWithContext(_makePathsAbsolute);
/**
* @param {string} context absolute context path
......@@ -127036,7 +127359,7 @@ const _contextify = (context, request) => {
.join("!");
};
const contextify = makeCacheable(_contextify);
const contextify = makeCacheableWithContext(_contextify);
exports.contextify = contextify;
/**
......@@ -127051,13 +127374,15 @@ const _absolutify = (context, request) => {
.join("!");
};
const absolutify = makeCacheable(_absolutify);
const absolutify = makeCacheableWithContext(_absolutify);
exports.absolutify = absolutify;
const PATH_QUERY_FRAGMENT_REGEXP =
/^((?:\0.|[^?#\0])*)(\?(?:\0.|[^#\0])*)?(#.*)?$/;
const PATH_QUERY_REGEXP = /^((?:\0.|[^?\0])*)(\?.*)?$/;
/** @typedef {{ resource: string, path: string, query: string, fragment: string }} ParsedResource */
/** @typedef {{ resource: string, path: string, query: string }} ParsedResourceWithoutFragment */
/**
* @param {string} str the path with query and fragment
......@@ -127072,47 +127397,24 @@ const _parseResource = str => {
fragment: match[3] || ""
};
};
exports.parseResource = (realFn => {
/** @type {WeakMap<object, Map<string, ParsedResource>>} */
const cache = new WeakMap();
const getCache = associatedObjectForCache => {
const entry = cache.get(associatedObjectForCache);
if (entry !== undefined) return entry;
/** @type {Map<string, ParsedResource>} */
const map = new Map();
cache.set(associatedObjectForCache, map);
return map;
};
exports.parseResource = makeCacheable(_parseResource);
/**
* @param {string} str the path with query and fragment
* @param {Object=} associatedObjectForCache an object to which the cache will be attached
* @returns {ParsedResource} parsed parts
*/
const fn = (str, associatedObjectForCache) => {
if (!associatedObjectForCache) return realFn(str);
const cache = getCache(associatedObjectForCache);
const entry = cache.get(str);
if (entry !== undefined) return entry;
const result = realFn(str);
cache.set(str, result);
return result;
};
fn.bindCache = associatedObjectForCache => {
const cache = getCache(associatedObjectForCache);
return str => {
const entry = cache.get(str);
if (entry !== undefined) return entry;
const result = realFn(str);
cache.set(str, result);
return result;
};
/**
* Parse resource, skips fragment part
* @param {string} str the path with query and fragment
* @returns {ParsedResourceWithoutFragment} parsed parts
*/
const _parseResourceWithoutFragment = str => {
const match = PATH_QUERY_REGEXP.exec(str);
return {
resource: str,
path: match[1].replace(/\0(.)/g, "$1"),
query: match[2] ? match[2].replace(/\0(.)/g, "$1") : ""
};
return fn;
})(_parseResource);
};
exports.parseResourceWithoutFragment = makeCacheable(
_parseResourceWithoutFragment
);
/**
* @param {string} filename the filename which should be undone
......@@ -127443,6 +127745,36 @@ const memoize = fn => {
module.exports = memoize;
/***/ }),
/***/ 55668:
/***/ (function(module) {
"use strict";
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Ivan Kopeykin @vankop
*/
const A_CODE = "a".charCodeAt(0);
/**
* @param {string} hash hash
* @param {number} hashLength hash length
* @returns {string} returns hash that has at least one non numeric char
*/
module.exports = (hash, hashLength) => {
if (hashLength < 1) return "";
const slice = hash.slice(0, hashLength);
if (slice.match(/[^\d]/)) return slice;
return `${String.fromCharCode(
A_CODE + (parseInt(hash[0], 10) % 6)
)}${slice.slice(1)}`;
};
/***/ }),
/***/ 70002:
......@@ -128725,7 +129057,9 @@ exports.versionLt = versionLt;
*/
exports.parseRange = str => {
const splitAndConvert = str => {
return str.split(".").map(item => (`${+item}` === item ? +item : item));
return str
.split(".")
.map(item => (item !== "NaN" && `${+item}` === item ? +item : item));
};
// see https://docs.npmjs.com/misc/semver#range-grammar for grammar
const parsePartial = str => {
......@@ -128767,13 +129101,15 @@ exports.parseRange = str => {
return [-range[0] - 1, ...range.slice(1)];
};
const parseSimple = str => {
// simple ::= primitive | partial | tilde | caret
// primitive ::= ( '<' | '>' | '>=' | '<=' | '=' ) partial
// tilde ::= '~' partial
// caret ::= '^' partial
// simple ::= primitive | partial | tilde | caret
// primitive ::= ( '<' | '>' | '>=' | '<=' | '=' | '!' ) ( ' ' ) * partial
// tilde ::= '~' ( ' ' ) * partial
// caret ::= '^' ( ' ' ) * partial
const match = /^(\^|~|<=|<|>=|>|=|v|!)/.exec(str);
const start = match ? match[0] : "";
const remainder = parsePartial(str.slice(start.length));
const remainder = parsePartial(
start.length ? str.slice(start.length).trim() : str.trim()
);
switch (start) {
case "^":
if (remainder.length > 1 && remainder[1] === 0) {
......@@ -128827,11 +129163,14 @@ exports.parseRange = str => {
return [, ...arr, ...items.slice(1).map(() => fn)];
};
const parseRange = str => {
// range ::= hyphen | simple ( ' ' simple ) * | ''
// hyphen ::= partial ' - ' partial
const items = str.split(" - ");
// range ::= hyphen | simple ( ' ' ( ' ' ) * simple ) * | ''
// hyphen ::= partial ( ' ' ) * ' - ' ( ' ' ) * partial
const items = str.split(/\s+-\s+/);
if (items.length === 1) {
const items = str.trim().split(/\s+/g).map(parseSimple);
const items = str
.trim()
.split(/(?<=[-0-9A-Za-z])\s+/g)
.map(parseSimple);
return combine(items, 2);
}
const a = parsePartial(items[0]);
......@@ -135437,7 +135776,7 @@ module.exports = class MainFieldPlugin {
/***/ }),
/***/ 48506:
/***/ 79024:
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
"use strict";
......@@ -135454,7 +135793,7 @@ const getPaths = __webpack_require__(82918);
/** @typedef {import("./Resolver")} Resolver */
/** @typedef {import("./Resolver").ResolveStepHook} ResolveStepHook */
module.exports = class ModulesInHierachicDirectoriesPlugin {
module.exports = class ModulesInHierarchicalDirectoriesPlugin {
/**
* @param {string | ResolveStepHook} source source
* @param {string | Array<string>} directories directories
......@@ -135475,7 +135814,7 @@ module.exports = class ModulesInHierachicDirectoriesPlugin {
resolver
.getHook(this.source)
.tapAsync(
"ModulesInHierachicDirectoriesPlugin",
"ModulesInHierarchicalDirectoriesPlugin",
(request, resolveContext, callback) => {
const fs = resolver.fileSystem;
const addrs = getPaths(request.path)
......@@ -135924,6 +136263,7 @@ const {
* @property {WriteOnlySet<string>=} missingDependencies dependencies that was not found on file system
* @property {Set<StackEntry>=} stack set of hooks' calls. For instance, `resolve → parsedResolve → describedResolve`,
* @property {(function(string): void)=} log log function
* @property {(function (ResolveRequest): void)=} yield yield result, if provided plugins can return several results
*/
/** @typedef {AsyncSeriesBailHook<[ResolveRequest, ResolveContext], ResolveRequest | null>} ResolveStepHook */
......@@ -136092,6 +136432,16 @@ class Resolver {
request: request
};
let yield_;
let yieldCalled = false;
if (typeof resolveContext.yield === "function") {
const old = resolveContext.yield;
yield_ = obj => {
yieldCalled = true;
old(obj);
};
}
const message = `resolve '${request}' in '${path}'`;
const finishResolved = result => {
......@@ -136129,6 +136479,7 @@ class Resolver {
parentLog(msg);
log.push(msg);
},
yield: yield_,
fileDependencies: resolveContext.fileDependencies,
contextDependencies: resolveContext.contextDependencies,
missingDependencies: resolveContext.missingDependencies,
......@@ -136138,6 +136489,7 @@ class Resolver {
if (err) return callback(err);
if (result) return finishResolved(result);
if (yieldCalled) return callback(null);
return finishWithoutResolve(log);
}
......@@ -136151,6 +136503,7 @@ class Resolver {
message,
{
log: undefined,
yield: yield_,
fileDependencies: resolveContext.fileDependencies,
contextDependencies: resolveContext.contextDependencies,
missingDependencies: resolveContext.missingDependencies,
......@@ -136160,6 +136513,7 @@ class Resolver {
if (err) return callback(err);
if (result) return finishResolved(result);
if (yieldCalled) return callback(null);
// log is missing for the error details
// so we redo the resolving for the log info
......@@ -136174,11 +136528,15 @@ class Resolver {
message,
{
log: msg => log.push(msg),
yield: yield_,
stack: resolveContext.stack
},
(err, result) => {
err => {
if (err) return callback(err);
// In a case that there is a race condition and yield will be called
if (yieldCalled) return callback(null);
return finishWithoutResolve(log);
}
);
......@@ -136217,6 +136575,7 @@ class Resolver {
const innerContext = createInnerContext(
{
log: resolveContext.log,
yield: resolveContext.yield,
fileDependencies: resolveContext.fileDependencies,
contextDependencies: resolveContext.contextDependencies,
missingDependencies: resolveContext.missingDependencies,
......@@ -136326,7 +136685,7 @@ const ImportsFieldPlugin = __webpack_require__(7317);
const JoinRequestPartPlugin = __webpack_require__(35949);
const JoinRequestPlugin = __webpack_require__(5190);
const MainFieldPlugin = __webpack_require__(47450);
const ModulesInHierachicDirectoriesPlugin = __webpack_require__(48506);
const ModulesInHierarchicalDirectoriesPlugin = __webpack_require__(79024);
const ModulesInRootPlugin = __webpack_require__(88138);
const NextPlugin = __webpack_require__(40777);
const ParsePlugin = __webpack_require__(97849);
......@@ -136376,7 +136735,7 @@ const UseFilePlugin = __webpack_require__(96972);
* @property {boolean=} fullySpecified The request is already fully specified and no extensions or directories are resolved for it
* @property {boolean=} resolveToContext Resolve to a context instead of a file
* @property {(string|RegExp)[]=} restrictions A list of resolve restrictions
* @property {boolean=} useSyncFileSystemCalls Use only the sync constiants of the file system calls
* @property {boolean=} useSyncFileSystemCalls Use only the sync constraints of the file system calls
* @property {boolean=} preferRelative Prefer to resolve module requests as relative requests before falling back to modules
* @property {boolean=} preferAbsolute Prefer to resolve server-relative urls as absolute paths before falling back to resolve in roots
*/
......@@ -136583,7 +136942,7 @@ exports.createResolver = function (options) {
resolver.ensureHook("resolve");
resolver.ensureHook("internalResolve");
resolver.ensureHook("newInteralResolve");
resolver.ensureHook("newInternalResolve");
resolver.ensureHook("parsedResolve");
resolver.ensureHook("describedResolve");
resolver.ensureHook("internal");
......@@ -136605,6 +136964,11 @@ exports.createResolver = function (options) {
resolver.ensureHook("existingFile");
resolver.ensureHook("resolved");
// TODO remove in next major
// cspell:word Interal
// Backward-compat
resolver.hooks.newInteralResolve = resolver.hooks.newInternalResolve;
// resolve
for (const { source, resolveOptions } of [
{ source: "resolve", resolveOptions: { fullySpecified } },
......@@ -136709,7 +137073,7 @@ exports.createResolver = function (options) {
if (Array.isArray(item)) {
if (item.includes("node_modules") && pnpApi) {
plugins.push(
new ModulesInHierachicDirectoriesPlugin(
new ModulesInHierarchicalDirectoriesPlugin(
"raw-module",
item.filter(i => i !== "node_modules"),
"module"
......@@ -136720,7 +137084,11 @@ exports.createResolver = function (options) {
);
} else {
plugins.push(
new ModulesInHierachicDirectoriesPlugin("raw-module", item, "module")
new ModulesInHierarchicalDirectoriesPlugin(
"raw-module",
item,
"module"
)
);
}
} else {
......@@ -137065,7 +137433,12 @@ module.exports = class ResultPlugin {
resolverContext.log("reporting result " + obj.path);
resolver.hooks.result.callAsync(obj, resolverContext, err => {
if (err) return callback(err);
callback(null, obj);
if (typeof resolverContext.yield === "function") {
resolverContext.yield(obj);
callback(null, null);
} else {
callback(null, obj);
}
});
}
);
......@@ -137273,7 +137646,7 @@ module.exports = class SymlinkPlugin {
.tapAsync("SymlinkPlugin", (request, resolveContext, callback) => {
if (request.ignoreSymlinks) return callback();
const pathsResult = getPaths(request.path);
const pathSeqments = pathsResult.seqments;
const pathSegments = pathsResult.segments;
const paths = pathsResult.paths;
let containsSymlink = false;
......@@ -137286,7 +137659,7 @@ module.exports = class SymlinkPlugin {
resolveContext.fileDependencies.add(path);
fs.readlink(path, (err, result) => {
if (!err && result) {
pathSeqments[idx] = result;
pathSegments[idx] = result;
containsSymlink = true;
// Shortcut when absolute symlink found
const resultType = getType(result.toString());
......@@ -137302,11 +137675,11 @@ module.exports = class SymlinkPlugin {
},
(err, idx) => {
if (!containsSymlink) return callback();
const resultSeqments =
const resultSegments =
typeof idx === "number"
? pathSeqments.slice(0, idx + 1)
: pathSeqments.slice();
const result = resultSeqments.reduceRight((a, b) => {
? pathSegments.slice(0, idx + 1)
: pathSegments.slice();
const result = resultSegments.reduceRight((a, b) => {
return resolver.join(a, b);
});
const obj = {
......@@ -137646,6 +138019,7 @@ module.exports = function createInnerContext(
}
const childContext = {
log: innerLog,
yield: options.yield,
fileDependencies: options.fileDependencies,
contextDependencies: options.contextDependencies,
missingDependencies: options.missingDependencies,
......@@ -137737,23 +138111,24 @@ module.exports = function getInnerRequest(resolver, request) {
module.exports = function getPaths(path) {
if (path === "/") return { paths: ["/"], segments: [""] };
const parts = path.split(/(.*?[\\/]+)/);
const paths = [path];
const seqments = [parts[parts.length - 1]];
const segments = [parts[parts.length - 1]];
let part = parts[parts.length - 1];
path = path.substr(0, path.length - part.length - 1);
for (let i = parts.length - 2; i > 2; i -= 2) {
paths.push(path);
part = parts[i];
path = path.substr(0, path.length - part.length) || "/";
seqments.push(part.substr(0, part.length - 1));
segments.push(part.substr(0, part.length - 1));
}
part = parts[1];
seqments.push(part);
segments.push(part);
paths.push(part);
return {
paths: paths,
seqments: seqments
segments: segments
};
};
......@@ -141590,7 +141965,7 @@ module.exports = JSON.parse('{"application/1d-interleaved-parityfec":{"source":"
/***/ (function(module) {
"use strict";
module.exports = {"i8":"5.68.0"};
module.exports = {"i8":"5.69.0"};
/***/ }),
......@@ -267,7 +267,7 @@
"webpack-sources1": "npm:webpack-sources@1.4.3",
"webpack-sources3": "npm:webpack-sources@3.2.3",
"webpack4": "npm:webpack@4.44.1",
"webpack5": "npm:webpack@5.68.0",
"webpack5": "npm:webpack@5.69.0",
"ws": "8.2.3"
},
"resolutions": {
......
......@@ -4501,10 +4501,10 @@
version "4.1.5"
resolved "https://registry.yarnpkg.com/@types/debug/-/debug-4.1.5.tgz#b14efa8852b7768d898906613c23f688713e02cd"
"@types/eslint-scope@^3.7.0":
version "3.7.0"
resolved "https://registry.yarnpkg.com/@types/eslint-scope/-/eslint-scope-3.7.0.tgz#4792816e31119ebd506902a482caec4951fabd86"
integrity sha512-O/ql2+rrCUe2W2rs7wMR+GqPRcgB6UiqN5RhrR5xruFlY7l9YLMn0ZkDzjoHLeiFkR8MCQZVudUuuvQ2BLC9Qw==
"@types/eslint-scope@^3.7.3":
version "3.7.3"
resolved "https://registry.yarnpkg.com/@types/eslint-scope/-/eslint-scope-3.7.3.tgz#125b88504b61e3c8bc6f870882003253005c3224"
integrity sha512-PB3ldyrcnAicT35TWPs5IcwKD8S333HMaa2VVv4+wdvebJkjWuW/xESoB8IwRcog8HYVYamb1g/R31Qv5Bx03g==
dependencies:
"@types/eslint" "*"
"@types/estree" "*"
......@@ -4526,10 +4526,10 @@
version "0.0.39"
resolved "https://registry.yarnpkg.com/@types/estree/-/estree-0.0.39.tgz#e177e699ee1b8c22d23174caaa7422644389509f"
"@types/estree@^0.0.50":
version "0.0.50"
resolved "https://registry.yarnpkg.com/@types/estree/-/estree-0.0.50.tgz#1e0caa9364d3fccd2931c3ed96fdbeaa5d4cca83"
integrity sha512-C6N5s2ZFtuZRj54k2/zyRhNDjJwwcViAM3Nbm8zjBpbqAdZ00mr0CFxvSKeO8Y/e03WVFLpQMdHYVfUd6SB+Hw==
"@types/estree@^0.0.51":
version "0.0.51"
resolved "https://registry.yarnpkg.com/@types/estree/-/estree-0.0.51.tgz#cfd70924a25a3fd32b218e5e420e6897e1ac4f40"
integrity sha512-CuPgU6f3eT/XgKKPqKd/gLZV1Xmvf1a2R5POBOGQa6uv82xpls89HU5zKeVoyR8XzHd1RGNOlQlvUe3CFkjWNQ==
"@types/etag@1.8.0":
version "1.8.0"
......@@ -8878,10 +8878,10 @@ enhanced-resolve@^4.3.0:
memory-fs "^0.5.0"
tapable "^1.0.0"
enhanced-resolve@^5.8.3:
version "5.8.3"
resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-5.8.3.tgz#6d552d465cce0423f5b3d718511ea53826a7b2f0"
integrity sha512-EGAbGvH7j7Xt2nc0E7D99La1OiEs8LnyimkRgwExpUMScN6O+3x9tIWs7PLQZVNx4YD+00skHXPXi1yQHpAmZA==
enhanced-resolve@^5.9.0:
version "5.9.0"
resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-5.9.0.tgz#49ac24953ac8452ed8fed2ef1340fc8e043667ee"
integrity sha512-weDYmzbBygL7HzGGS26M3hGQx68vehdEg6VUmqSOaFzXExFqlnKuSvsEJCVGQHScS8CQMbrAqftT+AzzHNt/YA==
dependencies:
graceful-fs "^4.2.4"
tapable "^2.2.0"
......@@ -20847,13 +20847,13 @@ webpack-bundle-analyzer@4.3.0:
watchpack "^1.7.4"
webpack-sources "^1.4.1"
"webpack5@npm:webpack@5.68.0":
version "5.68.0"
resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.68.0.tgz#a653a58ed44280062e47257f260117e4be90d560"
integrity sha512-zUcqaUO0772UuuW2bzaES2Zjlm/y3kRBQDVFVCge+s2Y8mwuUTdperGaAv65/NtRL/1zanpSJOq/MD8u61vo6g==
"webpack5@npm:webpack@5.69.0":
version "5.69.0"
resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.69.0.tgz#c9eb607d4f6c49f1e5755492323a7b055c3450e3"
integrity sha512-E5Fqu89Gu8fR6vejRqu26h8ld/k6/dCVbeGUcuZjc+goQHDfCPU9rER71JmdtBYGmci7Ec2aFEATQ2IVXKy2wg==
dependencies:
"@types/eslint-scope" "^3.7.0"
"@types/estree" "^0.0.50"
"@types/eslint-scope" "^3.7.3"
"@types/estree" "^0.0.51"
"@webassemblyjs/ast" "1.11.1"
"@webassemblyjs/wasm-edit" "1.11.1"
"@webassemblyjs/wasm-parser" "1.11.1"
......@@ -20861,7 +20861,7 @@ webpack-bundle-analyzer@4.3.0:
acorn-import-assertions "^1.7.6"
browserslist "^4.14.5"
chrome-trace-event "^1.0.2"
enhanced-resolve "^5.8.3"
enhanced-resolve "^5.9.0"
es-module-lexer "^0.9.0"
eslint-scope "5.1.1"
events "^3.2.0"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment