Socket
Socket
Sign inDemoInstall

webpack

Package Overview
Dependencies
76
Maintainers
2
Versions
832
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 5.68.0 to 5.69.0

lib/util/nonNumericOnlyHash.js

5

lib/asset/AssetGenerator.js

@@ -15,2 +15,3 @@ /*

const { makePathsRelative } = require("../util/identifier");
const nonNumericOnlyHash = require("../util/nonNumericOnlyHash");

@@ -236,4 +237,4 @@ /** @typedef {import("webpack-sources").Source} Source */

);
const contentHash = fullHash.slice(
0,
const contentHash = nonNumericOnlyHash(
fullHash,
runtimeTemplate.outputOptions.hashDigestLength

@@ -240,0 +241,0 @@ );

2

lib/buildChunkGraph.js

@@ -908,3 +908,3 @@ /*

availableModules.has(module) ||
availableModules.plus.has(m)
availableModules.plus.has(module)
) {

@@ -911,0 +911,0 @@ cachedMinAvailableModules.add(module);

@@ -131,2 +131,7 @@ /*

};
let yieldResult;
if (typeof newResolveContext.yield === "function") {
yieldResult = [];
newResolveContext.yield = obj => yieldResult.push(obj);
}
const propagate = key => {

@@ -159,11 +164,15 @@ if (resolveContext[key]) {

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();
}
);
}

@@ -178,2 +187,4 @@ );

const activeRequests = new Map();
/** @type {Map<string, [function(Error=, Object=): void, function(Error=, Object=): void][]>} */
const activeRequestsWithYield = new Map();
hook.tap(

@@ -203,25 +214,59 @@ "ResolverCachePlugin",

}
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;
}
};
/**

@@ -283,4 +328,11 @@ * @param {Error=} err error if any

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);

@@ -287,0 +339,0 @@ }

@@ -49,2 +49,3 @@ /*

/** @typedef {(m: Module) => boolean} ModuleFilterPredicate */
/** @typedef {[Module, Entrypoint | undefined]} EntryModuleWithChunkGroup */

@@ -1184,4 +1185,2 @@ /**

/** @typedef {[Module, Entrypoint | undefined]} EntryModuleWithChunkGroup */
/**

@@ -1188,0 +1187,0 @@ * @param {Chunk} chunk the chunk

@@ -910,2 +910,3 @@ /*

const optimistic = v => v || v === undefined;
const conditionallyOptimistic = (v, c) => (v === undefined && c) || v;
F(

@@ -924,4 +925,8 @@ output.environment,

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)
);

@@ -928,0 +933,0 @@ const { trustedTypes } = output;

@@ -64,3 +64,3 @@ /*

* @typedef {Object} ContextModuleOptionsExtras
* @property {string} resource
* @property {string|string[]} resource
* @property {string=} resourceQuery

@@ -96,19 +96,32 @@ * @property {string=} resourceFragment

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;
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);
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) {

@@ -160,3 +173,7 @@ this.resolveOptions = options.resolveOptions;

_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) {

@@ -226,3 +243,12 @@ identifier += `|${this.options.resourceQuery}`;

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) {

@@ -277,7 +303,26 @@ identifier += ` ${this.options.resourceQuery}`;

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}`;

@@ -450,3 +495,7 @@ if (this.options.mode) {

null,
[this.context],
this.context
? [this.context]
: typeof this.options.resource === "string"
? [this.options.resource]
: this.options.resource,
null,

@@ -475,3 +524,9 @@ SNAPSHOT_OPTIONS,

) {
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);
}
}

@@ -478,0 +533,0 @@

@@ -170,2 +170,5 @@ /*

callback => {
const results = [];
const yield_ = obj => results.push(obj);
contextResolver.resolve(

@@ -178,7 +181,8 @@ {},

missingDependencies,
contextDependencies
contextDependencies,
yield: yield_
},
(err, result) => {
err => {
if (err) return callback(err);
callback(null, result);
callback(null, results);
}

@@ -218,3 +222,3 @@ );

}
const [contextResult, loaderResult] = result;
this.hooks.afterResolve.callAsync(

@@ -224,6 +228,11 @@ {

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

@@ -285,3 +294,4 @@ },

const addDirectoryChecked = (directory, visited, callback) => {
let severalContexts = false;
const addDirectoryChecked = (ctx, directory, visited, callback) => {
fs.realpath(directory, (err, realPath) => {

@@ -292,4 +302,5 @@ if (err) return callback(err);

addDirectory(
ctx,
directory,
(dir, callback) => {
(_, dir, callback) => {
if (recursionStack === undefined) {

@@ -299,3 +310,3 @@ recursionStack = new Set(visited);

}
addDirectoryChecked(dir, recursionStack, callback);
addDirectoryChecked(ctx, dir, recursionStack, callback);
},

@@ -307,3 +318,3 @@ callback

const addDirectory = (directory, addSubDirectory, callback) => {
const addDirectory = (ctx, directory, addSubDirectory, callback) => {
fs.readdir(directory, (err, files) => {

@@ -335,3 +346,3 @@ if (err) return callback(err);

if (!recursive) return callback();
addSubDirectory(subResource, callback);
addSubDirectory(ctx, subResource, callback);
} else if (

@@ -342,6 +353,5 @@ stat.isFile() &&

const obj = {
context: resource,
context: ctx,
request:
"." +
subResource.substr(resource.length).replace(/\\/g, "/")
"." + subResource.substr(ctx.length).replace(/\\/g, "/")
};

@@ -357,4 +367,7 @@

.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,

@@ -396,10 +409,36 @@ typePrefix,

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);
});
}
}
};

@@ -277,74 +277,67 @@ /*

? 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;"
]),
"}"
]),
"}"
])};`
])

@@ -351,0 +344,0 @@ : "// no chunk loading",

@@ -22,2 +22,3 @@ /*

const memoize = require("../util/memoize");
const nonNumericOnlyHash = require("../util/nonNumericOnlyHash");
const CssExportsGenerator = require("./CssExportsGenerator");

@@ -205,3 +206,3 @@ const CssGenerator = require("./CssGenerator");

const digest = /** @type {string} */ (hash.digest(hashDigest));
chunk.contentHash.css = digest.substr(0, hashDigestLength);
chunk.contentHash.css = nonNumericOnlyHash(digest, hashDigestLength);
});

