@atlaspack/core 2.21.0 → 2.23.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.
Files changed (104) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/lib/Atlaspack.js +2 -1
  3. package/lib/BundleGraph.js +9 -9
  4. package/lib/Environment.js +2 -0
  5. package/lib/PackagerRunner.js +2 -2
  6. package/lib/TargetDescriptor.schema.js +1 -1
  7. package/lib/atlaspack-v3/worker/compat/bitflags.js +2 -1
  8. package/lib/atlaspack-v3/worker/compat/environment.js +5 -2
  9. package/lib/public/Environment.js +5 -2
  10. package/lib/requests/WriteBundlesRequest.js +2 -2
  11. package/lib/{atlaspack-v3 → types/atlaspack-v3}/worker/compat/environment.d.ts +1 -0
  12. package/lib/{public → types/public}/Environment.d.ts +1 -0
  13. package/lib/{types.d.ts → types/types.d.ts} +1 -0
  14. package/lib/types.js +2 -1
  15. package/package.json +17 -16
  16. package/src/Atlaspack.ts +1 -0
  17. package/src/BundleGraph.ts +20 -7
  18. package/src/Environment.ts +2 -0
  19. package/src/PackagerRunner.ts +10 -2
  20. package/src/TargetDescriptor.schema.ts +1 -0
  21. package/src/atlaspack-v3/worker/compat/bitflags.ts +1 -0
  22. package/src/atlaspack-v3/worker/compat/environment.ts +6 -1
  23. package/src/public/Environment.ts +10 -1
  24. package/src/requests/WriteBundlesRequest.ts +6 -2
  25. package/src/types.ts +1 -0
  26. package/test/Environment.test.ts +22 -0
  27. package/test/PublicEnvironment.test.ts +21 -0
  28. /package/lib/{AssetGraph.d.ts → types/AssetGraph.d.ts} +0 -0
  29. /package/lib/{Atlaspack.d.ts → types/Atlaspack.d.ts} +0 -0
  30. /package/lib/{AtlaspackConfig.d.ts → types/AtlaspackConfig.d.ts} +0 -0
  31. /package/lib/{AtlaspackConfig.schema.d.ts → types/AtlaspackConfig.schema.d.ts} +0 -0
  32. /package/lib/{BundleGraph.d.ts → types/BundleGraph.d.ts} +0 -0
  33. /package/lib/{CommittedAsset.d.ts → types/CommittedAsset.d.ts} +0 -0
  34. /package/lib/{Dependency.d.ts → types/Dependency.d.ts} +0 -0
  35. /package/lib/{Environment.d.ts → types/Environment.d.ts} +0 -0
  36. /package/lib/{EnvironmentManager.d.ts → types/EnvironmentManager.d.ts} +0 -0
  37. /package/lib/{IdentifierRegistry.d.ts → types/IdentifierRegistry.d.ts} +0 -0
  38. /package/lib/{InternalConfig.d.ts → types/InternalConfig.d.ts} +0 -0
  39. /package/lib/{PackagerRunner.d.ts → types/PackagerRunner.d.ts} +0 -0
  40. /package/lib/{ReporterRunner.d.ts → types/ReporterRunner.d.ts} +0 -0
  41. /package/lib/{RequestTracker.d.ts → types/RequestTracker.d.ts} +0 -0
  42. /package/lib/{SymbolPropagation.d.ts → types/SymbolPropagation.d.ts} +0 -0
  43. /package/lib/{TargetDescriptor.schema.d.ts → types/TargetDescriptor.schema.d.ts} +0 -0
  44. /package/lib/{Transformation.d.ts → types/Transformation.d.ts} +0 -0
  45. /package/lib/{UncommittedAsset.d.ts → types/UncommittedAsset.d.ts} +0 -0
  46. /package/lib/{Validation.d.ts → types/Validation.d.ts} +0 -0
  47. /package/lib/{applyRuntimes.d.ts → types/applyRuntimes.d.ts} +0 -0
  48. /package/lib/{assetUtils.d.ts → types/assetUtils.d.ts} +0 -0
  49. /package/lib/{atlaspack-v3 → types/atlaspack-v3}/AtlaspackV3.d.ts +0 -0
  50. /package/lib/{atlaspack-v3 → types/atlaspack-v3}/NapiWorkerPool.d.ts +0 -0
  51. /package/lib/{atlaspack-v3 → types/atlaspack-v3}/fs.d.ts +0 -0
  52. /package/lib/{atlaspack-v3 → types/atlaspack-v3}/index.d.ts +0 -0
  53. /package/lib/{atlaspack-v3 → types/atlaspack-v3}/jsCallable.d.ts +0 -0
  54. /package/lib/{atlaspack-v3 → types/atlaspack-v3}/worker/compat/asset-symbols.d.ts +0 -0
  55. /package/lib/{atlaspack-v3 → types/atlaspack-v3}/worker/compat/bitflags.d.ts +0 -0
  56. /package/lib/{atlaspack-v3 → types/atlaspack-v3}/worker/compat/dependency.d.ts +0 -0
  57. /package/lib/{atlaspack-v3 → types/atlaspack-v3}/worker/compat/index.d.ts +0 -0
  58. /package/lib/{atlaspack-v3 → types/atlaspack-v3}/worker/compat/mutable-asset.d.ts +0 -0
  59. /package/lib/{atlaspack-v3 → types/atlaspack-v3}/worker/compat/plugin-config.d.ts +0 -0
  60. /package/lib/{atlaspack-v3 → types/atlaspack-v3}/worker/compat/plugin-logger.d.ts +0 -0
  61. /package/lib/{atlaspack-v3 → types/atlaspack-v3}/worker/compat/plugin-options.d.ts +0 -0
  62. /package/lib/{atlaspack-v3 → types/atlaspack-v3}/worker/compat/plugin-tracer.d.ts +0 -0
  63. /package/lib/{atlaspack-v3 → types/atlaspack-v3}/worker/compat/target.d.ts +0 -0
  64. /package/lib/{atlaspack-v3 → types/atlaspack-v3}/worker/worker.d.ts +0 -0
  65. /package/lib/{constants.d.ts → types/constants.d.ts} +0 -0
  66. /package/lib/{dumpGraphToGraphViz.d.ts → types/dumpGraphToGraphViz.d.ts} +0 -0
  67. /package/lib/{index.d.ts → types/index.d.ts} +0 -0
  68. /package/lib/{loadAtlaspackPlugin.d.ts → types/loadAtlaspackPlugin.d.ts} +0 -0
  69. /package/lib/{loadDotEnv.d.ts → types/loadDotEnv.d.ts} +0 -0
  70. /package/lib/{projectPath.d.ts → types/projectPath.d.ts} +0 -0
  71. /package/lib/{public → types/public}/Asset.d.ts +0 -0
  72. /package/lib/{public → types/public}/Bundle.d.ts +0 -0
  73. /package/lib/{public → types/public}/BundleGraph.d.ts +0 -0
  74. /package/lib/{public → types/public}/BundleGroup.d.ts +0 -0
  75. /package/lib/{public → types/public}/Config.d.ts +0 -0
  76. /package/lib/{public → types/public}/Dependency.d.ts +0 -0
  77. /package/lib/{public → types/public}/MutableBundleGraph.d.ts +0 -0
  78. /package/lib/{public → types/public}/PluginOptions.d.ts +0 -0
  79. /package/lib/{public → types/public}/Symbols.d.ts +0 -0
  80. /package/lib/{public → types/public}/Target.d.ts +0 -0
  81. /package/lib/{registerCoreWithSerializer.d.ts → types/registerCoreWithSerializer.d.ts} +0 -0
  82. /package/lib/{requests → types/requests}/AssetGraphRequest.d.ts +0 -0
  83. /package/lib/{requests → types/requests}/AssetGraphRequestRust.d.ts +0 -0
  84. /package/lib/{requests → types/requests}/AssetRequest.d.ts +0 -0
  85. /package/lib/{requests → types/requests}/AtlaspackBuildRequest.d.ts +0 -0
  86. /package/lib/{requests → types/requests}/AtlaspackConfigRequest.d.ts +0 -0
  87. /package/lib/{requests → types/requests}/BundleGraphRequest.d.ts +0 -0
  88. /package/lib/{requests → types/requests}/ConfigRequest.d.ts +0 -0
  89. /package/lib/{requests → types/requests}/DevDepRequest.d.ts +0 -0
  90. /package/lib/{requests → types/requests}/EntryRequest.d.ts +0 -0
  91. /package/lib/{requests → types/requests}/PackageRequest.d.ts +0 -0
  92. /package/lib/{requests → types/requests}/PathRequest.d.ts +0 -0
  93. /package/lib/{requests → types/requests}/TargetRequest.d.ts +0 -0
  94. /package/lib/{requests → types/requests}/ValidationRequest.d.ts +0 -0
  95. /package/lib/{requests → types/requests}/WriteBundleRequest.d.ts +0 -0
  96. /package/lib/{requests → types/requests}/WriteBundlesRequest.d.ts +0 -0
  97. /package/lib/{requests → types/requests}/asset-graph-diff.d.ts +0 -0
  98. /package/lib/{requests → types/requests}/asset-graph-dot.d.ts +0 -0
  99. /package/lib/{resolveOptions.d.ts → types/resolveOptions.d.ts} +0 -0
  100. /package/lib/{rustWorkerThreadDylibHack.d.ts → types/rustWorkerThreadDylibHack.d.ts} +0 -0
  101. /package/lib/{serializerCore.browser.d.ts → types/serializerCore.browser.d.ts} +0 -0
  102. /package/lib/{summarizeRequest.d.ts → types/summarizeRequest.d.ts} +0 -0
  103. /package/lib/{utils.d.ts → types/utils.d.ts} +0 -0
  104. /package/lib/{worker.d.ts → types/worker.d.ts} +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,49 @@
