@atlaspack/packager-js 2.12.1-dev.3450 → 2.12.1-dev.3466
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/package.json +9 -9
- package/src/DevPackager.js +4 -4
- package/src/ScopeHoistingPackager.js +20 -19
- package/src/index.js +1 -1
- package/src/utils.js +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaspack/packager-js",
|
|
3
|
-
"version": "2.12.1-dev.
|
|
3
|
+
"version": "2.12.1-dev.3466+9a12fb8bd",
|
|
4
4
|
"license": "(MIT OR Apache-2.0)",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -13,18 +13,18 @@
|
|
|
13
13
|
"source": "src/index.js",
|
|
14
14
|
"engines": {
|
|
15
15
|
"node": ">= 16.0.0",
|
|
16
|
-
"parcel": "^2.12.1-dev.
|
|
16
|
+
"parcel": "^2.12.1-dev.3466+9a12fb8bd"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@atlaspack/diagnostic": "2.12.1-dev.
|
|
20
|
-
"@atlaspack/feature-flags": "2.12.1-dev.
|
|
21
|
-
"@atlaspack/plugin": "2.12.1-dev.
|
|
22
|
-
"@atlaspack/rust": "2.12.1-dev.
|
|
23
|
-
"@atlaspack/types": "2.12.1-dev.
|
|
24
|
-
"@atlaspack/utils": "2.12.1-dev.
|
|
19
|
+
"@atlaspack/diagnostic": "2.12.1-dev.3466+9a12fb8bd",
|
|
20
|
+
"@atlaspack/feature-flags": "2.12.1-dev.3466+9a12fb8bd",
|
|
21
|
+
"@atlaspack/plugin": "2.12.1-dev.3466+9a12fb8bd",
|
|
22
|
+
"@atlaspack/rust": "2.12.1-dev.3466+9a12fb8bd",
|
|
23
|
+
"@atlaspack/types": "2.12.1-dev.3466+9a12fb8bd",
|
|
24
|
+
"@atlaspack/utils": "2.12.1-dev.3466+9a12fb8bd",
|
|
25
25
|
"@parcel/source-map": "^2.1.1",
|
|
26
26
|
"globals": "^13.2.0",
|
|
27
27
|
"nullthrows": "^1.1.1"
|
|
28
28
|
},
|
|
29
|
-
"gitHead": "
|
|
29
|
+
"gitHead": "9a12fb8bd1b72e407ed043e20337dc60fbec9cbe"
|
|
30
30
|
}
|
package/src/DevPackager.js
CHANGED
|
@@ -39,7 +39,7 @@ export class DevPackager {
|
|
|
39
39
|
async package(): Promise<{|contents: string, map: ?SourceMap|}> {
|
|
40
40
|
// Load assets
|
|
41
41
|
let queue = new PromiseQueue({maxConcurrent: 32});
|
|
42
|
-
this.bundle.traverseAssets(asset => {
|
|
42
|
+
this.bundle.traverseAssets((asset) => {
|
|
43
43
|
queue.add(async () => {
|
|
44
44
|
let [code, mapBuffer] = await Promise.all([
|
|
45
45
|
asset.getCode(),
|
|
@@ -60,7 +60,7 @@ export class DevPackager {
|
|
|
60
60
|
let lineOffset = countLines(prefix);
|
|
61
61
|
let script: ?{|code: string, mapBuffer: ?Buffer|} = null;
|
|
62
62
|
|
|
63
|
-
this.bundle.traverse(node => {
|
|
63
|
+
this.bundle.traverse((node) => {
|
|
64
64
|
let wrapped = first ? '' : ',';
|
|
65
65
|
|
|
66
66
|
if (node.type === 'dependency') {
|
|
@@ -166,7 +166,7 @@ export class DevPackager {
|
|
|
166
166
|
) {
|
|
167
167
|
// In async bundles we don't want the main entry to execute until we require it
|
|
168
168
|
// as there might be dependencies in a sibling bundle that hasn't loaded yet.
|
|
169
|
-
entries = entries.filter(a => a.id !== mainEntry?.id);
|
|
169
|
+
entries = entries.filter((a) => a.id !== mainEntry?.id);
|
|
170
170
|
mainEntry = null;
|
|
171
171
|
}
|
|
172
172
|
|
|
@@ -176,7 +176,7 @@ export class DevPackager {
|
|
|
176
176
|
assets +
|
|
177
177
|
'},' +
|
|
178
178
|
JSON.stringify(
|
|
179
|
-
entries.map(asset => this.bundleGraph.getAssetPublicId(asset)),
|
|
179
|
+
entries.map((asset) => this.bundleGraph.getAssetPublicId(asset)),
|
|
180
180
|
) +
|
|
181
181
|
', ' +
|
|
182
182
|
JSON.stringify(
|
|
@@ -156,7 +156,7 @@ export class ScopeHoistingPackager {
|
|
|
156
156
|
let res = '';
|
|
157
157
|
let lineCount = 0;
|
|
158
158
|
let sourceMap = null;
|
|
159
|
-
let processAsset = asset => {
|
|
159
|
+
let processAsset = (asset) => {
|
|
160
160
|
let [content, map, lines] = this.visitAsset(asset);
|
|
161
161
|
if (sourceMap && map) {
|
|
162
162
|
sourceMap.addSourceMap(map, lineCount);
|
|
@@ -198,7 +198,7 @@ export class ScopeHoistingPackager {
|
|
|
198
198
|
if (this.isAsyncBundle) {
|
|
199
199
|
// In async bundles we don't want the main entry to execute until we require it
|
|
200
200
|
// as there might be dependencies in a sibling bundle that hasn't loaded yet.
|
|
201
|
-
entries = entries.filter(a => a.id !== mainEntry?.id);
|
|
201
|
+
entries = entries.filter((a) => a.id !== mainEntry?.id);
|
|
202
202
|
mainEntry = null;
|
|
203
203
|
}
|
|
204
204
|
|
|
@@ -277,7 +277,7 @@ export class ScopeHoistingPackager {
|
|
|
277
277
|
|
|
278
278
|
shouldBundleQueue(bundle: NamedBundle): boolean {
|
|
279
279
|
let referencingBundles = this.bundleGraph.getReferencingBundles(bundle);
|
|
280
|
-
let hasHtmlReference = referencingBundles.some(b => b.type === 'html');
|
|
280
|
+
let hasHtmlReference = referencingBundles.some((b) => b.type === 'html');
|
|
281
281
|
|
|
282
282
|
return (
|
|
283
283
|
this.useAsyncBundleRuntime &&
|
|
@@ -293,8 +293,8 @@ export class ScopeHoistingPackager {
|
|
|
293
293
|
runWhenReady(bundle: NamedBundle, codeToRun: string): string {
|
|
294
294
|
let deps = this.bundleGraph
|
|
295
295
|
.getReferencedBundles(bundle)
|
|
296
|
-
.filter(b => this.shouldBundleQueue(b))
|
|
297
|
-
.map(b => b.publicId);
|
|
296
|
+
.filter((b) => this.shouldBundleQueue(b))
|
|
297
|
+
.map((b) => b.publicId);
|
|
298
298
|
|
|
299
299
|
if (deps.length === 0) {
|
|
300
300
|
// If no deps we can safely execute immediately
|
|
@@ -313,7 +313,7 @@ export class ScopeHoistingPackager {
|
|
|
313
313
|
async loadAssets(): Promise<Array<Asset>> {
|
|
314
314
|
let queue = new PromiseQueue({maxConcurrent: 32});
|
|
315
315
|
let wrapped = [];
|
|
316
|
-
this.bundle.traverseAssets(asset => {
|
|
316
|
+
this.bundle.traverseAssets((asset) => {
|
|
317
317
|
queue.add(async () => {
|
|
318
318
|
let [code, map] = await Promise.all([
|
|
319
319
|
asset.getCode(),
|
|
@@ -328,14 +328,14 @@ export class ScopeHoistingPackager {
|
|
|
328
328
|
this.bundleGraph.isAssetReferenced(this.bundle, asset) ||
|
|
329
329
|
this.bundleGraph
|
|
330
330
|
.getIncomingDependencies(asset)
|
|
331
|
-
.some(dep => dep.meta.shouldWrap && dep.specifierType !== 'url')
|
|
331
|
+
.some((dep) => dep.meta.shouldWrap && dep.specifierType !== 'url')
|
|
332
332
|
) {
|
|
333
333
|
// Don't wrap constant "entry" modules _except_ if they are referenced by any lazy dependency
|
|
334
334
|
if (
|
|
335
335
|
!asset.meta.isConstantModule ||
|
|
336
336
|
this.bundleGraph
|
|
337
337
|
.getIncomingDependencies(asset)
|
|
338
|
-
.some(dep => dep.priority === 'lazy')
|
|
338
|
+
.some((dep) => dep.priority === 'lazy')
|
|
339
339
|
) {
|
|
340
340
|
this.wrappedAssets.add(asset.id);
|
|
341
341
|
wrapped.push(asset);
|
|
@@ -361,7 +361,8 @@ export class ScopeHoistingPackager {
|
|
|
361
361
|
if (
|
|
362
362
|
this.forceSkipWrapAssets.length > 0 &&
|
|
363
363
|
this.forceSkipWrapAssets.some(
|
|
364
|
-
p =>
|
|
364
|
+
(p) =>
|
|
365
|
+
p === path.relative(this.options.projectRoot, asset.filePath),
|
|
365
366
|
)
|
|
366
367
|
) {
|
|
367
368
|
this.logger.verbose({
|
|
@@ -696,7 +697,7 @@ ${code}
|
|
|
696
697
|
if (
|
|
697
698
|
!shouldWrap &&
|
|
698
699
|
this.shouldBundleQueue(this.bundle) &&
|
|
699
|
-
this.bundle.getEntryAssets().some(entry => entry.id === asset.id)
|
|
700
|
+
this.bundle.getEntryAssets().some((entry) => entry.id === asset.id)
|
|
700
701
|
) {
|
|
701
702
|
code = this.runWhenReady(this.bundle, code);
|
|
702
703
|
}
|
|
@@ -1187,7 +1188,7 @@ ${code}
|
|
|
1187
1188
|
this.bundleGraph
|
|
1188
1189
|
.getIncomingDependencies(asset)
|
|
1189
1190
|
.some(
|
|
1190
|
-
dep =>
|
|
1191
|
+
(dep) =>
|
|
1191
1192
|
!dep.isEntry &&
|
|
1192
1193
|
this.bundle.hasDependency(dep) &&
|
|
1193
1194
|
nullthrows(this.bundleGraph.getUsedSymbols(dep)).has('*'),
|
|
@@ -1195,7 +1196,7 @@ ${code}
|
|
|
1195
1196
|
// If a symbol is imported (used) from a CJS asset but isn't listed in the symbols,
|
|
1196
1197
|
// we fallback on the namespace object.
|
|
1197
1198
|
(asset.symbols.hasExportSymbol('*') &&
|
|
1198
|
-
[...usedSymbols].some(s => !asset.symbols.hasExportSymbol(s))) ||
|
|
1199
|
+
[...usedSymbols].some((s) => !asset.symbols.hasExportSymbol(s))) ||
|
|
1199
1200
|
// If the exports has this asset's namespace (e.g. ESM output from CJS input),
|
|
1200
1201
|
// include the namespace object for the default export.
|
|
1201
1202
|
this.exportedSymbols.has(`$${assetId}$exports`) ||
|
|
@@ -1316,7 +1317,7 @@ ${code}
|
|
|
1316
1317
|
// incoming dependencies rather than the asset's own used exports so that we include
|
|
1317
1318
|
// re-exported symbols rather than only symbols declared in this asset.
|
|
1318
1319
|
let incomingDeps = this.bundleGraph.getIncomingDependencies(asset);
|
|
1319
|
-
let usedExports = [...asset.symbols.exportSymbols()].filter(symbol => {
|
|
1320
|
+
let usedExports = [...asset.symbols.exportSymbols()].filter((symbol) => {
|
|
1320
1321
|
if (symbol === '*') {
|
|
1321
1322
|
return false;
|
|
1322
1323
|
}
|
|
@@ -1327,7 +1328,7 @@ ${code}
|
|
|
1327
1328
|
return true;
|
|
1328
1329
|
}
|
|
1329
1330
|
|
|
1330
|
-
let unused = incomingDeps.every(d => {
|
|
1331
|
+
let unused = incomingDeps.every((d) => {
|
|
1331
1332
|
let symbols = nullthrows(this.bundleGraph.getUsedSymbols(d));
|
|
1332
1333
|
return !symbols.has(symbol) && !symbols.has('*');
|
|
1333
1334
|
});
|
|
@@ -1340,7 +1341,7 @@ ${code}
|
|
|
1340
1341
|
// required to simulate ESM live bindings. It's easier to do it this way rather than inserting
|
|
1341
1342
|
// additional assignments after each mutation of the original binding.
|
|
1342
1343
|
prepend += `\n${usedExports
|
|
1343
|
-
.map(exp => {
|
|
1344
|
+
.map((exp) => {
|
|
1344
1345
|
let resolved = this.getSymbolResolution(
|
|
1345
1346
|
asset,
|
|
1346
1347
|
asset,
|
|
@@ -1415,10 +1416,10 @@ ${code}
|
|
|
1415
1416
|
let parentBundles = this.bundleGraph.getParentBundles(this.bundle);
|
|
1416
1417
|
let mightBeFirstJS =
|
|
1417
1418
|
parentBundles.length === 0 ||
|
|
1418
|
-
parentBundles.some(b => b.type !== 'js') ||
|
|
1419
|
+
parentBundles.some((b) => b.type !== 'js') ||
|
|
1419
1420
|
this.bundleGraph
|
|
1420
1421
|
.getBundleGroupsContainingBundle(this.bundle)
|
|
1421
|
-
.some(g => this.bundleGraph.isEntryBundleGroup(g)) ||
|
|
1422
|
+
.some((g) => this.bundleGraph.isEntryBundleGroup(g)) ||
|
|
1422
1423
|
this.bundle.env.isIsolated() ||
|
|
1423
1424
|
this.bundle.bundleBehavior === 'isolated' ||
|
|
1424
1425
|
// Conditional deps may be loaded before entrypoints on the server
|
|
@@ -1515,10 +1516,10 @@ ${code}
|
|
|
1515
1516
|
|
|
1516
1517
|
return this.bundle
|
|
1517
1518
|
.getEntryAssets()
|
|
1518
|
-
.some(entry =>
|
|
1519
|
+
.some((entry) =>
|
|
1519
1520
|
this.bundleGraph
|
|
1520
1521
|
.getIncomingDependencies(entry)
|
|
1521
|
-
.some(dep => dep.priority === 'conditional'),
|
|
1522
|
+
.some((dep) => dep.priority === 'conditional'),
|
|
1522
1523
|
);
|
|
1523
1524
|
}
|
|
1524
1525
|
}
|
package/src/index.js
CHANGED
package/src/utils.js
CHANGED
|
@@ -26,7 +26,7 @@ export function replaceScriptDependencies(
|
|
|
26
26
|
return '\n';
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
let dep = nullthrows(dependencies.find(d => getSpecifier(d) === s));
|
|
29
|
+
let dep = nullthrows(dependencies.find((d) => getSpecifier(d) === s));
|
|
30
30
|
let resolved = nullthrows(bundleGraph.getResolvedAsset(dep, bundle));
|
|
31
31
|
let publicId = bundleGraph.getAssetPublicId(resolved);
|
|
32
32
|
let replacement = `${parcelRequireName}("${publicId}")`;
|