@@ -208,0 +209,0 @@ compilation.hooks.renderManifest.tap(plugin, (result, options) => {

@@ -346,3 +346,4 @@ /*

const makeInterceptorFor = (instance, tracer) => hookName => ({
register: ({ name, type, context, fn }) => {
register: tapInfo => {
const { name, type, fn } = tapInfo;
const newFn =

@@ -358,5 +359,3 @@ // Don't tap our own hooks to ensure stream can close cleanly

return {
name,
type,
context,
...tapInfo,
fn: newFn

@@ -363,0 +362,0 @@ };

@@ -56,3 +56,6 @@ /*

serialize(context) {
context.write(this.referencedExports);
const { write } = context;
write(this._typePrefix);
write(this._category);
write(this.referencedExports);
super.serialize(context);

@@ -62,3 +65,6 @@ }

deserialize(context) {
this.referencedExports = context.read();
const { read } = context;
this._typePrefix = read();
this._category = read();
this.referencedExports = read();
super.deserialize(context);

@@ -65,0 +71,0 @@ }

@@ -49,2 +49,8 @@ /*

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":

@@ -51,0 +57,0 @@ return (

@@ -294,2 +294,6 @@ /*

for (const exportInfo of this._exports.values()) {
if (!canMangle && exportInfo.canMangleProvide !== false) {
exportInfo.canMangleProvide = false;
changed = true;
}
if (excludeExports && excludeExports.has(exportInfo.name)) continue;

@@ -300,6 +304,2 @@ if (exportInfo.provided !== true && exportInfo.provided !== null) {

}
if (!canMangle && exportInfo.canMangleProvide !== false) {
exportInfo.canMangleProvide = false;
changed = true;
}
if (targetKey) {

@@ -306,0 +306,0 @@ exportInfo.setTarget(targetKey, targetModule, [exportInfo.name], -1);

@@ -14,2 +14,3 @@ /*

/** @typedef {import("../declarations/WebpackOptions").EntryObject} EntryObject */
/** @typedef {import("../declarations/WebpackOptions").FileCacheOptions} FileCacheOptions */
/** @typedef {import("../declarations/WebpackOptions").LibraryOptions} LibraryOptions */

@@ -30,2 +31,4 @@ /** @typedef {import("../declarations/WebpackOptions").ModuleOptions} ModuleOptions */

/** @typedef {import("./Compilation").AssetInfo} AssetInfo */
/** @typedef {import("./Compilation").EntryOptions} EntryOptions */
/** @typedef {import("./Compiler").AssetEmittedInfo} AssetEmittedInfo */
/** @typedef {import("./MultiStats")} MultiStats */

@@ -36,2 +39,4 @@ /** @typedef {import("./Parser").ParserState} ParserState */

/** @typedef {import("./Watching")} Watching */
/** @typedef {import("./cli").Argument} Argument */
/** @typedef {import("./cli").Problem} Problem */
/** @typedef {import("./stats/DefaultStatsFactoryPlugin").StatsAsset} StatsAsset */

@@ -38,0 +43,0 @@ /** @typedef {import("./stats/DefaultStatsFactoryPlugin").StatsChunk} StatsChunk */

@@ -27,2 +27,3 @@ /*

const createHash = require("../util/createHash");
const nonNumericOnlyHash = require("../util/nonNumericOnlyHash");
const { intersectRuntime } = require("../util/runtime");

@@ -106,2 +107,3 @@ const JavascriptGenerator = require("./JavascriptGenerator");

* @property {Chunk} chunk the chunk
* @property {CodeGenerationResults} codeGenerationResults results of code generation
* @property {RuntimeTemplate} runtimeTemplate the runtime template

@@ -336,2 +338,3 @@ * @property {ModuleGraph} moduleGraph the module graph

chunk,
codeGenerationResults: context.codeGenerationResults,
chunkGraph: context.chunkGraph,

@@ -349,2 +352,3 @@ moduleGraph: context.moduleGraph,

chunkGraph,
codeGenerationResults,
moduleGraph,

@@ -367,2 +371,3 @@ runtimeTemplate,

chunk,
codeGenerationResults,
chunkGraph: compilation.chunkGraph,

@@ -380,2 +385,3 @@ moduleGraph: compilation.moduleGraph,

chunkGraph,
codeGenerationResults,
moduleGraph,

@@ -407,3 +413,6 @@ runtimeTemplate

const digest = /** @type {string} */ (hash.digest(hashDigest));
chunk.contentHash.javascript = digest.substr(0, hashDigestLength);
chunk.contentHash.javascript = nonNumericOnlyHash(
digest,
hashDigestLength
);
});

