@atlaspack/packager-js 2.20.0 → 2.21.1

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 CHANGED
@@ -1,5 +1,32 @@
1
1
  # @atlaspack/packager-js
2
2
 
3
+ ## 2.21.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [[`f6b3f22`](https://github.com/atlassian-labs/atlaspack/commit/f6b3f2276c7e417580b49c4879563aab51f156b1)]:
8
+ - @atlaspack/feature-flags@2.23.0
9
+ - @atlaspack/utils@2.18.2
10
+ - @atlaspack/plugin@2.14.25
11
+ - @atlaspack/types@2.15.15
12
+
13
+ ## 2.21.0
14
+
15
+ ### Minor Changes
16
+
17
+ - [#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
18
+
19
+ ### Patch Changes
20
+
21
+ - [#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
22
+ wrapped, which means there is no top level scope.
23
+ - 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)]:
24
+ - @atlaspack/rust@3.6.0
25
+ - @atlaspack/feature-flags@2.22.0
26
+ - @atlaspack/utils@2.18.1
27
+ - @atlaspack/plugin@2.14.24
28
+ - @atlaspack/types@2.15.14
29
+
3
30
  ## 2.20.0
4
31
 
5
32
  ### Minor Changes
@@ -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`;
@@ -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)])
@@ -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) {
@@ -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.20.0",
3
+ "version": "2.21.1",
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.0",
21
- "@atlaspack/plugin": "2.14.23",
22
- "@atlaspack/rust": "3.5.0",
20
+ "@atlaspack/feature-flags": "2.23.0",
21
+ "@atlaspack/plugin": "2.14.25",
22
+ "@atlaspack/rust": "3.6.0",
23
23
  "@parcel/source-map": "^2.1.1",
24
- "@atlaspack/types": "2.15.13",
25
- "@atlaspack/utils": "2.18.0",
24
+ "@atlaspack/types": "2.15.15",
25
+ "@atlaspack/utils": "2.18.2",
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
+ }
@@ -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(
@@ -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([
@@ -387,6 +388,7 @@ export class ScopeHoistingPackager {
387
388
  let queue = new PromiseQueue({maxConcurrent: 32});
388
389
  let wrapped: Array<Asset> = [];
389
390
  let constant: Array<Asset> = [];
391
+
390
392
  this.bundle.traverseAssets((asset) => {
391
393
  queue.add(async () => {
392
394
  let [code, map] = await Promise.all([
@@ -425,6 +427,14 @@ export class ScopeHoistingPackager {
425
427
  });
426
428
 
427
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
+
428
438
  // Tracks which assets have been assigned to a wrap group
429
439
  let assignedAssets = new Set<Asset>();
430
440
 
@@ -1682,7 +1692,11 @@ ${code}
1682
1692
  }
1683
1693
 
1684
1694
  // Add importScripts for sibling bundles in workers.
1685
- if (this.bundle.env.isWorker() || this.bundle.env.isWorklet()) {
1695
+ if (
1696
+ this.bundle.env.isWorker() ||
1697
+ this.bundle.env.isTesseract() ||
1698
+ this.bundle.env.isWorklet()
1699
+ ) {
1686
1700
  let importScripts = '';
1687
1701
  let bundles = this.bundleGraph.getReferencedBundles(this.bundle);
1688
1702
  for (let b of bundles) {
File without changes
File without changes
File without changes