@atlaspack/runtime-js 2.14.1-dev.53 → 2.14.1-dev.55

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/lib/JSRuntime.js CHANGED
@@ -46,8 +46,23 @@ function _featureFlags() {
46
46
  };
47
47
  return data;
48
48
  }
49
+ function _core() {
50
+ const data = require("@atlaspack/core");
51
+ _core = function () {
52
+ return data;
53
+ };
54
+ return data;
55
+ }
49
56
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
57
+ const domainShardingImports = (0, _core().isSuperPackage)() ? {
58
+ specifier: '@atlaspack/super/lib/domain-sharding.js',
59
+ helper: './helpers/browser/esm-js-loader-shards-super.js'
60
+ } : {
61
+ specifier: '@atlaspack/domain-sharding',
62
+ helper: './helpers/browser/esm-js-loader-shards.js'
63
+ };
50
64
  const filename = /*#__ATLASPACK_IGNORE__*/__filename;
65
+ const dirname = /*#__ATLASPACK_IGNORE__*/__dirname;
51
66
 
52
67
  // Used for as="" in preload/prefetch
53
68
  const TYPE_TO_RESOURCE_PRIORITY = {
@@ -179,7 +194,7 @@ var _default = exports.default = new (_plugin().Runtime)({
179
194
  let referencedBundle = bundleGraph.getReferencedBundle(dependency, bundle);
180
195
  if ((referencedBundle === null || referencedBundle === void 0 ? void 0 : referencedBundle.bundleBehavior) === 'inline') {
181
196
  assets.push({
182
- filePath: _path().default.join(__dirname, `/bundles/${referencedBundle.id}.js`),
197
+ filePath: _path().default.join(dirname, `/bundles/${referencedBundle.id}.js`),
183
198
  code: `module.exports = Promise.resolve(${JSON.stringify(dependency.id)});`,
184
199
  dependency,
185
200
  env: {
@@ -210,7 +225,7 @@ var _default = exports.default = new (_plugin().Runtime)({
210
225
  const requireName = bundle.env.shouldScopeHoist ? 'parcelRequire' : '__parcel__require__';
211
226
  const assetCode = `module.exports = require('../helpers/conditional-loader${options.mode === 'development' ? '-dev' : ''}')('${cond.key}', function (){return ${requireName}('${cond.ifTrueAssetId}')}, function (){return ${requireName}('${cond.ifFalseAssetId}')})`;
212
227
  assets.push({
213
- filePath: _path().default.join(__dirname, `/conditions/${cond.publicId}.js`),
228
+ filePath: _path().default.join(dirname, `/conditions/${cond.publicId}.js`),
214
229
  code: assetCode,
215
230
  // This dependency is important, as it's the last symbol handled in scope hoisting.
216
231
  // That means that scope hoisting will use the module id for this asset to replace the symbol
@@ -228,7 +243,7 @@ var _default = exports.default = new (_plugin().Runtime)({
228
243
  let referencedBundle = bundleGraph.getReferencedBundle(dependency, bundle);
229
244
  if ((referencedBundle === null || referencedBundle === void 0 ? void 0 : referencedBundle.bundleBehavior) === 'inline') {
230
245
  assets.push({
231
- filePath: _path().default.join(__dirname, `/bundles/${referencedBundle.id}.js`),
246
+ filePath: _path().default.join(dirname, `/bundles/${referencedBundle.id}.js`),
232
247
  code: `module.exports = ${JSON.stringify(dependency.id)};`,
233
248
  dependency,
234
249
  env: {
@@ -420,7 +435,7 @@ function getLoaderRuntime({
420
435
  let publicId = JSON.stringify(to.publicId);
421
436
  absoluteUrlExpr = `require('./helpers/bundle-manifest').resolve(${publicId})`;
422
437
  if (shardingConfig) {
423
- absoluteUrlExpr = `require('@atlaspack/domain-sharding').shardUrl(${absoluteUrlExpr}, ${shardingConfig.maxShards})`;
438
+ absoluteUrlExpr = `require('${domainShardingImports.specifier}').shardUrl(${absoluteUrlExpr}, ${shardingConfig.maxShards})`;
424
439
  }
425
440
  } else {
426
441
  absoluteUrlExpr = getAbsoluteUrlExpr(relativePathExpr, bundle, shardingConfig);
@@ -522,7 +537,7 @@ function getLoaderRuntime({
522
537
  }
523
538
  let code = [];
524
539
  if (needsEsmLoadPrelude) {
525
- let preludeLoad = shardingConfig ? `let load = require('./helpers/browser/esm-js-loader-shards')(${shardingConfig.maxShards});` : `let load = require('./helpers/browser/esm-js-loader');`;
540
+ let preludeLoad = shardingConfig ? `let load = require('${domainShardingImports.helper}')(${shardingConfig.maxShards});` : `let load = require('./helpers/browser/esm-js-loader');`;
526
541
  code.push(preludeLoad);
527
542
  }
528
543
  code.push(`module.exports = ${loaderCode};`);
@@ -593,7 +608,7 @@ function getURLRuntime(dependency, from, to, options, shardingConfig) {
593
608
  code += `let bundleURL = require('./helpers/bundle-url');\n`;
594
609
  code += `let url = bundleURL.getBundleURL('${from.publicId}') + ${relativePathExpr};`;
595
610
  if (shardingConfig) {
596
- code += `url = require('@atlaspack/domain-sharding').shardUrl(url, ${shardingConfig.maxShards});`;
611
+ code += `url = require('${domainShardingImports.specifier}').shardUrl(url, ${shardingConfig.maxShards});`;
597
612
  }
598
613
  code += `module.exports = workerURL(url, bundleURL.getOrigin(url), ${String(from.env.outputFormat === 'esmodule')});`;
599
614
  }
@@ -655,7 +670,7 @@ function getAbsoluteUrlExpr(relativePathExpr, fromBundle, shardingConfig) {
655
670
  if (!shardingConfig) {
656
671
  return regularBundleUrl;
657
672
  }
658
- return `require('@atlaspack/domain-sharding').shardUrl(${regularBundleUrl}, ${shardingConfig.maxShards})`;
673
+ return `require('${domainShardingImports.specifier}').shardUrl(${regularBundleUrl}, ${shardingConfig.maxShards})`;
659
674
  }
660
675
  function shouldUseRuntimeManifest(bundle, options) {
661
676
  let env = bundle.env;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+
3
+ let load = maxShards => id => {
4
+ // eslint-disable-next-line no-undef
5
+ return __parcel__import__(require('@atlaspack/super/lib/domain-sharding').shardUrl(require('../bundle-manifest').resolve(id), maxShards));
6
+ };
7
+ module.exports = load;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaspack/runtime-js",
3
- "version": "2.14.1-dev.53+75290c6cb",
3
+ "version": "2.14.1-dev.55+f298b7f5c",
4
4
  "license": "(MIT OR Apache-2.0)",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -18,13 +18,13 @@
18
18
  "node": ">= 16.0.0"
19
19
  },
20
20
  "dependencies": {
21
- "@atlaspack/diagnostic": "2.14.1-dev.53+75290c6cb",
22
- "@atlaspack/domain-sharding": "2.14.1-dev.53+75290c6cb",
23
- "@atlaspack/feature-flags": "2.14.1-dev.53+75290c6cb",
24
- "@atlaspack/plugin": "2.14.1-dev.53+75290c6cb",
25
- "@atlaspack/utils": "2.14.1-dev.53+75290c6cb",
21
+ "@atlaspack/diagnostic": "2.14.1-dev.55+f298b7f5c",
22
+ "@atlaspack/domain-sharding": "2.14.1-dev.55+f298b7f5c",
23
+ "@atlaspack/feature-flags": "2.14.1-dev.55+f298b7f5c",
24
+ "@atlaspack/plugin": "2.14.1-dev.55+f298b7f5c",
25
+ "@atlaspack/utils": "2.14.1-dev.55+f298b7f5c",
26
26
  "nullthrows": "^1.1.1"
27
27
  },
28
28
  "type": "commonjs",
29
- "gitHead": "75290c6cb03e7253ab1f9bfc6859d518a7d313cc"
29
+ "gitHead": "f298b7f5cac438d5150790475bde0cb959b3f6a5"
30
30
  }
package/src/JSRuntime.js CHANGED
@@ -19,8 +19,20 @@ import {encodeJSONKeyComponent} from '@atlaspack/diagnostic';
19
19
  import path from 'path';
20
20
  import nullthrows from 'nullthrows';
21
21
  import {getFeatureFlag} from '@atlaspack/feature-flags';
22
+ import {isSuperPackage} from '@atlaspack/core';
23
+
24
+ const domainShardingImports = isSuperPackage()
25
+ ? {
26
+ specifier: '@atlaspack/super/lib/domain-sharding.js',
27
+ helper: './helpers/browser/esm-js-loader-shards-super.js',
28
+ }
29
+ : {
30
+ specifier: '@atlaspack/domain-sharding',
31
+ helper: './helpers/browser/esm-js-loader-shards.js',
32
+ };
22
33
 
23
34
  const filename = /*#__ATLASPACK_IGNORE__*/ __filename;
35
+ const dirname = /*#__ATLASPACK_IGNORE__*/ __dirname;
24
36
 
25
37
  // Used for as="" in preload/prefetch
26
38
  const TYPE_TO_RESOURCE_PRIORITY = {
@@ -176,10 +188,7 @@ export default (new Runtime({
176
188
  );
177
189
  if (referencedBundle?.bundleBehavior === 'inline') {
178
190
  assets.push({
179
- filePath: path.join(
180
- __dirname,
181
- `/bundles/${referencedBundle.id}.js`,
182
- ),
191
+ filePath: path.join(dirname, `/bundles/${referencedBundle.id}.js`),
183
192
  code: `module.exports = Promise.resolve(${JSON.stringify(
184
193
  dependency.id,
185
194
  )});`,
@@ -224,7 +233,7 @@ export default (new Runtime({
224
233
  }')}, function (){return ${requireName}('${cond.ifFalseAssetId}')})`;
225
234
 
226
235
  assets.push({
227
- filePath: path.join(__dirname, `/conditions/${cond.publicId}.js`),
236
+ filePath: path.join(dirname, `/conditions/${cond.publicId}.js`),
228
237
  code: assetCode,
229
238
  // This dependency is important, as it's the last symbol handled in scope hoisting.
230
239
  // That means that scope hoisting will use the module id for this asset to replace the symbol
@@ -244,7 +253,7 @@ export default (new Runtime({
244
253
  );
245
254
  if (referencedBundle?.bundleBehavior === 'inline') {
246
255
  assets.push({
247
- filePath: path.join(__dirname, `/bundles/${referencedBundle.id}.js`),
256
+ filePath: path.join(dirname, `/bundles/${referencedBundle.id}.js`),
248
257
  code: `module.exports = ${JSON.stringify(dependency.id)};`,
249
258
  dependency,
250
259
  env: {sourceType: 'module'},
@@ -504,7 +513,7 @@ function getLoaderRuntime({
504
513
  absoluteUrlExpr = `require('./helpers/bundle-manifest').resolve(${publicId})`;
505
514
 
506
515
  if (shardingConfig) {
507
- absoluteUrlExpr = `require('@atlaspack/domain-sharding').shardUrl(${absoluteUrlExpr}, ${shardingConfig.maxShards})`;
516
+ absoluteUrlExpr = `require('${domainShardingImports.specifier}').shardUrl(${absoluteUrlExpr}, ${shardingConfig.maxShards})`;
508
517
  }
509
518
  } else {
510
519
  absoluteUrlExpr = getAbsoluteUrlExpr(
@@ -711,7 +720,7 @@ function getLoaderRuntime({
711
720
 
712
721
  if (needsEsmLoadPrelude) {
713
722
  let preludeLoad = shardingConfig
714
- ? `let load = require('./helpers/browser/esm-js-loader-shards')(${shardingConfig.maxShards});`
723
+ ? `let load = require('${domainShardingImports.helper}')(${shardingConfig.maxShards});`
715
724
  : `let load = require('./helpers/browser/esm-js-loader');`;
716
725
 
717
726
  code.push(preludeLoad);
@@ -833,7 +842,7 @@ function getURLRuntime(
833
842
  code += `let bundleURL = require('./helpers/bundle-url');\n`;
834
843
  code += `let url = bundleURL.getBundleURL('${from.publicId}') + ${relativePathExpr};`;
835
844
  if (shardingConfig) {
836
- code += `url = require('@atlaspack/domain-sharding').shardUrl(url, ${shardingConfig.maxShards});`;
845
+ code += `url = require('${domainShardingImports.specifier}').shardUrl(url, ${shardingConfig.maxShards});`;
837
846
  }
838
847
  code += `module.exports = workerURL(url, bundleURL.getOrigin(url), ${String(
839
848
  from.env.outputFormat === 'esmodule',
@@ -934,7 +943,7 @@ function getAbsoluteUrlExpr(
934
943
  return regularBundleUrl;
935
944
  }
936
945
 
937
- return `require('@atlaspack/domain-sharding').shardUrl(${regularBundleUrl}, ${shardingConfig.maxShards})`;
946
+ return `require('${domainShardingImports.specifier}').shardUrl(${regularBundleUrl}, ${shardingConfig.maxShards})`;
938
947
  }
939
948
 
940
949
  function shouldUseRuntimeManifest(
@@ -0,0 +1,11 @@
1
+ let load = (maxShards) => (id) => {
2
+ // eslint-disable-next-line no-undef
3
+ return __parcel__import__(
4
+ require('@atlaspack/super/lib/domain-sharding').shardUrl(
5
+ require('../bundle-manifest').resolve(id),
6
+ maxShards,
7
+ ),
8
+ );
9
+ };
10
+
11
+ module.exports = load;