@atlaspack/runtime-js 2.14.1-dev.15 → 2.14.1-dev.36

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
@@ -47,6 +47,8 @@ function _featureFlags() {
47
47
  return data;
48
48
  }
49
49
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
50
+ const filename = /*#__ATLASPACK_IGNORE__*/__filename;
51
+
50
52
  // Used for as="" in preload/prefetch
51
53
  const TYPE_TO_RESOURCE_PRIORITY = {
52
54
  css: 'style',
@@ -163,7 +165,7 @@ var _default = exports.default = new (_plugin().Runtime)({
163
165
  // return a simple runtime of `Promise.resolve(internalRequire(assetId))`.
164
166
  // The linker handles this for scope-hoisting.
165
167
  assets.push({
166
- filePath: __filename,
168
+ filePath: filename,
167
169
  code: `module.exports = Promise.resolve(module.bundle.root(${JSON.stringify(bundleGraph.getAssetPublicId(resolved.value))}))`,
168
170
  dependency,
169
171
  env: {
@@ -243,7 +245,7 @@ var _default = exports.default = new (_plugin().Runtime)({
243
245
  // If a URL dependency was not able to be resolved, add a runtime that
244
246
  // exports the original specifier.
245
247
  assets.push({
246
- filePath: __filename,
248
+ filePath: filename,
247
249
  code: `module.exports = ${JSON.stringify(dependency.specifier)}`,
248
250
  dependency,
249
251
  env: {
@@ -261,6 +263,15 @@ var _default = exports.default = new (_plugin().Runtime)({
261
263
  return entries.some(e => bundleGroup.entryAssetId === e.id);
262
264
  }));
263
265
 
266
+ // Skip URL runtime for native node imports as they need to be require
267
+ // directly
268
+ // Currently enabled only for internal builds
269
+ if (process.env.ATLASPACK_SUPER_BUILD === 'true') {
270
+ if (mainBundle.bundleBehavior === 'isolated' && mainBundle.env.context === 'node' && mainBundle.type === 'node') {
271
+ continue;
272
+ }
273
+ }
274
+
264
275
  // Skip URL runtimes for library builds. This is handled in packaging so that
265
276
  // the url is inlined and statically analyzable.
266
277
  if (bundle.env.isLibrary && mainBundle.bundleBehavior !== 'isolated') {
@@ -288,7 +299,7 @@ var _default = exports.default = new (_plugin().Runtime)({
288
299
  let relativePathExpr = getRelativePathExpr(bundle, referencedBundle, options);
289
300
  let loaderCode = `require(${JSON.stringify(loader)})(${getAbsoluteUrlExpr(relativePathExpr, bundle, config.domainSharding)})`;
290
301
  assets.push({
291
- filePath: __filename,
302
+ filePath: filename,
292
303
  code: loaderCode,
293
304
  isEntry: true,
294
305
  env: {
@@ -299,7 +310,7 @@ var _default = exports.default = new (_plugin().Runtime)({
299
310
  }
300
311
  if (shouldUseRuntimeManifest(bundle, options) && bundleGraph.getChildBundles(bundle).some(b => b.bundleBehavior !== 'inline') && isNewContext(bundle, bundleGraph)) {
301
312
  assets.push({
302
- filePath: __filename,
313
+ filePath: filename,
303
314
  code: getRegisterCode(bundle, bundleGraph),
304
315
  isEntry: true,
305
316
  env: {
@@ -501,7 +512,7 @@ function getLoaderRuntime({
501
512
  });
502
513
  }})`;
503
514
  return {
504
- filePath: __filename,
515
+ filePath: filename,
505
516
  code: loaderCode,
506
517
  dependency,
507
518
  env: {
@@ -516,7 +527,7 @@ function getLoaderRuntime({
516
527
  }
517
528
  code.push(`module.exports = ${loaderCode};`);
518
529
  return {
519
- filePath: __filename,
530
+ filePath: filename,
520
531
  code: code.join('\n'),
521
532
  dependency,
522
533
  env: {
@@ -590,7 +601,7 @@ function getURLRuntime(dependency, from, to, options, shardingConfig) {
590
601
  code = `module.exports = ${getAbsoluteUrlExpr(relativePathExpr, from, shardingConfig)};`;
591
602
  }
592
603
  return {
593
- filePath: __filename,
604
+ filePath: filename,
594
605
  code,
595
606
  dependency,
596
607
  env: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaspack/runtime-js",
3
- "version": "2.14.1-dev.15+30b65feb9",
3
+ "version": "2.14.1-dev.36+b98b1df81",
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.15+30b65feb9",
19
- "@atlaspack/domain-sharding": "2.14.1-dev.15+30b65feb9",
20
- "@atlaspack/feature-flags": "2.14.1-dev.15+30b65feb9",
21
- "@atlaspack/plugin": "2.14.1-dev.15+30b65feb9",
22
- "@atlaspack/utils": "2.14.1-dev.15+30b65feb9",
21
+ "@atlaspack/diagnostic": "2.14.1-dev.36+b98b1df81",
22
+ "@atlaspack/domain-sharding": "2.14.1-dev.36+b98b1df81",
23
+ "@atlaspack/feature-flags": "2.14.1-dev.36+b98b1df81",
24
+ "@atlaspack/plugin": "2.14.1-dev.36+b98b1df81",
25
+ "@atlaspack/utils": "2.14.1-dev.36+b98b1df81",
23
26
  "nullthrows": "^1.1.1"
24
27
  },
25
28
  "type": "commonjs",
26
- "gitHead": "30b65feb98113722e721c7cdee547765d195b65a"
29
+ "gitHead": "b98b1df81bc5ca2c1f977d250c958c137bd0b4ee"
27
30
  }
package/src/JSRuntime.js CHANGED
@@ -20,6 +20,8 @@ import path from 'path';
20
20
  import nullthrows from 'nullthrows';
21
21
  import {getFeatureFlag} from '@atlaspack/feature-flags';
22
22
 
23
+ const filename = /*#__ATLASPACK_IGNORE__*/ __filename;
24
+
23
25
  // Used for as="" in preload/prefetch
24
26
  const TYPE_TO_RESOURCE_PRIORITY = {
25
27
  css: 'style',
@@ -157,7 +159,7 @@ export default (new Runtime({
157
159
  // return a simple runtime of `Promise.resolve(internalRequire(assetId))`.
158
160
  // The linker handles this for scope-hoisting.
159
161
  assets.push({
160
- filePath: __filename,
162
+ filePath: filename,
161
163
  code: `module.exports = Promise.resolve(module.bundle.root(${JSON.stringify(
162
164
  bundleGraph.getAssetPublicId(resolved.value),
163
165
  )}))`,
@@ -257,7 +259,7 @@ export default (new Runtime({
257
259
  // If a URL dependency was not able to be resolved, add a runtime that
258
260
  // exports the original specifier.
259
261
  assets.push({
260
- filePath: __filename,
262
+ filePath: filename,
261
263
  code: `module.exports = ${JSON.stringify(dependency.specifier)}`,
262
264
  dependency,
263
265
  env: {sourceType: 'module'},
@@ -277,6 +279,19 @@ export default (new Runtime({
277
279
  }),
278
280
  );
279
281
 
282
+ // Skip URL runtime for native node imports as they need to be require
283
+ // directly
284
+ // Currently enabled only for internal builds
285
+ if (process.env.ATLASPACK_SUPER_BUILD === 'true') {
286
+ if (
287
+ mainBundle.bundleBehavior === 'isolated' &&
288
+ mainBundle.env.context === 'node' &&
289
+ mainBundle.type === 'node'
290
+ ) {
291
+ continue;
292
+ }
293
+ }
294
+
280
295
  // Skip URL runtimes for library builds. This is handled in packaging so that
281
296
  // the url is inlined and statically analyzable.
282
297
  if (bundle.env.isLibrary && mainBundle.bundleBehavior !== 'isolated') {
@@ -324,7 +339,7 @@ export default (new Runtime({
324
339
  config.domainSharding,
325
340
  )})`;
326
341
  assets.push({
327
- filePath: __filename,
342
+ filePath: filename,
328
343
  code: loaderCode,
329
344
  isEntry: true,
330
345
  env: {sourceType: 'module'},
@@ -340,7 +355,7 @@ export default (new Runtime({
340
355
  isNewContext(bundle, bundleGraph)
341
356
  ) {
342
357
  assets.push({
343
- filePath: __filename,
358
+ filePath: filename,
344
359
  code: getRegisterCode(bundle, bundleGraph),
345
360
  isEntry: true,
346
361
  env: {sourceType: 'module'},
@@ -685,7 +700,7 @@ function getLoaderRuntime({
685
700
  }})`;
686
701
 
687
702
  return {
688
- filePath: __filename,
703
+ filePath: filename,
689
704
  code: loaderCode,
690
705
  dependency,
691
706
  env: {sourceType: 'module'},
@@ -705,7 +720,7 @@ function getLoaderRuntime({
705
720
  code.push(`module.exports = ${loaderCode};`);
706
721
 
707
722
  return {
708
- filePath: __filename,
723
+ filePath: filename,
709
724
  code: code.join('\n'),
710
725
  dependency,
711
726
  env: {sourceType: 'module'},
@@ -833,7 +848,7 @@ function getURLRuntime(
833
848
  }
834
849
 
835
850
  return {
836
- filePath: __filename,
851
+ filePath: filename,
837
852
  code,
838
853
  dependency,
839
854
  env: {sourceType: 'module'},