@atlaspack/runtime-js 2.16.1 → 2.18.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 CHANGED
@@ -1,5 +1,31 @@
1
1
  # @atlaspack/runtime-js
2
2
 
3
+ ## 2.18.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 [[`73dd7ba`](https://github.com/atlassian-labs/atlaspack/commit/73dd7baab69456ef2f6e4a0cc7dbb04f407eb148)]:
12
+ - @atlaspack/feature-flags@2.22.0
13
+ - @atlaspack/utils@2.18.1
14
+ - @atlaspack/plugin@2.14.24
15
+
16
+ ## 2.17.0
17
+
18
+ ### Minor Changes
19
+
20
+ - [#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
21
+
22
+ ### Patch Changes
23
+
24
+ - Updated dependencies [[`23d561e`](https://github.com/atlassian-labs/atlaspack/commit/23d561e51e68b0c38fd1ff4e4fb173e5e7b01cf2)]:
25
+ - @atlaspack/feature-flags@2.21.0
26
+ - @atlaspack/utils@2.18.0
27
+ - @atlaspack/plugin@2.14.23
28
+
3
29
  ## 2.16.1
4
30
 
5
31
  ### Patch Changes
package/lib/JSRuntime.js CHANGED
@@ -77,7 +77,7 @@ const LOADERS = {
77
77
  };
78
78
  function getLoaders(ctx) {
79
79
  // @ts-expect-error TS2322
80
- if (ctx.isWorker()) return LOADERS.worker;
80
+ if (ctx.isWorker() || ctx.isTesseract()) return LOADERS.worker;
81
81
  if (ctx.isBrowser()) return LOADERS.browser;
82
82
  // @ts-expect-error TS2322
83
83
  if (ctx.isNode()) return LOADERS.node;
@@ -179,7 +179,7 @@ var _default = exports.default = new (_plugin().Runtime)({
179
179
  // Resolve the dependency to a bundle. If inline, export the dependency id,
180
180
  // which will be replaced with the contents of that bundle later.
181
181
  let referencedBundle = bundleGraph.getReferencedBundle(dependency, bundle);
182
- if ((referencedBundle === null || referencedBundle === void 0 ? void 0 : referencedBundle.bundleBehavior) === 'inline') {
182
+ if ((referencedBundle === null || referencedBundle === void 0 ? void 0 : referencedBundle.bundleBehavior) === 'inline' || (referencedBundle === null || referencedBundle === void 0 ? void 0 : referencedBundle.bundleBehavior) === 'inlineIsolated') {
183
183
  assets.push({
184
184
  filePath: _path().default.join(__dirname, `/bundles/${referencedBundle.id}.js`),
185
185
  code: `module.exports = Promise.resolve(${JSON.stringify(dependency.id)});`,
@@ -240,7 +240,7 @@ var _default = exports.default = new (_plugin().Runtime)({
240
240
  // Resolve the dependency to a bundle. If inline, export the dependency id,
241
241
  // which will be replaced with the contents of that bundle later.
242
242
  let referencedBundle = bundleGraph.getReferencedBundle(dependency, bundle);
243
- if ((referencedBundle === null || referencedBundle === void 0 ? void 0 : referencedBundle.bundleBehavior) === 'inline') {
243
+ if ((referencedBundle === null || referencedBundle === void 0 ? void 0 : referencedBundle.bundleBehavior) === 'inline' || (referencedBundle === null || referencedBundle === void 0 ? void 0 : referencedBundle.bundleBehavior) === 'inlineIsolated') {
244
244
  assets.push({
245
245
  filePath: _path().default.join(__dirname, `/bundles/${referencedBundle.id}.js`),
246
246
  code: `module.exports = ${JSON.stringify(dependency.id)};`,
@@ -279,7 +279,7 @@ var _default = exports.default = new (_plugin().Runtime)({
279
279
 
280
280
  // Skip URL runtimes for library builds. This is handled in packaging so that
281
281
  // the url is inlined and statically analyzable.
282
- if (bundle.env.isLibrary && mainBundle.bundleBehavior !== 'isolated') {
282
+ if (bundle.env.isLibrary && mainBundle.bundleBehavior !== 'isolated' && mainBundle.bundleBehavior !== 'inlineIsolated') {
283
283
  continue;
284
284
  }
285
285
 
@@ -313,7 +313,7 @@ var _default = exports.default = new (_plugin().Runtime)({
313
313
  });
314
314
  }
315
315
  }
316
- if (shouldUseRuntimeManifest(bundle, options) && bundleGraph.getChildBundles(bundle).some(b => b.bundleBehavior !== 'inline') && isNewContext(bundle, bundleGraph)) {
316
+ if (shouldUseRuntimeManifest(bundle, options) && bundleGraph.getChildBundles(bundle).some(b => b.bundleBehavior !== 'inline' && b.bundleBehavior !== 'inlineIsolated') && isNewContext(bundle, bundleGraph)) {
317
317
  assets.push({
318
318
  filePath: __filename,
319
319
  code: getRegisterCode(bundle, bundleGraph),
@@ -634,7 +634,7 @@ function getRegisterCode(entryBundle, bundleGraph) {
634
634
  // @ts-expect-error TS2304
635
635
  let mappings = [];
636
636
  bundleGraph.traverseBundles((bundle, _, actions) => {
637
- if (bundle.bundleBehavior === 'inline') {
637
+ if (bundle.bundleBehavior === 'inline' || bundle.bundleBehavior === 'inlineIsolated') {
638
638
  return;
639
639
  }
640
640
 
@@ -687,7 +687,7 @@ function getAbsoluteUrlExpr(relativePathExpr, fromBundle, shardingConfig) {
687
687
  }
688
688
  function shouldUseRuntimeManifest(bundle, options) {
689
689
  let env = bundle.env;
690
- return !env.isLibrary && bundle.bundleBehavior !== 'inline' && env.isBrowser() && options.mode === 'production';
690
+ return !env.isLibrary && bundle.bundleBehavior !== 'inline' && bundle.bundleBehavior !== 'inlineIsolated' && env.isBrowser() && options.mode === 'production';
691
691
  }
692
692
  function getManifestBundlePriority(bundleGraph, bundle, threshold) {
693
693
  let bundleSize = 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaspack/runtime-js",
3
- "version": "2.16.1",
3
+ "version": "2.18.0",
4
4
  "license": "(MIT OR Apache-2.0)",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -11,20 +11,21 @@
11
11
  },
12
12
  "main": "./lib/JSRuntime.js",
13
13
  "source": "./src/JSRuntime.ts",
14
- "types": "./lib/JSRuntime.d.ts",
14
+ "types": "./lib/types/JSRuntime.d.ts",
15
15
  "engines": {
16
16
  "node": ">= 16.0.0"
17
17
  },
18
18
  "dependencies": {
19
19
  "@atlaspack/diagnostic": "2.14.2",
20
20
  "@atlaspack/domain-sharding": "2.14.2",
21
- "@atlaspack/feature-flags": "2.20.1",
22
- "@atlaspack/plugin": "2.14.22",
23
- "@atlaspack/utils": "2.17.4",
21
+ "@atlaspack/feature-flags": "2.22.0",
22
+ "@atlaspack/plugin": "2.14.24",
23
+ "@atlaspack/utils": "2.18.1",
24
24
  "nullthrows": "^1.1.1"
25
25
  },
26
26
  "type": "commonjs",
27
27
  "scripts": {
28
- "check-ts": "tsc --emitDeclarationOnly --rootDir src"
28
+ "check-ts": "tsc --emitDeclarationOnly --rootDir src",
29
+ "build:lib": "gulp build --gulpfile ../../../gulpfile.js --cwd ."
29
30
  }
30
- }
31
+ }
package/src/JSRuntime.ts CHANGED
@@ -59,7 +59,7 @@ function getLoaders(ctx: Environment):
59
59
  | null
60
60
  | undefined {
61
61
  // @ts-expect-error TS2322
62
- if (ctx.isWorker()) return LOADERS.worker;
62
+ if (ctx.isWorker() || ctx.isTesseract()) return LOADERS.worker;
63
63
  if (ctx.isBrowser()) return LOADERS.browser;
64
64
  // @ts-expect-error TS2322
65
65
  if (ctx.isNode()) return LOADERS.node;
@@ -183,7 +183,10 @@ export default new Runtime({
183
183
  dependency,
184
184
  bundle,
185
185
  );
186
- if (referencedBundle?.bundleBehavior === 'inline') {
186
+ if (
187
+ referencedBundle?.bundleBehavior === 'inline' ||
188
+ referencedBundle?.bundleBehavior === 'inlineIsolated'
189
+ ) {
187
190
  assets.push({
188
191
  filePath: path.join(
189
192
  __dirname,
@@ -286,7 +289,10 @@ export default new Runtime({
286
289
  dependency,
287
290
  bundle,
288
291
  );
289
- if (referencedBundle?.bundleBehavior === 'inline') {
292
+ if (
293
+ referencedBundle?.bundleBehavior === 'inline' ||
294
+ referencedBundle?.bundleBehavior === 'inlineIsolated'
295
+ ) {
290
296
  assets.push({
291
297
  filePath: path.join(__dirname, `/bundles/${referencedBundle.id}.js`),
292
298
  code: `module.exports = ${JSON.stringify(dependency.id)};`,
@@ -325,7 +331,11 @@ export default new Runtime({
325
331
 
326
332
  // Skip URL runtimes for library builds. This is handled in packaging so that
327
333
  // the url is inlined and statically analyzable.
328
- if (bundle.env.isLibrary && mainBundle.bundleBehavior !== 'isolated') {
334
+ if (
335
+ bundle.env.isLibrary &&
336
+ mainBundle.bundleBehavior !== 'isolated' &&
337
+ mainBundle.bundleBehavior !== 'inlineIsolated'
338
+ ) {
329
339
  continue;
330
340
  }
331
341
 
@@ -382,7 +392,11 @@ export default new Runtime({
382
392
  shouldUseRuntimeManifest(bundle, options) &&
383
393
  bundleGraph
384
394
  .getChildBundles(bundle)
385
- .some((b) => b.bundleBehavior !== 'inline') &&
395
+ .some(
396
+ (b) =>
397
+ b.bundleBehavior !== 'inline' &&
398
+ b.bundleBehavior !== 'inlineIsolated',
399
+ ) &&
386
400
  isNewContext(bundle, bundleGraph)
387
401
  ) {
388
402
  assets.push({
@@ -891,7 +905,10 @@ function getRegisterCode(
891
905
  // @ts-expect-error TS2304
892
906
  let mappings: Array<FilePath | string> = [];
893
907
  bundleGraph.traverseBundles((bundle, _, actions) => {
894
- if (bundle.bundleBehavior === 'inline') {
908
+ if (
909
+ bundle.bundleBehavior === 'inline' ||
910
+ bundle.bundleBehavior === 'inlineIsolated'
911
+ ) {
895
912
  return;
896
913
  }
897
914
 
@@ -982,6 +999,7 @@ function shouldUseRuntimeManifest(
982
999
  return (
983
1000
  !env.isLibrary &&
984
1001
  bundle.bundleBehavior !== 'inline' &&
1002
+ bundle.bundleBehavior !== 'inlineIsolated' &&
985
1003
  env.isBrowser() &&
986
1004
  options.mode === 'production'
987
1005
  );
File without changes