@atlaspack/runtime-js 2.14.5-dev.55 → 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 +8 -0
- package/lib/JSRuntime.js +40 -14
- package/lib/helpers/browser/css-loader.js +3 -4
- package/lib/helpers/browser/esm-js-loader-shards-super.js +7 -0
- package/lib/helpers/browser/html-loader.js +1 -1
- package/lib/helpers/browser/import-polyfill.js +1 -1
- package/lib/helpers/browser/js-loader.js +3 -4
- package/lib/helpers/browser/prefetch-loader.js +1 -1
- package/lib/helpers/browser/preload-loader.js +1 -1
- package/lib/helpers/browser/wasm-loader.js +1 -1
- package/lib/helpers/cacheLoader.js +1 -1
- package/lib/helpers/conditional-loader-dev.js +1 -1
- package/lib/helpers/conditional-loader.js +1 -1
- package/lib/helpers/get-worker-url.js +1 -1
- package/lib/helpers/node/css-loader.js +1 -1
- package/lib/helpers/node/html-loader.js +1 -1
- package/lib/helpers/node/js-loader.js +1 -1
- package/lib/helpers/node/wasm-loader.js +1 -1
- package/lib/helpers/worker/js-loader.js +1 -1
- package/lib/helpers/worker/wasm-loader.js +1 -1
- package/package.json +10 -7
- package/src/JSRuntime.js +41 -17
- package/src/helpers/browser/esm-js-loader-shards-super.js +11 -0
package/CHANGELOG.md
CHANGED
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',
|
|
@@ -163,7 +180,7 @@ var _default = exports.default = new (_plugin().Runtime)({
|
|
|
163
180
|
// return a simple runtime of `Promise.resolve(internalRequire(assetId))`.
|
|
164
181
|
// The linker handles this for scope-hoisting.
|
|
165
182
|
assets.push({
|
|
166
|
-
filePath:
|
|
183
|
+
filePath: filename,
|
|
167
184
|
code: `module.exports = Promise.resolve(module.bundle.root(${JSON.stringify(bundleGraph.getAssetPublicId(resolved.value))}))`,
|
|
168
185
|
dependency,
|
|
169
186
|
env: {
|
|
@@ -177,7 +194,7 @@ var _default = exports.default = new (_plugin().Runtime)({
|
|
|
177
194
|
let referencedBundle = bundleGraph.getReferencedBundle(dependency, bundle);
|
|
178
195
|
if ((referencedBundle === null || referencedBundle === void 0 ? void 0 : referencedBundle.bundleBehavior) === 'inline') {
|
|
179
196
|
assets.push({
|
|
180
|
-
filePath: _path().default.join(
|
|
197
|
+
filePath: _path().default.join(dirname, `/bundles/${referencedBundle.id}.js`),
|
|
181
198
|
code: `module.exports = Promise.resolve(${JSON.stringify(dependency.id)});`,
|
|
182
199
|
dependency,
|
|
183
200
|
env: {
|
|
@@ -208,7 +225,7 @@ var _default = exports.default = new (_plugin().Runtime)({
|
|
|
208
225
|
const requireName = bundle.env.shouldScopeHoist ? 'parcelRequire' : '__parcel__require__';
|
|
209
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}')})`;
|
|
210
227
|
assets.push({
|
|
211
|
-
filePath: _path().default.join(
|
|
228
|
+
filePath: _path().default.join(dirname, `/conditions/${cond.publicId}.js`),
|
|
212
229
|
code: assetCode,
|
|
213
230
|
// This dependency is important, as it's the last symbol handled in scope hoisting.
|
|
214
231
|
// That means that scope hoisting will use the module id for this asset to replace the symbol
|
|
@@ -226,7 +243,7 @@ var _default = exports.default = new (_plugin().Runtime)({
|
|
|
226
243
|
let referencedBundle = bundleGraph.getReferencedBundle(dependency, bundle);
|
|
227
244
|
if ((referencedBundle === null || referencedBundle === void 0 ? void 0 : referencedBundle.bundleBehavior) === 'inline') {
|
|
228
245
|
assets.push({
|
|
229
|
-
filePath: _path().default.join(
|
|
246
|
+
filePath: _path().default.join(dirname, `/bundles/${referencedBundle.id}.js`),
|
|
230
247
|
code: `module.exports = ${JSON.stringify(dependency.id)};`,
|
|
231
248
|
dependency,
|
|
232
249
|
env: {
|
|
@@ -243,7 +260,7 @@ var _default = exports.default = new (_plugin().Runtime)({
|
|
|
243
260
|
// If a URL dependency was not able to be resolved, add a runtime that
|
|
244
261
|
// exports the original specifier.
|
|
245
262
|
assets.push({
|
|
246
|
-
filePath:
|
|
263
|
+
filePath: filename,
|
|
247
264
|
code: `module.exports = ${JSON.stringify(dependency.specifier)}`,
|
|
248
265
|
dependency,
|
|
249
266
|
env: {
|
|
@@ -261,6 +278,15 @@ var _default = exports.default = new (_plugin().Runtime)({
|
|
|
261
278
|
return entries.some(e => bundleGroup.entryAssetId === e.id);
|
|
262
279
|
}));
|
|
263
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
|
+
|
|
264
290
|
// Skip URL runtimes for library builds. This is handled in packaging so that
|
|
265
291
|
// the url is inlined and statically analyzable.
|
|
266
292
|
if (bundle.env.isLibrary && mainBundle.bundleBehavior !== 'isolated') {
|
|
@@ -288,7 +314,7 @@ var _default = exports.default = new (_plugin().Runtime)({
|
|
|
288
314
|
let relativePathExpr = getRelativePathExpr(bundle, referencedBundle, options);
|
|
289
315
|
let loaderCode = `require(${JSON.stringify(loader)})(${getAbsoluteUrlExpr(relativePathExpr, bundle, config.domainSharding)})`;
|
|
290
316
|
assets.push({
|
|
291
|
-
filePath:
|
|
317
|
+
filePath: filename,
|
|
292
318
|
code: loaderCode,
|
|
293
319
|
isEntry: true,
|
|
294
320
|
env: {
|
|
@@ -299,7 +325,7 @@ var _default = exports.default = new (_plugin().Runtime)({
|
|
|
299
325
|
}
|
|
300
326
|
if (shouldUseRuntimeManifest(bundle, options) && bundleGraph.getChildBundles(bundle).some(b => b.bundleBehavior !== 'inline') && isNewContext(bundle, bundleGraph)) {
|
|
301
327
|
assets.push({
|
|
302
|
-
filePath:
|
|
328
|
+
filePath: filename,
|
|
303
329
|
code: getRegisterCode(bundle, bundleGraph),
|
|
304
330
|
isEntry: true,
|
|
305
331
|
env: {
|
|
@@ -409,7 +435,7 @@ function getLoaderRuntime({
|
|
|
409
435
|
let publicId = JSON.stringify(to.publicId);
|
|
410
436
|
absoluteUrlExpr = `require('./helpers/bundle-manifest').resolve(${publicId})`;
|
|
411
437
|
if (shardingConfig) {
|
|
412
|
-
absoluteUrlExpr = `require('
|
|
438
|
+
absoluteUrlExpr = `require('${domainShardingImports.specifier}').shardUrl(${absoluteUrlExpr}, ${shardingConfig.maxShards})`;
|
|
413
439
|
}
|
|
414
440
|
} else {
|
|
415
441
|
absoluteUrlExpr = getAbsoluteUrlExpr(relativePathExpr, bundle, shardingConfig);
|
|
@@ -501,7 +527,7 @@ function getLoaderRuntime({
|
|
|
501
527
|
});
|
|
502
528
|
}})`;
|
|
503
529
|
return {
|
|
504
|
-
filePath:
|
|
530
|
+
filePath: filename,
|
|
505
531
|
code: loaderCode,
|
|
506
532
|
dependency,
|
|
507
533
|
env: {
|
|
@@ -511,12 +537,12 @@ function getLoaderRuntime({
|
|
|
511
537
|
}
|
|
512
538
|
let code = [];
|
|
513
539
|
if (needsEsmLoadPrelude) {
|
|
514
|
-
let preludeLoad = shardingConfig ? `let load = require('
|
|
540
|
+
let preludeLoad = shardingConfig ? `let load = require('${domainShardingImports.helper}')(${shardingConfig.maxShards});` : `let load = require('./helpers/browser/esm-js-loader');`;
|
|
515
541
|
code.push(preludeLoad);
|
|
516
542
|
}
|
|
517
543
|
code.push(`module.exports = ${loaderCode};`);
|
|
518
544
|
return {
|
|
519
|
-
filePath:
|
|
545
|
+
filePath: filename,
|
|
520
546
|
code: code.join('\n'),
|
|
521
547
|
dependency,
|
|
522
548
|
env: {
|
|
@@ -582,7 +608,7 @@ function getURLRuntime(dependency, from, to, options, shardingConfig) {
|
|
|
582
608
|
code += `let bundleURL = require('./helpers/bundle-url');\n`;
|
|
583
609
|
code += `let url = bundleURL.getBundleURL('${from.publicId}') + ${relativePathExpr};`;
|
|
584
610
|
if (shardingConfig) {
|
|
585
|
-
code += `url = require('
|
|
611
|
+
code += `url = require('${domainShardingImports.specifier}').shardUrl(url, ${shardingConfig.maxShards});`;
|
|
586
612
|
}
|
|
587
613
|
code += `module.exports = workerURL(url, bundleURL.getOrigin(url), ${String(from.env.outputFormat === 'esmodule')});`;
|
|
588
614
|
}
|
|
@@ -590,7 +616,7 @@ function getURLRuntime(dependency, from, to, options, shardingConfig) {
|
|
|
590
616
|
code = `module.exports = ${getAbsoluteUrlExpr(relativePathExpr, from, shardingConfig)};`;
|
|
591
617
|
}
|
|
592
618
|
return {
|
|
593
|
-
filePath:
|
|
619
|
+
filePath: filename,
|
|
594
620
|
code,
|
|
595
621
|
dependency,
|
|
596
622
|
env: {
|
|
@@ -644,7 +670,7 @@ function getAbsoluteUrlExpr(relativePathExpr, fromBundle, shardingConfig) {
|
|
|
644
670
|
if (!shardingConfig) {
|
|
645
671
|
return regularBundleUrl;
|
|
646
672
|
}
|
|
647
|
-
return `require('
|
|
673
|
+
return `require('${domainShardingImports.specifier}').shardUrl(${regularBundleUrl}, ${shardingConfig.maxShards})`;
|
|
648
674
|
}
|
|
649
675
|
function shouldUseRuntimeManifest(bundle, options) {
|
|
650
676
|
let env = bundle.env;
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
const cacheLoader = require('../cacheLoader');
|
|
4
|
-
module.exports = cacheLoader(function
|
|
4
|
+
module.exports = cacheLoader(function (bundle) {
|
|
5
5
|
return new Promise(function (resolve, reject) {
|
|
6
6
|
// Don't insert the same link element twice (e.g. if it was already in the HTML)
|
|
7
7
|
let existingLinks = document.getElementsByTagName('link');
|
|
8
|
-
|
|
8
|
+
if ([].concat(existingLinks).some(function (link) {
|
|
9
9
|
return link.href === bundle && link.rel.indexOf('stylesheet') > -1;
|
|
10
|
-
}
|
|
11
|
-
if ([].concat(existingLinks).some(isCurrentBundle)) {
|
|
10
|
+
})) {
|
|
12
11
|
resolve();
|
|
13
12
|
return;
|
|
14
13
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
const cacheLoader = require('../cacheLoader');
|
|
4
|
-
module.exports = cacheLoader(function
|
|
4
|
+
module.exports = cacheLoader(function (bundle) {
|
|
5
5
|
return new Promise((resolve, reject) => {
|
|
6
6
|
// Add a global function to handle when the script loads.
|
|
7
7
|
let globalName = `i${('' + Math.random()).slice(2)}`;
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
const cacheLoader = require('../cacheLoader');
|
|
4
|
-
module.exports = cacheLoader(function
|
|
4
|
+
module.exports = cacheLoader(function (bundle) {
|
|
5
5
|
return new Promise(function (resolve, reject) {
|
|
6
6
|
// Don't insert the same script twice (e.g. if it was already in the HTML)
|
|
7
7
|
let existingScripts = document.getElementsByTagName('script');
|
|
8
|
-
|
|
8
|
+
if ([].concat(existingScripts).some(function (script) {
|
|
9
9
|
return script.src === bundle;
|
|
10
|
-
}
|
|
11
|
-
if ([].concat(existingScripts).some(isCurrentBundle)) {
|
|
10
|
+
})) {
|
|
12
11
|
resolve();
|
|
13
12
|
return;
|
|
14
13
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
const cacheLoader = require('../cacheLoader');
|
|
4
|
-
module.exports = cacheLoader(function
|
|
4
|
+
module.exports = cacheLoader(function (bundle, priority) {
|
|
5
5
|
var link = document.createElement('link');
|
|
6
6
|
link.rel = 'prefetch';
|
|
7
7
|
link.href = bundle;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
const cacheLoader = require('../cacheLoader');
|
|
4
|
-
module.exports = cacheLoader(function
|
|
4
|
+
module.exports = cacheLoader(function (bundle, priority, isModule) {
|
|
5
5
|
var link = document.createElement('link');
|
|
6
6
|
link.charset = 'utf-8';
|
|
7
7
|
link.rel = isModule ? 'modulepreload' : 'preload';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
const cacheLoader = require('../cacheLoader');
|
|
4
|
-
module.exports = cacheLoader(function
|
|
4
|
+
module.exports = cacheLoader(function (bundle) {
|
|
5
5
|
return fetch(bundle).then(function (res) {
|
|
6
6
|
if (WebAssembly.instantiateStreaming) {
|
|
7
7
|
return WebAssembly.instantiateStreaming(res);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
module.exports = function
|
|
3
|
+
module.exports = function (cond, ifTrue, ifFalse) {
|
|
4
4
|
if (typeof globalThis.__MCOND !== 'function') {
|
|
5
5
|
throw new TypeError('"globalThis.__MCOND" was not set to an object. Ensure the function is set to return the key condition for conditional bundles to load with.');
|
|
6
6
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
module.exports = function
|
|
3
|
+
module.exports = function (workerUrl, origin, isESM) {
|
|
4
4
|
if (origin === self.location.origin) {
|
|
5
5
|
// If the worker bundle's url is on the same origin as the document,
|
|
6
6
|
// use the worker bundle's own url.
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
const fs = require('fs');
|
|
4
4
|
const cacheLoader = require('../cacheLoader');
|
|
5
|
-
module.exports = cacheLoader(function
|
|
5
|
+
module.exports = cacheLoader(function (bundle) {
|
|
6
6
|
return new Promise(function (resolve, reject) {
|
|
7
7
|
fs.readFile(__dirname + bundle, 'utf8', function (err, data) {
|
|
8
8
|
if (err) {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
const fs = require('fs');
|
|
4
4
|
const cacheLoader = require('../cacheLoader');
|
|
5
|
-
module.exports = cacheLoader(function
|
|
5
|
+
module.exports = cacheLoader(function (bundle) {
|
|
6
6
|
return new Promise(function (resolve, reject) {
|
|
7
7
|
fs.readFile(__dirname + bundle, 'utf8', function (err, data) {
|
|
8
8
|
if (err) {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
const fs = require('fs');
|
|
4
4
|
const cacheLoader = require('../cacheLoader');
|
|
5
|
-
module.exports = cacheLoader(function
|
|
5
|
+
module.exports = cacheLoader(function (bundle) {
|
|
6
6
|
return new Promise(function (resolve, reject) {
|
|
7
7
|
fs.readFile(__dirname + bundle, function (err, data) {
|
|
8
8
|
if (err) {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
/* global __parcel__importScripts__:readonly*/
|
|
4
4
|
const cacheLoader = require('../cacheLoader');
|
|
5
|
-
module.exports = cacheLoader(function
|
|
5
|
+
module.exports = cacheLoader(function (bundle) {
|
|
6
6
|
return new Promise(function (resolve, reject) {
|
|
7
7
|
try {
|
|
8
8
|
__parcel__importScripts__(bundle);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
const cacheLoader = require('../cacheLoader');
|
|
4
|
-
module.exports = cacheLoader(function
|
|
4
|
+
module.exports = cacheLoader(function (bundle) {
|
|
5
5
|
return fetch(bundle).then(function (res) {
|
|
6
6
|
if (WebAssembly.instantiateStreaming) {
|
|
7
7
|
return WebAssembly.instantiateStreaming(res);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaspack/runtime-js",
|
|
3
|
-
"version": "2.14.5-dev.
|
|
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.
|
|
19
|
-
"@atlaspack/domain-sharding": "2.14.1-dev.
|
|
20
|
-
"@atlaspack/feature-flags": "2.14.1-dev.
|
|
21
|
-
"@atlaspack/plugin": "2.14.5-dev.
|
|
22
|
-
"@atlaspack/utils": "2.14.5-dev.
|
|
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": "
|
|
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 = {
|
|
@@ -157,7 +171,7 @@ export default (new Runtime({
|
|
|
157
171
|
// return a simple runtime of `Promise.resolve(internalRequire(assetId))`.
|
|
158
172
|
// The linker handles this for scope-hoisting.
|
|
159
173
|
assets.push({
|
|
160
|
-
filePath:
|
|
174
|
+
filePath: filename,
|
|
161
175
|
code: `module.exports = Promise.resolve(module.bundle.root(${JSON.stringify(
|
|
162
176
|
bundleGraph.getAssetPublicId(resolved.value),
|
|
163
177
|
)}))`,
|
|
@@ -174,10 +188,7 @@ export default (new Runtime({
|
|
|
174
188
|
);
|
|
175
189
|
if (referencedBundle?.bundleBehavior === 'inline') {
|
|
176
190
|
assets.push({
|
|
177
|
-
filePath: path.join(
|
|
178
|
-
__dirname,
|
|
179
|
-
`/bundles/${referencedBundle.id}.js`,
|
|
180
|
-
),
|
|
191
|
+
filePath: path.join(dirname, `/bundles/${referencedBundle.id}.js`),
|
|
181
192
|
code: `module.exports = Promise.resolve(${JSON.stringify(
|
|
182
193
|
dependency.id,
|
|
183
194
|
)});`,
|
|
@@ -222,7 +233,7 @@ export default (new Runtime({
|
|
|
222
233
|
}')}, function (){return ${requireName}('${cond.ifFalseAssetId}')})`;
|
|
223
234
|
|
|
224
235
|
assets.push({
|
|
225
|
-
filePath: path.join(
|
|
236
|
+
filePath: path.join(dirname, `/conditions/${cond.publicId}.js`),
|
|
226
237
|
code: assetCode,
|
|
227
238
|
// This dependency is important, as it's the last symbol handled in scope hoisting.
|
|
228
239
|
// That means that scope hoisting will use the module id for this asset to replace the symbol
|
|
@@ -242,7 +253,7 @@ export default (new Runtime({
|
|
|
242
253
|
);
|
|
243
254
|
if (referencedBundle?.bundleBehavior === 'inline') {
|
|
244
255
|
assets.push({
|
|
245
|
-
filePath: path.join(
|
|
256
|
+
filePath: path.join(dirname, `/bundles/${referencedBundle.id}.js`),
|
|
246
257
|
code: `module.exports = ${JSON.stringify(dependency.id)};`,
|
|
247
258
|
dependency,
|
|
248
259
|
env: {sourceType: 'module'},
|
|
@@ -257,7 +268,7 @@ export default (new Runtime({
|
|
|
257
268
|
// If a URL dependency was not able to be resolved, add a runtime that
|
|
258
269
|
// exports the original specifier.
|
|
259
270
|
assets.push({
|
|
260
|
-
filePath:
|
|
271
|
+
filePath: filename,
|
|
261
272
|
code: `module.exports = ${JSON.stringify(dependency.specifier)}`,
|
|
262
273
|
dependency,
|
|
263
274
|
env: {sourceType: 'module'},
|
|
@@ -277,6 +288,19 @@ export default (new Runtime({
|
|
|
277
288
|
}),
|
|
278
289
|
);
|
|
279
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
|
+
|
|
280
304
|
// Skip URL runtimes for library builds. This is handled in packaging so that
|
|
281
305
|
// the url is inlined and statically analyzable.
|
|
282
306
|
if (bundle.env.isLibrary && mainBundle.bundleBehavior !== 'isolated') {
|
|
@@ -324,7 +348,7 @@ export default (new Runtime({
|
|
|
324
348
|
config.domainSharding,
|
|
325
349
|
)})`;
|
|
326
350
|
assets.push({
|
|
327
|
-
filePath:
|
|
351
|
+
filePath: filename,
|
|
328
352
|
code: loaderCode,
|
|
329
353
|
isEntry: true,
|
|
330
354
|
env: {sourceType: 'module'},
|
|
@@ -340,7 +364,7 @@ export default (new Runtime({
|
|
|
340
364
|
isNewContext(bundle, bundleGraph)
|
|
341
365
|
) {
|
|
342
366
|
assets.push({
|
|
343
|
-
filePath:
|
|
367
|
+
filePath: filename,
|
|
344
368
|
code: getRegisterCode(bundle, bundleGraph),
|
|
345
369
|
isEntry: true,
|
|
346
370
|
env: {sourceType: 'module'},
|
|
@@ -489,7 +513,7 @@ function getLoaderRuntime({
|
|
|
489
513
|
absoluteUrlExpr = `require('./helpers/bundle-manifest').resolve(${publicId})`;
|
|
490
514
|
|
|
491
515
|
if (shardingConfig) {
|
|
492
|
-
absoluteUrlExpr = `require('
|
|
516
|
+
absoluteUrlExpr = `require('${domainShardingImports.specifier}').shardUrl(${absoluteUrlExpr}, ${shardingConfig.maxShards})`;
|
|
493
517
|
}
|
|
494
518
|
} else {
|
|
495
519
|
absoluteUrlExpr = getAbsoluteUrlExpr(
|
|
@@ -685,7 +709,7 @@ function getLoaderRuntime({
|
|
|
685
709
|
}})`;
|
|
686
710
|
|
|
687
711
|
return {
|
|
688
|
-
filePath:
|
|
712
|
+
filePath: filename,
|
|
689
713
|
code: loaderCode,
|
|
690
714
|
dependency,
|
|
691
715
|
env: {sourceType: 'module'},
|
|
@@ -696,7 +720,7 @@ function getLoaderRuntime({
|
|
|
696
720
|
|
|
697
721
|
if (needsEsmLoadPrelude) {
|
|
698
722
|
let preludeLoad = shardingConfig
|
|
699
|
-
? `let load = require('
|
|
723
|
+
? `let load = require('${domainShardingImports.helper}')(${shardingConfig.maxShards});`
|
|
700
724
|
: `let load = require('./helpers/browser/esm-js-loader');`;
|
|
701
725
|
|
|
702
726
|
code.push(preludeLoad);
|
|
@@ -705,7 +729,7 @@ function getLoaderRuntime({
|
|
|
705
729
|
code.push(`module.exports = ${loaderCode};`);
|
|
706
730
|
|
|
707
731
|
return {
|
|
708
|
-
filePath:
|
|
732
|
+
filePath: filename,
|
|
709
733
|
code: code.join('\n'),
|
|
710
734
|
dependency,
|
|
711
735
|
env: {sourceType: 'module'},
|
|
@@ -818,7 +842,7 @@ function getURLRuntime(
|
|
|
818
842
|
code += `let bundleURL = require('./helpers/bundle-url');\n`;
|
|
819
843
|
code += `let url = bundleURL.getBundleURL('${from.publicId}') + ${relativePathExpr};`;
|
|
820
844
|
if (shardingConfig) {
|
|
821
|
-
code += `url = require('
|
|
845
|
+
code += `url = require('${domainShardingImports.specifier}').shardUrl(url, ${shardingConfig.maxShards});`;
|
|
822
846
|
}
|
|
823
847
|
code += `module.exports = workerURL(url, bundleURL.getOrigin(url), ${String(
|
|
824
848
|
from.env.outputFormat === 'esmodule',
|
|
@@ -833,7 +857,7 @@ function getURLRuntime(
|
|
|
833
857
|
}
|
|
834
858
|
|
|
835
859
|
return {
|
|
836
|
-
filePath:
|
|
860
|
+
filePath: filename,
|
|
837
861
|
code,
|
|
838
862
|
dependency,
|
|
839
863
|
env: {sourceType: 'module'},
|
|
@@ -919,7 +943,7 @@ function getAbsoluteUrlExpr(
|
|
|
919
943
|
return regularBundleUrl;
|
|
920
944
|
}
|
|
921
945
|
|
|
922
|
-
return `require('
|
|
946
|
+
return `require('${domainShardingImports.specifier}').shardUrl(${regularBundleUrl}, ${shardingConfig.maxShards})`;
|
|
923
947
|
}
|
|
924
948
|
|
|
925
949
|
function shouldUseRuntimeManifest(
|