@@ -984,3 +993,9 @@ compilation.hooks.additionalTreeRuntimeRequirements.tap(

renderBootstrap(renderContext, hooks) {
const { chunkGraph, moduleGraph, chunk, runtimeTemplate } = renderContext;
const {
chunkGraph,
codeGenerationResults,
moduleGraph,
chunk,
runtimeTemplate
} = renderContext;

@@ -1109,4 +1124,14 @@ const runtimeRequirements = chunkGraph.getTreeRuntimeRequirements(chunk);

}
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 ||

@@ -1113,0 +1138,0 @@ !entryModule.buildInfo.topLevelDeclarations)

@@ -17,2 +17,3 @@ /*

/** @typedef {import("../ChunkGraph")} ChunkGraph */
/** @typedef {import("../ChunkGraph").EntryModuleWithChunkGroup} EntryModuleWithChunkGroup */
/** @typedef {import("../ChunkGroup")} ChunkGroup */

@@ -27,3 +28,3 @@ /** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */

* @param {RuntimeTemplate} runtimeTemplate runtimeTemplate
* @param {import("../ChunkGraph").EntryModuleWithChunkGroup[]} entries entries
* @param {EntryModuleWithChunkGroup[]} entries entries
* @param {Chunk} chunk chunk

@@ -106,3 +107,3 @@ * @param {boolean} passive true: passive startup with on chunks loaded

* @param {ChunkGraph} chunkGraph chunkGraph
* @param {import("../ChunkGraph").EntryModuleWithChunkGroup[]} entries entries
* @param {EntryModuleWithChunkGroup[]} entries entries
* @param {Chunk} chunk chunk

@@ -109,0 +110,0 @@ * @returns {void}

@@ -225,5 +225,11 @@ /*

*/
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)

@@ -230,0 +236,0 @@ return "it doesn't tell about top level declarations.";

@@ -57,2 +57,3 @@ /*

"util",
"util/types",
"v8",

@@ -59,0 +60,0 @@ "vm",

@@ -31,3 +31,6 @@ /*

const { join } = require("./util/fs");
const { parseResource } = require("./util/identifier");
const {
parseResource,
parseResourceWithoutFragment
} = require("./util/identifier");

@@ -70,2 +73,7 @@ /** @typedef {import("../declarations/WebpackOptions").ModuleOptionsNormalized} ModuleOptions */

