@atlaspack/runtime-js 2.14.5-dev.72 → 2.14.5-dev.73

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,24 +46,7 @@ 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
- }
56
49
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
57
- const domainShardingImports = (0, _core().isSuperPackage)() ? {
58
- specifier: 'atlaspack/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
- };
64
- const filename = /*#__ATLASPACK_IGNORE__*/__filename;
65
- const dirname = /*#__ATLASPACK_IGNORE__*/__dirname;
66
-
67
50
  // Used for as="" in preload/prefetch
68
51
  const TYPE_TO_RESOURCE_PRIORITY = {
69
52
  css: 'style',
@@ -180,7 +163,7 @@ var _default = exports.default = new (_plugin().Runtime)({
180
163
  // return a simple runtime of `Promise.resolve(internalRequire(assetId))`.
181
164
  // The linker handles this for scope-hoisting.
182
165
  assets.push({
183
- filePath: filename,
166
+ filePath: __filename,
184
167
  code: `module.exports = Promise.resolve(module.bundle.root(${JSON.stringify(bundleGraph.getAssetPublicId(resolved.value))}))`,
185
168
  dependency,
186
169
  env: {
@@ -194,7 +177,7 @@ var _default = exports.default = new (_plugin().Runtime)({
194
177
  let referencedBundle = bundleGraph.getReferencedBundle(dependency, bundle);
195
178
  if ((referencedBundle === null || referencedBundle === void 0 ? void 0 : referencedBundle.bundleBehavior) === 'inline') {
196
179
  assets.push({
197
- filePath: _path().default.join(dirname, `/bundles/${referencedBundle.id}.js`),
180
+ filePath: _path().default.join(__dirname, `/bundles/${referencedBundle.id}.js`),
198
181
  code: `module.exports = Promise.resolve(${JSON.stringify(dependency.id)});`,
199
182
  dependency,
200
183
  env: {
@@ -225,7 +208,7 @@ var _default = exports.default = new (_plugin().Runtime)({
225
208
  const requireName = bundle.env.shouldScopeHoist ? 'parcelRequire' : '__parcel__require__';
226
209
  const assetCode = `module.exports = require('../helpers/conditional-loader${options.mode === 'development' ? '-dev' : ''}')('${cond.key}', function (){return ${requireName}('${cond.ifTrueAssetId}')}, function (){return ${requireName}('${cond.ifFalseAssetId}')})`;
227
210
  assets.push({
228
- filePath: _path().default.join(dirname, `/conditions/${cond.publicId}.js`),
211
+ filePath: _path().default.join(__dirname, `/conditions/${cond.publicId}.js`),
229
212
  code: assetCode,
230
213
  // This dependency is important, as it's the last symbol handled in scope hoisting.
231
214
  // That means that scope hoisting will use the module id for this asset to replace the symbol
@@ -243,7 +226,7 @@ var _default = exports.default = new (_plugin().Runtime)({
243
226
  let referencedBundle = bundleGraph.getReferencedBundle(dependency, bundle);
244
227
  if ((referencedBundle === null || referencedBundle === void 0 ? void 0 : referencedBundle.bundleBehavior) === 'inline') {
245
228
  assets.push({
246
- filePath: _path().default.join(dirname, `/bundles/${referencedBundle.id}.js`),
229
+ filePath: _path().default.join(__dirname, `/bundles/${referencedBundle.id}.js`),
247
230
  code: `module.exports = ${JSON.stringify(dependency.id)};`,
248
231
  dependency,
249
232
  env: {
@@ -260,7 +243,7 @@ var _default = exports.default = new (_plugin().Runtime)({
260
243
  // If a URL dependency was not able to be resolved, add a runtime that
261
244
  // exports the original specifier.
262
245
  assets.push({
263
- filePath: filename,
246
+ filePath: __filename,
264
247
  code: `module.exports = ${JSON.stringify(dependency.specifier)}`,
265
248
  dependency,
266
249
  env: {
@@ -278,15 +261,6 @@ var _default = exports.default = new (_plugin().Runtime)({
278
261
  return entries.some(e => bundleGroup.entryAssetId === e.id);
279
262
  }));
280
263
 
281
- // Skip URL runtime for native node imports as they need to be require
282
- // directly
283
- // Currently enabled only for internal builds
284
- if (process.env.ATLASPACK_SUPER_BUILD === 'true') {
285
- if (mainBundle.bundleBehavior === 'isolated' && mainBundle.env.context === 'node' && mainBundle.type === 'node') {
286
- continue;
287
- }
288
- }
289
-
290
264
  // Skip URL runtimes for library builds. This is handled in packaging so that
291
265
  // the url is inlined and statically analyzable.
292
266
  if (bundle.env.isLibrary && mainBundle.bundleBehavior !== 'isolated') {
@@ -314,7 +288,7 @@ var _default = exports.default = new (_plugin().Runtime)({
314
288
  let relativePathExpr = getRelativePathExpr(bundle, referencedBundle, options);
315
289
  let loaderCode = `require(${JSON.stringify(loader)})(${getAbsoluteUrlExpr(relativePathExpr, bundle, config.domainSharding)})`;
316
290
  assets.push({
317
- filePath: filename,
291
+ filePath: __filename,
318
292
  code: loaderCode,
319
293
  isEntry: true,
320
294
  env: {
@@ -325,7 +299,7 @@ var _default = exports.default = new (_plugin().Runtime)({
325
299
  }
326
300
  if (shouldUseRuntimeManifest(bundle, options) && bundleGraph.getChildBundles(bundle).some(b => b.bundleBehavior !== 'inline') && isNewContext(bundle, bundleGraph)) {
327
301
  assets.push({
328
- filePath: filename,
302
+ filePath: __filename,
329
303
  code: getRegisterCode(bundle, bundleGraph),
330
304
  isEntry: true,
331
305
  env: {
@@ -435,7 +409,7 @@ function getLoaderRuntime({
435
409
  let publicId = JSON.stringify(to.publicId);
436
410
  absoluteUrlExpr = `require('./helpers/bundle-manifest').resolve(${publicId})`;
437
411
  if (shardingConfig) {
438
- absoluteUrlExpr = `require('${domainShardingImports.specifier}').shardUrl(${absoluteUrlExpr}, ${shardingConfig.maxShards})`;
412
+ absoluteUrlExpr = `require('@atlaspack/domain-sharding').shardUrl(${absoluteUrlExpr}, ${shardingConfig.maxShards})`;
439
413
  }
440
414
  } else {
441
415
  absoluteUrlExpr = getAbsoluteUrlExpr(relativePathExpr, bundle, shardingConfig);
@@ -527,7 +501,7 @@ function getLoaderRuntime({
527
501
  });
528
502
  }})`;
529
503
  return {
530
- filePath: filename,
504
+ filePath: __filename,
531
505
  code: loaderCode,
532
506
  dependency,
533
507
  env: {
@@ -537,12 +511,12 @@ function getLoaderRuntime({
537
511
  }
538
512
  let code = [];
539
513
  if (needsEsmLoadPrelude) {
540
- let preludeLoad = shardingConfig ? `let load = require('${domainShardingImports.helper}')(${shardingConfig.maxShards});` : `let load = require('./helpers/browser/esm-js-loader');`;
514
+ let preludeLoad = shardingConfig ? `let load = require('./helpers/browser/esm-js-loader-shards')(${shardingConfig.maxShards});` : `let load = require('./helpers/browser/esm-js-loader');`;
541
515
  code.push(preludeLoad);
542
516
  }
543
517
  code.push(`module.exports = ${loaderCode};`);
544
518
  return {
545
- filePath: filename,
519
+ filePath: __filename,
546
520
  code: code.join('\n'),
547
521
  dependency,
548
522
  env: {
@@ -608,7 +582,7 @@ function getURLRuntime(dependency, from, to, options, shardingConfig) {
608
582
  code += `let bundleURL = require('./helpers/bundle-url');\n`;
609
583
  code += `let url = bundleURL.getBundleURL('${from.publicId}') + ${relativePathExpr};`;
610
584
  if (shardingConfig) {
611
- code += `url = require('${domainShardingImports.specifier}').shardUrl(url, ${shardingConfig.maxShards});`;
585
+ code += `url = require('@atlaspack/domain-sharding').shardUrl(url, ${shardingConfig.maxShards});`;
612
586
  }
613
587
  code += `module.exports = workerURL(url, bundleURL.getOrigin(url), ${String(from.env.outputFormat === 'esmodule')});`;
614
588
  }
@@ -616,7 +590,7 @@ function getURLRuntime(dependency, from, to, options, shardingConfig) {
616
590
  code = `module.exports = ${getAbsoluteUrlExpr(relativePathExpr, from, shardingConfig)};`;
617
591
  }
618
592
  return {
619
- filePath: filename,
593
+ filePath: __filename,
620
594
  code,
621
595
  dependency,
622
596
  env: {
@@ -670,7 +644,7 @@ function getAbsoluteUrlExpr(relativePathExpr, fromBundle, shardingConfig) {
670
644
  if (!shardingConfig) {
671
645
  return regularBundleUrl;
672
646
  }
673
- return `require('${domainShardingImports.specifier}').shardUrl(${regularBundleUrl}, ${shardingConfig.maxShards})`;
647
+ return `require('@atlaspack/domain-sharding').shardUrl(${regularBundleUrl}, ${shardingConfig.maxShards})`;
674
648
  }
675
649
  function shouldUseRuntimeManifest(bundle, options) {
676
650
  let env = bundle.env;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaspack/runtime-js",
3
- "version": "2.14.5-dev.72+9840480de",
3
+ "version": "2.14.5-dev.73+84eec3484",
4
4
  "license": "(MIT OR Apache-2.0)",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -11,20 +11,17 @@
11
11
  },
12
12
  "main": "lib/JSRuntime.js",
13
13
  "source": "src/JSRuntime.js",
14
- "atlaspackReferences": [
15
- "./src/helpers/**/*"
16
- ],
17
14
  "engines": {
18
15
  "node": ">= 16.0.0"
19
16
  },
20
17
  "dependencies": {
21
- "@atlaspack/diagnostic": "2.14.1-dev.140+9840480de",
22
- "@atlaspack/domain-sharding": "2.14.1-dev.140+9840480de",
23
- "@atlaspack/feature-flags": "2.14.1-dev.140+9840480de",
24
- "@atlaspack/plugin": "2.14.5-dev.72+9840480de",
25
- "@atlaspack/utils": "2.14.5-dev.72+9840480de",
18
+ "@atlaspack/diagnostic": "2.14.1-dev.141+84eec3484",
19
+ "@atlaspack/domain-sharding": "2.14.1-dev.141+84eec3484",
20
+ "@atlaspack/feature-flags": "2.14.1-dev.141+84eec3484",
21
+ "@atlaspack/plugin": "2.14.5-dev.73+84eec3484",
22
+ "@atlaspack/utils": "2.14.5-dev.73+84eec3484",
26
23
  "nullthrows": "^1.1.1"
27
24
  },
28
25
  "type": "commonjs",
29
- "gitHead": "9840480de27511f558d8f5b8cf82220de977b4fb"
26
+ "gitHead": "84eec348413c647de4872f902c4bc8ff54c347f3"
30
27
  }
package/src/JSRuntime.js CHANGED
@@ -19,20 +19,6 @@ 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/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
- };
33
-
34
- const filename = /*#__ATLASPACK_IGNORE__*/ __filename;
35
- const dirname = /*#__ATLASPACK_IGNORE__*/ __dirname;
36
22
 
37
23
  // Used for as="" in preload/prefetch
38
24
  const TYPE_TO_RESOURCE_PRIORITY = {
@@ -171,7 +157,7 @@ export default (new Runtime({
171
157
  // return a simple runtime of `Promise.resolve(internalRequire(assetId))`.
172
158
  // The linker handles this for scope-hoisting.
173
159
  assets.push({
174
- filePath: filename,
160
+ filePath: __filename,
175
161
  code: `module.exports = Promise.resolve(module.bundle.root(${JSON.stringify(
176
162
  bundleGraph.getAssetPublicId(resolved.value),
177
163
  )}))`,
@@ -188,7 +174,10 @@ export default (new Runtime({
188
174
  );
189
175
  if (referencedBundle?.bundleBehavior === 'inline') {
190
176
  assets.push({
191
- filePath: path.join(dirname, `/bundles/${referencedBundle.id}.js`),
177
+ filePath: path.join(
178
+ __dirname,
179
+ `/bundles/${referencedBundle.id}.js`,
180
+ ),
192
181
  code: `module.exports = Promise.resolve(${JSON.stringify(
193
182
  dependency.id,
194
183
  )});`,
@@ -233,7 +222,7 @@ export default (new Runtime({
233
222
  }')}, function (){return ${requireName}('${cond.ifFalseAssetId}')})`;
234
223
 
235
224
  assets.push({
236
- filePath: path.join(dirname, `/conditions/${cond.publicId}.js`),
225
+ filePath: path.join(__dirname, `/conditions/${cond.publicId}.js`),
237
226
  code: assetCode,
238
227
  // This dependency is important, as it's the last symbol handled in scope hoisting.
239
228
  // That means that scope hoisting will use the module id for this asset to replace the symbol
@@ -253,7 +242,7 @@ export default (new Runtime({
253
242
  );
254
243
  if (referencedBundle?.bundleBehavior === 'inline') {
255
244
  assets.push({
256
- filePath: path.join(dirname, `/bundles/${referencedBundle.id}.js`),
245
+ filePath: path.join(__dirname, `/bundles/${referencedBundle.id}.js`),
257
246
  code: `module.exports = ${JSON.stringify(dependency.id)};`,
258
247
  dependency,
259
248
  env: {sourceType: 'module'},
@@ -268,7 +257,7 @@ export default (new Runtime({
268
257
  // If a URL dependency was not able to be resolved, add a runtime that
269
258
  // exports the original specifier.
270
259
  assets.push({
271
- filePath: filename,
260
+ filePath: __filename,
272
261
  code: `module.exports = ${JSON.stringify(dependency.specifier)}`,
273
262
  dependency,
274
263
  env: {sourceType: 'module'},
@@ -288,19 +277,6 @@ export default (new Runtime({
288
277
  }),
289
278
  );
290
279
 
291
- // Skip URL runtime for native node imports as they need to be require
292
- // directly
293
- // Currently enabled only for internal builds
294
- if (process.env.ATLASPACK_SUPER_BUILD === 'true') {
295
- if (
296
- mainBundle.bundleBehavior === 'isolated' &&
297
- mainBundle.env.context === 'node' &&
298
- mainBundle.type === 'node'
299
- ) {
300
- continue;
301
- }
302
- }
303
-
304
280
  // Skip URL runtimes for library builds. This is handled in packaging so that
305
281
  // the url is inlined and statically analyzable.
306
282
  if (bundle.env.isLibrary && mainBundle.bundleBehavior !== 'isolated') {
@@ -348,7 +324,7 @@ export default (new Runtime({
348
324
  config.domainSharding,
349
325
  )})`;
350
326
  assets.push({
351
- filePath: filename,
327
+ filePath: __filename,
352
328
  code: loaderCode,
353
329
  isEntry: true,
354
330
  env: {sourceType: 'module'},
@@ -364,7 +340,7 @@ export default (new Runtime({
364
340
  isNewContext(bundle, bundleGraph)
365
341
  ) {
366
342
  assets.push({
367
- filePath: filename,
343
+ filePath: __filename,
368
344
  code: getRegisterCode(bundle, bundleGraph),
369
345
  isEntry: true,
370
346
  env: {sourceType: 'module'},
@@ -513,7 +489,7 @@ function getLoaderRuntime({
513
489
  absoluteUrlExpr = `require('./helpers/bundle-manifest').resolve(${publicId})`;
514
490
 
515
491
  if (shardingConfig) {
516
- absoluteUrlExpr = `require('${domainShardingImports.specifier}').shardUrl(${absoluteUrlExpr}, ${shardingConfig.maxShards})`;
492
+ absoluteUrlExpr = `require('@atlaspack/domain-sharding').shardUrl(${absoluteUrlExpr}, ${shardingConfig.maxShards})`;
517
493
  }
518
494
  } else {
519
495
  absoluteUrlExpr = getAbsoluteUrlExpr(
@@ -709,7 +685,7 @@ function getLoaderRuntime({
709
685
  }})`;
710
686
 
711
687
  return {
712
- filePath: filename,
688
+ filePath: __filename,
713
689
  code: loaderCode,
714
690
  dependency,
715
691
  env: {sourceType: 'module'},
@@ -720,7 +696,7 @@ function getLoaderRuntime({
720
696
 
721
697
  if (needsEsmLoadPrelude) {
722
698
  let preludeLoad = shardingConfig
723
- ? `let load = require('${domainShardingImports.helper}')(${shardingConfig.maxShards});`
699
+ ? `let load = require('./helpers/browser/esm-js-loader-shards')(${shardingConfig.maxShards});`
724
700
  : `let load = require('./helpers/browser/esm-js-loader');`;
725
701
 
726
702
  code.push(preludeLoad);
@@ -729,7 +705,7 @@ function getLoaderRuntime({
729
705
  code.push(`module.exports = ${loaderCode};`);
730
706
 
731
707
  return {
732
- filePath: filename,
708
+ filePath: __filename,
733
709
  code: code.join('\n'),
734
710
  dependency,
735
711
  env: {sourceType: 'module'},
@@ -842,7 +818,7 @@ function getURLRuntime(
842
818
  code += `let bundleURL = require('./helpers/bundle-url');\n`;
843
819
  code += `let url = bundleURL.getBundleURL('${from.publicId}') + ${relativePathExpr};`;
844
820
  if (shardingConfig) {
845
- code += `url = require('${domainShardingImports.specifier}').shardUrl(url, ${shardingConfig.maxShards});`;
821
+ code += `url = require('@atlaspack/domain-sharding').shardUrl(url, ${shardingConfig.maxShards});`;
846
822
  }
847
823
  code += `module.exports = workerURL(url, bundleURL.getOrigin(url), ${String(
848
824
  from.env.outputFormat === 'esmodule',
@@ -857,7 +833,7 @@ function getURLRuntime(
857
833
  }
858
834
 
859
835
  return {
860
- filePath: filename,
836
+ filePath: __filename,
861
837
  code,
862
838
  dependency,
863
839
  env: {sourceType: 'module'},
@@ -943,7 +919,7 @@ function getAbsoluteUrlExpr(
943
919
  return regularBundleUrl;
944
920
  }
945
921
 
946
- return `require('${domainShardingImports.specifier}').shardUrl(${regularBundleUrl}, ${shardingConfig.maxShards})`;
922
+ return `require('@atlaspack/domain-sharding').shardUrl(${regularBundleUrl}, ${shardingConfig.maxShards})`;
947
923
  }
948
924
 
949
925
  function shouldUseRuntimeManifest(
@@ -1,7 +0,0 @@
1
- "use strict";
2
-
3
- let load = maxShards => id => {
4
- // eslint-disable-next-line no-undef
5
- return __parcel__import__(require('atlaspack/lib/domain-sharding').shardUrl(require('../bundle-manifest').resolve(id), maxShards));
6
- };
7
- module.exports = load;
@@ -1,11 +0,0 @@
1
- let load = (maxShards) => (id) => {
2
- // eslint-disable-next-line no-undef
3
- return __parcel__import__(
4
- require('atlaspack/lib/domain-sharding').shardUrl(
5
- require('../bundle-manifest').resolve(id),
6
- maxShards,
7
- ),
8
- );
9
- };
10
-
11
- module.exports = load;