@atlaspack/packager-js 2.14.5-canary.202 → 2.14.5-canary.204
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/dist/ESMOutputFormat.js +1 -1
- package/dist/ScopeHoistingPackager.js +53 -59
- package/lib/ESMOutputFormat.js +1 -1
- package/lib/ScopeHoistingPackager.js +49 -68
- package/lib/types/ScopeHoistingPackager.d.ts +6 -8
- package/package.json +8 -8
- package/src/ESMOutputFormat.ts +1 -1
- package/src/ScopeHoistingPackager.ts +65 -83
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -97,13 +97,13 @@ const OUTPUT_FORMATS = {
|
|
|
97
97
|
global: _GlobalOutputFormat.GlobalOutputFormat
|
|
98
98
|
};
|
|
99
99
|
class ScopeHoistingPackager {
|
|
100
|
-
|
|
101
|
-
|
|
100
|
+
assetOutputs = new Map();
|
|
102
101
|
exportedSymbols = new Map();
|
|
103
102
|
externals = new Map();
|
|
104
103
|
topLevelNames = new Map();
|
|
105
104
|
seenAssets = new Set();
|
|
106
105
|
wrappedAssets = new Set();
|
|
106
|
+
constantAssets = new Set();
|
|
107
107
|
hoistedRequires = new Map();
|
|
108
108
|
seenHoistedRequires = new Set();
|
|
109
109
|
needsPrelude = false;
|
|
@@ -124,10 +124,7 @@ class ScopeHoistingPackager {
|
|
|
124
124
|
}
|
|
125
125
|
async package() {
|
|
126
126
|
var _sourceMap;
|
|
127
|
-
|
|
128
|
-
wrapped: wrappedAssets,
|
|
129
|
-
constant: constantAssets
|
|
130
|
-
} = await this.loadAssets();
|
|
127
|
+
await this.loadAssets();
|
|
131
128
|
this.buildExportedSymbols();
|
|
132
129
|
|
|
133
130
|
// If building a library, the target is actually another bundler rather
|
|
@@ -144,14 +141,12 @@ class ScopeHoistingPackager {
|
|
|
144
141
|
}
|
|
145
142
|
let res = '';
|
|
146
143
|
let lineCount = 0;
|
|
147
|
-
// @ts-expect-error TS7034
|
|
148
144
|
let sourceMap = null;
|
|
149
145
|
let processAsset = asset => {
|
|
150
146
|
this.seenHoistedRequires.clear();
|
|
151
147
|
let [content, map, lines] = this.visitAsset(asset);
|
|
152
|
-
|
|
153
|
-
// @ts-expect-error TS7005
|
|
154
148
|
if (sourceMap && map) {
|
|
149
|
+
// @ts-expect-error TS2551 - addSourceMap method exists but missing from @parcel/source-map type definitions
|
|
155
150
|
sourceMap.addSourceMap(map, lineCount);
|
|
156
151
|
} else if (this.bundle.env.sourceMap) {
|
|
157
152
|
sourceMap = map;
|
|
@@ -161,8 +156,8 @@ class ScopeHoistingPackager {
|
|
|
161
156
|
};
|
|
162
157
|
if ((0, _featureFlags().getFeatureFlag)('inlineConstOptimisationFix') || this.useBothScopeHoistingImprovements) {
|
|
163
158
|
// Write out all constant modules used by this bundle
|
|
164
|
-
for (let asset of constantAssets) {
|
|
165
|
-
if (!this.seenAssets.has(asset
|
|
159
|
+
for (let asset of this.constantAssets) {
|
|
160
|
+
if (!this.seenAssets.has(asset)) {
|
|
166
161
|
processAsset(asset);
|
|
167
162
|
}
|
|
168
163
|
}
|
|
@@ -170,8 +165,8 @@ class ScopeHoistingPackager {
|
|
|
170
165
|
|
|
171
166
|
// Hoist wrapped asset to the top of the bundle to ensure that they are registered
|
|
172
167
|
// before they are used.
|
|
173
|
-
for (let asset of wrappedAssets) {
|
|
174
|
-
if (!this.seenAssets.has(asset
|
|
168
|
+
for (let asset of this.wrappedAssets) {
|
|
169
|
+
if (!this.seenAssets.has(asset)) {
|
|
175
170
|
processAsset(asset);
|
|
176
171
|
}
|
|
177
172
|
}
|
|
@@ -179,7 +174,7 @@ class ScopeHoistingPackager {
|
|
|
179
174
|
// Add each asset that is directly connected to the bundle. Dependencies will be handled
|
|
180
175
|
// by replacing `import` statements in the code.
|
|
181
176
|
this.bundle.traverseAssets((asset, _, actions) => {
|
|
182
|
-
if (this.seenAssets.has(asset
|
|
177
|
+
if (this.seenAssets.has(asset)) {
|
|
183
178
|
actions.skipChildren();
|
|
184
179
|
return;
|
|
185
180
|
}
|
|
@@ -189,7 +184,7 @@ class ScopeHoistingPackager {
|
|
|
189
184
|
let [prelude, preludeLines] = this.buildBundlePrelude();
|
|
190
185
|
res = prelude + res;
|
|
191
186
|
lineCount += preludeLines;
|
|
192
|
-
// @ts-expect-error TS2339
|
|
187
|
+
// @ts-expect-error TS2339 - offsetLines method exists but missing from @parcel/source-map type definitions
|
|
193
188
|
(_sourceMap = sourceMap) === null || _sourceMap === void 0 || _sourceMap.offsetLines(1, preludeLines);
|
|
194
189
|
let entries = this.bundle.getEntryAssets();
|
|
195
190
|
let mainEntry = this.bundle.getMainEntry();
|
|
@@ -217,7 +212,7 @@ class ScopeHoistingPackager {
|
|
|
217
212
|
|
|
218
213
|
// If any of the entry assets are wrapped, call parcelRequire so they are executed.
|
|
219
214
|
for (let entry of entries) {
|
|
220
|
-
if (this.wrappedAssets.has(entry
|
|
215
|
+
if (this.wrappedAssets.has(entry) && !this.isScriptEntry(entry)) {
|
|
221
216
|
var _entry$symbols$get;
|
|
222
217
|
let parcelRequire = `parcelRequire(${JSON.stringify(this.bundleGraph.getAssetPublicId(entry))});\n`;
|
|
223
218
|
let entryExports = (_entry$symbols$get = entry.symbols.get('*')) === null || _entry$symbols$get === void 0 ? void 0 : _entry$symbols$get.local;
|
|
@@ -247,14 +242,14 @@ class ScopeHoistingPackager {
|
|
|
247
242
|
let {
|
|
248
243
|
code,
|
|
249
244
|
map: mapBuffer
|
|
250
|
-
} = (0, _nullthrows().default)(this.assetOutputs.get(mainEntry
|
|
245
|
+
} = (0, _nullthrows().default)(this.assetOutputs.get(mainEntry));
|
|
251
246
|
let map;
|
|
252
247
|
if (mapBuffer) {
|
|
253
248
|
map = new (_sourceMap2().default)(this.options.projectRoot, mapBuffer);
|
|
254
249
|
}
|
|
255
250
|
res += (0, _utils2.replaceScriptDependencies)(this.bundleGraph, this.bundle, code, map, this.parcelRequireName);
|
|
256
251
|
if (sourceMap && map) {
|
|
257
|
-
// @ts-expect-error TS2339
|
|
252
|
+
// @ts-expect-error TS2339 - addSourceMap method exists but missing from @parcel/source-map type definitions
|
|
258
253
|
sourceMap.addSourceMap(map, lineCount);
|
|
259
254
|
}
|
|
260
255
|
}
|
|
@@ -301,12 +296,10 @@ class ScopeHoistingPackager {
|
|
|
301
296
|
let queue = new (_utils().PromiseQueue)({
|
|
302
297
|
maxConcurrent: 32
|
|
303
298
|
});
|
|
304
|
-
let wrapped = [];
|
|
305
|
-
let constant = [];
|
|
306
299
|
this.bundle.traverseAssets(asset => {
|
|
307
300
|
queue.add(async () => {
|
|
308
301
|
let [code, map] = await Promise.all([asset.getCode(), this.bundle.env.sourceMap ? asset.getMapBuffer() : null]);
|
|
309
|
-
return [asset
|
|
302
|
+
return [asset, {
|
|
310
303
|
code,
|
|
311
304
|
map
|
|
312
305
|
}];
|
|
@@ -314,10 +307,9 @@ class ScopeHoistingPackager {
|
|
|
314
307
|
if (asset.meta.shouldWrap || this.bundle.env.sourceType === 'script' || this.bundleGraph.isAssetReferenced(this.bundle, asset) || this.bundleGraph.getIncomingDependencies(asset).some(dep => dep.meta.shouldWrap && dep.specifierType !== 'url')) {
|
|
315
308
|
// Don't wrap constant "entry" modules _except_ if they are referenced by any lazy dependency
|
|
316
309
|
if (!asset.meta.isConstantModule || this.bundleGraph.getIncomingDependencies(asset).some(dep => dep.priority === 'lazy')) {
|
|
317
|
-
this.wrappedAssets.add(asset
|
|
318
|
-
wrapped.push(asset);
|
|
310
|
+
this.wrappedAssets.add(asset);
|
|
319
311
|
} else if (((0, _featureFlags().getFeatureFlag)('inlineConstOptimisationFix') || this.useBothScopeHoistingImprovements) && asset.meta.isConstantModule) {
|
|
320
|
-
|
|
312
|
+
this.constantAssets.add(asset);
|
|
321
313
|
}
|
|
322
314
|
}
|
|
323
315
|
});
|
|
@@ -330,18 +322,20 @@ class ScopeHoistingPackager {
|
|
|
330
322
|
if (!(0, _featureFlags().getFeatureFlag)('applyScopeHoistingImprovementV2')) {
|
|
331
323
|
// Make all entry assets wrapped, to avoid any top level hoisting
|
|
332
324
|
for (let entryAsset of this.bundle.getEntryAssets()) {
|
|
333
|
-
if (!this.wrappedAssets.has(entryAsset
|
|
334
|
-
this.wrappedAssets.add(entryAsset
|
|
335
|
-
wrapped.push(entryAsset);
|
|
325
|
+
if (!this.wrappedAssets.has(entryAsset)) {
|
|
326
|
+
this.wrappedAssets.add(entryAsset);
|
|
336
327
|
}
|
|
337
328
|
}
|
|
338
329
|
}
|
|
339
|
-
|
|
330
|
+
|
|
331
|
+
// We need to make a new copy here so that we can add to the list and
|
|
332
|
+
// iterate the newly added items, without mutating the wrappedAssets set
|
|
333
|
+
let moduleGroupParents = [...this.wrappedAssets.values()];
|
|
340
334
|
if ((0, _featureFlags().getFeatureFlag)('applyScopeHoistingImprovementV2')) {
|
|
341
335
|
// The main entry needs to be check to find assets that would have gone in
|
|
342
336
|
// the top level scope
|
|
343
337
|
let mainEntry = this.bundle.getMainEntry();
|
|
344
|
-
if (mainEntry && !this.wrappedAssets.has(mainEntry
|
|
338
|
+
if (mainEntry && !this.wrappedAssets.has(mainEntry)) {
|
|
345
339
|
moduleGroupParents.unshift(mainEntry);
|
|
346
340
|
}
|
|
347
341
|
}
|
|
@@ -350,13 +344,12 @@ class ScopeHoistingPackager {
|
|
|
350
344
|
if (asset === moduleGroupParentAsset) {
|
|
351
345
|
return;
|
|
352
346
|
}
|
|
353
|
-
if (this.wrappedAssets.has(asset
|
|
347
|
+
if (this.wrappedAssets.has(asset)) {
|
|
354
348
|
actions.skipChildren();
|
|
355
349
|
return;
|
|
356
350
|
}
|
|
357
351
|
if (!asset.meta.isConstantModule && (assignedAssets.has(asset) || this.isReExported(asset))) {
|
|
358
|
-
|
|
359
|
-
this.wrappedAssets.add(asset.id);
|
|
352
|
+
this.wrappedAssets.add(asset);
|
|
360
353
|
|
|
361
354
|
// This also needs to be added to the traversal so that we iterate
|
|
362
355
|
// it during this check.
|
|
@@ -368,29 +361,22 @@ class ScopeHoistingPackager {
|
|
|
368
361
|
}, moduleGroupParentAsset);
|
|
369
362
|
}
|
|
370
363
|
} else {
|
|
371
|
-
for (let wrappedAssetRoot of
|
|
364
|
+
for (let wrappedAssetRoot of this.wrappedAssets) {
|
|
372
365
|
this.bundle.traverseAssets((asset, _, actions) => {
|
|
373
366
|
if (asset === wrappedAssetRoot) {
|
|
374
367
|
return;
|
|
375
368
|
}
|
|
376
|
-
if (this.wrappedAssets.has(asset
|
|
369
|
+
if (this.wrappedAssets.has(asset)) {
|
|
377
370
|
actions.skipChildren();
|
|
378
371
|
return;
|
|
379
372
|
}
|
|
380
373
|
if (!asset.meta.isConstantModule) {
|
|
381
|
-
this.wrappedAssets.add(asset
|
|
382
|
-
wrapped.push(asset);
|
|
374
|
+
this.wrappedAssets.add(asset);
|
|
383
375
|
}
|
|
384
376
|
}, wrappedAssetRoot);
|
|
385
377
|
}
|
|
386
378
|
}
|
|
387
|
-
|
|
388
|
-
// @ts-expect-error TS2769
|
|
389
379
|
this.assetOutputs = new Map(await queue.run());
|
|
390
|
-
return {
|
|
391
|
-
wrapped,
|
|
392
|
-
constant
|
|
393
|
-
};
|
|
394
380
|
}
|
|
395
381
|
isReExported(asset) {
|
|
396
382
|
let parentSymbols = this.bundleGraph.getIncomingDependencies(asset).map(dep => this.bundleGraph.getAssetWithDependency(dep)).flatMap(parent => {
|
|
@@ -409,7 +395,7 @@ class ScopeHoistingPackager {
|
|
|
409
395
|
|
|
410
396
|
// TODO: handle ESM exports of wrapped entry assets...
|
|
411
397
|
let entry = this.bundle.getMainEntry();
|
|
412
|
-
if (entry && !this.wrappedAssets.has(entry
|
|
398
|
+
if (entry && !this.wrappedAssets.has(entry)) {
|
|
413
399
|
let hasNamespace = entry.symbols.hasExportSymbol('*');
|
|
414
400
|
for (let {
|
|
415
401
|
asset,
|
|
@@ -478,19 +464,19 @@ class ScopeHoistingPackager {
|
|
|
478
464
|
return `${obj}[${JSON.stringify(property)}]`;
|
|
479
465
|
}
|
|
480
466
|
visitAsset(asset) {
|
|
481
|
-
(0, _assert().default)(!this.seenAssets.has(asset
|
|
482
|
-
this.seenAssets.add(asset
|
|
467
|
+
(0, _assert().default)(!this.seenAssets.has(asset), 'Already visited asset');
|
|
468
|
+
this.seenAssets.add(asset);
|
|
483
469
|
let {
|
|
484
470
|
code,
|
|
485
471
|
map
|
|
486
|
-
} = (0, _nullthrows().default)(this.assetOutputs.get(asset
|
|
472
|
+
} = (0, _nullthrows().default)(this.assetOutputs.get(asset));
|
|
487
473
|
return this.buildAsset(asset, code, map);
|
|
488
474
|
}
|
|
489
475
|
getAssetFilePath(asset) {
|
|
490
476
|
return _path().default.relative(this.options.projectRoot, asset.filePath);
|
|
491
477
|
}
|
|
492
478
|
buildAsset(asset, code, map) {
|
|
493
|
-
let shouldWrap = this.wrappedAssets.has(asset
|
|
479
|
+
let shouldWrap = this.wrappedAssets.has(asset);
|
|
494
480
|
let deps = this.bundleGraph.getDependencies(asset);
|
|
495
481
|
let sourceMap = this.bundle.env.sourceMap && map ? new (_sourceMap2().default)(this.options.projectRoot, map) : null;
|
|
496
482
|
|
|
@@ -510,11 +496,11 @@ class ScopeHoistingPackager {
|
|
|
510
496
|
}
|
|
511
497
|
continue;
|
|
512
498
|
}
|
|
513
|
-
if (this.bundle.hasAsset(resolved) && !this.seenAssets.has(resolved
|
|
499
|
+
if (this.bundle.hasAsset(resolved) && !this.seenAssets.has(resolved)) {
|
|
514
500
|
let [code, map, lines] = this.visitAsset(resolved);
|
|
515
501
|
depCode += code + '\n';
|
|
516
502
|
if (sourceMap && map) {
|
|
517
|
-
// @ts-expect-error TS2551
|
|
503
|
+
// @ts-expect-error TS2551 - addSourceMap method exists but missing from @parcel/source-map type definitions
|
|
518
504
|
sourceMap.addSourceMap(map, lineCount);
|
|
519
505
|
}
|
|
520
506
|
lineCount += lines + 1;
|
|
@@ -540,7 +526,6 @@ class ScopeHoistingPackager {
|
|
|
540
526
|
}
|
|
541
527
|
code += append;
|
|
542
528
|
let lineCount = 0;
|
|
543
|
-
// @ts-expect-error TS2552
|
|
544
529
|
let depContent = [];
|
|
545
530
|
if (depMap.size === 0 && replacements.size === 0) {
|
|
546
531
|
// If there are no dependencies or replacements, use a simple function to count the number of lines.
|
|
@@ -584,13 +569,13 @@ class ScopeHoistingPackager {
|
|
|
584
569
|
if (!(0, _featureFlags().getFeatureFlag)('applyScopeHoistingImprovementV2')) {
|
|
585
570
|
[res, lines] = this.getHoistedParcelRequires(asset, dep, resolved);
|
|
586
571
|
}
|
|
587
|
-
if (this.bundle.hasAsset(resolved) && !this.seenAssets.has(resolved
|
|
572
|
+
if (this.bundle.hasAsset(resolved) && !this.seenAssets.has(resolved)) {
|
|
588
573
|
// If this asset is wrapped, we need to hoist the code for the dependency
|
|
589
574
|
// outside our parcelRequire.register wrapper. This is safe because all
|
|
590
575
|
// assets referenced by this asset will also be wrapped. Otherwise, inline the
|
|
591
576
|
// asset content where the import statement was.
|
|
592
577
|
if (this.useBothScopeHoistingImprovements) {
|
|
593
|
-
if (!resolved.meta.isConstantModule && !this.wrappedAssets.has(resolved
|
|
578
|
+
if (!resolved.meta.isConstantModule && !this.wrappedAssets.has(resolved)) {
|
|
594
579
|
let [depCode, depMap, depLines] = this.visitAsset(resolved);
|
|
595
580
|
if (_utils().debugTools['asset-file-names-in-output']) {
|
|
596
581
|
let resolvedPath = this.getAssetFilePath(resolved);
|
|
@@ -633,7 +618,7 @@ class ScopeHoistingPackager {
|
|
|
633
618
|
sourceMap.offsetLines(lineCount + 1, lines);
|
|
634
619
|
}
|
|
635
620
|
if (map) {
|
|
636
|
-
// @ts-expect-error TS2551
|
|
621
|
+
// @ts-expect-error TS2551 - addSourceMap method exists but missing from @parcel/source-map type definitions
|
|
637
622
|
sourceMap.addSourceMap(map, lineCount);
|
|
638
623
|
}
|
|
639
624
|
}
|
|
@@ -678,7 +663,7 @@ ${code}
|
|
|
678
663
|
if (!depCode) continue;
|
|
679
664
|
code += depCode + '\n';
|
|
680
665
|
if (sourceMap && map) {
|
|
681
|
-
// @ts-expect-error TS2551
|
|
666
|
+
// @ts-expect-error TS2551 - addSourceMap method exists but missing from @parcel/source-map type definitions
|
|
682
667
|
sourceMap.addSourceMap(map, lineCount);
|
|
683
668
|
}
|
|
684
669
|
lineCount += lines + 1;
|
|
@@ -747,7 +732,7 @@ ${code}
|
|
|
747
732
|
|
|
748
733
|
// If this asset is wrapped, we need to replace the exports namespace with `module.exports`,
|
|
749
734
|
// which will be provided to us by the wrapper.
|
|
750
|
-
if (this.wrappedAssets.has(asset
|
|
735
|
+
if (this.wrappedAssets.has(asset) || this.bundle.env.outputFormat === 'commonjs' && asset === this.bundle.getMainEntry()) {
|
|
751
736
|
var _asset$symbols$get;
|
|
752
737
|
let exportsName = ((_asset$symbols$get = asset.symbols.get('*')) === null || _asset$symbols$get === void 0 ? void 0 : _asset$symbols$get.local) || `$${assetId}$exports`;
|
|
753
738
|
replacements.set(exportsName, 'module.exports');
|
|
@@ -845,9 +830,7 @@ ${code}
|
|
|
845
830
|
continue;
|
|
846
831
|
}
|
|
847
832
|
}
|
|
848
|
-
|
|
849
|
-
// @ts-expect-error TS2322
|
|
850
|
-
renamed = this.bundleGraph.getSymbolResolution(entry, imported, this.bundle).symbol;
|
|
833
|
+
renamed = this.bundleGraph.getSymbolResolution(entry, imported, this.bundle).symbol || undefined;
|
|
851
834
|
}
|
|
852
835
|
}
|
|
853
836
|
|
|
@@ -888,7 +871,7 @@ ${code}
|
|
|
888
871
|
}
|
|
889
872
|
return false;
|
|
890
873
|
}
|
|
891
|
-
return !this.bundle.hasAsset(resolved) && !this.externalAssets.has(resolved) || this.wrappedAssets.has(resolved
|
|
874
|
+
return !this.bundle.hasAsset(resolved) && !this.externalAssets.has(resolved) || this.wrappedAssets.has(resolved) && resolved !== parentAsset;
|
|
892
875
|
}
|
|
893
876
|
getSymbolResolution(parentAsset, resolved, imported, dep, replacements) {
|
|
894
877
|
let {
|
|
@@ -915,12 +898,12 @@ ${code}
|
|
|
915
898
|
// Only do this if the asset is part of a different bundle (so it was definitely
|
|
916
899
|
// parcelRequire.register'ed there), or if it is indeed registered in this bundle.
|
|
917
900
|
!this.bundle.hasAsset(resolvedAsset) || !this.shouldSkipAsset(resolvedAsset))) {
|
|
918
|
-
let hoisted = this.hoistedRequires.get(dep
|
|
901
|
+
let hoisted = this.hoistedRequires.get(dep);
|
|
919
902
|
if (!hoisted) {
|
|
920
903
|
hoisted = new Map();
|
|
921
|
-
this.hoistedRequires.set(dep
|
|
904
|
+
this.hoistedRequires.set(dep, hoisted);
|
|
922
905
|
}
|
|
923
|
-
hoisted.set(resolvedAsset
|
|
906
|
+
hoisted.set(resolvedAsset, `var $${publicId} = parcelRequire(${JSON.stringify(publicId)});`);
|
|
924
907
|
}
|
|
925
908
|
if (isWrapped) {
|
|
926
909
|
this.needsPrelude = true;
|
|
@@ -949,7 +932,7 @@ ${code}
|
|
|
949
932
|
}
|
|
950
933
|
if (imported === '*' || exportSymbol === '*' || isDefaultInterop) {
|
|
951
934
|
// Resolve to the namespace object if requested or this is a CJS default interop reqiure.
|
|
952
|
-
if (parentAsset === resolvedAsset && this.wrappedAssets.has(resolvedAsset
|
|
935
|
+
if (parentAsset === resolvedAsset && this.wrappedAssets.has(resolvedAsset)) {
|
|
953
936
|
// Directly use module.exports for wrapped assets importing themselves.
|
|
954
937
|
return 'module.exports';
|
|
955
938
|
} else {
|
|
@@ -977,7 +960,7 @@ ${code}
|
|
|
977
960
|
if (resolved.type !== 'js') {
|
|
978
961
|
return ['', 0];
|
|
979
962
|
}
|
|
980
|
-
let hoisted = this.hoistedRequires.get(dep
|
|
963
|
+
let hoisted = this.hoistedRequires.get(dep);
|
|
981
964
|
let res = '';
|
|
982
965
|
let lineCount = 0;
|
|
983
966
|
let isWrapped = this.isWrapped(resolved, parentAsset);
|
|
@@ -986,7 +969,7 @@ ${code}
|
|
|
986
969
|
// we need to run side effects when this asset runs. If the resolved asset is not
|
|
987
970
|
// the first one in the hoisted requires, we need to insert a parcelRequire here
|
|
988
971
|
// so it runs first.
|
|
989
|
-
if (isWrapped && !dep.meta.shouldWrap && (!hoisted || hoisted.keys().next().value !== resolved
|
|
972
|
+
if (isWrapped && !dep.meta.shouldWrap && (!hoisted || hoisted.keys().next().value !== resolved) && !this.bundleGraph.isDependencySkipped(dep) && !this.shouldSkipAsset(resolved)) {
|
|
990
973
|
this.needsPrelude = true;
|
|
991
974
|
res += `parcelRequire(${JSON.stringify(this.bundleGraph.getAssetPublicId(resolved))});`;
|
|
992
975
|
}
|
|
@@ -1010,7 +993,7 @@ ${code}
|
|
|
1010
993
|
let prepend = '';
|
|
1011
994
|
let prependLineCount = 0;
|
|
1012
995
|
let append = '';
|
|
1013
|
-
let shouldWrap = this.wrappedAssets.has(asset
|
|
996
|
+
let shouldWrap = this.wrappedAssets.has(asset);
|
|
1014
997
|
let usedSymbols = (0, _nullthrows().default)(this.bundleGraph.getUsedSymbols(asset));
|
|
1015
998
|
let assetId = asset.meta.id;
|
|
1016
999
|
(0, _assert().default)(typeof assetId === 'string');
|
|
@@ -1188,10 +1171,8 @@ ${code}
|
|
|
1188
1171
|
this.usedHelpers.add('$parcel$global');
|
|
1189
1172
|
}
|
|
1190
1173
|
for (let helper of this.usedHelpers) {
|
|
1191
|
-
// @ts-expect-error TS7053
|
|
1192
1174
|
let currentHelper = _helpers.helpers[helper];
|
|
1193
1175
|
if (typeof currentHelper === 'function') {
|
|
1194
|
-
// @ts-expect-error TS7053
|
|
1195
1176
|
currentHelper = _helpers.helpers[helper](this.bundle.env);
|
|
1196
1177
|
}
|
|
1197
1178
|
res += currentHelper;
|
|
@@ -13,7 +13,7 @@ export declare class ScopeHoistingPackager {
|
|
|
13
13
|
outputFormat: OutputFormat;
|
|
14
14
|
isAsyncBundle: boolean;
|
|
15
15
|
globalNames: ReadonlySet<string>;
|
|
16
|
-
assetOutputs: Map<
|
|
16
|
+
assetOutputs: Map<Asset, {
|
|
17
17
|
code: string;
|
|
18
18
|
map: Buffer | null | undefined;
|
|
19
19
|
}>;
|
|
@@ -25,9 +25,10 @@ export declare class ScopeHoistingPackager {
|
|
|
25
25
|
}>;
|
|
26
26
|
externals: Map<string, Map<string, string>>;
|
|
27
27
|
topLevelNames: Map<string, number>;
|
|
28
|
-
seenAssets: Set<
|
|
29
|
-
wrappedAssets: Set<
|
|
30
|
-
|
|
28
|
+
seenAssets: Set<Asset>;
|
|
29
|
+
wrappedAssets: Set<Asset>;
|
|
30
|
+
constantAssets: Set<Asset>;
|
|
31
|
+
hoistedRequires: Map<Dependency, Map<Asset, string>>;
|
|
31
32
|
seenHoistedRequires: Set<string>;
|
|
32
33
|
needsPrelude: boolean;
|
|
33
34
|
usedHelpers: Set<string>;
|
|
@@ -41,10 +42,7 @@ export declare class ScopeHoistingPackager {
|
|
|
41
42
|
}>;
|
|
42
43
|
shouldBundleQueue(bundle: NamedBundle): boolean;
|
|
43
44
|
runWhenReady(bundle: NamedBundle, codeToRun: string): string;
|
|
44
|
-
loadAssets(): Promise<
|
|
45
|
-
wrapped: Array<Asset>;
|
|
46
|
-
constant: Array<Asset>;
|
|
47
|
-
}>;
|
|
45
|
+
loadAssets(): Promise<void>;
|
|
48
46
|
isReExported(asset: Asset): boolean;
|
|
49
47
|
buildExportedSymbols(): void;
|
|
50
48
|
getTopLevelName(name: string): string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaspack/packager-js",
|
|
3
|
-
"version": "2.14.5-canary.
|
|
3
|
+
"version": "2.14.5-canary.204+87fce0918",
|
|
4
4
|
"license": "(MIT OR Apache-2.0)",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -16,12 +16,12 @@
|
|
|
16
16
|
"node": ">= 16.0.0"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@atlaspack/diagnostic": "2.14.1-canary.
|
|
20
|
-
"@atlaspack/feature-flags": "2.14.1-canary.
|
|
21
|
-
"@atlaspack/plugin": "2.14.5-canary.
|
|
22
|
-
"@atlaspack/rust": "3.2.1-canary.
|
|
23
|
-
"@atlaspack/types": "2.14.5-canary.
|
|
24
|
-
"@atlaspack/utils": "2.14.5-canary.
|
|
19
|
+
"@atlaspack/diagnostic": "2.14.1-canary.272+87fce0918",
|
|
20
|
+
"@atlaspack/feature-flags": "2.14.1-canary.272+87fce0918",
|
|
21
|
+
"@atlaspack/plugin": "2.14.5-canary.204+87fce0918",
|
|
22
|
+
"@atlaspack/rust": "3.2.1-canary.204+87fce0918",
|
|
23
|
+
"@atlaspack/types": "2.14.5-canary.204+87fce0918",
|
|
24
|
+
"@atlaspack/utils": "2.14.5-canary.204+87fce0918",
|
|
25
25
|
"@parcel/source-map": "^2.1.1",
|
|
26
26
|
"globals": "^13.2.0",
|
|
27
27
|
"nullthrows": "^1.1.1",
|
|
@@ -31,5 +31,5 @@
|
|
|
31
31
|
"scripts": {
|
|
32
32
|
"build:lib": "gulp build --gulpfile ../../../gulpfile.js --cwd ."
|
|
33
33
|
},
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "87fce091862f100469b0c854f908598e84cd0ceb"
|
|
35
35
|
}
|
package/src/ESMOutputFormat.ts
CHANGED
|
@@ -83,7 +83,7 @@ export class ESMOutputFormat implements OutputFormat {
|
|
|
83
83
|
local,
|
|
84
84
|
exportAs,
|
|
85
85
|
} of this.packager.exportedSymbols.values()) {
|
|
86
|
-
if (this.packager.wrappedAssets.has(asset
|
|
86
|
+
if (this.packager.wrappedAssets.has(asset)) {
|
|
87
87
|
let obj = `parcelRequire("${this.packager.bundleGraph.getAssetPublicId(
|
|
88
88
|
asset,
|
|
89
89
|
)}")`;
|