/** @typedef {Object} ParsedLoaderRequest
* @property {string} loader loader
* @property {string|undefined} options options
*/
const EMPTY_RESOLVE_OPTIONS = {};

@@ -102,23 +110,2 @@ const EMPTY_PARSER_OPTIONS = {};

/**
* @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) => {

@@ -270,2 +257,5 @@ return err => {

);
const cachedParseResourceWithoutFragment =
parseResourceWithoutFragment.bindCache(associatedObjectForCache);
this._parseResourceWithoutFragment = cachedParseResourceWithoutFragment;

@@ -358,3 +348,3 @@ this.hooks.factorize.tapAsync(

let unresolvedResource;
/** @type {{loader: string, options: string|undefined}[]} */
/** @type {ParsedLoaderRequest[]} */
let elements;

@@ -413,3 +403,9 @@ let noPreAutoLoaders = false;

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);

@@ -1026,8 +1022,10 @@ } else {

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,

@@ -1034,0 +1032,0 @@ ident: item.options === undefined ? undefined : item.ident

@@ -825,6 +825,2 @@ /*

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);

@@ -1117,2 +1113,4 @@ }

const allUsedNames = new Set(RESERVED_NAMES);
// Updated Top level declarations are created by renaming
const topLevelDeclarations = new Set();

@@ -1262,2 +1260,3 @@ // List of additional names in scope for module references

info.internalNames.set(name, newName);
topLevelDeclarations.add(newName);
const source = info.source;

@@ -1289,2 +1288,3 @@ const allIdentifiers = new Set(

info.internalNames.set(name, name);
topLevelDeclarations.add(name);
}

@@ -1307,2 +1307,3 @@ }

info.namespaceObjectName = namespaceObjectName;
topLevelDeclarations.add(namespaceObjectName);
break;

@@ -1319,2 +1320,3 @@ }

info.name = externalName;
topLevelDeclarations.add(externalName);
break;

@@ -1332,2 +1334,3 @@ }

info.interopNamespaceObjectName = externalNameInterop;
topLevelDeclarations.add(externalNameInterop);
}

@@ -1346,2 +1349,3 @@ if (

info.interopNamespaceObject2Name = externalNameInterop;
topLevelDeclarations.add(externalNameInterop);
}

@@ -1360,2 +1364,3 @@ if (

info.interopDefaultAccessName = externalNameInterop;
topLevelDeclarations.add(externalNameInterop);
}

@@ -1630,2 +1635,3 @@ }

data.set("chunkInitFragments", chunkInitFragments);
data.set("topLevelDeclarations", topLevelDeclarations);

@@ -1632,0 +1638,0 @@ /** @type {CodeGenerationResult} */

@@ -99,3 +99,3 @@ /*

* @param {number} p
* @param {...string[]} [args]
* @param {...string} [args]
* @returns {void}

@@ -102,0 +102,0 @@ */

@@ -512,3 +512,3 @@ /*

* @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

@@ -607,5 +607,26 @@ * @returns {void}

) {
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
});
}
}

@@ -612,0 +633,0 @@ const contentType = res.headers["content-type"] || "";

@@ -43,2 +43,4 @@ /*

const VERSION = 0x01637077;
const WRITE_LIMIT_TOTAL = 0x7fff0000;
const WRITE_LIMIT_CHUNK = 511 * 1024 * 1024;

@@ -91,3 +93,3 @@ /**

* @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

@@ -217,5 +219,5 @@ * @returns {Promise<SerializeResult>} resulting file pointer and promise

}
backgroundJobs.push(writeFile(name, buf));
let size = 0;
for (const b of buf) size += b.length;
backgroundJobs.push(writeFile(name, buf, size));
return {

@@ -428,3 +430,3 @@ size,

const allWrittenFiles = new Set();
const writeFile = async (name, content) => {
const writeFile = async (name, content, size) => {
const file = name

@@ -448,6 +450,3 @@ ? join(this.fs, filename, `../${name}${extension}`)

[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
}

@@ -464,4 +463,40 @@ });

}
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();
});

@@ -468,0 +503,0 @@ if (name) allWrittenFiles.add(file);

@@ -8,2 +8,3 @@ /*

const mime = require("mime-types");
const { basename, extname } = require("path");

@@ -121,25 +122,49 @@ const util = require("util");

if (typeof data.filename === "string") {
const { path: file, query, fragment } = parseResource(data.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);
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", 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);
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"
)
);
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"
)
);
}
}

@@ -146,0 +171,0 @@

@@ -21,3 +21,3 @@ /*

* @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
*/

@@ -24,0 +24,0 @@ const compileBooleanMatcher = map => {

@@ -501,3 +501,3 @@ /*

return result.map(group => {
/** @type {GroupedItems} */
/** @type {GroupedItems<T>} */
return {

@@ -504,0 +504,0 @@ key: group.key,

@@ -84,3 +84,45 @@ /*

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>>>} */

@@ -219,3 +261,3 @@ const cache = new WeakMap();

exports.makePathsRelative = makeCacheable(_makePathsRelative);
exports.makePathsRelative = makeCacheableWithContext(_makePathsRelative);

@@ -235,3 +277,3 @@ /**

exports.makePathsAbsolute = makeCacheable(_makePathsAbsolute);
exports.makePathsAbsolute = makeCacheableWithContext(_makePathsAbsolute);

@@ -250,3 +292,3 @@ /**

const contextify = makeCacheable(_contextify);
const contextify = makeCacheableWithContext(_contextify);
exports.contextify = contextify;

@@ -266,3 +308,3 @@

const absolutify = makeCacheable(_absolutify);
const absolutify = makeCacheableWithContext(_absolutify);
exports.absolutify = absolutify;

@@ -272,4 +314,6 @@

/^((?:\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 */

@@ -289,44 +333,21 @@ /**

};
exports.parseResource = (realFn => {
/** @type {WeakMap<object, Map<string, ParsedResource>>} */
const cache = new WeakMap();
exports.parseResource = makeCacheable(_parseResource);
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;
/**
* 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") : ""
};
};
exports.parseResourceWithoutFragment = makeCacheable(
_parseResourceWithoutFragment
);
/**
* @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;
})(_parseResource);
/**

@@ -333,0 +354,0 @@ * @param {string} filename the filename which should be undone

@@ -92,3 +92,5 @@ /*

const splitAndConvert = str => {
return str.split(".").map(item => (`${+item}` === item ? +item : item));
return str
.split(".")
.map(item => (item !== "NaN" && `${+item}` === item ? +item : item));
};

@@ -135,9 +137,11 @@ // see https://docs.npmjs.com/misc/semver#range-grammar for grammar

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) {

@@ -196,7 +200,10 @@ case "^":

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);

@@ -203,0 +210,0 @@ }

{
"name": "webpack",
"version": "5.68.0",
"version": "5.69.0",
"author": "Tobias Koppers @sokra",

@@ -8,4 +8,4 @@ "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.",

"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",

@@ -18,3 +18,3 @@ "@webassemblyjs/wasm-edit": "1.11.1",

"chrome-trace-event": "^1.0.2",
"enhanced-resolve": "^5.8.3",
"enhanced-resolve": "^5.9.0",
"es-module-lexer": "^0.9.0",

@@ -44,4 +44,4 @@ "eslint-scope": "5.1.1",

"@types/es-module-lexer": "^0.4.1",
"@types/jest": "^27.0.2",
"@types/node": "^15.0.1",
"@types/jest": "^27.4.0",
"@types/node": "^17.0.16",
"assemblyscript": "^0.19.16",

@@ -62,3 +62,3 @@ "babel-loader": "^8.1.0",

"eslint-config-prettier": "^8.1.0",
"eslint-plugin-jest": "^24.3.6",
"eslint-plugin-jest": "^24.7.0",
"eslint-plugin-jsdoc": "^33.0.0",

@@ -73,6 +73,6 @@ "eslint-plugin-node": "^11.0.0",

"istanbul": "^0.4.5",
"jest": "^27.3.1",
"jest-circus": "^27.3.1",
"jest-cli": "^27.3.1",
"jest-diff": "^27.3.1",
"jest": "^27.5.0",
"jest-circus": "^27.5.0",
"jest-cli": "^27.5.0",
"jest-diff": "^27.5.0",
"jest-junit": "^13.0.0",

@@ -106,5 +106,5 @@ "json-loader": "^0.5.7",

"toml": "^3.0.0",
"tooling": "webpack/tooling#v1.20.1",
"tooling": "webpack/tooling#v1.21.0",
"ts-loader": "^8.0.2",
"typescript": "^4.2.0-beta",
"typescript": "^4.5.5",
"url-loader": "^4.1.0",

@@ -111,0 +111,0 @@ "wast-loader": "^1.11.0",

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc