New:Socket for Asana Is Now Available.Learn more
Get Started

webpack

Package Overview
Dependencies
Maintainers
8
Versions
886
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

webpack - npm Package Compare versions

Comparing version
5.110.0
to
5.110.1
+1
-3
lib/asset/AssetBytesGenerator.js

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

case JAVASCRIPT_TYPE: {
return new RawSource(
`throw new Error(${JSON.stringify(error.message)});`
);
return new RawSource(Generator.throwBuildErrorCode(error));
}

@@ -122,0 +120,0 @@ default:

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

case JAVASCRIPT_TYPE: {
return new RawSource(
`throw new Error(${JSON.stringify(error.message)});`
);
return new RawSource(Generator.throwBuildErrorCode(error));
}

@@ -785,0 +783,0 @@ default:

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

case JAVASCRIPT_TYPE: {
return new RawSource(
`throw new Error(${JSON.stringify(error.message)});`
);
return new RawSource(Generator.throwBuildErrorCode(error));
}

@@ -166,0 +164,0 @@ default:

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

case JAVASCRIPT_TYPE: {
return new RawSource(
`throw new Error(${JSON.stringify(error.message)});`
);
return new RawSource(Generator.throwBuildErrorCode(error));
}

@@ -625,0 +623,0 @@ case CSS_TYPE: {

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

const { JAVASCRIPT_TYPE } = require("./ModuleSourceTypeConstants");
const memoize = require("./util/memoize");

@@ -64,2 +65,4 @@ /** @import { Source } from "webpack-sources" */

const getModuleParseError = memoize(() => require("./errors/ModuleParseError"));
class Generator {

@@ -75,2 +78,16 @@ /**

/**
* Returns the statement a module that failed to build throws when executed.
* @param {Error} error the build error
* @param {string=} parseErrorConstructor constructor for a rejected source, defaults to `SyntaxError` (WebAssembly rejects with `WebAssembly.CompileError` instead)
* @returns {string} javascript statement
*/
static throwBuildErrorCode(error, parseErrorConstructor = "SyntaxError") {
// A source the parser rejected throws what a native load of it would.
const name =
error instanceof getModuleParseError() ? parseErrorConstructor : "Error";
return `throw new ${name}(${JSON.stringify(error.message)});`;
}
/* istanbul ignore next */

@@ -77,0 +94,0 @@ /**

@@ -335,3 +335,3 @@ /*

generateError(error, module, generateContext) {
return new RawSource(`throw new Error(${JSON.stringify(error.message)});`);
return new RawSource(Generator.throwBuildErrorCode(error));
}

@@ -338,0 +338,0 @@ }

@@ -262,3 +262,3 @@ /*

generateError(error, module, generateContext) {
return new RawSource(`throw new Error(${JSON.stringify(error.message)});`);
return new RawSource(Generator.throwBuildErrorCode(error));
}

@@ -265,0 +265,0 @@

@@ -464,3 +464,3 @@ /*

let currentPosTypeLookup = 0;
/** @type {Map<ComplexSerializableType, number>} */
/** @type {Map<SerializerConfigWithSerializer, number>} */
let objectTypeLookup = new Map();

@@ -577,2 +577,4 @@ /** @type {Set<ComplexSerializableType>} */

this.extendContext(ctx);
// Dispatched on `typeof` first: two thirds of the items are numbers,
// booleans and `undefined`, and only 3% are buffers.
/**

@@ -583,131 +585,149 @@ * Processes the provided item.

const process = (item) => {
if (Buffer.isBuffer(item)) {
// check if we can emit a reference
const ref = referenceable.get(item);
if (ref !== undefined) {
result.push(ESCAPE, ref - currentPos);
switch (typeof item) {
case "number":
case "boolean":
result.push(item);
return;
case "string": {
if (item.length > 1) {
// short strings are shorter when not emitting a reference (this saves 1 byte per empty string)
// check if we can emit a reference
const ref = referenceable.get(item);
if (ref !== undefined) {
const offset = ref - currentPos;
if (
// One far ref → 5 bytes (`null` + offset), one near ref -> 2/3 bytes
offset >= -32768 ||
// long enough that the ref wins, keep it
item.length >= 4 ||
// multibyte → inline would be even bigger, keep it
Buffer.byteLength(item) !== item.length
) {
// A back-reference is `null` + the offset.
result.push(ESCAPE, offset);
return;
}
}
addReferenceable(item);
}
if (item.length > 102400 && context.logger) {
context.logger.warn(
`Serializing big strings (${Math.round(
item.length / 1024
)}kiB) impacts deserialization performance (consider using Buffer instead and decode when needed)`
);
}
result.push(item);
return;
}
const alreadyUsedBuffer = dedupeBuffer(item);
if (alreadyUsedBuffer !== item) {
const ref = referenceable.get(alreadyUsedBuffer);
case "undefined":
result.push(ESCAPE, ESCAPE_UNDEFINED);
return;
case "object": {
// ESCAPE is null, so this covers null too
if (item === ESCAPE) {
result.push(ESCAPE, ESCAPE_ESCAPE_VALUE);
return;
}
if (Buffer.isBuffer(item)) {
// check if we can emit a reference
const ref = referenceable.get(item);
if (ref !== undefined) {
result.push(ESCAPE, ref - currentPos);
return;
}
const alreadyUsedBuffer = dedupeBuffer(item);
if (alreadyUsedBuffer !== item) {
const ref = referenceable.get(alreadyUsedBuffer);
if (ref !== undefined) {
referenceable.set(item, ref);
result.push(ESCAPE, ref - currentPos);
return;
}
item = alreadyUsedBuffer;
}
addReferenceable(item);
result.push(/** @type {Buffer} */ (item));
return;
}
// check if we can emit a reference
const ref = referenceable.get(item);
if (ref !== undefined) {
referenceable.set(item, ref);
result.push(ESCAPE, ref - currentPos);
return;
}
item = alreadyUsedBuffer;
}
addReferenceable(item);
result.push(/** @type {Buffer} */ (item));
} else if (item === ESCAPE) {
result.push(ESCAPE, ESCAPE_ESCAPE_VALUE);
} else if (
typeof item === "object"
// We don't have to check for null as ESCAPE is null and this has been checked before
) {
// check if we can emit a reference
const ref = referenceable.get(item);
if (ref !== undefined) {
result.push(ESCAPE, ref - currentPos);
return;
}
if (cycleStack.has(item)) {
throw new Error(
"This is a circular references. To serialize circular references use 'setCircularReference' somewhere in the circle during serialize and deserialize."
);
}
if (cycleStack.has(item)) {
throw new Error(
"This is a circular references. To serialize circular references use 'setCircularReference' somewhere in the circle during serialize and deserialize."
// Keyed by the registration itself: one per class, so it stands in for
// `${request}/${name}` without building that string per object.
const config = ObjectMiddleware.getSerializerFor(
/** @type {Constructor} */
(item)
);
}
const { request, name, serializer } = config;
const lastIndex = objectTypeLookup.get(config);
const { request, name, serializer } = ObjectMiddleware.getSerializerFor(
/** @type {Constructor} */
(item)
);
const key = `${request}/${name}`;
const lastIndex = objectTypeLookup.get(key);
if (lastIndex === undefined) {
objectTypeLookup.set(config, currentPosTypeLookup++);
if (lastIndex === undefined) {
objectTypeLookup.set(key, currentPosTypeLookup++);
result.push(ESCAPE, request, name);
} else {
result.push(ESCAPE, currentPosTypeLookup - lastIndex);
}
result.push(ESCAPE, request, name);
} else {
result.push(ESCAPE, currentPosTypeLookup - lastIndex);
}
cycleStack.add(item);
cycleStack.add(item);
try {
serializer.serialize(item, ctx);
} finally {
cycleStack.delete(item);
}
try {
serializer.serialize(item, ctx);
} finally {
cycleStack.delete(item);
}
result.push(ESCAPE, ESCAPE_END_OBJECT);
result.push(ESCAPE, ESCAPE_END_OBJECT);
addReferenceable(item);
} else if (typeof item === "string") {
if (item.length > 1) {
// short strings are shorter when not emitting a reference (this saves 1 byte per empty string)
// check if we can emit a reference
const ref = referenceable.get(item);
if (ref !== undefined) {
const offset = ref - currentPos;
if (
// One far ref → 5 bytes (`null` + offset), one near ref -> 2/3 bytes
offset >= -32768 ||
// long enough that the ref wins, keep it
item.length >= 4 ||
// multibyte → inline would be even bigger, keep it
Buffer.byteLength(item) !== item.length
) {
// A back-reference is `null` + the offset.
result.push(ESCAPE, offset);
return;
}
}
addReferenceable(item);
return;
}
case "function": {
if (!SerializerMiddleware.isLazy(item)) {
throw new Error(`Unexpected function ${item}`);
}
if (item.length > 102400 && context.logger) {
context.logger.warn(
`Serializing big strings (${Math.round(
item.length / 1024
)}kiB) impacts deserialization performance (consider using Buffer instead and decode when needed)`
);
}
/** @type {SerializedType | undefined} */
const serializedData =
SerializerMiddleware.getLazySerializedValue(item);
result.push(item);
} else if (typeof item === "function") {
if (!SerializerMiddleware.isLazy(item)) {
throw new Error(`Unexpected function ${item}`);
}
/** @type {SerializedType | undefined} */
const serializedData =
SerializerMiddleware.getLazySerializedValue(item);
if (serializedData !== undefined) {
if (typeof serializedData === "function") {
result.push(serializedData);
if (serializedData !== undefined) {
if (typeof serializedData === "function") {
result.push(serializedData);
} else {
throw new Error("Not implemented");
}
} else if (SerializerMiddleware.isLazy(item, this)) {
throw new Error("Not implemented");
} else {
throw new Error("Not implemented");
const data =
/** @type {() => PrimitiveSerializableType[] | Promise<PrimitiveSerializableType[]>} */
(
SerializerMiddleware.serializeLazy(item, (data) =>
this.serialize([data], context)
)
);
SerializerMiddleware.setLazySerializedValue(item, data);
result.push(data);
}
} else if (SerializerMiddleware.isLazy(item, this)) {
throw new Error("Not implemented");
} else {
const data =
/** @type {() => PrimitiveSerializableType[] | Promise<PrimitiveSerializableType[]>} */
(
SerializerMiddleware.serializeLazy(item, (data) =>
this.serialize([data], context)
)
);
SerializerMiddleware.setLazySerializedValue(item, data);
result.push(data);
return;
}
} else if (item === undefined) {
result.push(ESCAPE, ESCAPE_UNDEFINED);
} else {
result.push(item);
default:
result.push(item);
}

@@ -714,0 +734,0 @@ };

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

generateError(error, module, generateContext) {
return new RawSource(`throw new Error(${JSON.stringify(error.message)});`);
return new RawSource(
Generator.throwBuildErrorCode(error, "WebAssembly.CompileError")
);
}

@@ -308,0 +310,0 @@ }

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

generateError(error, module, generateContext) {
return new RawSource(`throw new Error(${JSON.stringify(error.message)});`);
return new RawSource(
Generator.throwBuildErrorCode(error, "WebAssembly.CompileError")
);
}

@@ -237,0 +239,0 @@ }

{
"name": "webpack",
"version": "5.110.0",
"version": "5.110.1",
"description": "Packs ECMAScript/CommonJs/AMD modules for the browser. Allows you to split your codebase into multiple bundles, which can be loaded on demand. Supports loaders to preprocess files, i.e. json, jsx, es7, css, less, ... and your custom stuff.",

@@ -5,0 +5,0 @@ "homepage": "https://github.com/webpack/webpack",

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

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

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

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

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