1
1
  # @atlaspack/core
2
2
 
3
+ ## 2.23.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
+ - 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)]:
12
+ - @atlaspack/rust@3.6.0
13
+ - @atlaspack/feature-flags@2.22.0
14
+ - @atlaspack/cache@3.2.19
15
+ - @atlaspack/fs@2.15.19
16
+ - @atlaspack/logger@2.14.16
17
+ - @atlaspack/utils@2.18.1
18
+ - @atlaspack/package-manager@2.14.24
19
+ - @atlaspack/graph@3.5.13
20
+ - @atlaspack/plugin@2.14.24
21
+ - @atlaspack/profiler@2.14.21
22
+ - @atlaspack/types@2.15.14
23
+ - @atlaspack/workers@2.14.24
24
+
25
+ ## 2.22.0
26
+
27
+ ### Minor Changes
28
+
29
+ - [#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
30
+
31
+ ### Patch Changes
32
+
33
+ - Updated dependencies [[`23d561e`](https://github.com/atlassian-labs/atlaspack/commit/23d561e51e68b0c38fd1ff4e4fb173e5e7b01cf2)]:
34
+ - @atlaspack/feature-flags@2.21.0
35
+ - @atlaspack/utils@2.18.0
36
+ - @atlaspack/rust@3.5.0
37
+ - @atlaspack/cache@3.2.18
38
+ - @atlaspack/fs@2.15.18
39
+ - @atlaspack/graph@3.5.12
40
+ - @atlaspack/package-manager@2.14.23
41
+ - @atlaspack/workers@2.14.23
42
+ - @atlaspack/logger@2.14.15
43
+ - @atlaspack/profiler@2.14.20
44
+ - @atlaspack/types@2.15.13
45
+ - @atlaspack/plugin@2.14.23
46
+
3
47
  ## 2.21.0
4
48
 
5
49
  ### Minor Changes
package/lib/Atlaspack.js CHANGED
@@ -226,7 +226,8 @@ class Atlaspack {
226
226
  env: resolvedOptions.env,
227
227
  fs: inputFS && new _atlaspackV.FileSystemV3(inputFS),
228
228
  defaultTargetOptions: resolvedOptions.defaultTargetOptions,
229
- lmdb
229
+ lmdb,
230
+ featureFlags: resolvedOptions.featureFlags
230
231
  });
231
232
  this.#disposable.add(() => {
232
233
  rustAtlaspack.end();
@@ -930,7 +930,7 @@ class BundleGraph {
930
930
  isAssetReachableFromBundle(asset, bundle) {
931
931
  // If a bundle's environment is isolated, it can't access assets present
932
932
  // in any ancestor bundles. Don't consider any assets reachable.
933
- if (_Environment.ISOLATED_ENVS.has((0, _EnvironmentManager.fromEnvironmentId)(bundle.env).context) || !bundle.isSplittable || bundle.bundleBehavior === _types.BundleBehavior.isolated || bundle.bundleBehavior === _types.BundleBehavior.inline) {
933
+ if (_Environment.ISOLATED_ENVS.has((0, _EnvironmentManager.fromEnvironmentId)(bundle.env).context) || !bundle.isSplittable || bundle.bundleBehavior === _types.BundleBehavior.isolated || bundle.bundleBehavior === _types.BundleBehavior.inline || bundle.bundleBehavior === _types.BundleBehavior.inlineIsolated) {
934
934
  return false;
935
935
  }
936
936
 
@@ -940,7 +940,7 @@ class BundleGraph {
940
940
  return bundleGroups.every(bundleGroup => {
941
941
  // If the asset is in any sibling bundles of the original bundle, it is reachable.
942
942
  let bundles = this.getBundlesInBundleGroup(bundleGroup);
943
- if (bundles.some(b => b.id !== bundle.id && b.bundleBehavior !== _types.BundleBehavior.isolated && b.bundleBehavior !== _types.BundleBehavior.inline && this.bundleHasAsset(b, asset))) {
943
+ if (bundles.some(b => b.id !== bundle.id && b.bundleBehavior !== _types.BundleBehavior.isolated && b.bundleBehavior !== _types.BundleBehavior.inline && b.bundleBehavior !== _types.BundleBehavior.inlineIsolated && this.bundleHasAsset(b, asset))) {
944
944
  return true;
945
945
  }
946
946
 
@@ -950,7 +950,7 @@ class BundleGraph {
950
950
  // Check that every parent bundle has a bundle group in its ancestry that contains the asset.
951
951
  return parentBundleNodes.every(bundleNodeId => {
952
952
  let bundleNode = (0, _nullthrows().default)(this._graph.getNode(bundleNodeId));
953
- if (bundleNode.type !== 'bundle' || bundleNode.value.bundleBehavior === _types.BundleBehavior.isolated || bundleNode.value.bundleBehavior === _types.BundleBehavior.inline) {
953
+ if (bundleNode.type !== 'bundle' || bundleNode.value.bundleBehavior === _types.BundleBehavior.isolated || bundleNode.value.bundleBehavior === _types.BundleBehavior.inline || bundleNode.value.bundleBehavior === _types.BundleBehavior.inlineIsolated) {
954
954
  return false;
955
955
  }
956
956
  let isReachable = true;
@@ -965,7 +965,7 @@ class BundleGraph {
965
965
  }
966
966
  if (node.type === 'bundle_group') {
967
967
  let childBundles = this.getBundlesInBundleGroup(node.value);
968
- if (childBundles.some(b => b.id !== bundle.id && b.bundleBehavior !== _types.BundleBehavior.isolated && b.bundleBehavior !== _types.BundleBehavior.inline && this.bundleHasAsset(b, asset))) {
968
+ if (childBundles.some(b => b.id !== bundle.id && b.bundleBehavior !== _types.BundleBehavior.isolated && b.bundleBehavior !== _types.BundleBehavior.inline && b.bundleBehavior !== _types.BundleBehavior.inlineIsolated && this.bundleHasAsset(b, asset))) {
969
969
  actions.skipChildren();
970
970
  return;
971
971
  }
@@ -1057,7 +1057,7 @@ class BundleGraph {
1057
1057
  getBundles(opts) {
1058
1058
  let bundles = [];
1059
1059
  this.traverseBundles(bundle => {
1060
- if (opts !== null && opts !== void 0 && opts.includeInline || bundle.bundleBehavior !== _types.BundleBehavior.inline) {
1060
+ if (opts !== null && opts !== void 0 && opts.includeInline || bundle.bundleBehavior !== _types.BundleBehavior.inline && bundle.bundleBehavior !== _types.BundleBehavior.inlineIsolated) {
1061
1061
  bundles.push(bundle);
1062
1062
  }
1063
1063
  });
@@ -1108,7 +1108,7 @@ class BundleGraph {
1108
1108
  let bundleNode = (0, _nullthrows().default)(this._graph.getNode(bundleNodeId));
1109
1109
  (0, _assert().default)(bundleNode.type === 'bundle');
1110
1110
  let bundle = bundleNode.value;
1111
- if (opts !== null && opts !== void 0 && opts.includeInline || bundle.bundleBehavior !== _types.BundleBehavior.inline) {
1111
+ if (opts !== null && opts !== void 0 && opts.includeInline || bundle.bundleBehavior !== _types.BundleBehavior.inline && bundle.bundleBehavior !== _types.BundleBehavior.inlineIsolated) {
1112
1112
  bundles.add(bundle);
1113
1113
  }
1114
1114
  for (let referencedBundle of this.getReferencedBundles(bundle, {
@@ -1132,7 +1132,7 @@ class BundleGraph {
1132
1132
  if (node.value.id === bundle.id) {
1133
1133
  return;
1134
1134
  }
1135
- if (includeInline || node.value.bundleBehavior !== _types.BundleBehavior.inline) {
1135
+ if (includeInline || node.value.bundleBehavior !== _types.BundleBehavior.inline && node.value.bundleBehavior !== _types.BundleBehavior.inlineIsolated) {
1136
1136
  referencedBundles.add(node.value);
1137
1137
  }
1138
1138
  if (!recursive) {
@@ -1445,7 +1445,7 @@ class BundleGraph {
1445
1445
  includeInline: true
1446
1446
  });
1447
1447
  for (let referenced of referencedBundles) {
1448
- if (referenced.bundleBehavior === _types.BundleBehavior.inline) {
1448
+ if (referenced.bundleBehavior === _types.BundleBehavior.inline || referenced.bundleBehavior === _types.BundleBehavior.inlineIsolated) {
1449
1449
  bundles.push(referenced);
1450
1450
  addReferencedBundles(referenced);
1451
1451
  }
@@ -1453,7 +1453,7 @@ class BundleGraph {
1453
1453
  };
1454
1454
  addReferencedBundles(bundle);
1455
1455
  this.traverseBundles((childBundle, _, traversal) => {
1456
- if (childBundle.bundleBehavior === _types.BundleBehavior.inline) {
1456
+ if (childBundle.bundleBehavior === _types.BundleBehavior.inline || childBundle.bundleBehavior === _types.BundleBehavior.inlineIsolated) {
1457
1457
  bundles.push(childBundle);
1458
1458
  } else if (childBundle.id !== bundle.id) {
1459
1459
  traversal.skipChildren();
@@ -59,6 +59,7 @@ function createEnvironment({
59
59
  case 'browser':
60
60
  case 'web-worker':
61
61
  case 'service-worker':
62
+ case 'tesseract':
62
63
  case 'electron-renderer':
63
64
  engines = {
64
65
  // @ts-expect-error TS2322
@@ -79,6 +80,7 @@ function createEnvironment({
79
80
  case 'browser':
80
81
  case 'web-worker':
81
82
  case 'service-worker':
83
+ case 'tesseract':
82
84
  default:
83
85
  includeNodeModules = true;
84
86
  break;
@@ -254,7 +254,7 @@ class PackagerRunner {
254
254
  };
255
255
  }
256
256
  getSourceMapReference(bundle, map) {
257
- if (map && bundle.env.sourceMap && bundle.bundleBehavior !== 'inline') {
257
+ if (map && bundle.env.sourceMap && bundle.bundleBehavior !== 'inline' && bundle.bundleBehavior !== 'inlineIsolated') {
258
258
  if (bundle.env.sourceMap && bundle.env.sourceMap.inline) {
259
259
  return this.generateSourceMap((0, _Bundle.bundleToInternalBundle)(bundle), map);
260
260
  } else {
@@ -300,7 +300,7 @@ class PackagerRunner {
300
300
  category: 'package'
301
301
  }),
302
302
  getInlineBundleContents: async (bundle, bundleGraph) => {
303
- if (bundle.bundleBehavior !== 'inline') {
303
+ if (bundle.bundleBehavior !== 'inline' && bundle.bundleBehavior !== 'inlineIsolated') {
304
304
  throw new Error('Bundle is not inline and unable to retrieve contents');
305
305
  }
306
306
  let res = await this.getBundleResult((0, _Bundle.bundleToInternalBundle)(bundle), (0, _BundleGraph.bundleGraphToInternalBundleGraph)(bundleGraph), configs, bundleConfigs);
@@ -28,7 +28,7 @@ const PACKAGE_DESCRIPTOR_SCHEMA = exports.PACKAGE_DESCRIPTOR_SCHEMA = {
28
28
  properties: {
29
29
  context: {
30
30
  type: 'string',
31
- enum: ['node', 'browser', 'web-worker', 'electron-main', 'electron-renderer', 'service-worker']
31
+ enum: ['node', 'browser', 'web-worker', 'electron-main', 'electron-renderer', 'service-worker', 'tesseract']
32
32
  },
33
33
  includeNodeModules: {
34
34
  oneOf: [{
@@ -52,7 +52,8 @@ class BitFlags {
52
52
  exports.BitFlags = BitFlags;
53
53
  const bundleBehaviorMap = exports.bundleBehaviorMap = new BitFlags({
54
54
  inline: 0,
55
- isolated: 1
55
+ isolated: 1,
56
+ inlineIsolated: 2
56
57
  });
57
58
  const dependencyPriorityMap = exports.dependencyPriorityMap = new BitFlags({
58
59
  sync: 0,
@@ -23,7 +23,7 @@ class Environment {
23
23
  this.unstableSingleFileOutput = false;
24
24
  }
25
25
  isBrowser() {
26
- return this.context === 'browser' || this.isWorker() || this.isWorklet() || this.context === 'electron-renderer';
26
+ return this.context === 'browser' || this.isWorker() || this.isTesseract() || this.isWorklet() || this.context === 'electron-renderer';
27
27
  }
28
28
  isNode() {
29
29
  return this.context === 'node' || this.isElectron();
@@ -37,8 +37,11 @@ class Environment {
37
37
  isWorklet() {
38
38
  return this.context === 'worklet';
39
39
  }
40
+ isTesseract() {
41
+ return this.context === 'tesseract';
42
+ }
40
43
  isIsolated() {
41
- return this.isWorker() || this.isWorklet();
44
+ return this.isWorker() || this.isTesseract() || this.isWorklet();
42
45
  }
43
46
 
44
47
  // TODO
@@ -29,11 +29,11 @@ function _semver() {
29
29
  var _utils = require("../utils");
30
30
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
31
31
  const inspect = Symbol.for('nodejs.util.inspect.custom');
32
- const BROWSER_ENVS = exports.BROWSER_ENVS = new Set(['browser', 'web-worker', 'service-worker', 'worklet', 'electron-renderer']);
32
+ const BROWSER_ENVS = exports.BROWSER_ENVS = new Set(['browser', 'web-worker', 'service-worker', 'worklet', 'tesseract', 'electron-renderer']);
33
33
  const ELECTRON_ENVS = new Set(['electron-main', 'electron-renderer']);
34
34
  const NODE_ENVS = new Set(['node', ...ELECTRON_ENVS]);
35
35
  const WORKER_ENVS = new Set(['web-worker', 'service-worker']);
36
- const ISOLATED_ENVS = exports.ISOLATED_ENVS = new Set([...WORKER_ENVS, 'worklet']);
36
+ const ISOLATED_ENVS = exports.ISOLATED_ENVS = new Set([...WORKER_ENVS, 'worklet', 'tesseract']);
37
37
  const ALL_BROWSERS = ['chrome', 'and_chr', 'edge', 'firefox', 'and_ff', 'safari', 'ios', 'samsung', 'opera', 'ie', 'op_mini', 'blackberry', 'op_mob', 'ie_mob', 'and_uc', 'and_qq', 'baidu', 'kaios'];
38
38
 
39
39
  // See require("caniuse-api").getSupport(<feature name>)
@@ -199,6 +199,9 @@ class Environment {
199
199
  isWorklet() {
200
200
  return this.#environment.context === 'worklet';
201
201
  }
202
+ isTesseract() {
203
+ return this.#environment.context === 'tesseract';
204
+ }
202
205
  matchesEngines(minVersions, defaultValue = false) {
203
206
  // Determine if the environment matches some minimum version requirements.
204
207
  // For browsers, we run a browserslist query with and without the minimum
@@ -82,9 +82,9 @@ async function run({
82
82
  const allBundles = bundleGraph.getBundles({
83
83
  includeInline: (0, _featureFlags().getFeatureFlag)('inlineBundlesSourceMapFixes')
84
84
  });
85
- const bundles = allBundles
85
+ const bundles = allBundles.filter(
86
86
  // @ts-expect-error TS7006
87
- .filter(bundle => bundle.bundleBehavior !== 'inline')
87
+ bundle => bundle.bundleBehavior !== 'inline' && bundle.bundleBehavior !== 'inline-isolated')
88
88
  // @ts-expect-error TS7006
89
89
  .filter(bundle => {
90
90
  // Do not package and write placeholder bundles to disk. We just
@@ -19,6 +19,7 @@ export declare class Environment implements IEnvironment {
19
19
  isElectron(): boolean;
20
20
  isWorker(): boolean;
21
21
  isWorklet(): boolean;
22
+ isTesseract(): boolean;
22
23
  isIsolated(): boolean;
23
24
  matchesEngines(minVersions: VersionMap, defaultValue?: boolean): boolean;
24
25
  supports(feature: EnvironmentFeature, defaultValue?: boolean): boolean;
@@ -26,6 +26,7 @@ export default class Environment implements IEnvironment {
26
26
  isIsolated(): boolean;
27
27
  isWorker(): boolean;
28
28
  isWorklet(): boolean;
29
+ isTesseract(): boolean;
29
30
  matchesEngines(minVersions: VersionMap, defaultValue?: boolean): boolean;
30
31
  supports(feature: EnvironmentFeature, defaultValue?: boolean): boolean;
31
32
  }
@@ -123,6 +123,7 @@ export type Dependency = {
123
123
  export declare const BundleBehavior: {
124
124
  readonly inline: 0;
125
125
  readonly isolated: 1;
126
+ readonly inlineIsolated: 2;
126
127
  };
127
128
  export declare const BundleBehaviorNames: Array<keyof typeof BundleBehavior>;
128
129
  export type Asset = {
package/lib/types.js CHANGED
@@ -32,7 +32,8 @@ const ExportsCondition = exports.ExportsCondition = {
32
32
  };
33
33
  const BundleBehavior = exports.BundleBehavior = {
34
34
  inline: 0,
35
- isolated: 1
35
+ isolated: 1,
36
+ inlineIsolated: 2
36
37
  };
37
38
 
38
39
  // @ts-expect-error TS2322
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaspack/core",
3
- "version": "2.21.0",
3
+ "version": "2.23.0",
4
4
  "license": "(MIT OR Apache-2.0)",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -11,7 +11,7 @@
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
  },
@@ -19,25 +19,26 @@
19
19
  "test": "mocha",
20
20
  "test-ci": "mocha",
21
21
  "generate-ts": "tsc --emitDeclarationOnly",
22
- "check-ts": "tsc --emitDeclarationOnly --rootDir src"
22
+ "check-ts": "tsc --emitDeclarationOnly --rootDir src",
23
+ "build:lib": "gulp build --gulpfile ../../../gulpfile.js --cwd ."
23
24
  },
24
25
  "dependencies": {
25
26
  "@mischnic/json-sourcemap": "^0.1.0",
26
27
  "@atlaspack/build-cache": "2.13.4",
27
- "@atlaspack/cache": "3.2.17",
28
+ "@atlaspack/cache": "3.2.19",
28
29
  "@atlaspack/diagnostic": "2.14.2",
29
30
  "@atlaspack/events": "2.14.2",
30
- "@atlaspack/feature-flags": "2.20.1",
31
- "@atlaspack/fs": "2.15.17",
32
- "@atlaspack/graph": "3.5.11",
33
- "@atlaspack/logger": "2.14.14",
34
- "@atlaspack/package-manager": "2.14.22",
35
- "@atlaspack/plugin": "2.14.22",
36
- "@atlaspack/profiler": "2.14.19",
37
- "@atlaspack/rust": "3.4.2",
38
- "@atlaspack/types": "2.15.12",
39
- "@atlaspack/utils": "2.17.4",
40
- "@atlaspack/workers": "2.14.22",
31
+ "@atlaspack/feature-flags": "2.22.0",
32
+ "@atlaspack/fs": "2.15.19",
33
+ "@atlaspack/graph": "3.5.13",
34
+ "@atlaspack/logger": "2.14.16",
35
+ "@atlaspack/package-manager": "2.14.24",
36
+ "@atlaspack/plugin": "2.14.24",
37
+ "@atlaspack/profiler": "2.14.21",
38
+ "@atlaspack/rust": "3.6.0",
39
+ "@atlaspack/types": "2.15.14",
40
+ "@atlaspack/utils": "2.18.1",
41
+ "@atlaspack/workers": "2.14.24",
41
42
  "@parcel/source-map": "^2.1.1",
42
43
  "base-x": "^3.0.8",
43
44
  "browserslist": "^4.6.6",
@@ -61,4 +62,4 @@
61
62
  "./src/serializerCore.js": "./src/serializerCore.browser.js"
62
63
  },
63
64
  "type": "commonjs"
64
- }
65
+ }
package/src/Atlaspack.ts CHANGED
@@ -199,6 +199,7 @@ export default class Atlaspack {
199
199
  fs: inputFS && new FileSystemV3(inputFS),
200
200
  defaultTargetOptions: resolvedOptions.defaultTargetOptions,
201
201
  lmdb,
202
+ featureFlags: resolvedOptions.featureFlags,
202
203
  });
203
204
  this.#disposable.add(() => {
204
205
  rustAtlaspack.end();
@@ -1455,7 +1455,8 @@ export default class BundleGraph {
1455
1455
  ISOLATED_ENVS.has(fromEnvironmentId(bundle.env).context) ||
1456
1456
  !bundle.isSplittable ||
1457
1457
  bundle.bundleBehavior === BundleBehavior.isolated ||
1458
- bundle.bundleBehavior === BundleBehavior.inline
1458
+ bundle.bundleBehavior === BundleBehavior.inline ||
1459
+ bundle.bundleBehavior === BundleBehavior.inlineIsolated
1459
1460
  ) {
1460
1461
  return false;
1461
1462
  }
@@ -1472,6 +1473,7 @@ export default class BundleGraph {
1472
1473
  b.id !== bundle.id &&
1473
1474
  b.bundleBehavior !== BundleBehavior.isolated &&
1474
1475
  b.bundleBehavior !== BundleBehavior.inline &&
1476
+ b.bundleBehavior !== BundleBehavior.inlineIsolated &&
1475
1477
  this.bundleHasAsset(b, asset),
1476
1478
  )
1477
1479
  ) {
@@ -1490,7 +1492,8 @@ export default class BundleGraph {
1490
1492
  if (
1491
1493
  bundleNode.type !== 'bundle' ||
1492
1494
  bundleNode.value.bundleBehavior === BundleBehavior.isolated ||
1493
- bundleNode.value.bundleBehavior === BundleBehavior.inline
1495
+ bundleNode.value.bundleBehavior === BundleBehavior.inline ||
1496
+ bundleNode.value.bundleBehavior === BundleBehavior.inlineIsolated
1494
1497
  ) {
1495
1498
  return false;
1496
1499
  }
@@ -1522,6 +1525,7 @@ export default class BundleGraph {
1522
1525
  b.id !== bundle.id &&
1523
1526
  b.bundleBehavior !== BundleBehavior.isolated &&
1524
1527
  b.bundleBehavior !== BundleBehavior.inline &&
1528
+ b.bundleBehavior !== BundleBehavior.inlineIsolated &&
1525
1529
  this.bundleHasAsset(b, asset),
1526
1530
  )
1527
1531
  ) {
@@ -1664,7 +1668,8 @@ export default class BundleGraph {
1664
1668
  this.traverseBundles((bundle) => {
1665
1669
  if (
1666
1670
  opts?.includeInline ||
1667
- bundle.bundleBehavior !== BundleBehavior.inline
1671
+ (bundle.bundleBehavior !== BundleBehavior.inline &&
1672
+ bundle.bundleBehavior !== BundleBehavior.inlineIsolated)
1668
1673
  ) {
1669
1674
  bundles.push(bundle);
1670
1675
  }
@@ -1748,7 +1753,8 @@ export default class BundleGraph {
1748
1753
  let bundle = bundleNode.value;
1749
1754
  if (
1750
1755
  opts?.includeInline ||
1751
- bundle.bundleBehavior !== BundleBehavior.inline
1756
+ (bundle.bundleBehavior !== BundleBehavior.inline &&
1757
+ bundle.bundleBehavior !== BundleBehavior.inlineIsolated)
1752
1758
  ) {
1753
1759
  bundles.add(bundle);
1754
1760
  }
@@ -1786,7 +1792,8 @@ export default class BundleGraph {
1786
1792
 
1787
1793
  if (
1788
1794
  includeInline ||
1789
- node.value.bundleBehavior !== BundleBehavior.inline
1795
+ (node.value.bundleBehavior !== BundleBehavior.inline &&
1796
+ node.value.bundleBehavior !== BundleBehavior.inlineIsolated)
1790
1797
  ) {
1791
1798
  referencedBundles.add(node.value);
1792
1799
  }
@@ -2161,7 +2168,10 @@ export default class BundleGraph {
2161
2168
  includeInline: true,
2162
2169
  });
2163
2170
  for (let referenced of referencedBundles) {
2164
- if (referenced.bundleBehavior === BundleBehavior.inline) {
2171
+ if (
2172
+ referenced.bundleBehavior === BundleBehavior.inline ||
2173
+ referenced.bundleBehavior === BundleBehavior.inlineIsolated
2174
+ ) {
2165
2175
  bundles.push(referenced);
2166
2176
  addReferencedBundles(referenced);
2167
2177
  }
@@ -2171,7 +2181,10 @@ export default class BundleGraph {
2171
2181
  addReferencedBundles(bundle);
2172
2182
 
2173
2183
  this.traverseBundles((childBundle, _, traversal) => {
2174
- if (childBundle.bundleBehavior === BundleBehavior.inline) {
2184
+ if (
2185
+ childBundle.bundleBehavior === BundleBehavior.inline ||
2186
+ childBundle.bundleBehavior === BundleBehavior.inlineIsolated
2187
+ ) {
2175
2188
  bundles.push(childBundle);
2176
2189
  } else if (childBundle.id !== bundle.id) {
2177
2190
  traversal.skipChildren();
@@ -57,6 +57,7 @@ export function createEnvironment({
57
57
  case 'browser':
58
58
  case 'web-worker':
59
59
  case 'service-worker':
60
+ case 'tesseract':
60
61
  case 'electron-renderer':
61
62
  engines = {
62
63
  // @ts-expect-error TS2322
@@ -78,6 +79,7 @@ export function createEnvironment({
78
79
  case 'browser':
79
80
  case 'web-worker':
80
81
  case 'service-worker':
82
+ case 'tesseract':
81
83
  default:
82
84
  includeNodeModules = true;
83
85
  break;
@@ -377,7 +377,12 @@ export default class PackagerRunner {
377
377
  bundle: NamedBundle,
378
378
  map?: SourceMap | null,
379
379
  ): Async<string | null | undefined> {
380
- if (map && bundle.env.sourceMap && bundle.bundleBehavior !== 'inline') {
380
+ if (
381
+ map &&
382
+ bundle.env.sourceMap &&
383
+ bundle.bundleBehavior !== 'inline' &&
384
+ bundle.bundleBehavior !== 'inlineIsolated'
385
+ ) {
381
386
  if (bundle.env.sourceMap && bundle.env.sourceMap.inline) {
382
387
  return this.generateSourceMap(bundleToInternalBundle(bundle), map);
383
388
  } else {
@@ -427,7 +432,10 @@ export default class PackagerRunner {
427
432
  bundle: BundleType,
428
433
  bundleGraph: BundleGraphType<NamedBundleType>,
429
434
  ) => {
430
- if (bundle.bundleBehavior !== 'inline') {
435
+ if (
436
+ bundle.bundleBehavior !== 'inline' &&
437
+ bundle.bundleBehavior !== 'inlineIsolated'
438
+ ) {
431
439
  throw new Error(
432
440
  'Bundle is not inline and unable to retrieve contents',
433
441
  );
@@ -35,6 +35,7 @@ export const PACKAGE_DESCRIPTOR_SCHEMA: SchemaObject = {
35
35
  'electron-main',
36
36
  'electron-renderer',
37
37
  'service-worker',
38
+ 'tesseract',
38
39
  ],
39
40
  },
40
41
  includeNodeModules: {
@@ -62,6 +62,7 @@ export const bundleBehaviorMap: BitFlags<BundleBehavior, number> = new BitFlags(
62
62
  {
63
63
  inline: 0,
64
64
  isolated: 1,
65
+ inlineIsolated: 2,
65
66
  },
66
67
  );
67
68
 
@@ -50,6 +50,7 @@ export class Environment implements IEnvironment {
50
50
  return (
51
51
  this.context === 'browser' ||
52
52
  this.isWorker() ||
53
+ this.isTesseract() ||
53
54
  this.isWorklet() ||
54
55
  this.context === 'electron-renderer'
55
56
  );
@@ -73,8 +74,12 @@ export class Environment implements IEnvironment {
73
74
  return this.context === 'worklet';
74
75
  }
75
76
 
77
+ isTesseract(): boolean {
78
+ return this.context === 'tesseract';
79
+ }
80
+
76
81
  isIsolated(): boolean {
77
- return this.isWorker() || this.isWorklet();
82
+ return this.isWorker() || this.isTesseract() || this.isWorklet();
78
83
  }
79
84
 
80
85
  // TODO
@@ -26,12 +26,17 @@ export const BROWSER_ENVS: Set<string> = new Set<string>([
26
26
  'web-worker',
27
27
  'service-worker',
28
28
  'worklet',
29
+ 'tesseract',
29
30
  'electron-renderer',
30
31
  ]);
31
32
  const ELECTRON_ENVS = new Set(['electron-main', 'electron-renderer']);
32
33
  const NODE_ENVS = new Set(['node', ...ELECTRON_ENVS]);
33
34
  const WORKER_ENVS = new Set(['web-worker', 'service-worker']);
34
- export const ISOLATED_ENVS: Set<string> = new Set([...WORKER_ENVS, 'worklet']);
35
+ export const ISOLATED_ENVS: Set<string> = new Set([
36
+ ...WORKER_ENVS,
37
+ 'worklet',
38
+ 'tesseract',
39
+ ]);
35
40
 
36
41
  const ALL_BROWSERS = [
37
42
  'chrome',
@@ -255,6 +260,10 @@ export default class Environment implements IEnvironment {
255
260
  return this.#environment.context === 'worklet';
256
261
  }
257
262
 
263
+ isTesseract(): boolean {
264
+ return this.#environment.context === 'tesseract';
265
+ }
266
+
258
267
  matchesEngines(
259
268
  minVersions: VersionMap,
260
269
  defaultValue: boolean = false,
@@ -86,8 +86,12 @@ async function run({input, api, farm, options}) {
86
86
  includeInline: getFeatureFlag('inlineBundlesSourceMapFixes'),
87
87
  });
88
88
  const bundles = allBundles
89
- // @ts-expect-error TS7006
90
- .filter((bundle) => bundle.bundleBehavior !== 'inline')
89
+ .filter(
90
+ // @ts-expect-error TS7006
91
+ (bundle) =>
92
+ bundle.bundleBehavior !== 'inline' &&
93
+ bundle.bundleBehavior !== 'inline-isolated',
94
+ )
91
95
  // @ts-expect-error TS7006
92
96
  .filter((bundle) => {
93
97
  // Do not package and write placeholder bundles to disk. We just
package/src/types.ts CHANGED
@@ -179,6 +179,7 @@ export type Dependency = {
179
179
  export const BundleBehavior = {
180
180
  inline: 0,
181
181
  isolated: 1,
182
+ inlineIsolated: 2,
182
183
  } as const;
183
184
 
184
185
  // @ts-expect-error TS2322
@@ -110,6 +110,28 @@ describe('Environment', () => {
110
110
  },
111
111
  );
112
112
  });
113
+
114
+ it('assigns default engines for tesseract (same as web-worker)', () => {
115
+ assert.deepEqual(
116
+ fromEnvironmentId(createEnvironment({context: 'tesseract'})),
117
+ {
118
+ id: '9917be65326c5de9',
119
+ context: 'tesseract',
120
+ engines: {
121
+ browsers: ['> 0.25%'],
122
+ },
123
+ includeNodeModules: true,
124
+ outputFormat: 'global',
125
+ isLibrary: false,
126
+ shouldOptimize: false,
127
+ shouldScopeHoist: false,
128
+ sourceMap: undefined,
129
+ loc: undefined,
130
+ sourceType: 'module',
131
+ unstableSingleFileOutput: false,
132
+ },
133
+ );
134
+ });
113
135
  });
114
136
 
115
137
  describe('createEnvironment', function () {
@@ -25,4 +25,25 @@ describe('Public Environment', () => {
25
25
  assert(env.supports('import-meta-url'));
26
26
  assert(env.supports('arrow-functions'));
27
27
  });
28
+
29
+ it('correctly identifies tesseract context', () => {
30
+ let env = new PublicEnvironment(
31
+ fromEnvironmentId(
32
+ createEnvironment({
33
+ context: 'tesseract',
34
+ engines: {
35
+ browsers: ['last 1 Chrome version'],
36
+ },
37
+ }),
38
+ ),
39
+ DEFAULT_OPTIONS,
40
+ );
41
+
42
+ assert(env.isTesseract());
43
+ assert(env.isBrowser());
44
+ assert(env.isIsolated());
45
+ assert(!env.isNode());
46
+ assert(!env.isElectron());
47
+ assert(!env.isWorklet());
48
+ });
28
49
  });
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes