@lwrjs/view-registry 0.10.0-alpha.13 → 0.10.0-alpha.14
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/build/cjs/linkers/legacy_view_bootstrap.cjs +115 -99
- package/build/cjs/linkers/preload-utils.cjs +81 -0
- package/build/cjs/linkers/utils.cjs +0 -39
- package/build/cjs/linkers/view_bootstrap.cjs +109 -92
- package/build/es/linkers/legacy_view_bootstrap.js +153 -135
- package/build/es/linkers/preload-utils.d.ts +17 -0
- package/build/es/linkers/preload-utils.js +70 -0
- package/build/es/linkers/utils.d.ts +1 -7
- package/build/es/linkers/utils.js +1 -51
- package/build/es/linkers/view_bootstrap.js +141 -122
- package/package.json +6 -6
|
@@ -30,6 +30,7 @@ var import_shared_utils = __toModule(require("@lwrjs/shared-utils"));
|
|
|
30
30
|
var import_identity = __toModule(require("@lwrjs/app-service/identity"));
|
|
31
31
|
var import_utils = __toModule(require("../utils.cjs"));
|
|
32
32
|
var import_utils2 = __toModule(require("./utils.cjs"));
|
|
33
|
+
var import_preload_utils = __toModule(require("./preload-utils.cjs"));
|
|
33
34
|
async function getHtmlResources(view, viewParams, resourceContext) {
|
|
34
35
|
const {
|
|
35
36
|
runtimeEnvironment,
|
|
@@ -39,8 +40,13 @@ async function getHtmlResources(view, viewParams, resourceContext) {
|
|
|
39
40
|
resourceRegistry,
|
|
40
41
|
viewMetadata
|
|
41
42
|
} = resourceContext;
|
|
43
|
+
const {lwrVersion, format, hmrEnabled, bundle, debug, minify} = runtimeEnvironment;
|
|
44
|
+
const {customElements} = viewMetadata;
|
|
45
|
+
const version = lwrVersion;
|
|
46
|
+
const isAMD = format === "amd";
|
|
42
47
|
const {bundleConfig} = resourceContext;
|
|
43
48
|
const {external = {}} = bundleConfig;
|
|
49
|
+
const groups = isAMD ? bundleConfig.groups || {} : {};
|
|
44
50
|
const isExternal = function(rawSpecifier) {
|
|
45
51
|
const {specifier} = (0, import_shared_utils.explodeSpecifier)(rawSpecifier);
|
|
46
52
|
return Object.keys(external).some((e) => specifier === e);
|
|
@@ -52,10 +58,8 @@ async function getHtmlResources(view, viewParams, resourceContext) {
|
|
|
52
58
|
preloadModules: []
|
|
53
59
|
}
|
|
54
60
|
} = view;
|
|
55
|
-
const
|
|
56
|
-
const {
|
|
57
|
-
const version = lwrVersion;
|
|
58
|
-
const isAMD = format === "amd";
|
|
61
|
+
const defRegistry = bundle ? moduleBundler : moduleRegistry;
|
|
62
|
+
const depth = isAMD ? {static: import_shared_utils.GraphDepth.ALL, dynamic: 1} : {static: import_shared_utils.GraphDepth.NONE, dynamic: 0};
|
|
59
63
|
const appIdentity = {
|
|
60
64
|
appName,
|
|
61
65
|
format: runtimeEnvironment.format,
|
|
@@ -69,116 +73,132 @@ async function getHtmlResources(view, viewParams, resourceContext) {
|
|
|
69
73
|
const imports = {};
|
|
70
74
|
const rootComponents = [];
|
|
71
75
|
const requiredAmdModules = [];
|
|
72
|
-
const
|
|
76
|
+
const viewPreloads = {
|
|
77
|
+
uris: [],
|
|
78
|
+
specifiers: [],
|
|
79
|
+
groups: new Map()
|
|
80
|
+
};
|
|
73
81
|
const isSSR = view.bootstrap?.ssr;
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
} else {
|
|
83
|
-
fallbackShimBundle = "lwr-loader-shim-legacy.bundle.js";
|
|
84
|
-
def = await resourceRegistry.getResource({specifier: fallbackShimBundle, version}, runtimeEnvironment, runtimeParams);
|
|
85
|
-
}
|
|
82
|
+
let bootstrapModuleRef, versionedSpecifier = bootstrapSpecifier;
|
|
83
|
+
const customElementsRecords = [];
|
|
84
|
+
const flattenedElements = (0, import_utils2.flattenCustomElements)(customElements, isSSR);
|
|
85
|
+
const viewContainsHydratedElements = !isSSR || flattenedElements.some(({props}) => (0, import_shared_utils.hasHydrateDirective)(props));
|
|
86
|
+
if (viewContainsHydratedElements) {
|
|
87
|
+
if (isAMD) {
|
|
88
|
+
const shimBundle = debug || minify === false ? "lwr-loader-shim-legacy.bundle.js" : "lwr-loader-shim-legacy.bundle.min.js";
|
|
89
|
+
let def = await resourceRegistry.getResource({specifier: shimBundle, version}, runtimeEnvironment, runtimeParams);
|
|
86
90
|
if (!def) {
|
|
87
|
-
|
|
91
|
+
let fallbackShimBundle;
|
|
92
|
+
if (shimBundle === "lwr-loader-shim-legacy.bundle.js") {
|
|
93
|
+
fallbackShimBundle = "lwr-loader-shim-legacy.bundle.min.js";
|
|
94
|
+
def = await resourceRegistry.getResource({specifier: fallbackShimBundle, version}, runtimeEnvironment, runtimeParams);
|
|
95
|
+
} else {
|
|
96
|
+
fallbackShimBundle = "lwr-loader-shim-legacy.bundle.js";
|
|
97
|
+
def = await resourceRegistry.getResource({specifier: fallbackShimBundle, version}, runtimeEnvironment, runtimeParams);
|
|
98
|
+
}
|
|
99
|
+
if (!def) {
|
|
100
|
+
throw Error("Failed to find definition of resource: " + shimBundle);
|
|
101
|
+
}
|
|
88
102
|
}
|
|
103
|
+
requiredResources.push(def);
|
|
104
|
+
const errorShimDef = await resourceRegistry.getResource({specifier: "lwr-error-shim.js", version}, runtimeEnvironment, runtimeParams);
|
|
105
|
+
if (!errorShimDef) {
|
|
106
|
+
throw Error("Failed to find definition of resource: lwr-error-shim.js");
|
|
107
|
+
}
|
|
108
|
+
requiredResources.push(errorShimDef);
|
|
89
109
|
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
if (!isExternal(depSpecifier)) {
|
|
105
|
-
const uri2 = bootstrapModuleGraph.uriMap[depSpecifier];
|
|
106
|
-
preloadModulesMeta.set(depSpecifier, uri2);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
if ((0, import_shared_utils.isBundler)(defRegistry)) {
|
|
110
|
-
for (const specifier of preloadModules) {
|
|
111
|
-
await (0, import_utils2.getPreloadModulesMeta)(specifier, preloadModulesMeta, bundleConfig, moduleRegistry, defRegistry, runtimeEnvironment, runtimeParams);
|
|
110
|
+
const bootstrapModuleGraph = await (0, import_shared_utils.getModuleGraphs)(bootstrapSpecifier, {includeUris: true, includeLinkedDefinitions: true, depth}, moduleRegistry, defRegistry, runtimeEnvironment, runtimeParams, visitedCache);
|
|
111
|
+
bootstrapModuleRef = {
|
|
112
|
+
specifier: bootstrapModuleGraph.graphs[0].specifier,
|
|
113
|
+
flatGraph: bootstrapModuleGraph,
|
|
114
|
+
resources: configResources
|
|
115
|
+
};
|
|
116
|
+
versionedSpecifier = bootstrapModuleGraph.graphs[0].specifier;
|
|
117
|
+
const uri = bootstrapModuleGraph.uriMap[versionedSpecifier];
|
|
118
|
+
moduleResources.push((0, import_utils.getModuleResourceByUri)(uri, runtimeEnvironment, {isPreload: false, isSSR}));
|
|
119
|
+
for (const depSpecifier of bootstrapModuleGraph.graphs[0].static) {
|
|
120
|
+
if (!isExternal(depSpecifier)) {
|
|
121
|
+
const uri2 = bootstrapModuleGraph.uriMap[depSpecifier];
|
|
122
|
+
(0, import_preload_utils.setPreloadModulesMeta)(depSpecifier, uri2, groups, viewPreloads);
|
|
123
|
+
}
|
|
112
124
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
imports[versionedSpecifier] = uri;
|
|
117
|
-
for (const staticDep of bootstrapModuleGraph.graphs[0].static) {
|
|
118
|
-
const uri2 = bootstrapModuleGraph.uriMap[staticDep];
|
|
119
|
-
imports[staticDep] = uri2;
|
|
120
|
-
if (services && services.length) {
|
|
121
|
-
requiredAmdModules.push(staticDep);
|
|
125
|
+
if ((0, import_shared_utils.isBundler)(defRegistry)) {
|
|
126
|
+
for (const specifier of preloadModules) {
|
|
127
|
+
await (0, import_preload_utils.getPreloadModulesMeta)(specifier, viewPreloads, bundleConfig, moduleRegistry, defRegistry, runtimeEnvironment, runtimeParams);
|
|
122
128
|
}
|
|
123
129
|
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
+
if (isAMD) {
|
|
131
|
+
requiredAmdModules.push(versionedSpecifier);
|
|
132
|
+
imports[versionedSpecifier] = uri;
|
|
133
|
+
for (const staticDep of bootstrapModuleGraph.graphs[0].static) {
|
|
134
|
+
const uri2 = bootstrapModuleGraph.uriMap[staticDep];
|
|
135
|
+
imports[staticDep] = uri2;
|
|
136
|
+
if (services && services.length) {
|
|
137
|
+
requiredAmdModules.push(staticDep);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
for (const dynamicDep of bootstrapModuleGraph.graphs[0].dynamicRefs) {
|
|
141
|
+
const uri2 = bootstrapModuleGraph.uriMap[dynamicDep];
|
|
142
|
+
if (uri2) {
|
|
143
|
+
imports[dynamicDep] = uri2;
|
|
144
|
+
} else {
|
|
145
|
+
import_shared_utils.logger.warn("Skipping unknown dynamic import " + dynamicDep);
|
|
146
|
+
}
|
|
130
147
|
}
|
|
131
148
|
}
|
|
132
149
|
}
|
|
133
|
-
const customElementsRecords = [];
|
|
134
|
-
const flattenedElements = (0, import_utils2.flattenCustomElements)(customElements, isSSR);
|
|
135
150
|
await Promise.all(flattenedElements.map(async ({tagName: element, props}) => {
|
|
136
151
|
const graph = await (0, import_shared_utils.getModuleGraphs)((0, import_shared_utils.kebabCaseToModuleSpecifier)(element), {includeUris: true, includeLinkedDefinitions: true, depth}, moduleRegistry, defRegistry, runtimeEnvironment, runtimeParams ? runtimeParams : {}, visitedCache);
|
|
137
152
|
customElementsRecords.push({elementName: element, flatGraph: graph});
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
153
|
+
if (!isSSR || (0, import_shared_utils.hasHydrateDirective)(props)) {
|
|
154
|
+
const specifier = graph.graphs[0].specifier;
|
|
155
|
+
const uri = graph.uriMap[specifier];
|
|
156
|
+
(0, import_preload_utils.setPreloadModulesMeta)(specifier, uri, groups, viewPreloads);
|
|
157
|
+
if (bundle) {
|
|
158
|
+
for (const depSpecifier of graph.graphs[0].static) {
|
|
159
|
+
if (!isExternal(depSpecifier)) {
|
|
160
|
+
const uri2 = graph.uriMap[depSpecifier];
|
|
161
|
+
(0, import_preload_utils.setPreloadModulesMeta)(depSpecifier, uri2, groups, viewPreloads);
|
|
162
|
+
}
|
|
146
163
|
}
|
|
147
164
|
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
165
|
+
rootComponents.push(specifier);
|
|
166
|
+
imports[specifier] = uri;
|
|
167
|
+
if (isAMD) {
|
|
168
|
+
for (const staticDep of graph.graphs[0].static) {
|
|
169
|
+
const uri2 = graph.uriMap[staticDep];
|
|
170
|
+
imports[staticDep] = uri2;
|
|
171
|
+
}
|
|
172
|
+
for (const dynamicDep of graph.graphs[0].dynamicRefs) {
|
|
173
|
+
const uri2 = graph.uriMap[dynamicDep];
|
|
174
|
+
imports[dynamicDep] = uri2;
|
|
175
|
+
}
|
|
159
176
|
}
|
|
160
177
|
}
|
|
161
178
|
}));
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
179
|
+
if (viewContainsHydratedElements) {
|
|
180
|
+
configResources.unshift((0, import_utils2.getViewBootstrapConfigurationResource)({
|
|
181
|
+
id: view.id,
|
|
182
|
+
url: viewParams?.page?.url,
|
|
183
|
+
configAsSrc: view.bootstrap?.configAsSrc || false
|
|
184
|
+
}, {
|
|
185
|
+
appId: appIdentity.appName,
|
|
186
|
+
bootstrapModule: versionedSpecifier,
|
|
187
|
+
autoBoot: view.bootstrap?.autoBoot === false ? false : true,
|
|
188
|
+
importMappings: {
|
|
189
|
+
imports,
|
|
190
|
+
default: (0, import_shared_utils.getModuleUriPrefix)(runtimeEnvironment, runtimeParams)
|
|
191
|
+
},
|
|
192
|
+
rootComponents,
|
|
193
|
+
...isAMD && {requiredModules: requiredAmdModules},
|
|
194
|
+
...isAMD && {preloadModules: viewPreloads.specifiers}
|
|
195
|
+
}, runtimeEnvironment, runtimeParams));
|
|
196
|
+
}
|
|
178
197
|
if (!isAMD && hmrEnabled) {
|
|
179
|
-
configResources.unshift(
|
|
198
|
+
configResources.unshift((0, import_utils2.getViewHmrConfigurationResource)(view, viewMetadata));
|
|
180
199
|
}
|
|
181
|
-
|
|
200
|
+
const dedupedUris = [...new Set(viewPreloads.uris)];
|
|
201
|
+
for (const preloadUri of dedupedUris) {
|
|
182
202
|
moduleResources.push((0, import_utils.getModuleResourceByUri)(preloadUri, runtimeEnvironment, {isPreload: true, isSSR}));
|
|
183
203
|
}
|
|
184
204
|
const htmlResources = await Promise.all([...configResources, ...requiredResources, ...moduleResources].map(import_utils.generateHtmlTag));
|
|
@@ -187,11 +207,7 @@ async function getHtmlResources(view, viewParams, resourceContext) {
|
|
|
187
207
|
viewRecord: {
|
|
188
208
|
resources: requiredResources,
|
|
189
209
|
customElements: customElementsRecords,
|
|
190
|
-
bootstrapModule:
|
|
191
|
-
specifier: bootstrapModuleGraph.graphs[0].specifier,
|
|
192
|
-
flatGraph: bootstrapModuleGraph,
|
|
193
|
-
resources: configResources
|
|
194
|
-
}
|
|
210
|
+
bootstrapModule: bootstrapModuleRef
|
|
195
211
|
}
|
|
196
212
|
};
|
|
197
213
|
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", {value: true});
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, {get: all[name], enumerable: true});
|
|
11
|
+
};
|
|
12
|
+
var __exportStar = (target, module2, desc) => {
|
|
13
|
+
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(module2))
|
|
15
|
+
if (!__hasOwnProp.call(target, key) && key !== "default")
|
|
16
|
+
__defProp(target, key, {get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable});
|
|
17
|
+
}
|
|
18
|
+
return target;
|
|
19
|
+
};
|
|
20
|
+
var __toModule = (module2) => {
|
|
21
|
+
return __exportStar(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? {get: () => module2.default, enumerable: true} : {value: module2, enumerable: true})), module2);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
// packages/@lwrjs/view-registry/src/linkers/preload-utils.ts
|
|
25
|
+
__markAsModule(exports);
|
|
26
|
+
__export(exports, {
|
|
27
|
+
getPreloadModulesMeta: () => getPreloadModulesMeta,
|
|
28
|
+
setPreloadModulesMeta: () => setPreloadModulesMeta
|
|
29
|
+
});
|
|
30
|
+
var import_shared_utils = __toModule(require("@lwrjs/shared-utils"));
|
|
31
|
+
function setPreloadModulesMeta(specifier, uri, groups, preloads) {
|
|
32
|
+
const preloadModulesSpecifiers = preloads.specifiers;
|
|
33
|
+
const preloadBundleGroupsMap = preloads.groups;
|
|
34
|
+
const preloadModulesURIs = preloads.uris;
|
|
35
|
+
preloadModulesSpecifiers.push(specifier);
|
|
36
|
+
const {specifier: unversionedSpecifier} = (0, import_shared_utils.explodeSpecifier)(specifier);
|
|
37
|
+
const groupName = (0, import_shared_utils.getGroupName)(unversionedSpecifier, groups);
|
|
38
|
+
if (groupName && preloadBundleGroupsMap.has(groupName)) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
preloadModulesURIs.push(uri);
|
|
42
|
+
groupName && preloadBundleGroupsMap.set(groupName, true);
|
|
43
|
+
}
|
|
44
|
+
async function getPreloadModulesMeta(specifier, viewPreloads, bundleConfig, moduleRegistry, defRegistry, runtimeEnvironment, runtimeParams, pending) {
|
|
45
|
+
const {exclude = [], external = {}, groups = {}} = bundleConfig;
|
|
46
|
+
const isExternal = function(rawSpecifier) {
|
|
47
|
+
const {specifier: specifier2} = (0, import_shared_utils.explodeSpecifier)(rawSpecifier);
|
|
48
|
+
return Object.keys(external).includes(specifier2);
|
|
49
|
+
};
|
|
50
|
+
const isExclude = function(specifier2) {
|
|
51
|
+
return exclude.includes(specifier2);
|
|
52
|
+
};
|
|
53
|
+
if (isExternal(specifier)) {
|
|
54
|
+
import_shared_utils.logger.warn(`"${specifier}" is configured in both bundleConfig.externals and bootstrap.preloadModules. We are treating it as external.`);
|
|
55
|
+
} else {
|
|
56
|
+
const versionedModuleId = await (0, import_shared_utils.getVersionedModuleId)(specifier, moduleRegistry);
|
|
57
|
+
const versionedModuleSpecifier = (0, import_shared_utils.getSpecifier)({
|
|
58
|
+
specifier,
|
|
59
|
+
version: (0, import_shared_utils.normalizeVersionToUri)(versionedModuleId.version)
|
|
60
|
+
});
|
|
61
|
+
const uri = await defRegistry.resolveModuleUri(versionedModuleId, runtimeEnvironment, runtimeParams);
|
|
62
|
+
const normalizedSpecifier = versionedModuleId.version === import_shared_utils.VERSION_NOT_PROVIDED ? specifier : versionedModuleSpecifier;
|
|
63
|
+
setPreloadModulesMeta(normalizedSpecifier, uri, groups, viewPreloads);
|
|
64
|
+
if (exclude.length || Object.keys(groups).length) {
|
|
65
|
+
const preloadModuleRecord = await defRegistry.getModuleBundle(versionedModuleId, runtimeEnvironment, runtimeParams);
|
|
66
|
+
const {imports} = preloadModuleRecord.bundleRecord;
|
|
67
|
+
if (imports) {
|
|
68
|
+
if (!pending) {
|
|
69
|
+
pending = new Map();
|
|
70
|
+
}
|
|
71
|
+
for (let i = 0; i < imports.length; i++) {
|
|
72
|
+
const imp = imports[i];
|
|
73
|
+
if (!pending.has(imp.specifier) && (isExclude(imp.specifier) || (0, import_shared_utils.isGroupie)(imp.specifier, groups))) {
|
|
74
|
+
pending.set(imp.specifier, true);
|
|
75
|
+
await getPreloadModulesMeta(imp.specifier, viewPreloads, bundleConfig, moduleRegistry, defRegistry, runtimeEnvironment, runtimeParams, pending);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
@@ -25,7 +25,6 @@ var __toModule = (module2) => {
|
|
|
25
25
|
__markAsModule(exports);
|
|
26
26
|
__export(exports, {
|
|
27
27
|
flattenCustomElements: () => flattenCustomElements,
|
|
28
|
-
getPreloadModulesMeta: () => getPreloadModulesMeta,
|
|
29
28
|
getViewBootstrapConfigurationResource: () => getViewBootstrapConfigurationResource,
|
|
30
29
|
getViewHmrConfigurationResource: () => getViewHmrConfigurationResource
|
|
31
30
|
});
|
|
@@ -121,41 +120,3 @@ function flattenCustomElements(arr, isSSR = false) {
|
|
|
121
120
|
flatten(arr);
|
|
122
121
|
return ret;
|
|
123
122
|
}
|
|
124
|
-
async function getPreloadModulesMeta(specifier, preloadModulesMeta, bundleConfig, moduleRegistry, defRegistry, runtimeEnvironment, runtimeParams, pending) {
|
|
125
|
-
const {exclude = [], external = {}} = bundleConfig;
|
|
126
|
-
const isExternal = function(rawSpecifier) {
|
|
127
|
-
const {specifier: specifier2} = (0, import_shared_utils.explodeSpecifier)(rawSpecifier);
|
|
128
|
-
return Object.keys(external).includes(specifier2);
|
|
129
|
-
};
|
|
130
|
-
const isExclude = function(specifier2) {
|
|
131
|
-
return exclude.includes(specifier2);
|
|
132
|
-
};
|
|
133
|
-
if (isExternal(specifier)) {
|
|
134
|
-
import_shared_utils.logger.warn(`"${specifier}" is configured in both bundleConfig.externals and bootstrap.preloadModules. We are treating it as external.`);
|
|
135
|
-
} else {
|
|
136
|
-
const versionedModuleId = await (0, import_shared_utils.getVersionedModuleId)(specifier, moduleRegistry);
|
|
137
|
-
const versionedModuleSpecifier = (0, import_shared_utils.getSpecifier)({
|
|
138
|
-
specifier,
|
|
139
|
-
version: (0, import_shared_utils.normalizeVersionToUri)(versionedModuleId.version)
|
|
140
|
-
});
|
|
141
|
-
const uri = await defRegistry.resolveModuleUri(versionedModuleId, runtimeEnvironment, runtimeParams);
|
|
142
|
-
const normalizedSpecifier = versionedModuleId.version === import_shared_utils.VERSION_NOT_PROVIDED ? specifier : versionedModuleSpecifier;
|
|
143
|
-
preloadModulesMeta.set(normalizedSpecifier, uri);
|
|
144
|
-
if (exclude.length) {
|
|
145
|
-
const preloadModuleRecord = await defRegistry.getModuleBundle(versionedModuleId, runtimeEnvironment, runtimeParams);
|
|
146
|
-
const {imports} = preloadModuleRecord.bundleRecord;
|
|
147
|
-
if (imports) {
|
|
148
|
-
if (!pending) {
|
|
149
|
-
pending = new Map();
|
|
150
|
-
}
|
|
151
|
-
for (let i = 0; i < imports.length; i++) {
|
|
152
|
-
const imp = imports[i];
|
|
153
|
-
if (!pending.has(imp.specifier) && isExclude(imp.specifier)) {
|
|
154
|
-
pending.set(imp.specifier, true);
|
|
155
|
-
await getPreloadModulesMeta(imp.specifier, preloadModulesMeta, bundleConfig, moduleRegistry, defRegistry, runtimeEnvironment, runtimeParams, pending);
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
}
|