@atlaspack/runtime-js 2.12.1-dev.3365 → 2.12.1-dev.3398
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 +7 -7
- package/lib/helpers/browser/esm-js-loader-retry.js +6 -6
- package/lib/helpers/browser/esm-js-loader.js +1 -1
- package/lib/helpers/worker/js-loader.js +2 -2
- package/package.json +6 -6
- package/src/JSRuntime.js +8 -8
- package/src/helpers/browser/esm-js-loader-retry.js +6 -6
- package/src/helpers/browser/esm-js-loader.js +1 -1
- package/src/helpers/worker/js-loader.js +2 -2
package/lib/JSRuntime.js
CHANGED
|
@@ -353,12 +353,12 @@ function getLoaderRuntime({
|
|
|
353
353
|
// Use esmodule loader if possible
|
|
354
354
|
if (to.type === 'js' && to.env.outputFormat === 'esmodule') {
|
|
355
355
|
if (!needsDynamicImportPolyfill) {
|
|
356
|
-
loaderModules.push(`
|
|
356
|
+
loaderModules.push(`__parcel__import__("./" + ${relativePathExpr})`);
|
|
357
357
|
continue;
|
|
358
358
|
}
|
|
359
359
|
loader = (0, _nullthrows().default)(loaders.IMPORT_POLYFILL, `No import() polyfill available for context '${bundle.env.context}'`);
|
|
360
360
|
} else if (to.type === 'js' && to.env.outputFormat === 'commonjs') {
|
|
361
|
-
loaderModules.push(`Promise.resolve(
|
|
361
|
+
loaderModules.push(`Promise.resolve(__parcel__require__("./" + ${relativePathExpr}))`);
|
|
362
362
|
continue;
|
|
363
363
|
}
|
|
364
364
|
let absoluteUrlExpr = shouldUseRuntimeManifest(bundle, options) ? `require('./helpers/bundle-manifest').resolve(${JSON.stringify(to.publicId)})` : getAbsoluteUrlExpr(relativePathExpr, bundle);
|
|
@@ -395,8 +395,8 @@ function getLoaderRuntime({
|
|
|
395
395
|
loaderCode = `(${loaderCode})`;
|
|
396
396
|
}
|
|
397
397
|
if (mainBundle.type === 'js') {
|
|
398
|
-
let
|
|
399
|
-
loaderCode += `.then(() => ${
|
|
398
|
+
let parcelRequire = bundle.env.shouldScopeHoist ? 'parcelRequire' : 'module.bundle.root';
|
|
399
|
+
loaderCode += `.then(() => ${parcelRequire}('${bundleGraph.getAssetPublicId(bundleGraph.getAssetById(bundleGroup.entryAssetId))}'))`;
|
|
400
400
|
}
|
|
401
401
|
if (needsEsmLoadPrelude && options.featureFlags.importRetry) {
|
|
402
402
|
loaderCode = `
|
|
@@ -482,7 +482,7 @@ function getURLRuntime(dependency, from, to, options) {
|
|
|
482
482
|
if (dependency.meta.webworker === true && !from.env.isLibrary) {
|
|
483
483
|
code = `let workerURL = require('./helpers/get-worker-url');\n`;
|
|
484
484
|
if (from.env.outputFormat === 'esmodule' && from.env.supports('import-meta-url')) {
|
|
485
|
-
code += `let url = new
|
|
485
|
+
code += `let url = new __parcel__URL__(${relativePathExpr});\n`;
|
|
486
486
|
code += `module.exports = workerURL(url.toString(), url.origin, ${String(from.env.outputFormat === 'esmodule')});`;
|
|
487
487
|
} else {
|
|
488
488
|
code += `let bundleURL = require('./helpers/bundle-url');\n`;
|
|
@@ -524,7 +524,7 @@ function getRegisterCode(entryBundle, bundleGraph) {
|
|
|
524
524
|
actions.skipChildren();
|
|
525
525
|
}
|
|
526
526
|
}, entryBundle);
|
|
527
|
-
let baseUrl = entryBundle.env.outputFormat === 'esmodule' && entryBundle.env.supports('import-meta-url') ? 'new
|
|
527
|
+
let baseUrl = entryBundle.env.outputFormat === 'esmodule' && entryBundle.env.supports('import-meta-url') ? 'new __parcel__URL__("").toString()' // <-- this isn't ideal. We should use `import.meta.url` directly but it gets replaced currently
|
|
528
528
|
: `require('./helpers/bundle-url').getBundleURL('${entryBundle.publicId}')`;
|
|
529
529
|
return `require('./helpers/bundle-manifest').register(${baseUrl},JSON.parse(${JSON.stringify(JSON.stringify(mappings))}));`;
|
|
530
530
|
}
|
|
@@ -541,7 +541,7 @@ function getRelativePathExpr(from, to, options) {
|
|
|
541
541
|
function getAbsoluteUrlExpr(relativePathExpr, bundle) {
|
|
542
542
|
if (bundle.env.outputFormat === 'esmodule' && bundle.env.supports('import-meta-url') || bundle.env.outputFormat === 'commonjs') {
|
|
543
543
|
// This will be compiled to new URL(url, import.meta.url) or new URL(url, 'file:' + __filename).
|
|
544
|
-
return `new
|
|
544
|
+
return `new __parcel__URL__(${relativePathExpr}).toString()`;
|
|
545
545
|
} else {
|
|
546
546
|
return `require('./helpers/bundle-url').getBundleURL('${bundle.publicId}') + ${relativePathExpr}`;
|
|
547
547
|
}
|
|
@@ -13,8 +13,8 @@ function _load() {
|
|
|
13
13
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
14
14
|
while (1) switch (_context.prev = _context.next) {
|
|
15
15
|
case 0:
|
|
16
|
-
if (!
|
|
17
|
-
|
|
16
|
+
if (!parcelRequire.retryState) {
|
|
17
|
+
parcelRequire.retryState = {};
|
|
18
18
|
}
|
|
19
19
|
if (globalThis.navigator.onLine) {
|
|
20
20
|
_context.next = 4;
|
|
@@ -28,18 +28,18 @@ function _load() {
|
|
|
28
28
|
});
|
|
29
29
|
case 4:
|
|
30
30
|
url = require('../bundle-manifest').resolve(id);
|
|
31
|
-
if (
|
|
32
|
-
url = "".concat(url, "?retry=").concat(
|
|
31
|
+
if (parcelRequire.retryState[id] != undefined) {
|
|
32
|
+
url = "".concat(url, "?retry=").concat(parcelRequire.retryState[id]);
|
|
33
33
|
}
|
|
34
34
|
_context.prev = 6;
|
|
35
35
|
_context.next = 9;
|
|
36
|
-
return
|
|
36
|
+
return __parcel__import__(url);
|
|
37
37
|
case 9:
|
|
38
38
|
return _context.abrupt("return", _context.sent);
|
|
39
39
|
case 12:
|
|
40
40
|
_context.prev = 12;
|
|
41
41
|
_context.t0 = _context["catch"](6);
|
|
42
|
-
|
|
42
|
+
parcelRequire.retryState[id] = Date.now();
|
|
43
43
|
case 15:
|
|
44
44
|
case "end":
|
|
45
45
|
return _context.stop();
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
/* global
|
|
3
|
+
/* global __parcel__importScripts__:readonly*/
|
|
4
4
|
var cacheLoader = require('../cacheLoader');
|
|
5
5
|
module.exports = cacheLoader(function (bundle) {
|
|
6
6
|
return new Promise(function (resolve, reject) {
|
|
7
7
|
try {
|
|
8
|
-
|
|
8
|
+
__parcel__importScripts__(bundle);
|
|
9
9
|
resolve();
|
|
10
10
|
} catch (e) {
|
|
11
11
|
reject(e);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaspack/runtime-js",
|
|
3
|
-
"version": "2.12.1-dev.
|
|
3
|
+
"version": "2.12.1-dev.3398+81c73b3cd",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -13,13 +13,13 @@
|
|
|
13
13
|
"source": "src/JSRuntime.js",
|
|
14
14
|
"engines": {
|
|
15
15
|
"node": ">= 16.0.0",
|
|
16
|
-
"
|
|
16
|
+
"parcel": "^2.12.1-dev.3398+81c73b3cd"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@atlaspack/diagnostic": "2.12.1-dev.
|
|
20
|
-
"@atlaspack/plugin": "2.12.1-dev.
|
|
21
|
-
"@atlaspack/utils": "2.12.1-dev.
|
|
19
|
+
"@atlaspack/diagnostic": "2.12.1-dev.3398+81c73b3cd",
|
|
20
|
+
"@atlaspack/plugin": "2.12.1-dev.3398+81c73b3cd",
|
|
21
|
+
"@atlaspack/utils": "2.12.1-dev.3398+81c73b3cd",
|
|
22
22
|
"nullthrows": "^1.1.1"
|
|
23
23
|
},
|
|
24
|
-
"gitHead": "
|
|
24
|
+
"gitHead": "81c73b3cdf93adf8b0013be9fed5422579bd5910"
|
|
25
25
|
}
|
package/src/JSRuntime.js
CHANGED
|
@@ -400,7 +400,7 @@ function getLoaderRuntime({
|
|
|
400
400
|
// Use esmodule loader if possible
|
|
401
401
|
if (to.type === 'js' && to.env.outputFormat === 'esmodule') {
|
|
402
402
|
if (!needsDynamicImportPolyfill) {
|
|
403
|
-
loaderModules.push(`
|
|
403
|
+
loaderModules.push(`__parcel__import__("./" + ${relativePathExpr})`);
|
|
404
404
|
continue;
|
|
405
405
|
}
|
|
406
406
|
|
|
@@ -410,7 +410,7 @@ function getLoaderRuntime({
|
|
|
410
410
|
);
|
|
411
411
|
} else if (to.type === 'js' && to.env.outputFormat === 'commonjs') {
|
|
412
412
|
loaderModules.push(
|
|
413
|
-
`Promise.resolve(
|
|
413
|
+
`Promise.resolve(__parcel__require__("./" + ${relativePathExpr}))`,
|
|
414
414
|
);
|
|
415
415
|
continue;
|
|
416
416
|
}
|
|
@@ -476,10 +476,10 @@ function getLoaderRuntime({
|
|
|
476
476
|
}
|
|
477
477
|
|
|
478
478
|
if (mainBundle.type === 'js') {
|
|
479
|
-
let
|
|
480
|
-
? '
|
|
479
|
+
let parcelRequire = bundle.env.shouldScopeHoist
|
|
480
|
+
? 'parcelRequire'
|
|
481
481
|
: 'module.bundle.root';
|
|
482
|
-
loaderCode += `.then(() => ${
|
|
482
|
+
loaderCode += `.then(() => ${parcelRequire}('${bundleGraph.getAssetPublicId(
|
|
483
483
|
bundleGraph.getAssetById(bundleGroup.entryAssetId),
|
|
484
484
|
)}'))`;
|
|
485
485
|
}
|
|
@@ -615,7 +615,7 @@ function getURLRuntime(
|
|
|
615
615
|
from.env.outputFormat === 'esmodule' &&
|
|
616
616
|
from.env.supports('import-meta-url')
|
|
617
617
|
) {
|
|
618
|
-
code += `let url = new
|
|
618
|
+
code += `let url = new __parcel__URL__(${relativePathExpr});\n`;
|
|
619
619
|
code += `module.exports = workerURL(url.toString(), url.origin, ${String(
|
|
620
620
|
from.env.outputFormat === 'esmodule',
|
|
621
621
|
)});`;
|
|
@@ -675,7 +675,7 @@ function getRegisterCode(
|
|
|
675
675
|
let baseUrl =
|
|
676
676
|
entryBundle.env.outputFormat === 'esmodule' &&
|
|
677
677
|
entryBundle.env.supports('import-meta-url')
|
|
678
|
-
? 'new
|
|
678
|
+
? 'new __parcel__URL__("").toString()' // <-- this isn't ideal. We should use `import.meta.url` directly but it gets replaced currently
|
|
679
679
|
: `require('./helpers/bundle-url').getBundleURL('${entryBundle.publicId}')`;
|
|
680
680
|
|
|
681
681
|
return `require('./helpers/bundle-manifest').register(${baseUrl},JSON.parse(${JSON.stringify(
|
|
@@ -704,7 +704,7 @@ function getAbsoluteUrlExpr(relativePathExpr: string, bundle: NamedBundle) {
|
|
|
704
704
|
bundle.env.outputFormat === 'commonjs'
|
|
705
705
|
) {
|
|
706
706
|
// This will be compiled to new URL(url, import.meta.url) or new URL(url, 'file:' + __filename).
|
|
707
|
-
return `new
|
|
707
|
+
return `new __parcel__URL__(${relativePathExpr}).toString()`;
|
|
708
708
|
} else {
|
|
709
709
|
return `require('./helpers/bundle-url').getBundleURL('${bundle.publicId}') + ${relativePathExpr}`;
|
|
710
710
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
async function load(id) {
|
|
2
|
-
if (!
|
|
3
|
-
|
|
2
|
+
if (!parcelRequire.retryState) {
|
|
3
|
+
parcelRequire.retryState = {};
|
|
4
4
|
}
|
|
5
5
|
|
|
6
6
|
if (!globalThis.navigator.onLine) {
|
|
@@ -11,15 +11,15 @@ async function load(id) {
|
|
|
11
11
|
|
|
12
12
|
let url = require('../bundle-manifest').resolve(id);
|
|
13
13
|
|
|
14
|
-
if (
|
|
15
|
-
url = `${url}?retry=${
|
|
14
|
+
if (parcelRequire.retryState[id] != undefined) {
|
|
15
|
+
url = `${url}?retry=${parcelRequire.retryState[id]}`;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
try {
|
|
19
19
|
// eslint-disable-next-line no-undef
|
|
20
|
-
return await
|
|
20
|
+
return await __parcel__import__(url);
|
|
21
21
|
} catch (error) {
|
|
22
|
-
|
|
22
|
+
parcelRequire.retryState[id] = Date.now();
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
/* global
|
|
1
|
+
/* global __parcel__importScripts__:readonly*/
|
|
2
2
|
const cacheLoader = require('../cacheLoader');
|
|
3
3
|
|
|
4
4
|
module.exports = cacheLoader(function loadJSBundle(bundle) {
|
|
5
5
|
return new Promise(function (resolve, reject) {
|
|
6
6
|
try {
|
|
7
|
-
|
|
7
|
+
__parcel__importScripts__(bundle);
|
|
8
8
|
resolve();
|
|
9
9
|
} catch (e) {
|
|
10
10
|
reject(e);
|