@atlaspack/runtime-js 2.19.9-dev-swc44-2ebba71e5.0 → 2.20.0
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 +23 -0
- package/dist/JSRuntime.js +274 -0
- package/lib/JSRuntime.js +330 -1
- package/package.json +8 -9
- package/src/JSRuntime.ts +305 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/LICENSE +0 -201
package/src/JSRuntime.ts
CHANGED
|
@@ -174,6 +174,13 @@ export default new Runtime({
|
|
|
174
174
|
)}))`,
|
|
175
175
|
dependency,
|
|
176
176
|
env: {sourceType: 'module'},
|
|
177
|
+
// Pre-computed symbols: exports Promise, no external dependencies (uses global)
|
|
178
|
+
symbolData: {
|
|
179
|
+
symbols: new Map([
|
|
180
|
+
['default', {local: 'module.exports', loc: null}],
|
|
181
|
+
]),
|
|
182
|
+
dependencies: [],
|
|
183
|
+
},
|
|
177
184
|
});
|
|
178
185
|
}
|
|
179
186
|
} else {
|
|
@@ -197,6 +204,13 @@ export default new Runtime({
|
|
|
197
204
|
)});`,
|
|
198
205
|
dependency,
|
|
199
206
|
env: {sourceType: 'module'},
|
|
207
|
+
// Pre-computed symbols: exports Promise, no external dependencies
|
|
208
|
+
symbolData: {
|
|
209
|
+
symbols: new Map([
|
|
210
|
+
['default', {local: 'module.exports', loc: null}],
|
|
211
|
+
]),
|
|
212
|
+
dependencies: [],
|
|
213
|
+
},
|
|
200
214
|
});
|
|
201
215
|
continue;
|
|
202
216
|
}
|
|
@@ -291,6 +305,32 @@ export default new Runtime({
|
|
|
291
305
|
// (rather than the actual conditional deps)
|
|
292
306
|
dependency: cond.ifFalseDependency,
|
|
293
307
|
env: {sourceType: 'module'},
|
|
308
|
+
// Pre-computed symbols: conditional loader with potential sync-js-loader fallback
|
|
309
|
+
symbolData: {
|
|
310
|
+
symbols: new Map([
|
|
311
|
+
['default', {local: 'module.exports', loc: null}],
|
|
312
|
+
]),
|
|
313
|
+
dependencies: [
|
|
314
|
+
{
|
|
315
|
+
specifier: loaderPath,
|
|
316
|
+
symbols: new Map([
|
|
317
|
+
['default', {local: 'default', loc: null, isWeak: false}],
|
|
318
|
+
]),
|
|
319
|
+
usedSymbols: new Set(['default']),
|
|
320
|
+
},
|
|
321
|
+
...(shouldUseFallback
|
|
322
|
+
? [
|
|
323
|
+
{
|
|
324
|
+
specifier: './helpers/browser/sync-js-loader',
|
|
325
|
+
symbols: new Map([
|
|
326
|
+
['default', {local: 'l', loc: null, isWeak: false}],
|
|
327
|
+
]),
|
|
328
|
+
usedSymbols: new Set(['default']),
|
|
329
|
+
},
|
|
330
|
+
]
|
|
331
|
+
: []),
|
|
332
|
+
],
|
|
333
|
+
},
|
|
294
334
|
});
|
|
295
335
|
}
|
|
296
336
|
}
|
|
@@ -311,6 +351,13 @@ export default new Runtime({
|
|
|
311
351
|
code: `module.exports = ${JSON.stringify(dependency.id)};`,
|
|
312
352
|
dependency,
|
|
313
353
|
env: {sourceType: 'module'},
|
|
354
|
+
// Pre-computed symbols: simple export with no dependencies
|
|
355
|
+
symbolData: {
|
|
356
|
+
symbols: new Map([
|
|
357
|
+
['default', {local: 'module.exports', loc: null}],
|
|
358
|
+
]),
|
|
359
|
+
dependencies: [],
|
|
360
|
+
},
|
|
314
361
|
});
|
|
315
362
|
continue;
|
|
316
363
|
}
|
|
@@ -326,6 +373,13 @@ export default new Runtime({
|
|
|
326
373
|
code: `module.exports = ${JSON.stringify(dependency.specifier)}`,
|
|
327
374
|
dependency,
|
|
328
375
|
env: {sourceType: 'module'},
|
|
376
|
+
// Pre-computed symbols: simple export with no dependencies
|
|
377
|
+
symbolData: {
|
|
378
|
+
symbols: new Map([
|
|
379
|
+
['default', {local: 'module.exports', loc: null}],
|
|
380
|
+
]),
|
|
381
|
+
dependencies: [],
|
|
382
|
+
},
|
|
329
383
|
});
|
|
330
384
|
continue;
|
|
331
385
|
}
|
|
@@ -397,6 +451,19 @@ export default new Runtime({
|
|
|
397
451
|
code: loaderCode,
|
|
398
452
|
isEntry: true,
|
|
399
453
|
env: {sourceType: 'module'},
|
|
454
|
+
// Pre-computed symbols: lazy bundle loader, requires specific loader helper
|
|
455
|
+
symbolData: {
|
|
456
|
+
symbols: new Map(), // No exports, just side effects
|
|
457
|
+
dependencies: [
|
|
458
|
+
{
|
|
459
|
+
specifier: loader,
|
|
460
|
+
symbols: new Map([
|
|
461
|
+
['default', {local: 'default', loc: null, isWeak: false}],
|
|
462
|
+
]),
|
|
463
|
+
usedSymbols: new Set(['default']),
|
|
464
|
+
},
|
|
465
|
+
],
|
|
466
|
+
},
|
|
400
467
|
});
|
|
401
468
|
}
|
|
402
469
|
}
|
|
@@ -423,6 +490,19 @@ export default new Runtime({
|
|
|
423
490
|
bundle,
|
|
424
491
|
config.splitManifestThreshold,
|
|
425
492
|
),
|
|
493
|
+
// Pre-computed symbols: requires bundle-manifest helper
|
|
494
|
+
symbolData: {
|
|
495
|
+
symbols: new Map(), // No exports, just executes
|
|
496
|
+
dependencies: [
|
|
497
|
+
{
|
|
498
|
+
specifier: './helpers/bundle-manifest',
|
|
499
|
+
symbols: new Map([
|
|
500
|
+
['register', {local: 'register', loc: null, isWeak: false}],
|
|
501
|
+
]),
|
|
502
|
+
usedSymbols: new Set(['register']),
|
|
503
|
+
},
|
|
504
|
+
],
|
|
505
|
+
},
|
|
426
506
|
});
|
|
427
507
|
}
|
|
428
508
|
|
|
@@ -749,6 +829,19 @@ function getLoaderRuntime({
|
|
|
749
829
|
code: loaderCode,
|
|
750
830
|
dependency,
|
|
751
831
|
env: {sourceType: 'module'},
|
|
832
|
+
// Pre-computed symbols: ESM loader with retry, requires esm-js-loader-retry helper
|
|
833
|
+
symbolData: {
|
|
834
|
+
symbols: new Map([['default', {local: 'module.exports', loc: null}]]),
|
|
835
|
+
dependencies: [
|
|
836
|
+
{
|
|
837
|
+
specifier: './helpers/browser/esm-js-loader-retry',
|
|
838
|
+
symbols: new Map([
|
|
839
|
+
['default', {local: 'default', loc: null, isWeak: false}],
|
|
840
|
+
]),
|
|
841
|
+
usedSymbols: new Set(['default']),
|
|
842
|
+
},
|
|
843
|
+
],
|
|
844
|
+
},
|
|
752
845
|
};
|
|
753
846
|
}
|
|
754
847
|
|
|
@@ -764,11 +857,145 @@ function getLoaderRuntime({
|
|
|
764
857
|
|
|
765
858
|
code.push(`module.exports = ${loaderCode};`);
|
|
766
859
|
|
|
860
|
+
// Collect all potential helper dependencies used in loader runtime
|
|
861
|
+
let helperDependencies: Array<{
|
|
862
|
+
specifier: string;
|
|
863
|
+
symbols: Map<string, {local: string; loc: null; isWeak: boolean}>;
|
|
864
|
+
usedSymbols: Set<string>;
|
|
865
|
+
}> = [];
|
|
866
|
+
|
|
867
|
+
// Always potential dependencies based on the code patterns
|
|
868
|
+
if (needsEsmLoadPrelude) {
|
|
869
|
+
if (shardingConfig) {
|
|
870
|
+
helperDependencies.push({
|
|
871
|
+
specifier: './helpers/browser/esm-js-loader-shards',
|
|
872
|
+
symbols: new Map([
|
|
873
|
+
['default', {local: 'default', loc: null, isWeak: false}],
|
|
874
|
+
]),
|
|
875
|
+
usedSymbols: new Set(['default']),
|
|
876
|
+
});
|
|
877
|
+
} else {
|
|
878
|
+
helperDependencies.push({
|
|
879
|
+
specifier: './helpers/browser/esm-js-loader',
|
|
880
|
+
symbols: new Map([
|
|
881
|
+
['default', {local: 'default', loc: null, isWeak: false}],
|
|
882
|
+
]),
|
|
883
|
+
usedSymbols: new Set(['default']),
|
|
884
|
+
});
|
|
885
|
+
}
|
|
886
|
+
}
|
|
887
|
+
|
|
888
|
+
// Bundle manifest dependency if using runtime manifest
|
|
889
|
+
if (shouldUseRuntimeManifest(bundle, options)) {
|
|
890
|
+
helperDependencies.push({
|
|
891
|
+
specifier: './helpers/bundle-manifest',
|
|
892
|
+
symbols: new Map([
|
|
893
|
+
['resolve', {local: 'resolve', loc: null, isWeak: false}],
|
|
894
|
+
]),
|
|
895
|
+
usedSymbols: new Set(['resolve']),
|
|
896
|
+
});
|
|
897
|
+
}
|
|
898
|
+
|
|
899
|
+
// Domain sharding dependency if configured
|
|
900
|
+
if (shardingConfig) {
|
|
901
|
+
helperDependencies.push({
|
|
902
|
+
specifier: '@atlaspack/domain-sharding',
|
|
903
|
+
symbols: new Map([
|
|
904
|
+
['shardUrl', {local: 'shardUrl', loc: null, isWeak: false}],
|
|
905
|
+
]),
|
|
906
|
+
usedSymbols: new Set(['shardUrl']),
|
|
907
|
+
});
|
|
908
|
+
}
|
|
909
|
+
|
|
910
|
+
// Various loader dependencies based on bundle types in externalBundles
|
|
911
|
+
for (let to of externalBundles) {
|
|
912
|
+
let loader = loaders[to.type];
|
|
913
|
+
if (loader && typeof loader === 'string') {
|
|
914
|
+
helperDependencies.push({
|
|
915
|
+
specifier: loader,
|
|
916
|
+
symbols: new Map([
|
|
917
|
+
['default', {local: 'default', loc: null, isWeak: false}],
|
|
918
|
+
]),
|
|
919
|
+
usedSymbols: new Set(['default']),
|
|
920
|
+
});
|
|
921
|
+
}
|
|
922
|
+
}
|
|
923
|
+
|
|
924
|
+
// Import polyfill if needed
|
|
925
|
+
if (needsDynamicImportPolyfill && loaders?.IMPORT_POLYFILL) {
|
|
926
|
+
helperDependencies.push({
|
|
927
|
+
specifier: loaders.IMPORT_POLYFILL,
|
|
928
|
+
symbols: new Map([
|
|
929
|
+
['default', {local: 'default', loc: null, isWeak: false}],
|
|
930
|
+
]),
|
|
931
|
+
usedSymbols: new Set(['default']),
|
|
932
|
+
});
|
|
933
|
+
}
|
|
934
|
+
|
|
935
|
+
// Conditional loaders if using conditional bundling
|
|
936
|
+
if (getFeatureFlag('conditionalBundlingApi')) {
|
|
937
|
+
const loaderPath = `./helpers/conditional-loader${
|
|
938
|
+
options.mode === 'development' ? '-dev' : ''
|
|
939
|
+
}`;
|
|
940
|
+
helperDependencies.push({
|
|
941
|
+
specifier: loaderPath,
|
|
942
|
+
symbols: new Map([
|
|
943
|
+
['default', {local: 'default', loc: null, isWeak: false}],
|
|
944
|
+
]),
|
|
945
|
+
usedSymbols: new Set(['default']),
|
|
946
|
+
});
|
|
947
|
+
|
|
948
|
+
// Sync loader for fallback
|
|
949
|
+
if (options.mode === 'development') {
|
|
950
|
+
helperDependencies.push({
|
|
951
|
+
specifier: './helpers/browser/sync-js-loader',
|
|
952
|
+
symbols: new Map([
|
|
953
|
+
['default', {local: 'default', loc: null, isWeak: false}],
|
|
954
|
+
]),
|
|
955
|
+
usedSymbols: new Set(['default']),
|
|
956
|
+
});
|
|
957
|
+
}
|
|
958
|
+
}
|
|
959
|
+
|
|
960
|
+
// Preload/prefetch loaders for browser context
|
|
961
|
+
if (bundle.env.context === 'browser') {
|
|
962
|
+
helperDependencies.push({
|
|
963
|
+
specifier: BROWSER_PRELOAD_LOADER,
|
|
964
|
+
symbols: new Map([
|
|
965
|
+
['default', {local: 'default', loc: null, isWeak: false}],
|
|
966
|
+
]),
|
|
967
|
+
usedSymbols: new Set(['default']),
|
|
968
|
+
});
|
|
969
|
+
helperDependencies.push({
|
|
970
|
+
specifier: BROWSER_PREFETCH_LOADER,
|
|
971
|
+
symbols: new Map([
|
|
972
|
+
['default', {local: 'default', loc: null, isWeak: false}],
|
|
973
|
+
]),
|
|
974
|
+
usedSymbols: new Set(['default']),
|
|
975
|
+
});
|
|
976
|
+
}
|
|
977
|
+
|
|
978
|
+
// ESM loader retry if using import retry feature
|
|
979
|
+
if (needsEsmLoadPrelude && options.featureFlags.importRetry) {
|
|
980
|
+
helperDependencies.push({
|
|
981
|
+
specifier: './helpers/browser/esm-js-loader-retry',
|
|
982
|
+
symbols: new Map([
|
|
983
|
+
['default', {local: 'default', loc: null, isWeak: false}],
|
|
984
|
+
]),
|
|
985
|
+
usedSymbols: new Set(['default']),
|
|
986
|
+
});
|
|
987
|
+
}
|
|
988
|
+
|
|
767
989
|
return {
|
|
768
990
|
filePath: __filename,
|
|
769
991
|
code: code.join('\n'),
|
|
770
992
|
dependency,
|
|
771
993
|
env: {sourceType: 'module'},
|
|
994
|
+
// Pre-computed symbols: loader runtime with comprehensive helper dependencies
|
|
995
|
+
symbolData: {
|
|
996
|
+
symbols: new Map([['default', {local: 'module.exports', loc: null}]]),
|
|
997
|
+
dependencies: helperDependencies,
|
|
998
|
+
},
|
|
772
999
|
};
|
|
773
1000
|
}
|
|
774
1001
|
|
|
@@ -904,11 +1131,89 @@ function getURLRuntime(
|
|
|
904
1131
|
)};`;
|
|
905
1132
|
}
|
|
906
1133
|
|
|
1134
|
+
// Collect dependencies based on the URL runtime code patterns
|
|
1135
|
+
let urlRuntimeDependencies: Array<{
|
|
1136
|
+
specifier: string;
|
|
1137
|
+
symbols: Map<string, {local: string; loc: null; isWeak: boolean}>;
|
|
1138
|
+
usedSymbols: Set<string>;
|
|
1139
|
+
}> = [];
|
|
1140
|
+
|
|
1141
|
+
if (dependency.meta.webworker === true && !from.env.isLibrary) {
|
|
1142
|
+
// Web worker runtime requires get-worker-url helper
|
|
1143
|
+
urlRuntimeDependencies.push({
|
|
1144
|
+
specifier: './helpers/get-worker-url',
|
|
1145
|
+
symbols: new Map([
|
|
1146
|
+
['default', {local: 'workerURL', loc: null, isWeak: false}],
|
|
1147
|
+
]),
|
|
1148
|
+
usedSymbols: new Set(['default']),
|
|
1149
|
+
});
|
|
1150
|
+
|
|
1151
|
+
if (
|
|
1152
|
+
!(
|
|
1153
|
+
from.env.outputFormat === 'esmodule' &&
|
|
1154
|
+
from.env.supports('import-meta-url')
|
|
1155
|
+
)
|
|
1156
|
+
) {
|
|
1157
|
+
// Also requires bundle-url helper in non-ESM environments
|
|
1158
|
+
urlRuntimeDependencies.push({
|
|
1159
|
+
specifier: './helpers/bundle-url',
|
|
1160
|
+
symbols: new Map([
|
|
1161
|
+
['getBundleURL', {local: 'getBundleURL', loc: null, isWeak: false}],
|
|
1162
|
+
['getOrigin', {local: 'getOrigin', loc: null, isWeak: false}],
|
|
1163
|
+
]),
|
|
1164
|
+
usedSymbols: new Set(['getBundleURL', 'getOrigin']),
|
|
1165
|
+
});
|
|
1166
|
+
|
|
1167
|
+
// Domain sharding if configured
|
|
1168
|
+
if (shardingConfig) {
|
|
1169
|
+
urlRuntimeDependencies.push({
|
|
1170
|
+
specifier: '@atlaspack/domain-sharding',
|
|
1171
|
+
symbols: new Map([
|
|
1172
|
+
['shardUrl', {local: 'shardUrl', loc: null, isWeak: false}],
|
|
1173
|
+
]),
|
|
1174
|
+
usedSymbols: new Set(['shardUrl']),
|
|
1175
|
+
});
|
|
1176
|
+
}
|
|
1177
|
+
}
|
|
1178
|
+
} else {
|
|
1179
|
+
// Regular URL runtime may use bundle-url helper
|
|
1180
|
+
if (
|
|
1181
|
+
!(
|
|
1182
|
+
from.env.outputFormat === 'esmodule' &&
|
|
1183
|
+
from.env.supports('import-meta-url')
|
|
1184
|
+
) &&
|
|
1185
|
+
!(from.env.outputFormat === 'commonjs')
|
|
1186
|
+
) {
|
|
1187
|
+
urlRuntimeDependencies.push({
|
|
1188
|
+
specifier: './helpers/bundle-url',
|
|
1189
|
+
symbols: new Map([
|
|
1190
|
+
['getBundleURL', {local: 'getBundleURL', loc: null, isWeak: false}],
|
|
1191
|
+
]),
|
|
1192
|
+
usedSymbols: new Set(['getBundleURL']),
|
|
1193
|
+
});
|
|
1194
|
+
|
|
1195
|
+
if (shardingConfig) {
|
|
1196
|
+
urlRuntimeDependencies.push({
|
|
1197
|
+
specifier: '@atlaspack/domain-sharding',
|
|
1198
|
+
symbols: new Map([
|
|
1199
|
+
['shardUrl', {local: 'shardUrl', loc: null, isWeak: false}],
|
|
1200
|
+
]),
|
|
1201
|
+
usedSymbols: new Set(['shardUrl']),
|
|
1202
|
+
});
|
|
1203
|
+
}
|
|
1204
|
+
}
|
|
1205
|
+
}
|
|
1206
|
+
|
|
907
1207
|
return {
|
|
908
1208
|
filePath: __filename,
|
|
909
1209
|
code,
|
|
910
1210
|
dependency,
|
|
911
1211
|
env: {sourceType: 'module'},
|
|
1212
|
+
// Pre-computed symbols: URL runtime with helper dependencies
|
|
1213
|
+
symbolData: {
|
|
1214
|
+
symbols: new Map([['default', {local: 'module.exports', loc: null}]]),
|
|
1215
|
+
dependencies: urlRuntimeDependencies,
|
|
1216
|
+
},
|
|
912
1217
|
};
|
|
913
1218
|
}
|
|
914
1219
|
|