@atlaspack/runtime-js 2.14.5-dev.1c70d50f9.99 → 2.14.5-dev.69

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,43 +1,5 @@
1
1
  # @atlaspack/runtime-js
2
2
 
3
- ## 2.14.14
4
-
5
- ### Patch Changes
6
-
7
- - Updated dependencies [[`644b157`](https://github.com/atlassian-labs/atlaspack/commit/644b157dee72a871acc2d0facf0b87b8eea51956)]:
8
- - @atlaspack/feature-flags@2.18.2
9
- - @atlaspack/utils@2.15.2
10
- - @atlaspack/plugin@2.14.14
11
-
12
- ## 2.14.13
13
-
14
- ### Patch Changes
15
-
16
- - [#633](https://github.com/atlassian-labs/atlaspack/pull/633) [`26aa9c5`](https://github.com/atlassian-labs/atlaspack/commit/26aa9c599d2be45ce1438a74c5fa22f39b9b554b) Thanks [@sbhuiyan-atlassian](https://github.com/sbhuiyan-atlassian)! - Ported various HMR changes from Parcel
17
-
18
- - Updated dependencies [[`26aa9c5`](https://github.com/atlassian-labs/atlaspack/commit/26aa9c599d2be45ce1438a74c5fa22f39b9b554b), [`0501255`](https://github.com/atlassian-labs/atlaspack/commit/05012550da35b05ce7d356a8cc29311e7f9afdca)]:
19
- - @atlaspack/feature-flags@2.18.1
20
- - @atlaspack/utils@2.15.1
21
- - @atlaspack/plugin@2.14.13
22
-
23
- ## 2.14.12
24
-
25
- ### Patch Changes
26
-
27
- - Updated dependencies [[`10fbcfb`](https://github.com/atlassian-labs/atlaspack/commit/10fbcfbfa49c7a83da5d7c40983e36e87f524a75), [`85c52d3`](https://github.com/atlassian-labs/atlaspack/commit/85c52d3f7717b3c84a118d18ab98cfbfd71dcbd2), [`e39c6cf`](https://github.com/atlassian-labs/atlaspack/commit/e39c6cf05f7e95ce5420dbcea66f401b1cbd397c)]:
28
- - @atlaspack/feature-flags@2.18.0
29
- - @atlaspack/utils@2.15.0
30
- - @atlaspack/plugin@2.14.12
31
-
32
- ## 2.14.11
33
-
34
- ### Patch Changes
35
-
36
- - Updated dependencies [[`73ea3c4`](https://github.com/atlassian-labs/atlaspack/commit/73ea3c4d85d4401fdd15abcbf988237e890e7ad3), [`b1b3693`](https://github.com/atlassian-labs/atlaspack/commit/b1b369317c66f8a431c170df2ebba4fa5b2e38ef)]:
37
- - @atlaspack/feature-flags@2.17.0
38
- - @atlaspack/utils@2.14.11
39
- - @atlaspack/plugin@2.14.11
40
-
41
3
  ## 2.14.10
42
4
 
43
5
  ### Patch Changes
package/lib/JSRuntime.js CHANGED
@@ -46,7 +46,24 @@ 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/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
+
50
67
  // Used for as="" in preload/prefetch
51
68
  const TYPE_TO_RESOURCE_PRIORITY = {
52
69
  css: 'style',
@@ -162,11 +179,9 @@ var _default = exports.default = new (_plugin().Runtime)({
162
179
  // If this bundle already has the asset this dependency references,
163
180
  // return a simple runtime of `Promise.resolve(internalRequire(assetId))`.
164
181
  // The linker handles this for scope-hoisting.
165
-
166
- const requireName = (0, _featureFlags().getFeatureFlag)('hmrImprovements') ? 'parcelRequire' : 'module.bundle.root';
167
182
  assets.push({
168
- filePath: __filename,
169
- code: `module.exports = Promise.resolve(${requireName}(${JSON.stringify(bundleGraph.getAssetPublicId(resolved.value))}))`,
183
+ filePath: filename,
184
+ code: `module.exports = Promise.resolve(module.bundle.root(${JSON.stringify(bundleGraph.getAssetPublicId(resolved.value))}))`,
170
185
  dependency,
171
186
  env: {
172
187
  sourceType: 'module'
@@ -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: {
@@ -207,10 +222,10 @@ var _default = exports.default = new (_plugin().Runtime)({
207
222
  // replaced with a reference to this asset to implement the selection.
208
223
  const conditions = bundleGraph.getConditionsForDependencies(conditionalDependencies, bundle);
209
224
  for (const cond of conditions) {
210
- const requireName = (0, _featureFlags().getFeatureFlag)('hmrImprovements') || bundle.env.shouldScopeHoist ? 'parcelRequire' : '__parcel__require__';
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: {
@@ -245,7 +260,7 @@ var _default = exports.default = new (_plugin().Runtime)({
245
260
  // If a URL dependency was not able to be resolved, add a runtime that
246
261
  // exports the original specifier.
247
262
  assets.push({
248
- filePath: __filename,
263
+ filePath: filename,
249
264
  code: `module.exports = ${JSON.stringify(dependency.specifier)}`,
250
265
  dependency,
251
266
  env: {
@@ -263,6 +278,15 @@ var _default = exports.default = new (_plugin().Runtime)({
263
278
  return entries.some(e => bundleGroup.entryAssetId === e.id);
264
279
  }));
265
280
 
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
+
266
290
  // Skip URL runtimes for library builds. This is handled in packaging so that
267
291
  // the url is inlined and statically analyzable.
268
292
  if (bundle.env.isLibrary && mainBundle.bundleBehavior !== 'isolated') {
@@ -290,7 +314,7 @@ var _default = exports.default = new (_plugin().Runtime)({
290
314
  let relativePathExpr = getRelativePathExpr(bundle, referencedBundle, options);
291
315
  let loaderCode = `require(${JSON.stringify(loader)})(${getAbsoluteUrlExpr(relativePathExpr, bundle, config.domainSharding)})`;
292
316
  assets.push({
293
- filePath: __filename,
317
+ filePath: filename,
294
318
  code: loaderCode,
295
319
  isEntry: true,
296
320
  env: {
@@ -301,7 +325,7 @@ var _default = exports.default = new (_plugin().Runtime)({
301
325
  }
302
326
  if (shouldUseRuntimeManifest(bundle, options) && bundleGraph.getChildBundles(bundle).some(b => b.bundleBehavior !== 'inline') && isNewContext(bundle, bundleGraph)) {
303
327
  assets.push({
304
- filePath: __filename,
328
+ filePath: filename,
305
329
  code: getRegisterCode(bundle, bundleGraph),
306
330
  isEntry: true,
307
331
  env: {
@@ -411,7 +435,7 @@ function getLoaderRuntime({
411
435
  let publicId = JSON.stringify(to.publicId);
412
436
  absoluteUrlExpr = `require('./helpers/bundle-manifest').resolve(${publicId})`;
413
437
  if (shardingConfig) {
414
- absoluteUrlExpr = `require('@atlaspack/domain-sharding').shardUrl(${absoluteUrlExpr}, ${shardingConfig.maxShards})`;
438
+ absoluteUrlExpr = `require('${domainShardingImports.specifier}').shardUrl(${absoluteUrlExpr}, ${shardingConfig.maxShards})`;
415
439
  }
416
440
  } else {
417
441
  absoluteUrlExpr = getAbsoluteUrlExpr(relativePathExpr, bundle, shardingConfig);
@@ -490,7 +514,7 @@ function getLoaderRuntime({
490
514
  loaderCode = `(${loaderCode})`;
491
515
  }
492
516
  if (mainBundle.type === 'js') {
493
- let parcelRequire = (0, _featureFlags().getFeatureFlag)('hmrImprovements') || bundle.env.shouldScopeHoist ? 'parcelRequire' : 'module.bundle.root';
517
+ let parcelRequire = bundle.env.shouldScopeHoist ? 'parcelRequire' : 'module.bundle.root';
494
518
  loaderCode += `.then(() => ${parcelRequire}('${bundleGraph.getAssetPublicId(bundleGraph.getAssetById(bundleGroup.entryAssetId))}'))`;
495
519
  }
496
520
  if (needsEsmLoadPrelude && options.featureFlags.importRetry) {
@@ -503,7 +527,7 @@ function getLoaderRuntime({
503
527
  });
504
528
  }})`;
505
529
  return {
506
- filePath: __filename,
530
+ filePath: filename,
507
531
  code: loaderCode,
508
532
  dependency,
509
533
  env: {
@@ -513,12 +537,12 @@ function getLoaderRuntime({
513
537
  }
514
538
  let code = [];
515
539
  if (needsEsmLoadPrelude) {
516
- 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');`;
517
541
  code.push(preludeLoad);
518
542
  }
519
543
  code.push(`module.exports = ${loaderCode};`);
520
544
  return {
521
- filePath: __filename,
545
+ filePath: filename,
522
546
  code: code.join('\n'),
523
547
  dependency,
524
548
  env: {
@@ -573,12 +597,7 @@ function isNewContext(bundle, bundleGraph) {
573
597
  return isInEntryBundleGroup || parents.length === 0 || parents.some(parent => parent.env.context !== bundle.env.context || parent.type !== 'js');
574
598
  }
575
599
  function getURLRuntime(dependency, from, to, options, shardingConfig) {
576
- let relativePathExpr;
577
- if ((0, _featureFlags().getFeatureFlag)('hmrImprovements')) {
578
- relativePathExpr = getRelativePathExpr(from, to, options, true);
579
- } else {
580
- relativePathExpr = getRelativePathExpr(from, to, options);
581
- }
600
+ let relativePathExpr = getRelativePathExpr(from, to, options);
582
601
  let code;
583
602
  if (dependency.meta.webworker === true && !from.env.isLibrary) {
584
603
  code = `let workerURL = require('./helpers/get-worker-url');\n`;
@@ -589,7 +608,7 @@ function getURLRuntime(dependency, from, to, options, shardingConfig) {
589
608
  code += `let bundleURL = require('./helpers/bundle-url');\n`;
590
609
  code += `let url = bundleURL.getBundleURL('${from.publicId}') + ${relativePathExpr};`;
591
610
  if (shardingConfig) {
592
- code += `url = require('@atlaspack/domain-sharding').shardUrl(url, ${shardingConfig.maxShards});`;
611
+ code += `url = require('${domainShardingImports.specifier}').shardUrl(url, ${shardingConfig.maxShards});`;
593
612
  }
594
613
  code += `module.exports = workerURL(url, bundleURL.getOrigin(url), ${String(from.env.outputFormat === 'esmodule')});`;
595
614
  }
@@ -597,7 +616,7 @@ function getURLRuntime(dependency, from, to, options, shardingConfig) {
597
616
  code = `module.exports = ${getAbsoluteUrlExpr(relativePathExpr, from, shardingConfig)};`;
598
617
  }
599
618
  return {
600
- filePath: __filename,
619
+ filePath: filename,
601
620
  code,
602
621
  dependency,
603
622
  env: {
@@ -632,19 +651,13 @@ function getRegisterCode(entryBundle, bundleGraph) {
632
651
  : `require('./helpers/bundle-url').getBundleURL('${entryBundle.publicId}')`;
633
652
  return `require('./helpers/bundle-manifest').register(${baseUrl},JSON.parse(${JSON.stringify(JSON.stringify(mappings))}));`;
634
653
  }
635
- function getRelativePathExpr(from, to, options, isURL = to.type !== 'js') {
654
+ function getRelativePathExpr(from, to, options) {
636
655
  let relativePath = (0, _utils().relativeBundlePath)(from, to, {
637
656
  leadingDotSlash: false
638
657
  });
639
658
  let res = JSON.stringify(relativePath);
640
- if ((0, _featureFlags().getFeatureFlag)('hmrImprovements')) {
641
- if (isURL && options.hmrOptions) {
642
- res += ' + "?" + Date.now()';
643
- }
644
- } else {
645
- if (options.hmrOptions) {
646
- res += ' + "?" + Date.now()';
647
- }
659
+ if (options.hmrOptions) {
660
+ res += ' + "?" + Date.now()';
648
661
  }
649
662
  return res;
650
663
  }
@@ -657,7 +670,7 @@ function getAbsoluteUrlExpr(relativePathExpr, fromBundle, shardingConfig) {
657
670
  if (!shardingConfig) {
658
671
  return regularBundleUrl;
659
672
  }
660
- return `require('@atlaspack/domain-sharding').shardUrl(${regularBundleUrl}, ${shardingConfig.maxShards})`;
673
+ return `require('${domainShardingImports.specifier}').shardUrl(${regularBundleUrl}, ${shardingConfig.maxShards})`;
661
674
  }
662
675
  function shouldUseRuntimeManifest(bundle, options) {
663
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/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.5-dev.1c70d50f9.99+1c70d50f9",
3
+ "version": "2.14.5-dev.69+67cb517ae",
4
4
  "license": "(MIT OR Apache-2.0)",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -11,17 +11,20 @@
11
11
  },
12
12
  "main": "lib/JSRuntime.js",
13
13
  "source": "src/JSRuntime.js",
14
+ "atlaspackReferences": [
15
+ "./src/helpers/**/*"
16
+ ],
14
17
  "engines": {
15
18
  "node": ">= 16.0.0"
16
19
  },
17
20
  "dependencies": {
18
- "@atlaspack/diagnostic": "2.14.1-dev.1c70d50f9.167+1c70d50f9",
19
- "@atlaspack/domain-sharding": "2.14.1-dev.1c70d50f9.167+1c70d50f9",
20
- "@atlaspack/feature-flags": "2.14.1-dev.1c70d50f9.167+1c70d50f9",
21
- "@atlaspack/plugin": "2.14.5-dev.1c70d50f9.99+1c70d50f9",
22
- "@atlaspack/utils": "2.14.5-dev.1c70d50f9.99+1c70d50f9",
21
+ "@atlaspack/diagnostic": "2.14.1-dev.137+67cb517ae",
22
+ "@atlaspack/domain-sharding": "2.14.1-dev.137+67cb517ae",
23
+ "@atlaspack/feature-flags": "2.14.1-dev.137+67cb517ae",
24
+ "@atlaspack/plugin": "2.14.5-dev.69+67cb517ae",
25
+ "@atlaspack/utils": "2.14.5-dev.69+67cb517ae",
23
26
  "nullthrows": "^1.1.1"
24
27
  },
25
28
  "type": "commonjs",
26
- "gitHead": "1c70d50f914cb662515b0b61053e51a06f3af234"
29
+ "gitHead": "67cb517ae793046fb5a0d2ef02ba74510fefccf3"
27
30
  }
package/src/JSRuntime.js CHANGED
@@ -19,6 +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/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;
22
36
 
23
37
  // Used for as="" in preload/prefetch
24
38
  const TYPE_TO_RESOURCE_PRIORITY = {
@@ -156,14 +170,9 @@ export default (new Runtime({
156
170
  // If this bundle already has the asset this dependency references,
157
171
  // return a simple runtime of `Promise.resolve(internalRequire(assetId))`.
158
172
  // The linker handles this for scope-hoisting.
159
-
160
- const requireName = getFeatureFlag('hmrImprovements')
161
- ? 'parcelRequire'
162
- : 'module.bundle.root';
163
-
164
173
  assets.push({
165
- filePath: __filename,
166
- code: `module.exports = Promise.resolve(${requireName}(${JSON.stringify(
174
+ filePath: filename,
175
+ code: `module.exports = Promise.resolve(module.bundle.root(${JSON.stringify(
167
176
  bundleGraph.getAssetPublicId(resolved.value),
168
177
  )}))`,
169
178
  dependency,
@@ -179,10 +188,7 @@ export default (new Runtime({
179
188
  );
180
189
  if (referencedBundle?.bundleBehavior === 'inline') {
181
190
  assets.push({
182
- filePath: path.join(
183
- __dirname,
184
- `/bundles/${referencedBundle.id}.js`,
185
- ),
191
+ filePath: path.join(dirname, `/bundles/${referencedBundle.id}.js`),
186
192
  code: `module.exports = Promise.resolve(${JSON.stringify(
187
193
  dependency.id,
188
194
  )});`,
@@ -216,10 +222,9 @@ export default (new Runtime({
216
222
  bundle,
217
223
  );
218
224
  for (const cond of conditions) {
219
- const requireName =
220
- getFeatureFlag('hmrImprovements') || bundle.env.shouldScopeHoist
221
- ? 'parcelRequire'
222
- : '__parcel__require__';
225
+ const requireName = bundle.env.shouldScopeHoist
226
+ ? 'parcelRequire'
227
+ : '__parcel__require__';
223
228
 
224
229
  const assetCode = `module.exports = require('../helpers/conditional-loader${
225
230
  options.mode === 'development' ? '-dev' : ''
@@ -228,7 +233,7 @@ export default (new Runtime({
228
233
  }')}, function (){return ${requireName}('${cond.ifFalseAssetId}')})`;
229
234
 
230
235
  assets.push({
231
- filePath: path.join(__dirname, `/conditions/${cond.publicId}.js`),
236
+ filePath: path.join(dirname, `/conditions/${cond.publicId}.js`),
232
237
  code: assetCode,
233
238
  // This dependency is important, as it's the last symbol handled in scope hoisting.
234
239
  // That means that scope hoisting will use the module id for this asset to replace the symbol
@@ -248,7 +253,7 @@ export default (new Runtime({
248
253
  );
249
254
  if (referencedBundle?.bundleBehavior === 'inline') {
250
255
  assets.push({
251
- filePath: path.join(__dirname, `/bundles/${referencedBundle.id}.js`),
256
+ filePath: path.join(dirname, `/bundles/${referencedBundle.id}.js`),
252
257
  code: `module.exports = ${JSON.stringify(dependency.id)};`,
253
258
  dependency,
254
259
  env: {sourceType: 'module'},
@@ -263,7 +268,7 @@ export default (new Runtime({
263
268
  // If a URL dependency was not able to be resolved, add a runtime that
264
269
  // exports the original specifier.
265
270
  assets.push({
266
- filePath: __filename,
271
+ filePath: filename,
267
272
  code: `module.exports = ${JSON.stringify(dependency.specifier)}`,
268
273
  dependency,
269
274
  env: {sourceType: 'module'},
@@ -283,6 +288,19 @@ export default (new Runtime({
283
288
  }),
284
289
  );
285
290
 
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
+
286
304
  // Skip URL runtimes for library builds. This is handled in packaging so that
287
305
  // the url is inlined and statically analyzable.
288
306
  if (bundle.env.isLibrary && mainBundle.bundleBehavior !== 'isolated') {
@@ -330,7 +348,7 @@ export default (new Runtime({
330
348
  config.domainSharding,
331
349
  )})`;
332
350
  assets.push({
333
- filePath: __filename,
351
+ filePath: filename,
334
352
  code: loaderCode,
335
353
  isEntry: true,
336
354
  env: {sourceType: 'module'},
@@ -346,7 +364,7 @@ export default (new Runtime({
346
364
  isNewContext(bundle, bundleGraph)
347
365
  ) {
348
366
  assets.push({
349
- filePath: __filename,
367
+ filePath: filename,
350
368
  code: getRegisterCode(bundle, bundleGraph),
351
369
  isEntry: true,
352
370
  env: {sourceType: 'module'},
@@ -495,7 +513,7 @@ function getLoaderRuntime({
495
513
  absoluteUrlExpr = `require('./helpers/bundle-manifest').resolve(${publicId})`;
496
514
 
497
515
  if (shardingConfig) {
498
- absoluteUrlExpr = `require('@atlaspack/domain-sharding').shardUrl(${absoluteUrlExpr}, ${shardingConfig.maxShards})`;
516
+ absoluteUrlExpr = `require('${domainShardingImports.specifier}').shardUrl(${absoluteUrlExpr}, ${shardingConfig.maxShards})`;
499
517
  }
500
518
  } else {
501
519
  absoluteUrlExpr = getAbsoluteUrlExpr(
@@ -672,11 +690,9 @@ function getLoaderRuntime({
672
690
  }
673
691
 
674
692
  if (mainBundle.type === 'js') {
675
- let parcelRequire =
676
- getFeatureFlag('hmrImprovements') || bundle.env.shouldScopeHoist
677
- ? 'parcelRequire'
678
- : 'module.bundle.root';
679
-
693
+ let parcelRequire = bundle.env.shouldScopeHoist
694
+ ? 'parcelRequire'
695
+ : 'module.bundle.root';
680
696
  loaderCode += `.then(() => ${parcelRequire}('${bundleGraph.getAssetPublicId(
681
697
  bundleGraph.getAssetById(bundleGroup.entryAssetId),
682
698
  )}'))`;
@@ -693,7 +709,7 @@ function getLoaderRuntime({
693
709
  }})`;
694
710
 
695
711
  return {
696
- filePath: __filename,
712
+ filePath: filename,
697
713
  code: loaderCode,
698
714
  dependency,
699
715
  env: {sourceType: 'module'},
@@ -704,7 +720,7 @@ function getLoaderRuntime({
704
720
 
705
721
  if (needsEsmLoadPrelude) {
706
722
  let preludeLoad = shardingConfig
707
- ? `let load = require('./helpers/browser/esm-js-loader-shards')(${shardingConfig.maxShards});`
723
+ ? `let load = require('${domainShardingImports.helper}')(${shardingConfig.maxShards});`
708
724
  : `let load = require('./helpers/browser/esm-js-loader');`;
709
725
 
710
726
  code.push(preludeLoad);
@@ -713,7 +729,7 @@ function getLoaderRuntime({
713
729
  code.push(`module.exports = ${loaderCode};`);
714
730
 
715
731
  return {
716
- filePath: __filename,
732
+ filePath: filename,
717
733
  code: code.join('\n'),
718
734
  dependency,
719
735
  env: {sourceType: 'module'},
@@ -809,12 +825,7 @@ function getURLRuntime(
809
825
  options: PluginOptions,
810
826
  shardingConfig: JSRuntimeConfig['domainSharding'],
811
827
  ): RuntimeAsset {
812
- let relativePathExpr;
813
- if (getFeatureFlag('hmrImprovements')) {
814
- relativePathExpr = getRelativePathExpr(from, to, options, true);
815
- } else {
816
- relativePathExpr = getRelativePathExpr(from, to, options);
817
- }
828
+ let relativePathExpr = getRelativePathExpr(from, to, options);
818
829
  let code;
819
830
 
820
831
  if (dependency.meta.webworker === true && !from.env.isLibrary) {
@@ -831,7 +842,7 @@ function getURLRuntime(
831
842
  code += `let bundleURL = require('./helpers/bundle-url');\n`;
832
843
  code += `let url = bundleURL.getBundleURL('${from.publicId}') + ${relativePathExpr};`;
833
844
  if (shardingConfig) {
834
- code += `url = require('@atlaspack/domain-sharding').shardUrl(url, ${shardingConfig.maxShards});`;
845
+ code += `url = require('${domainShardingImports.specifier}').shardUrl(url, ${shardingConfig.maxShards});`;
835
846
  }
836
847
  code += `module.exports = workerURL(url, bundleURL.getOrigin(url), ${String(
837
848
  from.env.outputFormat === 'esmodule',
@@ -846,7 +857,7 @@ function getURLRuntime(
846
857
  }
847
858
 
848
859
  return {
849
- filePath: __filename,
860
+ filePath: filename,
850
861
  code,
851
862
  dependency,
852
863
  env: {sourceType: 'module'},
@@ -902,18 +913,11 @@ function getRelativePathExpr(
902
913
  from: NamedBundle,
903
914
  to: NamedBundle,
904
915
  options: PluginOptions,
905
- isURL = to.type !== 'js',
906
916
  ): string {
907
917
  let relativePath = relativeBundlePath(from, to, {leadingDotSlash: false});
908
918
  let res = JSON.stringify(relativePath);
909
- if (getFeatureFlag('hmrImprovements')) {
910
- if (isURL && options.hmrOptions) {
911
- res += ' + "?" + Date.now()';
912
- }
913
- } else {
914
- if (options.hmrOptions) {
915
- res += ' + "?" + Date.now()';
916
- }
919
+ if (options.hmrOptions) {
920
+ res += ' + "?" + Date.now()';
917
921
  }
918
922
 
919
923
  return res;
@@ -939,7 +943,7 @@ function getAbsoluteUrlExpr(
939
943
  return regularBundleUrl;
940
944
  }
941
945
 
942
- return `require('@atlaspack/domain-sharding').shardUrl(${regularBundleUrl}, ${shardingConfig.maxShards})`;
946
+ return `require('${domainShardingImports.specifier}').shardUrl(${regularBundleUrl}, ${shardingConfig.maxShards})`;
943
947
  }
944
948
 
945
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/lib/domain-sharding').shardUrl(
5
+ require('../bundle-manifest').resolve(id),
6
+ maxShards,
7
+ ),
8
+ );
9
+ };
10
+
11
+ module.exports = load;