@atlaspack/packager-js 2.19.1 → 2.21.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 +32 -0
- package/lib/DevPackager.js +2 -2
- package/lib/ScopeHoistingPackager.js +13 -4
- package/package.json +10 -9
- package/src/DevPackager.ts +3 -2
- package/src/ScopeHoistingPackager.ts +19 -2
- /package/lib/{CJSOutputFormat.d.ts → types/CJSOutputFormat.d.ts} +0 -0
- /package/lib/{DevPackager.d.ts → types/DevPackager.d.ts} +0 -0
- /package/lib/{ESMOutputFormat.d.ts → types/ESMOutputFormat.d.ts} +0 -0
- /package/lib/{GlobalOutputFormat.d.ts → types/GlobalOutputFormat.d.ts} +0 -0
- /package/lib/{ScopeHoistingPackager.d.ts → types/ScopeHoistingPackager.d.ts} +0 -0
- /package/lib/{helpers.d.ts → types/helpers.d.ts} +0 -0
- /package/lib/{index.d.ts → types/index.d.ts} +0 -0
- /package/lib/{utils.d.ts → types/utils.d.ts} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,37 @@
|
|
|
1
1
|
# @atlaspack/packager-js
|
|
2
2
|
|
|
3
|
+
## 2.21.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#732](https://github.com/atlassian-labs/atlaspack/pull/732) [`7f5841c`](https://github.com/atlassian-labs/atlaspack/commit/7f5841c39df049f9546cccbeea2a7337e0337b45) Thanks [@vykimnguyen](https://github.com/vykimnguyen)! - add tesseract context
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- [#744](https://github.com/atlassian-labs/atlaspack/pull/744) [`3718bff`](https://github.com/atlassian-labs/atlaspack/commit/3718bff20484138e405e321472336ac058432e10) Thanks [@benjervis](https://github.com/benjervis)! - Fix the scope hoisting improvements feature by making all entry assets of a bundle
|
|
12
|
+
wrapped, which means there is no top level scope.
|
|
13
|
+
- Updated dependencies [[`ad26146`](https://github.com/atlassian-labs/atlaspack/commit/ad26146f13b4c1cc65d4a0f9c67060b90ef14ff3), [`f1b48e7`](https://github.com/atlassian-labs/atlaspack/commit/f1b48e7a04e005cef0f36a3e692087a9ecdb6f7a), [`7f5841c`](https://github.com/atlassian-labs/atlaspack/commit/7f5841c39df049f9546cccbeea2a7337e0337b45), [`73dd7ba`](https://github.com/atlassian-labs/atlaspack/commit/73dd7baab69456ef2f6e4a0cc7dbb04f407eb148)]:
|
|
14
|
+
- @atlaspack/rust@3.6.0
|
|
15
|
+
- @atlaspack/feature-flags@2.22.0
|
|
16
|
+
- @atlaspack/utils@2.18.1
|
|
17
|
+
- @atlaspack/plugin@2.14.24
|
|
18
|
+
- @atlaspack/types@2.15.14
|
|
19
|
+
|
|
20
|
+
## 2.20.0
|
|
21
|
+
|
|
22
|
+
### Minor Changes
|
|
23
|
+
|
|
24
|
+
- [#731](https://github.com/atlassian-labs/atlaspack/pull/731) [`23d561e`](https://github.com/atlassian-labs/atlaspack/commit/23d561e51e68b0c38fd1ff4e4fb173e5e7b01cf2) Thanks [@marcins](https://github.com/marcins)! - Implement "inline isolated" scripts
|
|
25
|
+
|
|
26
|
+
### Patch Changes
|
|
27
|
+
|
|
28
|
+
- Updated dependencies [[`23d561e`](https://github.com/atlassian-labs/atlaspack/commit/23d561e51e68b0c38fd1ff4e4fb173e5e7b01cf2)]:
|
|
29
|
+
- @atlaspack/feature-flags@2.21.0
|
|
30
|
+
- @atlaspack/utils@2.18.0
|
|
31
|
+
- @atlaspack/rust@3.5.0
|
|
32
|
+
- @atlaspack/types@2.15.13
|
|
33
|
+
- @atlaspack/plugin@2.14.23
|
|
34
|
+
|
|
3
35
|
## 2.19.1
|
|
4
36
|
|
|
5
37
|
### Patch Changes
|
package/lib/DevPackager.js
CHANGED
|
@@ -200,7 +200,7 @@ class DevPackager {
|
|
|
200
200
|
interpreter = _interpreter;
|
|
201
201
|
}
|
|
202
202
|
let importScripts = '';
|
|
203
|
-
if (this.bundle.env.isWorker()) {
|
|
203
|
+
if (this.bundle.env.isWorker() || this.bundle.env.isTesseract()) {
|
|
204
204
|
let bundles = this.bundleGraph.getReferencedBundles(this.bundle);
|
|
205
205
|
for (let b of bundles) {
|
|
206
206
|
importScripts += `importScripts("${(0, _utils().relativeBundlePath)(this.bundle, b)}");\n`;
|
|
@@ -212,7 +212,7 @@ class DevPackager {
|
|
|
212
212
|
);
|
|
213
213
|
}
|
|
214
214
|
isEntry() {
|
|
215
|
-
return !this.bundleGraph.hasParentBundleOfType(this.bundle, 'js') || this.bundle.env.isIsolated() || this.bundle.bundleBehavior === 'isolated';
|
|
215
|
+
return !this.bundleGraph.hasParentBundleOfType(this.bundle, 'js') || this.bundle.env.isIsolated() || this.bundle.bundleBehavior === 'isolated' || this.bundle.bundleBehavior === 'inlineIsolated';
|
|
216
216
|
}
|
|
217
217
|
}
|
|
218
218
|
exports.DevPackager = DevPackager;
|
|
@@ -86,6 +86,7 @@ const GLOBALS_BY_CONTEXT = {
|
|
|
86
86
|
'web-worker': new Set([...BUILTINS, ...Object.keys(_globals().default.worker)]),
|
|
87
87
|
'service-worker': new Set([...BUILTINS, ...Object.keys(_globals().default.serviceworker)]),
|
|
88
88
|
worklet: new Set([...BUILTINS]),
|
|
89
|
+
tesseract: new Set([...BUILTINS, ...Object.keys(_globals().default.worker)]),
|
|
89
90
|
node: new Set([...BUILTINS, ...Object.keys(_globals().default.node)]),
|
|
90
91
|
'electron-main': new Set([...BUILTINS, ...Object.keys(_globals().default.node)]),
|
|
91
92
|
'electron-renderer': new Set([...BUILTINS, ...Object.keys(_globals().default.node), ...Object.keys(_globals().default.browser)])
|
|
@@ -116,7 +117,7 @@ class ScopeHoistingPackager {
|
|
|
116
117
|
this.logger = logger;
|
|
117
118
|
let OutputFormat = OUTPUT_FORMATS[this.bundle.env.outputFormat];
|
|
118
119
|
this.outputFormat = new OutputFormat(this);
|
|
119
|
-
this.isAsyncBundle = this.bundleGraph.hasParentBundleOfType(this.bundle, 'js') && !this.bundle.env.isIsolated() && this.bundle.bundleBehavior !== 'isolated';
|
|
120
|
+
this.isAsyncBundle = this.bundleGraph.hasParentBundleOfType(this.bundle, 'js') && !this.bundle.env.isIsolated() && this.bundle.bundleBehavior !== 'isolated' && this.bundle.bundleBehavior !== 'inlineIsolated';
|
|
120
121
|
this.globalNames = GLOBALS_BY_CONTEXT[bundle.env.context];
|
|
121
122
|
}
|
|
122
123
|
async package() {
|
|
@@ -267,7 +268,7 @@ class ScopeHoistingPackager {
|
|
|
267
268
|
// If the bundle is a conditional bundle
|
|
268
269
|
isConditionalBundle = this.hasConditionalDependency();
|
|
269
270
|
}
|
|
270
|
-
return this.useAsyncBundleRuntime && bundle.type === 'js' && bundle.bundleBehavior !== 'inline' && bundle.env.outputFormat === 'esmodule' && !bundle.env.isIsolated() && bundle.bundleBehavior !== 'isolated' && (hasHtmlReference || hasConditionalReference || isConditionalBundle);
|
|
271
|
+
return this.useAsyncBundleRuntime && bundle.type === 'js' && bundle.bundleBehavior !== 'inline' && bundle.bundleBehavior !== 'inlineIsolated' && bundle.env.outputFormat === 'esmodule' && !bundle.env.isIsolated() && bundle.bundleBehavior !== 'isolated' && (hasHtmlReference || hasConditionalReference || isConditionalBundle);
|
|
271
272
|
}
|
|
272
273
|
runWhenReady(bundle, codeToRun) {
|
|
273
274
|
let deps = this.bundleGraph.getReferencedBundles(bundle).filter(b => this.shouldBundleQueue(b)).map(b => b.publicId);
|
|
@@ -315,6 +316,14 @@ class ScopeHoistingPackager {
|
|
|
315
316
|
}
|
|
316
317
|
});
|
|
317
318
|
if ((0, _featureFlags().getFeatureFlag)('applyScopeHoistingImprovement')) {
|
|
319
|
+
// Make all entry assets wrapped, to avoid any top level hoisting
|
|
320
|
+
for (let entryAsset of this.bundle.getEntryAssets()) {
|
|
321
|
+
if (!this.wrappedAssets.has(entryAsset.id)) {
|
|
322
|
+
this.wrappedAssets.add(entryAsset.id);
|
|
323
|
+
wrapped.push(entryAsset);
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
|
|
318
327
|
// Tracks which assets have been assigned to a wrap group
|
|
319
328
|
let assignedAssets = new Set();
|
|
320
329
|
for (let wrappedAsset of wrapped) {
|
|
@@ -1225,7 +1234,7 @@ ${code}
|
|
|
1225
1234
|
// Add the prelude if this is potentially the first JS bundle to load in a
|
|
1226
1235
|
// particular context (e.g. entry scripts in HTML, workers, etc.).
|
|
1227
1236
|
let parentBundles = this.bundleGraph.getParentBundles(this.bundle);
|
|
1228
|
-
let mightBeFirstJS = parentBundles.length === 0 || parentBundles.some(b => b.type !== 'js') || this.bundleGraph.getBundleGroupsContainingBundle(this.bundle).some(g => this.bundleGraph.isEntryBundleGroup(g)) || this.bundle.env.isIsolated() || this.bundle.bundleBehavior === 'isolated' ||
|
|
1237
|
+
let mightBeFirstJS = parentBundles.length === 0 || parentBundles.some(b => b.type !== 'js') || this.bundleGraph.getBundleGroupsContainingBundle(this.bundle).some(g => this.bundleGraph.isEntryBundleGroup(g)) || this.bundle.env.isIsolated() || this.bundle.bundleBehavior === 'isolated' || this.bundle.bundleBehavior === 'inlineIsolated' ||
|
|
1229
1238
|
// Conditional deps may be loaded before entrypoints on the server
|
|
1230
1239
|
this.hasConditionalDependency();
|
|
1231
1240
|
if (mightBeFirstJS) {
|
|
@@ -1252,7 +1261,7 @@ ${code}
|
|
|
1252
1261
|
}
|
|
1253
1262
|
|
|
1254
1263
|
// Add importScripts for sibling bundles in workers.
|
|
1255
|
-
if (this.bundle.env.isWorker() || this.bundle.env.isWorklet()) {
|
|
1264
|
+
if (this.bundle.env.isWorker() || this.bundle.env.isTesseract() || this.bundle.env.isWorklet()) {
|
|
1256
1265
|
let importScripts = '';
|
|
1257
1266
|
let bundles = this.bundleGraph.getReferencedBundles(this.bundle);
|
|
1258
1267
|
for (let b of bundles) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaspack/packager-js",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.21.0",
|
|
4
4
|
"license": "(MIT OR Apache-2.0)",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -11,24 +11,25 @@
|
|
|
11
11
|
},
|
|
12
12
|
"main": "./lib/index.js",
|
|
13
13
|
"source": "./src/index.ts",
|
|
14
|
-
"types": "./lib/index.d.ts",
|
|
14
|
+
"types": "./lib/types/index.d.ts",
|
|
15
15
|
"engines": {
|
|
16
16
|
"node": ">= 16.0.0"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"@atlaspack/diagnostic": "2.14.2",
|
|
20
|
-
"@atlaspack/feature-flags": "2.
|
|
21
|
-
"@atlaspack/plugin": "2.14.
|
|
22
|
-
"@atlaspack/rust": "3.
|
|
20
|
+
"@atlaspack/feature-flags": "2.22.0",
|
|
21
|
+
"@atlaspack/plugin": "2.14.24",
|
|
22
|
+
"@atlaspack/rust": "3.6.0",
|
|
23
23
|
"@parcel/source-map": "^2.1.1",
|
|
24
|
-
"@atlaspack/types": "2.15.
|
|
25
|
-
"@atlaspack/utils": "2.
|
|
24
|
+
"@atlaspack/types": "2.15.14",
|
|
25
|
+
"@atlaspack/utils": "2.18.1",
|
|
26
26
|
"globals": "^13.2.0",
|
|
27
27
|
"nullthrows": "^1.1.1",
|
|
28
28
|
"outdent": "^0.8.0"
|
|
29
29
|
},
|
|
30
30
|
"type": "commonjs",
|
|
31
31
|
"scripts": {
|
|
32
|
-
"check-ts": "tsc --emitDeclarationOnly --rootDir src"
|
|
32
|
+
"check-ts": "tsc --emitDeclarationOnly --rootDir src",
|
|
33
|
+
"build:lib": "gulp build --gulpfile ../../../gulpfile.js --cwd ."
|
|
33
34
|
}
|
|
34
|
-
}
|
|
35
|
+
}
|
package/src/DevPackager.ts
CHANGED
|
@@ -250,7 +250,7 @@ export class DevPackager {
|
|
|
250
250
|
}
|
|
251
251
|
|
|
252
252
|
let importScripts = '';
|
|
253
|
-
if (this.bundle.env.isWorker()) {
|
|
253
|
+
if (this.bundle.env.isWorker() || this.bundle.env.isTesseract()) {
|
|
254
254
|
let bundles = this.bundleGraph.getReferencedBundles(this.bundle);
|
|
255
255
|
for (let b of bundles) {
|
|
256
256
|
importScripts += `importScripts("${relativeBundlePath(
|
|
@@ -272,7 +272,8 @@ export class DevPackager {
|
|
|
272
272
|
return (
|
|
273
273
|
!this.bundleGraph.hasParentBundleOfType(this.bundle, 'js') ||
|
|
274
274
|
this.bundle.env.isIsolated() ||
|
|
275
|
-
this.bundle.bundleBehavior === 'isolated'
|
|
275
|
+
this.bundle.bundleBehavior === 'isolated' ||
|
|
276
|
+
this.bundle.bundleBehavior === 'inlineIsolated'
|
|
276
277
|
);
|
|
277
278
|
}
|
|
278
279
|
}
|
|
@@ -54,6 +54,7 @@ const GLOBALS_BY_CONTEXT = {
|
|
|
54
54
|
...Object.keys(globals.serviceworker),
|
|
55
55
|
]),
|
|
56
56
|
worklet: new Set([...BUILTINS]),
|
|
57
|
+
tesseract: new Set([...BUILTINS, ...Object.keys(globals.worker)]),
|
|
57
58
|
node: new Set([...BUILTINS, ...Object.keys(globals.node)]),
|
|
58
59
|
'electron-main': new Set([...BUILTINS, ...Object.keys(globals.node)]),
|
|
59
60
|
'electron-renderer': new Set([
|
|
@@ -131,7 +132,8 @@ export class ScopeHoistingPackager {
|
|
|
131
132
|
this.isAsyncBundle =
|
|
132
133
|
this.bundleGraph.hasParentBundleOfType(this.bundle, 'js') &&
|
|
133
134
|
!this.bundle.env.isIsolated() &&
|
|
134
|
-
this.bundle.bundleBehavior !== 'isolated'
|
|
135
|
+
this.bundle.bundleBehavior !== 'isolated' &&
|
|
136
|
+
this.bundle.bundleBehavior !== 'inlineIsolated';
|
|
135
137
|
|
|
136
138
|
this.globalNames = GLOBALS_BY_CONTEXT[bundle.env.context];
|
|
137
139
|
}
|
|
@@ -323,6 +325,7 @@ export class ScopeHoistingPackager {
|
|
|
323
325
|
this.useAsyncBundleRuntime &&
|
|
324
326
|
bundle.type === 'js' &&
|
|
325
327
|
bundle.bundleBehavior !== 'inline' &&
|
|
328
|
+
bundle.bundleBehavior !== 'inlineIsolated' &&
|
|
326
329
|
bundle.env.outputFormat === 'esmodule' &&
|
|
327
330
|
!bundle.env.isIsolated() &&
|
|
328
331
|
bundle.bundleBehavior !== 'isolated' &&
|
|
@@ -385,6 +388,7 @@ export class ScopeHoistingPackager {
|
|
|
385
388
|
let queue = new PromiseQueue({maxConcurrent: 32});
|
|
386
389
|
let wrapped: Array<Asset> = [];
|
|
387
390
|
let constant: Array<Asset> = [];
|
|
391
|
+
|
|
388
392
|
this.bundle.traverseAssets((asset) => {
|
|
389
393
|
queue.add(async () => {
|
|
390
394
|
let [code, map] = await Promise.all([
|
|
@@ -423,6 +427,14 @@ export class ScopeHoistingPackager {
|
|
|
423
427
|
});
|
|
424
428
|
|
|
425
429
|
if (getFeatureFlag('applyScopeHoistingImprovement')) {
|
|
430
|
+
// Make all entry assets wrapped, to avoid any top level hoisting
|
|
431
|
+
for (let entryAsset of this.bundle.getEntryAssets()) {
|
|
432
|
+
if (!this.wrappedAssets.has(entryAsset.id)) {
|
|
433
|
+
this.wrappedAssets.add(entryAsset.id);
|
|
434
|
+
wrapped.push(entryAsset);
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
|
|
426
438
|
// Tracks which assets have been assigned to a wrap group
|
|
427
439
|
let assignedAssets = new Set<Asset>();
|
|
428
440
|
|
|
@@ -1651,6 +1663,7 @@ ${code}
|
|
|
1651
1663
|
.some((g) => this.bundleGraph.isEntryBundleGroup(g)) ||
|
|
1652
1664
|
this.bundle.env.isIsolated() ||
|
|
1653
1665
|
this.bundle.bundleBehavior === 'isolated' ||
|
|
1666
|
+
this.bundle.bundleBehavior === 'inlineIsolated' ||
|
|
1654
1667
|
// Conditional deps may be loaded before entrypoints on the server
|
|
1655
1668
|
this.hasConditionalDependency();
|
|
1656
1669
|
|
|
@@ -1679,7 +1692,11 @@ ${code}
|
|
|
1679
1692
|
}
|
|
1680
1693
|
|
|
1681
1694
|
// Add importScripts for sibling bundles in workers.
|
|
1682
|
-
if (
|
|
1695
|
+
if (
|
|
1696
|
+
this.bundle.env.isWorker() ||
|
|
1697
|
+
this.bundle.env.isTesseract() ||
|
|
1698
|
+
this.bundle.env.isWorklet()
|
|
1699
|
+
) {
|
|
1683
1700
|
let importScripts = '';
|
|
1684
1701
|
let bundles = this.bundleGraph.getReferencedBundles(this.bundle);
|
|
1685
1702
|
for (let b of bundles) {
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|