webpack 5.49.0 → 5.50.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of webpack might be problematic. Click here for more details.
- package/lib/CompatibilityPlugin.js +21 -4
- package/lib/NormalModule.js +3 -1
- package/lib/Parser.js +1 -0
- package/lib/config/defaults.js +1 -1
- package/lib/javascript/JavascriptParser.js +2 -0
- package/lib/serialization/BinaryMiddleware.js +293 -265
- package/package.json +1 -1
- package/schemas/WebpackOptions.json +1 -1
- package/schemas/plugins/schemes/HttpUriPlugin.json +1 -1
- package/types.d.ts +3 -2
@@ -69,7 +69,8 @@ class CompatibilityPlugin {
|
|
69
69
|
* @param {JavascriptParser} parser the parser
|
70
70
|
* @returns {void}
|
71
71
|
*/
|
72
|
-
const
|
72
|
+
const handler = parser => {
|
73
|
+
// Handle nested requires
|
73
74
|
parser.hooks.preStatement.tap("CompatibilityPlugin", statement => {
|
74
75
|
if (
|
75
76
|
statement.type === "FunctionDeclaration" &&
|
@@ -117,17 +118,33 @@ class CompatibilityPlugin {
|
|
117
118
|
parser.state.module.addPresentationalDependency(dep);
|
118
119
|
return true;
|
119
120
|
});
|
121
|
+
|
122
|
+
// Handle hashbang
|
123
|
+
parser.hooks.program.tap(
|
124
|
+
"CompatibilityPlugin",
|
125
|
+
(program, comments) => {
|
126
|
+
if (comments.length === 0) return;
|
127
|
+
const c = comments[0];
|
128
|
+
if (c.type === "Line" && c.range[0] === 0) {
|
129
|
+
if (parser.state.source.slice(0, 2).toString() !== "#!") return;
|
130
|
+
// this is a hashbang comment
|
131
|
+
const dep = new ConstDependency("//", 0);
|
132
|
+
dep.loc = c.loc;
|
133
|
+
parser.state.module.addPresentationalDependency(dep);
|
134
|
+
}
|
135
|
+
}
|
136
|
+
);
|
120
137
|
};
|
121
138
|
|
122
139
|
normalModuleFactory.hooks.parser
|
123
140
|
.for("javascript/auto")
|
124
|
-
.tap("CompatibilityPlugin",
|
141
|
+
.tap("CompatibilityPlugin", handler);
|
125
142
|
normalModuleFactory.hooks.parser
|
126
143
|
.for("javascript/dynamic")
|
127
|
-
.tap("CompatibilityPlugin",
|
144
|
+
.tap("CompatibilityPlugin", handler);
|
128
145
|
normalModuleFactory.hooks.parser
|
129
146
|
.for("javascript/esm")
|
130
|
-
.tap("CompatibilityPlugin",
|
147
|
+
.tap("CompatibilityPlugin", handler);
|
131
148
|
}
|
132
149
|
);
|
133
150
|
}
|
package/lib/NormalModule.js
CHANGED
@@ -1025,7 +1025,9 @@ class NormalModule extends Module {
|
|
1025
1025
|
|
1026
1026
|
let result;
|
1027
1027
|
try {
|
1028
|
-
|
1028
|
+
const source = this._source.source();
|
1029
|
+
result = this.parser.parse(this._ast || source, {
|
1030
|
+
source,
|
1029
1031
|
current: this,
|
1030
1032
|
module: this,
|
1031
1033
|
compilation: compilation,
|
package/lib/Parser.js
CHANGED
package/lib/config/defaults.js
CHANGED
@@ -314,7 +314,7 @@ const applyCacheDefaults = (cache, { name, mode, development }) => {
|
|
314
314
|
);
|
315
315
|
D(cache, "hashAlgorithm", "md4");
|
316
316
|
D(cache, "store", "pack");
|
317
|
-
D(cache, "compression",
|
317
|
+
D(cache, "compression", false);
|
318
318
|
D(cache, "profile", false);
|
319
319
|
D(cache, "idleTimeout", 60000);
|
320
320
|
D(cache, "idleTimeoutForInitialStore", 5000);
|
@@ -133,17 +133,29 @@ class BinaryMiddleware extends SerializerMiddleware {
|
|
133
133
|
/**
|
134
134
|
* @param {DeserializedType} data data
|
135
135
|
* @param {Object} context context object
|
136
|
+
* @param {{ leftOverBuffer: Buffer | null, allocationSize: number, increaseCounter: number }} allocationScope allocation scope
|
136
137
|
* @returns {SerializedType} serialized data
|
137
138
|
*/
|
138
|
-
_serialize(
|
139
|
-
|
140
|
-
|
139
|
+
_serialize(
|
140
|
+
data,
|
141
|
+
context,
|
142
|
+
allocationScope = {
|
143
|
+
allocationSize: 1024,
|
144
|
+
increaseCounter: 0,
|
145
|
+
leftOverBuffer: null
|
146
|
+
}
|
147
|
+
) {
|
141
148
|
/** @type {Buffer} */
|
142
149
|
let leftOverBuffer = null;
|
143
|
-
let currentPosition = 0;
|
144
150
|
/** @type {BufferSerializableType[]} */
|
145
151
|
let buffers = [];
|
146
|
-
|
152
|
+
/** @type {Buffer} */
|
153
|
+
let currentBuffer = allocationScope ? allocationScope.leftOverBuffer : null;
|
154
|
+
allocationScope.leftOverBuffer = null;
|
155
|
+
let currentPosition = 0;
|
156
|
+
if (currentBuffer === null) {
|
157
|
+
currentBuffer = Buffer.allocUnsafe(allocationScope.allocationSize);
|
158
|
+
}
|
147
159
|
const allocate = bytesNeeded => {
|
148
160
|
if (currentBuffer !== null) {
|
149
161
|
if (currentBuffer.length - currentPosition >= bytesNeeded) return;
|
@@ -154,22 +166,28 @@ class BinaryMiddleware extends SerializerMiddleware {
|
|
154
166
|
leftOverBuffer = null;
|
155
167
|
} else {
|
156
168
|
currentBuffer = Buffer.allocUnsafe(
|
157
|
-
Math.max(
|
158
|
-
bytesNeeded,
|
159
|
-
Math.min(Math.max(buffersTotalLength, 1024), 16384)
|
160
|
-
)
|
169
|
+
Math.max(bytesNeeded, allocationScope.allocationSize)
|
161
170
|
);
|
171
|
+
if (
|
172
|
+
!(allocationScope.increaseCounter =
|
173
|
+
(allocationScope.increaseCounter + 1) % 4) &&
|
174
|
+
allocationScope.allocationSize < 16777216
|
175
|
+
) {
|
176
|
+
allocationScope.allocationSize = allocationScope.allocationSize << 1;
|
177
|
+
}
|
162
178
|
}
|
163
179
|
};
|
164
180
|
const flush = () => {
|
165
181
|
if (currentBuffer !== null) {
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
182
|
+
if (currentPosition > 0) {
|
183
|
+
buffers.push(
|
184
|
+
Buffer.from(
|
185
|
+
currentBuffer.buffer,
|
186
|
+
currentBuffer.byteOffset,
|
187
|
+
currentPosition
|
188
|
+
)
|
189
|
+
);
|
190
|
+
}
|
173
191
|
if (
|
174
192
|
!leftOverBuffer ||
|
175
193
|
leftOverBuffer.length < currentBuffer.length - currentPosition
|
@@ -180,8 +198,8 @@ class BinaryMiddleware extends SerializerMiddleware {
|
|
180
198
|
currentBuffer.byteLength - currentPosition
|
181
199
|
);
|
182
200
|
}
|
201
|
+
|
183
202
|
currentBuffer = null;
|
184
|
-
buffersTotalLength += currentPosition;
|
185
203
|
currentPosition = 0;
|
186
204
|
}
|
187
205
|
};
|
@@ -205,232 +223,237 @@ class BinaryMiddleware extends SerializerMiddleware {
|
|
205
223
|
}
|
206
224
|
return size;
|
207
225
|
};
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
if (
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
+
for (let i = 0; i < data.length; i++) {
|
227
|
+
const thing = data[i];
|
228
|
+
switch (typeof thing) {
|
229
|
+
case "function": {
|
230
|
+
if (!SerializerMiddleware.isLazy(thing))
|
231
|
+
throw new Error("Unexpected function " + thing);
|
232
|
+
/** @type {SerializedType | (() => SerializedType)} */
|
233
|
+
let serializedData =
|
234
|
+
SerializerMiddleware.getLazySerializedValue(thing);
|
235
|
+
if (serializedData === undefined) {
|
236
|
+
if (SerializerMiddleware.isLazy(thing, this)) {
|
237
|
+
flush();
|
238
|
+
allocationScope.leftOverBuffer = leftOverBuffer;
|
239
|
+
const result =
|
240
|
+
/** @type {(Exclude<PrimitiveSerializableType, Promise<PrimitiveSerializableType>>)[]} */ (
|
241
|
+
thing()
|
242
|
+
);
|
243
|
+
const data = this._serialize(result, context, allocationScope);
|
244
|
+
leftOverBuffer = allocationScope.leftOverBuffer;
|
245
|
+
allocationScope.leftOverBuffer = null;
|
246
|
+
SerializerMiddleware.setLazySerializedValue(thing, data);
|
247
|
+
serializedData = data;
|
248
|
+
} else {
|
249
|
+
serializedData = this._serializeLazy(thing, context);
|
250
|
+
flush();
|
251
|
+
buffers.push(serializedData);
|
252
|
+
break;
|
226
253
|
}
|
254
|
+
} else {
|
227
255
|
if (typeof serializedData === "function") {
|
228
256
|
flush();
|
229
257
|
buffers.push(serializedData);
|
230
|
-
|
231
|
-
const lengths = [];
|
232
|
-
for (const item of serializedData) {
|
233
|
-
let last;
|
234
|
-
if (typeof item === "function") {
|
235
|
-
lengths.push(0);
|
236
|
-
} else if (item.length === 0) {
|
237
|
-
// ignore
|
238
|
-
} else if (
|
239
|
-
lengths.length > 0 &&
|
240
|
-
(last = lengths[lengths.length - 1]) !== 0
|
241
|
-
) {
|
242
|
-
const remaining = 0xffffffff - last;
|
243
|
-
if (remaining >= item.length) {
|
244
|
-
lengths[lengths.length - 1] += item.length;
|
245
|
-
} else {
|
246
|
-
lengths.push(item.length - remaining);
|
247
|
-
lengths[lengths.length - 2] = 0xffffffff;
|
248
|
-
}
|
249
|
-
} else {
|
250
|
-
lengths.push(item.length);
|
251
|
-
}
|
252
|
-
}
|
253
|
-
allocate(5 + lengths.length * 4);
|
254
|
-
writeU8(LAZY_HEADER);
|
255
|
-
writeU32(lengths.length);
|
256
|
-
for (const l of lengths) {
|
257
|
-
writeU32(l);
|
258
|
-
}
|
259
|
-
flush();
|
260
|
-
for (const item of serializedData) {
|
261
|
-
buffers.push(item);
|
262
|
-
}
|
258
|
+
break;
|
263
259
|
}
|
264
|
-
break;
|
265
260
|
}
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
261
|
+
const lengths = [];
|
262
|
+
for (const item of serializedData) {
|
263
|
+
let last;
|
264
|
+
if (typeof item === "function") {
|
265
|
+
lengths.push(0);
|
266
|
+
} else if (item.length === 0) {
|
267
|
+
// ignore
|
268
|
+
} else if (
|
269
|
+
lengths.length > 0 &&
|
270
|
+
(last = lengths[lengths.length - 1]) !== 0
|
271
|
+
) {
|
272
|
+
const remaining = 0xffffffff - last;
|
273
|
+
if (remaining >= item.length) {
|
274
|
+
lengths[lengths.length - 1] += item.length;
|
275
|
+
} else {
|
276
|
+
lengths.push(item.length - remaining);
|
277
|
+
lengths[lengths.length - 2] = 0xffffffff;
|
278
|
+
}
|
273
279
|
} else {
|
274
|
-
|
275
|
-
writeU8(SHORT_STRING_HEADER | len);
|
276
|
-
currentBuffer.write(thing, currentPosition, "latin1");
|
280
|
+
lengths.push(item.length);
|
277
281
|
}
|
278
|
-
|
282
|
+
}
|
283
|
+
allocate(5 + lengths.length * 4);
|
284
|
+
writeU8(LAZY_HEADER);
|
285
|
+
writeU32(lengths.length);
|
286
|
+
for (const l of lengths) {
|
287
|
+
writeU32(l);
|
288
|
+
}
|
289
|
+
flush();
|
290
|
+
for (const item of serializedData) {
|
291
|
+
buffers.push(item);
|
292
|
+
}
|
293
|
+
break;
|
294
|
+
}
|
295
|
+
case "string": {
|
296
|
+
const len = Buffer.byteLength(thing);
|
297
|
+
if (len >= 128 || len !== thing.length) {
|
298
|
+
allocate(len + HEADER_SIZE + I32_SIZE);
|
299
|
+
writeU8(STRING_HEADER);
|
300
|
+
writeU32(len);
|
301
|
+
currentBuffer.write(thing, currentPosition);
|
302
|
+
} else {
|
303
|
+
allocate(len + HEADER_SIZE);
|
304
|
+
writeU8(SHORT_STRING_HEADER | len);
|
305
|
+
currentBuffer.write(thing, currentPosition, "latin1");
|
306
|
+
}
|
307
|
+
currentPosition += len;
|
308
|
+
break;
|
309
|
+
}
|
310
|
+
case "number": {
|
311
|
+
const type = identifyNumber(thing);
|
312
|
+
if (type === 0 && thing >= 0 && thing <= 10) {
|
313
|
+
// shortcut for very small numbers
|
314
|
+
allocate(I8_SIZE);
|
315
|
+
writeU8(thing);
|
279
316
|
break;
|
280
317
|
}
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
318
|
+
/**
|
319
|
+
* amount of numbers to write
|
320
|
+
* @type {number}
|
321
|
+
*/
|
322
|
+
let n = 1;
|
323
|
+
for (; n < 32 && i + n < data.length; n++) {
|
324
|
+
const item = data[i + n];
|
325
|
+
if (typeof item !== "number") break;
|
326
|
+
if (identifyNumber(item) !== type) break;
|
327
|
+
}
|
328
|
+
switch (type) {
|
329
|
+
case 0:
|
330
|
+
allocate(HEADER_SIZE + I8_SIZE * n);
|
331
|
+
writeU8(I8_HEADER | (n - 1));
|
332
|
+
while (n > 0) {
|
333
|
+
currentBuffer.writeInt8(
|
334
|
+
/** @type {number} */ (data[i]),
|
335
|
+
currentPosition
|
336
|
+
);
|
337
|
+
currentPosition += I8_SIZE;
|
338
|
+
n--;
|
339
|
+
i++;
|
340
|
+
}
|
287
341
|
break;
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
writeU8(I32_HEADER | (n - 1));
|
316
|
-
while (n > 0) {
|
317
|
-
currentBuffer.writeInt32LE(
|
318
|
-
/** @type {number} */ (data[i]),
|
319
|
-
currentPosition
|
320
|
-
);
|
321
|
-
currentPosition += I32_SIZE;
|
322
|
-
n--;
|
323
|
-
i++;
|
324
|
-
}
|
325
|
-
break;
|
326
|
-
case 2:
|
327
|
-
allocate(HEADER_SIZE + F64_SIZE * n);
|
328
|
-
writeU8(F64_HEADER | (n - 1));
|
329
|
-
while (n > 0) {
|
330
|
-
currentBuffer.writeDoubleLE(
|
331
|
-
/** @type {number} */ (data[i]),
|
332
|
-
currentPosition
|
333
|
-
);
|
334
|
-
currentPosition += F64_SIZE;
|
335
|
-
n--;
|
336
|
-
i++;
|
337
|
-
}
|
338
|
-
break;
|
339
|
-
}
|
342
|
+
case 1:
|
343
|
+
allocate(HEADER_SIZE + I32_SIZE * n);
|
344
|
+
writeU8(I32_HEADER | (n - 1));
|
345
|
+
while (n > 0) {
|
346
|
+
currentBuffer.writeInt32LE(
|
347
|
+
/** @type {number} */ (data[i]),
|
348
|
+
currentPosition
|
349
|
+
);
|
350
|
+
currentPosition += I32_SIZE;
|
351
|
+
n--;
|
352
|
+
i++;
|
353
|
+
}
|
354
|
+
break;
|
355
|
+
case 2:
|
356
|
+
allocate(HEADER_SIZE + F64_SIZE * n);
|
357
|
+
writeU8(F64_HEADER | (n - 1));
|
358
|
+
while (n > 0) {
|
359
|
+
currentBuffer.writeDoubleLE(
|
360
|
+
/** @type {number} */ (data[i]),
|
361
|
+
currentPosition
|
362
|
+
);
|
363
|
+
currentPosition += F64_SIZE;
|
364
|
+
n--;
|
365
|
+
i++;
|
366
|
+
}
|
367
|
+
break;
|
368
|
+
}
|
340
369
|
|
341
|
-
|
342
|
-
|
370
|
+
i--;
|
371
|
+
break;
|
372
|
+
}
|
373
|
+
case "boolean": {
|
374
|
+
let lastByte = thing === true ? 1 : 0;
|
375
|
+
const bytes = [];
|
376
|
+
let count = 1;
|
377
|
+
let n;
|
378
|
+
for (n = 1; n < 0xffffffff && i + n < data.length; n++) {
|
379
|
+
const item = data[i + n];
|
380
|
+
if (typeof item !== "boolean") break;
|
381
|
+
const pos = count & 0x7;
|
382
|
+
if (pos === 0) {
|
383
|
+
bytes.push(lastByte);
|
384
|
+
lastByte = item === true ? 1 : 0;
|
385
|
+
} else if (item === true) {
|
386
|
+
lastByte |= 1 << pos;
|
387
|
+
}
|
388
|
+
count++;
|
389
|
+
}
|
390
|
+
i += count - 1;
|
391
|
+
if (count === 1) {
|
392
|
+
allocate(HEADER_SIZE);
|
393
|
+
writeU8(lastByte === 1 ? TRUE_HEADER : FALSE_HEADER);
|
394
|
+
} else if (count === 2) {
|
395
|
+
allocate(HEADER_SIZE * 2);
|
396
|
+
writeU8(lastByte & 1 ? TRUE_HEADER : FALSE_HEADER);
|
397
|
+
writeU8(lastByte & 2 ? TRUE_HEADER : FALSE_HEADER);
|
398
|
+
} else if (count <= 6) {
|
399
|
+
allocate(HEADER_SIZE + I8_SIZE);
|
400
|
+
writeU8(BOOLEANS_HEADER);
|
401
|
+
writeU8((1 << count) | lastByte);
|
402
|
+
} else if (count <= 133) {
|
403
|
+
allocate(HEADER_SIZE + I8_SIZE + I8_SIZE * bytes.length + I8_SIZE);
|
404
|
+
writeU8(BOOLEANS_HEADER);
|
405
|
+
writeU8(0x80 | (count - 7));
|
406
|
+
for (const byte of bytes) writeU8(byte);
|
407
|
+
writeU8(lastByte);
|
408
|
+
} else {
|
409
|
+
allocate(
|
410
|
+
HEADER_SIZE +
|
411
|
+
I8_SIZE +
|
412
|
+
I32_SIZE +
|
413
|
+
I8_SIZE * bytes.length +
|
414
|
+
I8_SIZE
|
415
|
+
);
|
416
|
+
writeU8(BOOLEANS_HEADER);
|
417
|
+
writeU8(0xff);
|
418
|
+
writeU32(count);
|
419
|
+
for (const byte of bytes) writeU8(byte);
|
420
|
+
writeU8(lastByte);
|
343
421
|
}
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
422
|
+
break;
|
423
|
+
}
|
424
|
+
case "object": {
|
425
|
+
if (thing === null) {
|
348
426
|
let n;
|
349
|
-
for (n = 1; n <
|
427
|
+
for (n = 1; n < 0x100000104 && i + n < data.length; n++) {
|
350
428
|
const item = data[i + n];
|
351
|
-
if (
|
352
|
-
const pos = count & 0x7;
|
353
|
-
if (pos === 0) {
|
354
|
-
bytes.push(lastByte);
|
355
|
-
lastByte = item === true ? 1 : 0;
|
356
|
-
} else if (item === true) {
|
357
|
-
lastByte |= 1 << pos;
|
358
|
-
}
|
359
|
-
count++;
|
360
|
-
}
|
361
|
-
i += count - 1;
|
362
|
-
if (count === 1) {
|
363
|
-
allocate(HEADER_SIZE);
|
364
|
-
writeU8(lastByte === 1 ? TRUE_HEADER : FALSE_HEADER);
|
365
|
-
} else if (count === 2) {
|
366
|
-
allocate(HEADER_SIZE * 2);
|
367
|
-
writeU8(lastByte & 1 ? TRUE_HEADER : FALSE_HEADER);
|
368
|
-
writeU8(lastByte & 2 ? TRUE_HEADER : FALSE_HEADER);
|
369
|
-
} else if (count <= 6) {
|
370
|
-
allocate(HEADER_SIZE + I8_SIZE);
|
371
|
-
writeU8(BOOLEANS_HEADER);
|
372
|
-
writeU8((1 << count) | lastByte);
|
373
|
-
} else if (count <= 133) {
|
374
|
-
allocate(
|
375
|
-
HEADER_SIZE + I8_SIZE + I8_SIZE * bytes.length + I8_SIZE
|
376
|
-
);
|
377
|
-
writeU8(BOOLEANS_HEADER);
|
378
|
-
writeU8(0x80 | (count - 7));
|
379
|
-
for (const byte of bytes) writeU8(byte);
|
380
|
-
writeU8(lastByte);
|
381
|
-
} else {
|
382
|
-
allocate(
|
383
|
-
HEADER_SIZE +
|
384
|
-
I8_SIZE +
|
385
|
-
I32_SIZE +
|
386
|
-
I8_SIZE * bytes.length +
|
387
|
-
I8_SIZE
|
388
|
-
);
|
389
|
-
writeU8(BOOLEANS_HEADER);
|
390
|
-
writeU8(0xff);
|
391
|
-
writeU32(count);
|
392
|
-
for (const byte of bytes) writeU8(byte);
|
393
|
-
writeU8(lastByte);
|
429
|
+
if (item !== null) break;
|
394
430
|
}
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
431
|
+
i += n - 1;
|
432
|
+
if (n === 1) {
|
433
|
+
if (i + 1 < data.length) {
|
434
|
+
const next = data[i + 1];
|
435
|
+
if (next === true) {
|
436
|
+
allocate(HEADER_SIZE);
|
437
|
+
writeU8(NULL_AND_TRUE_HEADER);
|
438
|
+
i++;
|
439
|
+
} else if (next === false) {
|
440
|
+
allocate(HEADER_SIZE);
|
441
|
+
writeU8(NULL_AND_FALSE_HEADER);
|
442
|
+
i++;
|
443
|
+
} else if (typeof next === "number") {
|
444
|
+
const type = identifyNumber(next);
|
445
|
+
if (type === 0) {
|
446
|
+
allocate(HEADER_SIZE + I8_SIZE);
|
447
|
+
writeU8(NULL_AND_I8_HEADER);
|
448
|
+
currentBuffer.writeInt8(next, currentPosition);
|
449
|
+
currentPosition += I8_SIZE;
|
411
450
|
i++;
|
412
|
-
} else if (
|
413
|
-
allocate(HEADER_SIZE);
|
414
|
-
writeU8(
|
451
|
+
} else if (type === 1) {
|
452
|
+
allocate(HEADER_SIZE + I32_SIZE);
|
453
|
+
writeU8(NULL_AND_I32_HEADER);
|
454
|
+
currentBuffer.writeInt32LE(next, currentPosition);
|
455
|
+
currentPosition += I32_SIZE;
|
415
456
|
i++;
|
416
|
-
} else if (typeof next === "number") {
|
417
|
-
const type = identifyNumber(next);
|
418
|
-
if (type === 0) {
|
419
|
-
allocate(HEADER_SIZE + I8_SIZE);
|
420
|
-
writeU8(NULL_AND_I8_HEADER);
|
421
|
-
currentBuffer.writeInt8(next, currentPosition);
|
422
|
-
currentPosition += I8_SIZE;
|
423
|
-
i++;
|
424
|
-
} else if (type === 1) {
|
425
|
-
allocate(HEADER_SIZE + I32_SIZE);
|
426
|
-
writeU8(NULL_AND_I32_HEADER);
|
427
|
-
currentBuffer.writeInt32LE(next, currentPosition);
|
428
|
-
currentPosition += I32_SIZE;
|
429
|
-
i++;
|
430
|
-
} else {
|
431
|
-
allocate(HEADER_SIZE);
|
432
|
-
writeU8(NULL_HEADER);
|
433
|
-
}
|
434
457
|
} else {
|
435
458
|
allocate(HEADER_SIZE);
|
436
459
|
writeU8(NULL_HEADER);
|
@@ -439,59 +462,64 @@ class BinaryMiddleware extends SerializerMiddleware {
|
|
439
462
|
allocate(HEADER_SIZE);
|
440
463
|
writeU8(NULL_HEADER);
|
441
464
|
}
|
442
|
-
} else if (n === 2) {
|
443
|
-
allocate(HEADER_SIZE);
|
444
|
-
writeU8(NULL2_HEADER);
|
445
|
-
} else if (n === 3) {
|
446
|
-
allocate(HEADER_SIZE);
|
447
|
-
writeU8(NULL3_HEADER);
|
448
|
-
} else if (n < 260) {
|
449
|
-
allocate(HEADER_SIZE + I8_SIZE);
|
450
|
-
writeU8(NULLS8_HEADER);
|
451
|
-
writeU8(n - 4);
|
452
|
-
} else {
|
453
|
-
allocate(HEADER_SIZE + I32_SIZE);
|
454
|
-
writeU8(NULLS32_HEADER);
|
455
|
-
writeU32(n - 260);
|
456
|
-
}
|
457
|
-
} else if (Buffer.isBuffer(thing)) {
|
458
|
-
if (thing.length < 8192) {
|
459
|
-
allocate(HEADER_SIZE + I32_SIZE + thing.length);
|
460
|
-
writeU8(BUFFER_HEADER);
|
461
|
-
writeU32(thing.length);
|
462
|
-
thing.copy(currentBuffer, currentPosition);
|
463
|
-
currentPosition += thing.length;
|
464
465
|
} else {
|
465
|
-
allocate(HEADER_SIZE
|
466
|
-
writeU8(
|
467
|
-
writeU32(thing.length);
|
468
|
-
flush();
|
469
|
-
buffers.push(thing);
|
466
|
+
allocate(HEADER_SIZE);
|
467
|
+
writeU8(NULL_HEADER);
|
470
468
|
}
|
469
|
+
} else if (n === 2) {
|
470
|
+
allocate(HEADER_SIZE);
|
471
|
+
writeU8(NULL2_HEADER);
|
472
|
+
} else if (n === 3) {
|
473
|
+
allocate(HEADER_SIZE);
|
474
|
+
writeU8(NULL3_HEADER);
|
475
|
+
} else if (n < 260) {
|
476
|
+
allocate(HEADER_SIZE + I8_SIZE);
|
477
|
+
writeU8(NULLS8_HEADER);
|
478
|
+
writeU8(n - 4);
|
479
|
+
} else {
|
480
|
+
allocate(HEADER_SIZE + I32_SIZE);
|
481
|
+
writeU8(NULLS32_HEADER);
|
482
|
+
writeU32(n - 260);
|
471
483
|
}
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
484
|
+
} else if (Buffer.isBuffer(thing)) {
|
485
|
+
if (thing.length < 8192) {
|
486
|
+
allocate(HEADER_SIZE + I32_SIZE + thing.length);
|
487
|
+
writeU8(BUFFER_HEADER);
|
488
|
+
writeU32(thing.length);
|
489
|
+
thing.copy(currentBuffer, currentPosition);
|
490
|
+
currentPosition += thing.length;
|
491
|
+
} else {
|
479
492
|
allocate(HEADER_SIZE + I32_SIZE);
|
480
|
-
writeU8(
|
481
|
-
|
482
|
-
|
493
|
+
writeU8(BUFFER_HEADER);
|
494
|
+
writeU32(thing.length);
|
495
|
+
flush();
|
496
|
+
buffers.push(thing);
|
483
497
|
}
|
484
|
-
break;
|
485
498
|
}
|
499
|
+
break;
|
500
|
+
}
|
501
|
+
case "symbol": {
|
502
|
+
if (thing === MEASURE_START_OPERATION) {
|
503
|
+
measureStart();
|
504
|
+
} else if (thing === MEASURE_END_OPERATION) {
|
505
|
+
const size = measureEnd();
|
506
|
+
allocate(HEADER_SIZE + I32_SIZE);
|
507
|
+
writeU8(I32_HEADER);
|
508
|
+
currentBuffer.writeInt32LE(size, currentPosition);
|
509
|
+
currentPosition += I32_SIZE;
|
510
|
+
}
|
511
|
+
break;
|
486
512
|
}
|
487
513
|
}
|
488
|
-
}
|
489
|
-
serializeData(data);
|
514
|
+
}
|
490
515
|
flush();
|
491
516
|
|
517
|
+
allocationScope.leftOverBuffer = leftOverBuffer;
|
518
|
+
|
492
519
|
// avoid leaking memory
|
493
520
|
currentBuffer = null;
|
494
521
|
leftOverBuffer = null;
|
522
|
+
allocationScope = undefined;
|
495
523
|
const _buffers = buffers;
|
496
524
|
buffers = undefined;
|
497
525
|
return _buffers;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "webpack",
|
3
|
-
"version": "5.
|
3
|
+
"version": "5.50.0",
|
4
4
|
"author": "Tobias Koppers @sokra",
|
5
5
|
"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.",
|
6
6
|
"license": "MIT",
|
@@ -1213,7 +1213,7 @@
|
|
1213
1213
|
]
|
1214
1214
|
},
|
1215
1215
|
"frozen": {
|
1216
|
-
"description": "When set, anything that would lead to
|
1216
|
+
"description": "When set, anything that would lead to a modification of the lockfile or any resource content, will result in an error.",
|
1217
1217
|
"type": "boolean"
|
1218
1218
|
},
|
1219
1219
|
"lockfileLocation": {
|
@@ -18,7 +18,7 @@
|
|
18
18
|
]
|
19
19
|
},
|
20
20
|
"frozen": {
|
21
|
-
"description": "When set, anything that would lead to
|
21
|
+
"description": "When set, anything that would lead to a modification of the lockfile or any resource content, will result in an error.",
|
22
22
|
"type": "boolean"
|
23
23
|
},
|
24
24
|
"lockfileLocation": {
|
package/types.d.ts
CHANGED
@@ -4301,7 +4301,7 @@ declare interface HttpUriOptions {
|
|
4301
4301
|
cacheLocation?: string | false;
|
4302
4302
|
|
4303
4303
|
/**
|
4304
|
-
* When set, anything that would lead to
|
4304
|
+
* When set, anything that would lead to a modification of the lockfile or any resource content, will result in an error.
|
4305
4305
|
*/
|
4306
4306
|
frozen?: boolean;
|
4307
4307
|
|
@@ -4322,7 +4322,7 @@ declare class HttpUriPlugin {
|
|
4322
4322
|
*/
|
4323
4323
|
cacheLocation?: string | false;
|
4324
4324
|
/**
|
4325
|
-
* When set, anything that would lead to
|
4325
|
+
* When set, anything that would lead to a modification of the lockfile or any resource content, will result in an error.
|
4326
4326
|
*/
|
4327
4327
|
frozen?: boolean;
|
4328
4328
|
/**
|
@@ -8470,6 +8470,7 @@ declare interface ParserOptionsByModuleTypeUnknown {
|
|
8470
8470
|
}
|
8471
8471
|
type ParserState = Record<string, any> & ParserStateBase;
|
8472
8472
|
declare interface ParserStateBase {
|
8473
|
+
source: string | Buffer;
|
8473
8474
|
current: NormalModule;
|
8474
8475
|
module: NormalModule;
|
8475
8476
|
compilation: Compilation;
|