@atlaspack/core 2.34.0 → 2.36.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.
- package/CHANGELOG.md +70 -0
- package/dist/AssetGraph.js +4 -72
- package/dist/BundleGraph.js +34 -0
- package/dist/PackagerRunner.js +8 -53
- package/dist/RequestTracker.js +17 -80
- package/dist/TargetDescriptor.schema.js +3 -0
- package/dist/UncommittedAsset.js +0 -5
- package/dist/atlaspack-v3/AtlaspackV3.js +6 -2
- package/dist/requests/AssetGraphRequest.js +6 -15
- package/dist/requests/AssetGraphRequestRust.js +51 -7
- package/dist/requests/AtlaspackBuildRequest.js +8 -2
- package/dist/requests/BundleGraphRequest.js +17 -21
- package/dist/requests/BundleGraphRequestRust.js +2 -2
- package/dist/requests/BundleGraphRequestUtils.js +133 -2
- package/dist/requests/PackageRequest.js +1 -1
- package/dist/requests/TargetRequest.js +5 -0
- package/dist/requests/WriteBundleRequest.js +169 -24
- package/dist/resolveOptions.js +2 -4
- package/lib/AssetGraph.js +3 -62
- package/lib/BundleGraph.js +38 -0
- package/lib/PackagerRunner.js +8 -42
- package/lib/RequestTracker.js +15 -69
- package/lib/TargetDescriptor.schema.js +3 -0
- package/lib/UncommittedAsset.js +0 -11
- package/lib/atlaspack-v3/AtlaspackV3.js +6 -2
- package/lib/requests/AssetGraphRequest.js +4 -18
- package/lib/requests/AssetGraphRequestRust.js +51 -7
- package/lib/requests/AtlaspackBuildRequest.js +8 -2
- package/lib/requests/BundleGraphRequest.js +20 -22
- package/lib/requests/BundleGraphRequestRust.js +3 -3
- package/lib/requests/BundleGraphRequestUtils.js +132 -2
- package/lib/requests/PackageRequest.js +3 -1
- package/lib/requests/TargetRequest.js +5 -0
- package/lib/requests/WriteBundleRequest.js +182 -14
- package/lib/resolveOptions.js +2 -4
- package/lib/types/AssetGraph.d.ts +2 -27
- package/lib/types/BundleGraph.d.ts +5 -0
- package/lib/types/atlaspack-v3/AtlaspackV3.d.ts +3 -2
- package/lib/types/requests/BundleGraphRequest.d.ts +1 -1
- package/lib/types/requests/BundleGraphRequestUtils.d.ts +7 -0
- package/lib/types/requests/WriteBundleRequest.d.ts +33 -0
- package/lib/types/types.d.ts +1 -0
- package/package.json +15 -15
- package/src/AssetGraph.ts +4 -72
- package/src/BundleGraph.ts +39 -0
- package/src/PackagerRunner.ts +9 -55
- package/src/RequestTracker.ts +24 -110
- package/src/TargetDescriptor.schema.ts +3 -0
- package/src/UncommittedAsset.ts +1 -11
- package/src/atlaspack-v3/AtlaspackV3.ts +19 -3
- package/src/requests/AssetGraphRequest.ts +8 -20
- package/src/requests/AssetGraphRequestRust.ts +59 -7
- package/src/requests/AtlaspackBuildRequest.ts +16 -8
- package/src/requests/BundleGraphRequest.ts +22 -36
- package/src/requests/BundleGraphRequestRust.ts +4 -2
- package/src/requests/BundleGraphRequestUtils.ts +157 -1
- package/src/requests/PackageRequest.ts +1 -1
- package/src/requests/TargetRequest.ts +5 -0
- package/src/requests/WriteBundleRequest.ts +203 -29
- package/src/resolveOptions.ts +2 -4
- package/src/types.ts +1 -0
- package/test/AssetGraph.test.ts +0 -32
- package/test/RequestTracker.test.ts +0 -165
- package/test/TargetRequest.test.ts +25 -0
- package/test/requests/WriteBundleRequest.test.ts +363 -0
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -41,12 +41,15 @@ import {PluginTracer, tracer} from '@atlaspack/profiler';
|
|
|
41
41
|
import {requestTypes} from '../RequestTracker';
|
|
42
42
|
import {getFeatureFlag} from '@atlaspack/feature-flags';
|
|
43
43
|
import {fromEnvironmentId} from '../EnvironmentManager';
|
|
44
|
-
import SourceMap from '@atlaspack/source-map';
|
|
44
|
+
import SourceMap, {decodeVLQ, encodeVLQ} from '@atlaspack/source-map';
|
|
45
45
|
|
|
46
46
|
const HASH_REF_PREFIX_LEN = HASH_REF_PREFIX.length;
|
|
47
47
|
const BOUNDARY_LENGTH = HASH_REF_PREFIX.length + 32 - 1;
|
|
48
48
|
const HASH_REF_PLACEHOLDER_LEN = HASH_REF_PREFIX_LEN + HASH_REF_HASH_LEN;
|
|
49
49
|
|
|
50
|
+
// The JSON key prefix we scan for in the source map stream.
|
|
51
|
+
const MAPPINGS_KEY_BUF = Buffer.from('"mappings":"');
|
|
52
|
+
|
|
50
53
|
export type HashRefReplacement = {
|
|
51
54
|
line: number;
|
|
52
55
|
column: number;
|
|
@@ -185,43 +188,19 @@ async function run({input, options, api}) {
|
|
|
185
188
|
bundleReplacements,
|
|
186
189
|
);
|
|
187
190
|
|
|
188
|
-
const hasSourceMap =
|
|
189
|
-
? await options.cache.hasLargeBlob(mapKey)
|
|
190
|
-
: await options.cache.has(mapKey);
|
|
191
|
+
const hasSourceMap = await options.cache.has(mapKey);
|
|
191
192
|
if (mapKey && env.sourceMap && !env.sourceMap.inline && hasSourceMap) {
|
|
193
|
+
const mapEntry = await options.cache.getBlob(mapKey);
|
|
192
194
|
let mapStream: Readable;
|
|
193
195
|
if (
|
|
194
196
|
getFeatureFlag('fixSourceMapHashRefs') &&
|
|
195
197
|
bundleReplacements &&
|
|
196
198
|
bundleReplacements.length > 0
|
|
197
199
|
) {
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
: await options.cache.getBlob(mapKey);
|
|
201
|
-
const mapBuffer = Buffer.isBuffer(mapEntry)
|
|
202
|
-
? mapEntry
|
|
203
|
-
: Buffer.from(mapEntry);
|
|
204
|
-
const projectRoot =
|
|
205
|
-
typeof options.projectRoot === 'string'
|
|
206
|
-
? options.projectRoot
|
|
207
|
-
: String(options.projectRoot);
|
|
208
|
-
const sourceMap = new SourceMap(projectRoot, mapBuffer);
|
|
209
|
-
applyReplacementsToSourceMap(sourceMap, bundleReplacements);
|
|
210
|
-
const mapJson = await sourceMap.stringify({
|
|
211
|
-
format: 'string',
|
|
212
|
-
file: name,
|
|
213
|
-
sourceRoot: computeSourceMapRoot(bundle, options),
|
|
214
|
-
});
|
|
215
|
-
mapStream = blobToStream(
|
|
216
|
-
Buffer.from(
|
|
217
|
-
typeof mapJson === 'string' ? mapJson : JSON.stringify(mapJson),
|
|
218
|
-
'utf8',
|
|
219
|
-
),
|
|
200
|
+
mapStream = blobToStream(mapEntry).pipe(
|
|
201
|
+
new SourceMapHashRefRewriteStream(bundleReplacements),
|
|
220
202
|
);
|
|
221
203
|
} else {
|
|
222
|
-
const mapEntry = getFeatureFlag('cachePerformanceImprovements')
|
|
223
|
-
? await options.cache.getLargeBlob(mapKey)
|
|
224
|
-
: await options.cache.getBlob(mapKey);
|
|
225
204
|
mapStream = blobToStream(mapEntry);
|
|
226
205
|
}
|
|
227
206
|
await writeFiles(
|
|
@@ -275,6 +254,201 @@ export function applyReplacementsToSourceMap(
|
|
|
275
254
|
}
|
|
276
255
|
}
|
|
277
256
|
|
|
257
|
+
/**
|
|
258
|
+
* Applies hash-ref replacement column offsets directly to a VLQ mappings
|
|
259
|
+
* string without deserializing the full source map into a native struct.
|
|
260
|
+
*
|
|
261
|
+
* Each replacement r describes a hash-ref that was substituted in the output
|
|
262
|
+
* file. r.column is in the progressively-shifted post-replacement coordinate
|
|
263
|
+
* space (matching the already-shifted source map state after all previous
|
|
264
|
+
* offsetColumns calls), so thresholds are applied sequentially against the
|
|
265
|
+
* running absCol values exactly as the native offsetColumns implementation does.
|
|
266
|
+
*/
|
|
267
|
+
export function applyReplacementsToVLQMappings(
|
|
268
|
+
mappings: string,
|
|
269
|
+
replacements: HashRefReplacement[],
|
|
270
|
+
): string {
|
|
271
|
+
if (replacements.length === 0) return mappings;
|
|
272
|
+
|
|
273
|
+
// Group replacements by line (0-indexed), sorted by column ascending.
|
|
274
|
+
const byLine = new Map<number, HashRefReplacement[]>();
|
|
275
|
+
for (const r of replacements) {
|
|
276
|
+
let arr = byLine.get(r.line);
|
|
277
|
+
if (!arr) {
|
|
278
|
+
arr = [];
|
|
279
|
+
byLine.set(r.line, arr);
|
|
280
|
+
}
|
|
281
|
+
arr.push(r);
|
|
282
|
+
}
|
|
283
|
+
for (const arr of byLine.values()) {
|
|
284
|
+
arr.sort((a, b) => a.column - b.column);
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
const lines = mappings.split(';');
|
|
288
|
+
const resultLines: string[] = [];
|
|
289
|
+
|
|
290
|
+
for (let lineIdx = 0; lineIdx < lines.length; lineIdx++) {
|
|
291
|
+
const lineReps = byLine.get(lineIdx);
|
|
292
|
+
if (!lineReps || lineReps.length === 0) {
|
|
293
|
+
resultLines.push(lines[lineIdx]);
|
|
294
|
+
continue;
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
const line = lines[lineIdx];
|
|
298
|
+
if (!line) {
|
|
299
|
+
resultLines.push('');
|
|
300
|
+
continue;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
// Decode segment column deltas to absolute columns.
|
|
304
|
+
const segments = line.split(',');
|
|
305
|
+
const colVlqEnds: number[] = [];
|
|
306
|
+
const absCols: number[] = [];
|
|
307
|
+
let absCol = 0;
|
|
308
|
+
for (const seg of segments) {
|
|
309
|
+
const {value: colDelta, nextPos} = decodeVLQ(seg, 0);
|
|
310
|
+
absCol += colDelta;
|
|
311
|
+
colVlqEnds.push(nextPos);
|
|
312
|
+
absCols.push(absCol);
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
// Apply each replacement's column shift sequentially against the
|
|
316
|
+
// current absCol values (which have already been adjusted by previous
|
|
317
|
+
// replacements on this line), mirroring the sequential offsetColumns calls.
|
|
318
|
+
for (const r of lineReps) {
|
|
319
|
+
const delta = r.newLength - r.originalLength;
|
|
320
|
+
if (delta === 0) continue;
|
|
321
|
+
const threshold = r.column + r.originalLength;
|
|
322
|
+
for (let i = 0; i < absCols.length; i++) {
|
|
323
|
+
if (absCols[i] >= threshold) {
|
|
324
|
+
absCols[i] += delta;
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
// Re-encode with updated absolute columns; only the leading column VLQ
|
|
330
|
+
// field of each segment changes – the tail bytes are sliced unchanged.
|
|
331
|
+
const resultSegments: string[] = [];
|
|
332
|
+
let prevAbsCol = 0;
|
|
333
|
+
for (let i = 0; i < segments.length; i++) {
|
|
334
|
+
const newDelta = absCols[i] - prevAbsCol;
|
|
335
|
+
prevAbsCol = absCols[i];
|
|
336
|
+
resultSegments.push(
|
|
337
|
+
encodeVLQ(newDelta) + segments[i].slice(colVlqEnds[i]),
|
|
338
|
+
);
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
resultLines.push(resultSegments.join(','));
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
return resultLines.join(';');
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
type StreamState = 'scanning' | 'buffering' | 'passthrough';
|
|
348
|
+
|
|
349
|
+
/**
|
|
350
|
+
* A Transform stream that rewrites the "mappings" VLQ field of a source map
|
|
351
|
+
* JSON to account for hash-ref replacements, without ever loading the full
|
|
352
|
+
* JSON object or the native Rust SourceMapInner into memory.
|
|
353
|
+
*
|
|
354
|
+
* Field order in cached source maps (from partialVlqMapToSourceMap / toVLQ):
|
|
355
|
+
* mappings → sources → sourcesContent → names → version → file → sourceRoot
|
|
356
|
+
*
|
|
357
|
+
* "mappings" is the very first field, so we scan only a tiny header before
|
|
358
|
+
* switching to zero-copy passthrough for the bulk sourcesContent bytes.
|
|
359
|
+
*/
|
|
360
|
+
export class SourceMapHashRefRewriteStream extends Transform {
|
|
361
|
+
private replacements: HashRefReplacement[];
|
|
362
|
+
private state: StreamState;
|
|
363
|
+
private scanBuf: Buffer;
|
|
364
|
+
private mappingsBufs: Buffer[];
|
|
365
|
+
|
|
366
|
+
constructor(replacements: HashRefReplacement[]) {
|
|
367
|
+
super();
|
|
368
|
+
this.replacements = replacements;
|
|
369
|
+
this.state = 'scanning';
|
|
370
|
+
this.scanBuf = Buffer.alloc(0);
|
|
371
|
+
this.mappingsBufs = [];
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
// @ts-expect-error TS7006
|
|
375
|
+
_transform(chunk: Buffer, _encoding: string, cb): void {
|
|
376
|
+
if (this.state === 'passthrough') {
|
|
377
|
+
this.push(chunk);
|
|
378
|
+
cb();
|
|
379
|
+
return;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
if (this.state === 'scanning') {
|
|
383
|
+
const combined = Buffer.concat([this.scanBuf, chunk]);
|
|
384
|
+
const idx = combined.indexOf(MAPPINGS_KEY_BUF);
|
|
385
|
+
|
|
386
|
+
if (idx === -1) {
|
|
387
|
+
// Key not yet found – hold back enough bytes to handle a split key.
|
|
388
|
+
const keepLen = Math.min(combined.length, MAPPINGS_KEY_BUF.length - 1);
|
|
389
|
+
if (combined.length > keepLen) {
|
|
390
|
+
this.push(combined.slice(0, combined.length - keepLen));
|
|
391
|
+
}
|
|
392
|
+
this.scanBuf = combined.slice(combined.length - keepLen);
|
|
393
|
+
cb();
|
|
394
|
+
return;
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
// Emit everything up to and including the key.
|
|
398
|
+
const keyEnd = idx + MAPPINGS_KEY_BUF.length;
|
|
399
|
+
this.push(combined.slice(0, keyEnd));
|
|
400
|
+
this.scanBuf = Buffer.alloc(0);
|
|
401
|
+
this.state = 'buffering';
|
|
402
|
+
this._bufferingTransform(combined.slice(keyEnd), cb);
|
|
403
|
+
return;
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
// state === 'buffering'
|
|
407
|
+
this._bufferingTransform(chunk, cb);
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
// @ts-expect-error TS7006
|
|
411
|
+
private _bufferingTransform(chunk: Buffer, cb): void {
|
|
412
|
+
// Mappings values contain only base64 chars, ';', and ',' – no escaping –
|
|
413
|
+
// so scanning for the closing '"' (0x22) is safe.
|
|
414
|
+
const closeIdx = chunk.indexOf(0x22);
|
|
415
|
+
|
|
416
|
+
if (closeIdx === -1) {
|
|
417
|
+
this.mappingsBufs.push(chunk);
|
|
418
|
+
cb();
|
|
419
|
+
return;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
this.mappingsBufs.push(chunk.slice(0, closeIdx));
|
|
423
|
+
|
|
424
|
+
// VLQ chars are all ASCII (<128), so latin1 round-trips without loss.
|
|
425
|
+
const mappingsStr = Buffer.concat(this.mappingsBufs).toString('latin1');
|
|
426
|
+
const rewritten = applyReplacementsToVLQMappings(
|
|
427
|
+
mappingsStr,
|
|
428
|
+
this.replacements,
|
|
429
|
+
);
|
|
430
|
+
this.push(Buffer.from(rewritten, 'latin1'));
|
|
431
|
+
|
|
432
|
+
// Emit the closing '"' and everything remaining in one push.
|
|
433
|
+
this.push(chunk.slice(closeIdx));
|
|
434
|
+
|
|
435
|
+
this.state = 'passthrough';
|
|
436
|
+
this.mappingsBufs = [];
|
|
437
|
+
cb();
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
// @ts-expect-error TS7006
|
|
441
|
+
_flush(cb): void {
|
|
442
|
+
if (this.state === 'scanning' && this.scanBuf.length > 0) {
|
|
443
|
+
this.push(this.scanBuf);
|
|
444
|
+
} else if (this.state === 'buffering') {
|
|
445
|
+
// Malformed JSON – flush whatever we buffered as-is.
|
|
446
|
+
this.push(Buffer.concat(this.mappingsBufs));
|
|
447
|
+
}
|
|
448
|
+
cb();
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
|
|
278
452
|
/**
|
|
279
453
|
* Computes the sourceRoot for a source map file. This is the relative path from
|
|
280
454
|
* the output directory back to the project root, so that source paths (stored
|
package/src/resolveOptions.ts
CHANGED
|
@@ -184,10 +184,8 @@ export default async function resolveOptions(
|
|
|
184
184
|
const needsRustLmdbCache =
|
|
185
185
|
getFeatureFlag('atlaspackV3') || getFeatureFlag('nativePackager');
|
|
186
186
|
|
|
187
|
-
if (!
|
|
188
|
-
|
|
189
|
-
return new FSCache(outputFS, cacheDir);
|
|
190
|
-
}
|
|
187
|
+
if (!needsRustLmdbCache && !(outputFS instanceof NodeFS)) {
|
|
188
|
+
return new FSCache(outputFS, cacheDir);
|
|
191
189
|
}
|
|
192
190
|
|
|
193
191
|
return new LMDBLiteCache(cacheDir);
|
package/src/types.ts
CHANGED
package/test/AssetGraph.test.ts
CHANGED
|
@@ -687,36 +687,4 @@ describe('AssetGraph', () => {
|
|
|
687
687
|
invariant(node.type === 'asset_group');
|
|
688
688
|
assert(!node.hasDeferred);
|
|
689
689
|
});
|
|
690
|
-
|
|
691
|
-
it('should serialize the bundling version and incremental bundling flag', () => {
|
|
692
|
-
const graph = new AssetGraph();
|
|
693
|
-
graph.setDisableIncrementalBundling(true);
|
|
694
|
-
graph.setNeedsBundling();
|
|
695
|
-
const serialized = serialize(graph);
|
|
696
|
-
const deserialized = deserialize(serialized);
|
|
697
|
-
|
|
698
|
-
assert.equal(deserialized.getBundlingVersion(), 1);
|
|
699
|
-
assert.equal(deserialized.testing_getDisableIncrementalBundling(), true);
|
|
700
|
-
});
|
|
701
|
-
|
|
702
|
-
describe('setNeedsBundling', () => {
|
|
703
|
-
it('should increment the bundling version', () => {
|
|
704
|
-
const graph = new AssetGraph();
|
|
705
|
-
assert.equal(graph.getBundlingVersion(), 0);
|
|
706
|
-
graph.setNeedsBundling();
|
|
707
|
-
assert.equal(graph.getBundlingVersion(), 1);
|
|
708
|
-
graph.setNeedsBundling();
|
|
709
|
-
assert.equal(graph.getBundlingVersion(), 2);
|
|
710
|
-
});
|
|
711
|
-
});
|
|
712
|
-
|
|
713
|
-
describe('canIncrementallyBundle', () => {
|
|
714
|
-
it('should return true if the bundling version has changed', () => {
|
|
715
|
-
const graph = new AssetGraph();
|
|
716
|
-
const lastVersion = graph.getBundlingVersion();
|
|
717
|
-
assert.equal(graph.canIncrementallyBundle(lastVersion), true);
|
|
718
|
-
graph.setNeedsBundling();
|
|
719
|
-
assert.equal(graph.canIncrementallyBundle(lastVersion), false);
|
|
720
|
-
});
|
|
721
|
-
});
|
|
722
690
|
});
|
|
@@ -538,171 +538,6 @@ describe('RequestTracker', () => {
|
|
|
538
538
|
});
|
|
539
539
|
});
|
|
540
540
|
});
|
|
541
|
-
|
|
542
|
-
describe('incremental bundling', () => {
|
|
543
|
-
async function runIncrementalBundlingScenario(
|
|
544
|
-
incrementalBundlingVersioning: boolean,
|
|
545
|
-
) {
|
|
546
|
-
const fs = new OverlayFS(new MemoryFS(farm), new NodeFS());
|
|
547
|
-
const appRoot = __dirname;
|
|
548
|
-
await fs.mkdirp(path.join(appRoot, 'app'));
|
|
549
|
-
await fs.writeFile(path.join(appRoot, 'app', 'package.json'), '{}');
|
|
550
|
-
await fs.writeFile(path.join(appRoot, 'app', '.git'), '');
|
|
551
|
-
await fs.writeFile(
|
|
552
|
-
path.join(appRoot, 'app', '.parcelrc'),
|
|
553
|
-
'{"extends":"@atlaspack/config-default"}',
|
|
554
|
-
);
|
|
555
|
-
await fs.writeFile(
|
|
556
|
-
path.join(appRoot, 'app', 'target.js'),
|
|
557
|
-
'console.log("hello")',
|
|
558
|
-
);
|
|
559
|
-
|
|
560
|
-
const atlaspack = new Atlaspack({
|
|
561
|
-
featureFlags: {
|
|
562
|
-
incrementalBundlingVersioning,
|
|
563
|
-
},
|
|
564
|
-
workerFarm: farm,
|
|
565
|
-
entries: [path.join(appRoot, 'app', 'target.js')],
|
|
566
|
-
cache: new LMDBLiteCache(DEFAULT_OPTIONS.cacheDir),
|
|
567
|
-
inputFS: fs,
|
|
568
|
-
outputFS: fs,
|
|
569
|
-
});
|
|
570
|
-
await atlaspack._init();
|
|
571
|
-
const options = atlaspack._getResolvedAtlaspackOptions();
|
|
572
|
-
const tracker = new RequestTracker({farm, options});
|
|
573
|
-
let {ref: optionsRef} = await farm.createSharedReference(options, false);
|
|
574
|
-
|
|
575
|
-
const getAssetRequests = () =>
|
|
576
|
-
runRequestSpy
|
|
577
|
-
.getCalls()
|
|
578
|
-
.map((call: any) => call.args[0])
|
|
579
|
-
.filter(
|
|
580
|
-
(request: any) => request.type === requestTypes.asset_request,
|
|
581
|
-
);
|
|
582
|
-
|
|
583
|
-
// Running the build once builds one asset
|
|
584
|
-
const runRequestSpy = sinon.spy(tracker, 'runRequest');
|
|
585
|
-
await tracker.runRequest(
|
|
586
|
-
createAtlaspackBuildRequest({
|
|
587
|
-
optionsRef,
|
|
588
|
-
requestedAssetIds: new Set(),
|
|
589
|
-
}),
|
|
590
|
-
);
|
|
591
|
-
assert.equal(getAssetRequests().length, 1);
|
|
592
|
-
runRequestSpy.resetHistory();
|
|
593
|
-
|
|
594
|
-
// Running the build again with no invalidations does not build any assets
|
|
595
|
-
await tracker.runRequest(
|
|
596
|
-
createAtlaspackBuildRequest({
|
|
597
|
-
optionsRef,
|
|
598
|
-
requestedAssetIds: new Set(),
|
|
599
|
-
}),
|
|
600
|
-
);
|
|
601
|
-
assert.equal(getAssetRequests().length, 0);
|
|
602
|
-
runRequestSpy.resetHistory();
|
|
603
|
-
|
|
604
|
-
// Running the build again with a file change builds the asset again
|
|
605
|
-
tracker.respondToFSEvents(
|
|
606
|
-
[
|
|
607
|
-
{
|
|
608
|
-
type: 'update',
|
|
609
|
-
path: path.join(appRoot, 'app', 'target.js'),
|
|
610
|
-
},
|
|
611
|
-
],
|
|
612
|
-
Number.MAX_VALUE,
|
|
613
|
-
);
|
|
614
|
-
await tracker.runRequest(
|
|
615
|
-
createAtlaspackBuildRequest({
|
|
616
|
-
optionsRef,
|
|
617
|
-
requestedAssetIds: new Set(),
|
|
618
|
-
}),
|
|
619
|
-
);
|
|
620
|
-
assert.equal(getAssetRequests().length, 1);
|
|
621
|
-
runRequestSpy.resetHistory();
|
|
622
|
-
|
|
623
|
-
// Run the asset graph request, but not bundling
|
|
624
|
-
await fs.writeFile(
|
|
625
|
-
path.join(appRoot, 'app', 'target.js'),
|
|
626
|
-
'require("./dep.js")',
|
|
627
|
-
);
|
|
628
|
-
await fs.writeFile(
|
|
629
|
-
path.join(appRoot, 'app', 'dep.js'),
|
|
630
|
-
'console.log("dep")',
|
|
631
|
-
);
|
|
632
|
-
tracker.respondToFSEvents(
|
|
633
|
-
[
|
|
634
|
-
{
|
|
635
|
-
type: 'update',
|
|
636
|
-
path: path.join(appRoot, 'app', 'target.js'),
|
|
637
|
-
},
|
|
638
|
-
],
|
|
639
|
-
Number.MAX_VALUE,
|
|
640
|
-
);
|
|
641
|
-
const assetGraphRequestResult = await tracker.runRequest(
|
|
642
|
-
createAssetGraphRequest({
|
|
643
|
-
name: 'Main',
|
|
644
|
-
entries: [
|
|
645
|
-
toProjectPath(
|
|
646
|
-
path.join(appRoot, 'app'),
|
|
647
|
-
path.join(appRoot, 'app', 'target.js'),
|
|
648
|
-
),
|
|
649
|
-
],
|
|
650
|
-
optionsRef,
|
|
651
|
-
shouldBuildLazily: false,
|
|
652
|
-
lazyIncludes: [],
|
|
653
|
-
lazyExcludes: [],
|
|
654
|
-
requestedAssetIds: new Set(),
|
|
655
|
-
}),
|
|
656
|
-
);
|
|
657
|
-
assert.equal(getAssetRequests().length, 2);
|
|
658
|
-
assert.equal(
|
|
659
|
-
assetGraphRequestResult.assetGraph.safeToIncrementallyBundle,
|
|
660
|
-
false,
|
|
661
|
-
);
|
|
662
|
-
|
|
663
|
-
// Now make another change
|
|
664
|
-
tracker.respondToFSEvents(
|
|
665
|
-
[
|
|
666
|
-
{
|
|
667
|
-
type: 'update',
|
|
668
|
-
path: path.join(appRoot, 'app', 'target.js'),
|
|
669
|
-
},
|
|
670
|
-
{
|
|
671
|
-
type: 'update',
|
|
672
|
-
path: path.join(appRoot, 'app', 'dep.js'),
|
|
673
|
-
},
|
|
674
|
-
],
|
|
675
|
-
Number.MAX_VALUE,
|
|
676
|
-
);
|
|
677
|
-
// And run the build again
|
|
678
|
-
|
|
679
|
-
if (!incrementalBundlingVersioning) {
|
|
680
|
-
await assert.rejects(async () => {
|
|
681
|
-
await tracker.runRequest(
|
|
682
|
-
createAtlaspackBuildRequest({
|
|
683
|
-
optionsRef,
|
|
684
|
-
requestedAssetIds: new Set(),
|
|
685
|
-
}),
|
|
686
|
-
);
|
|
687
|
-
});
|
|
688
|
-
} else {
|
|
689
|
-
await tracker.runRequest(
|
|
690
|
-
createAtlaspackBuildRequest({
|
|
691
|
-
optionsRef,
|
|
692
|
-
requestedAssetIds: new Set(),
|
|
693
|
-
}),
|
|
694
|
-
);
|
|
695
|
-
}
|
|
696
|
-
}
|
|
697
|
-
|
|
698
|
-
it('throws a content key not found exception without bundling versioning', async () => {
|
|
699
|
-
await runIncrementalBundlingScenario(false);
|
|
700
|
-
});
|
|
701
|
-
|
|
702
|
-
it('works fine with bundling versioning', async () => {
|
|
703
|
-
await runIncrementalBundlingScenario(true);
|
|
704
|
-
});
|
|
705
|
-
});
|
|
706
541
|
});
|
|
707
542
|
|
|
708
543
|
describe('cleanUpOrphans', () => {
|
|
@@ -122,6 +122,7 @@ describe('TargetResolver', () => {
|
|
|
122
122
|
{
|
|
123
123
|
name: 'customA',
|
|
124
124
|
publicUrl: '/',
|
|
125
|
+
inlineRequires: false,
|
|
125
126
|
distDir: normalizeSeparators(path.resolve('customA')),
|
|
126
127
|
env: createEnvironment({
|
|
127
128
|
context: 'browser',
|
|
@@ -142,6 +143,7 @@ describe('TargetResolver', () => {
|
|
|
142
143
|
{
|
|
143
144
|
name: 'customB',
|
|
144
145
|
publicUrl: '/',
|
|
146
|
+
inlineRequires: false,
|
|
145
147
|
distEntry: 'b.js',
|
|
146
148
|
distDir: normalizeSeparators(path.resolve('customB')),
|
|
147
149
|
env: createEnvironment({
|
|
@@ -175,6 +177,7 @@ describe('TargetResolver', () => {
|
|
|
175
177
|
distDir: 'fixtures/common-targets/dist/main',
|
|
176
178
|
distEntry: 'index.js',
|
|
177
179
|
publicUrl: '/',
|
|
180
|
+
inlineRequires: false,
|
|
178
181
|
env: createEnvironment({
|
|
179
182
|
context: 'node',
|
|
180
183
|
engines: {
|
|
@@ -209,6 +212,7 @@ describe('TargetResolver', () => {
|
|
|
209
212
|
distDir: 'fixtures/common-targets/dist/module',
|
|
210
213
|
distEntry: 'index.js',
|
|
211
214
|
publicUrl: '/',
|
|
215
|
+
inlineRequires: false,
|
|
212
216
|
env: createEnvironment({
|
|
213
217
|
context: 'browser',
|
|
214
218
|
engines: {
|
|
@@ -245,6 +249,7 @@ describe('TargetResolver', () => {
|
|
|
245
249
|
distDir: 'fixtures/common-targets/dist/browser',
|
|
246
250
|
distEntry: 'index.js',
|
|
247
251
|
publicUrl: '/assets',
|
|
252
|
+
inlineRequires: false,
|
|
248
253
|
env: createEnvironment({
|
|
249
254
|
context: 'browser',
|
|
250
255
|
engines: {
|
|
@@ -291,6 +296,7 @@ describe('TargetResolver', () => {
|
|
|
291
296
|
),
|
|
292
297
|
distEntry: 'index.js',
|
|
293
298
|
publicUrl: '/',
|
|
299
|
+
inlineRequires: false,
|
|
294
300
|
env: createEnvironment({
|
|
295
301
|
context: 'node',
|
|
296
302
|
engines: {
|
|
@@ -334,6 +340,7 @@ describe('TargetResolver', () => {
|
|
|
334
340
|
distDir: 'fixtures/custom-targets/dist/main',
|
|
335
341
|
distEntry: 'index.js',
|
|
336
342
|
publicUrl: '/',
|
|
343
|
+
inlineRequires: false,
|
|
337
344
|
env: createEnvironment({
|
|
338
345
|
context: 'node',
|
|
339
346
|
engines: {
|
|
@@ -368,6 +375,7 @@ describe('TargetResolver', () => {
|
|
|
368
375
|
distDir: 'fixtures/custom-targets/dist/browserModern',
|
|
369
376
|
distEntry: 'index.js',
|
|
370
377
|
publicUrl: '/',
|
|
378
|
+
inlineRequires: false,
|
|
371
379
|
env: createEnvironment({
|
|
372
380
|
context: 'browser',
|
|
373
381
|
engines: {
|
|
@@ -405,6 +413,7 @@ describe('TargetResolver', () => {
|
|
|
405
413
|
distDir: 'fixtures/custom-targets/dist/browserLegacy',
|
|
406
414
|
distEntry: 'index.js',
|
|
407
415
|
publicUrl: '/',
|
|
416
|
+
inlineRequires: false,
|
|
408
417
|
env: createEnvironment({
|
|
409
418
|
context: 'browser',
|
|
410
419
|
engines: {
|
|
@@ -459,6 +468,7 @@ describe('TargetResolver', () => {
|
|
|
459
468
|
distDir: 'fixtures/custom-targets/dist/main',
|
|
460
469
|
distEntry: 'index.js',
|
|
461
470
|
publicUrl: '/',
|
|
471
|
+
inlineRequires: false,
|
|
462
472
|
env: createEnvironment({
|
|
463
473
|
context: 'node',
|
|
464
474
|
engines: {
|
|
@@ -493,6 +503,7 @@ describe('TargetResolver', () => {
|
|
|
493
503
|
distDir: 'fixtures/custom-targets/dist/browserModern',
|
|
494
504
|
distEntry: 'index.js',
|
|
495
505
|
publicUrl: '/',
|
|
506
|
+
inlineRequires: false,
|
|
496
507
|
env: createEnvironment({
|
|
497
508
|
context: 'browser',
|
|
498
509
|
engines: {
|
|
@@ -530,6 +541,7 @@ describe('TargetResolver', () => {
|
|
|
530
541
|
distDir: 'fixtures/custom-targets/dist/browserLegacy',
|
|
531
542
|
distEntry: 'index.js',
|
|
532
543
|
publicUrl: '/',
|
|
544
|
+
inlineRequires: false,
|
|
533
545
|
env: createEnvironment({
|
|
534
546
|
context: 'browser',
|
|
535
547
|
engines: {
|
|
@@ -576,6 +588,7 @@ describe('TargetResolver', () => {
|
|
|
576
588
|
distDir: 'fixtures/custom-targets-distdir/www',
|
|
577
589
|
distEntry: undefined,
|
|
578
590
|
publicUrl: 'www',
|
|
591
|
+
inlineRequires: false,
|
|
579
592
|
env: createEnvironment({
|
|
580
593
|
context: 'browser',
|
|
581
594
|
engines: {
|
|
@@ -631,6 +644,7 @@ describe('TargetResolver', () => {
|
|
|
631
644
|
name: 'customB',
|
|
632
645
|
distDir: normalizeSeparators(path.resolve('customB')),
|
|
633
646
|
publicUrl: '/',
|
|
647
|
+
inlineRequires: false,
|
|
634
648
|
env: createEnvironment({
|
|
635
649
|
context: 'browser',
|
|
636
650
|
engines: {
|
|
@@ -673,6 +687,7 @@ describe('TargetResolver', () => {
|
|
|
673
687
|
name: 'customA',
|
|
674
688
|
distDir: normalizeSeparators(path.resolve('customA')),
|
|
675
689
|
publicUrl: '/',
|
|
690
|
+
inlineRequires: false,
|
|
676
691
|
env: createEnvironment({
|
|
677
692
|
context: 'browser',
|
|
678
693
|
engines: {
|
|
@@ -702,6 +717,7 @@ describe('TargetResolver', () => {
|
|
|
702
717
|
distDir: 'fixtures/context/dist/main',
|
|
703
718
|
distEntry: 'index.js',
|
|
704
719
|
publicUrl: '/',
|
|
720
|
+
inlineRequires: false,
|
|
705
721
|
env: createEnvironment({
|
|
706
722
|
context: 'node',
|
|
707
723
|
engines: {
|
|
@@ -1073,6 +1089,7 @@ describe('TargetResolver', () => {
|
|
|
1073
1089
|
distDir: relative(path.join(fixture, 'dist')),
|
|
1074
1090
|
distEntry: 'index.mjs',
|
|
1075
1091
|
publicUrl: '/',
|
|
1092
|
+
inlineRequires: false,
|
|
1076
1093
|
env: createEnvironment({
|
|
1077
1094
|
context: 'browser',
|
|
1078
1095
|
engines: {
|
|
@@ -1118,6 +1135,7 @@ describe('TargetResolver', () => {
|
|
|
1118
1135
|
distDir: relative(path.join(fixture, 'dist')),
|
|
1119
1136
|
distEntry: 'index.js',
|
|
1120
1137
|
publicUrl: '/',
|
|
1138
|
+
inlineRequires: false,
|
|
1121
1139
|
env: createEnvironment({
|
|
1122
1140
|
context: 'browser',
|
|
1123
1141
|
engines: {
|
|
@@ -1167,6 +1185,7 @@ describe('TargetResolver', () => {
|
|
|
1167
1185
|
distDir: 'fixtures/common-targets/dist/main',
|
|
1168
1186
|
distEntry: 'index.js',
|
|
1169
1187
|
publicUrl: '/',
|
|
1188
|
+
inlineRequires: false,
|
|
1170
1189
|
env: createEnvironment({
|
|
1171
1190
|
context: 'node',
|
|
1172
1191
|
engines: {
|
|
@@ -1201,6 +1220,7 @@ describe('TargetResolver', () => {
|
|
|
1201
1220
|
distDir: 'fixtures/common-targets/dist/browser',
|
|
1202
1221
|
distEntry: 'index.js',
|
|
1203
1222
|
publicUrl: '/assets',
|
|
1223
|
+
inlineRequires: false,
|
|
1204
1224
|
env: createEnvironment({
|
|
1205
1225
|
context: 'browser',
|
|
1206
1226
|
engines: {
|
|
@@ -1249,6 +1269,7 @@ describe('TargetResolver', () => {
|
|
|
1249
1269
|
name: 'default',
|
|
1250
1270
|
distDir: serveDistDir,
|
|
1251
1271
|
publicUrl: '/',
|
|
1272
|
+
inlineRequires: false,
|
|
1252
1273
|
env: createEnvironment({
|
|
1253
1274
|
context: 'browser',
|
|
1254
1275
|
engines: {
|
|
@@ -1286,6 +1307,7 @@ describe('TargetResolver', () => {
|
|
|
1286
1307
|
path.join(DEFAULT_DISTPATH_FIXTURE_PATHS.none, 'dist'),
|
|
1287
1308
|
),
|
|
1288
1309
|
publicUrl: '/',
|
|
1310
|
+
inlineRequires: false,
|
|
1289
1311
|
env: createEnvironment({
|
|
1290
1312
|
context: 'browser',
|
|
1291
1313
|
engines: {
|
|
@@ -1319,6 +1341,7 @@ describe('TargetResolver', () => {
|
|
|
1319
1341
|
),
|
|
1320
1342
|
distEntry: undefined,
|
|
1321
1343
|
publicUrl: '/',
|
|
1344
|
+
inlineRequires: false,
|
|
1322
1345
|
env: createEnvironment({
|
|
1323
1346
|
context: 'browser',
|
|
1324
1347
|
engines: {
|
|
@@ -1369,6 +1392,7 @@ describe('TargetResolver', () => {
|
|
|
1369
1392
|
),
|
|
1370
1393
|
distEntry: undefined,
|
|
1371
1394
|
publicUrl: '/',
|
|
1395
|
+
inlineRequires: false,
|
|
1372
1396
|
env: createEnvironment({
|
|
1373
1397
|
context: 'browser',
|
|
1374
1398
|
engines: {
|
|
@@ -1409,6 +1433,7 @@ describe('TargetResolver', () => {
|
|
|
1409
1433
|
),
|
|
1410
1434
|
distEntry: undefined,
|
|
1411
1435
|
publicUrl: '/',
|
|
1436
|
+
inlineRequires: false,
|
|
1412
1437
|
env: createEnvironment({
|
|
1413
1438
|
context: 'browser',
|
|
1414
1439
|
engines: {
|