@lwrjs/loader 0.10.0-alpha.2 → 0.10.0-alpha.20
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/assets/prod/lwr-error-shim.js +2 -1
- package/build/assets/prod/lwr-loader-shim-legacy.bundle.js +636 -256
- package/build/assets/prod/lwr-loader-shim-legacy.bundle.min.js +6 -2
- package/build/assets/prod/lwr-loader-shim-legacy.js +150 -55
- package/build/assets/prod/lwr-loader-shim.bundle.js +583 -259
- package/build/assets/prod/lwr-loader-shim.bundle.min.js +6 -2
- package/build/assets/prod/lwr-loader-shim.js +149 -55
- package/build/bundle/prod/lwr/esmLoader/esmLoader.js +2 -1
- package/build/cjs/index.cjs +1 -1
- package/build/cjs/modules/lwr/esmLoader/importResolver.cjs +17 -0
- package/build/cjs/modules/lwr/esmLoader/importResolverLegacy.cjs +17 -0
- package/build/cjs/modules/lwr/loader/constants/constants.cjs +1 -1
- package/build/cjs/modules/lwr/loader/errors/reportError.cjs +1 -0
- package/build/cjs/modules/lwr/loader/hooks/moduleInvalidation.cjs +1 -0
- package/build/cjs/modules/lwr/loader/hooks/resolveAndLoadHook.cjs +3 -1
- package/build/cjs/modules/lwr/loader/moduleRegistry/importMetadataResolver.cjs +2 -0
- package/build/cjs/modules/lwr/loader/moduleRegistry/moduleRegistry.cjs +2 -0
- package/build/cjs/modules/lwr/loaderLegacy/constants/constants.cjs +1 -1
- package/build/cjs/modules/lwr/loaderLegacy/errors/reportError.cjs +1 -0
- package/build/cjs/modules/lwr/loaderLegacy/hooks/moduleInvalidation.cjs +1 -0
- package/build/cjs/modules/lwr/loaderLegacy/hooks/resolveAndLoadHook.cjs +3 -1
- package/build/cjs/modules/lwr/loaderLegacy/importMap/importMapResolver.cjs +1 -0
- package/build/cjs/modules/lwr/loaderLegacy/importResolver/importResolver.cjs +17 -0
- package/build/cjs/modules/lwr/loaderLegacy/moduleRegistry/moduleRegistry.cjs +3 -0
- package/build/index.d.ts +1 -1
- package/build/index.js +1 -1
- package/build/modules/lwr/esmLoader/esmLoader.js +45 -15
- package/build/modules/lwr/loader/loader.js +433 -203
- package/build/modules/lwr/loaderLegacy/loaderLegacy.js +485 -200
- package/package.json +16 -9
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* SPDX-License-Identifier: MIT
|
|
5
5
|
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
|
|
6
6
|
*/
|
|
7
|
-
/* LWR Legacy Module Loader Shim v0.10.0-alpha.
|
|
7
|
+
/* LWR Legacy Module Loader Shim v0.10.0-alpha.20 */
|
|
8
8
|
(function () {
|
|
9
9
|
'use strict';
|
|
10
10
|
|
|
@@ -12,11 +12,11 @@
|
|
|
12
12
|
const BOOTSTRAP_PREFIX = 'lwr.bootstrap.';
|
|
13
13
|
const BOOTSTRAP_ERROR = `${BOOTSTRAP_PREFIX}error`;
|
|
14
14
|
|
|
15
|
-
var Phase
|
|
16
|
-
(function (Phase) {
|
|
15
|
+
var Phase = /*#__PURE__*/function (Phase) {
|
|
17
16
|
Phase[Phase["Start"] = 0] = "Start";
|
|
18
17
|
Phase[Phase["End"] = 1] = "End";
|
|
19
|
-
|
|
18
|
+
return Phase;
|
|
19
|
+
}(Phase || {});
|
|
20
20
|
// Attach a custom dispatcher
|
|
21
21
|
let customDispatcher;
|
|
22
22
|
function attachDispatcher(dispatcher) {
|
|
@@ -27,21 +27,46 @@
|
|
|
27
27
|
// e.g. JSDom (used in Jest) doesn't implement these
|
|
28
28
|
const perf = globalThis.performance;
|
|
29
29
|
const isPerfSupported = typeof perf !== 'undefined' && typeof perf.mark === 'function' && typeof perf.clearMarks === 'function' && typeof perf.measure === 'function' && typeof perf.clearMeasures === 'function';
|
|
30
|
+
function getMeasureName(id, specifier) {
|
|
31
|
+
return specifier ? `${id}-${specifier}` : id;
|
|
32
|
+
}
|
|
33
|
+
function getMarkName(id, specifier, specifierIndex) {
|
|
34
|
+
const measureName = getMeasureName(id, specifier);
|
|
35
|
+
return specifier && specifierIndex ? `${measureName}_${specifierIndex}` : measureName;
|
|
36
|
+
}
|
|
37
|
+
function getDetail(specifier, metadata) {
|
|
38
|
+
const detail = specifier || metadata ? {
|
|
39
|
+
...metadata
|
|
40
|
+
} : null;
|
|
41
|
+
if (detail && specifier) {
|
|
42
|
+
detail['specifier'] = specifier;
|
|
43
|
+
}
|
|
44
|
+
return detail;
|
|
45
|
+
}
|
|
30
46
|
|
|
31
47
|
// For marking request metrics
|
|
32
48
|
// Fallback to the Performance API if there is no custom dispatcher
|
|
33
49
|
function logOperationStart({
|
|
34
50
|
id,
|
|
35
|
-
specifier
|
|
51
|
+
specifier,
|
|
52
|
+
specifierIndex,
|
|
53
|
+
metadata
|
|
36
54
|
}) {
|
|
37
55
|
if (customDispatcher) {
|
|
38
56
|
customDispatcher({
|
|
39
57
|
id,
|
|
40
58
|
phase: Phase.Start,
|
|
41
|
-
specifier
|
|
59
|
+
specifier,
|
|
60
|
+
metadata
|
|
61
|
+
});
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
if (isPerfSupported) {
|
|
65
|
+
const markName = getMarkName(id, specifier, specifierIndex);
|
|
66
|
+
const detail = getDetail(specifier, metadata);
|
|
67
|
+
perf.mark(markName, {
|
|
68
|
+
detail
|
|
42
69
|
});
|
|
43
|
-
} else if (isPerfSupported) {
|
|
44
|
-
perf.mark(id + (specifier ? `.${specifier}` : ''));
|
|
45
70
|
}
|
|
46
71
|
}
|
|
47
72
|
|
|
@@ -50,19 +75,25 @@
|
|
|
50
75
|
/* istanbul ignore next */
|
|
51
76
|
function logOperationEnd({
|
|
52
77
|
id,
|
|
53
|
-
specifier
|
|
78
|
+
specifier,
|
|
79
|
+
specifierIndex,
|
|
80
|
+
metadata
|
|
54
81
|
}) {
|
|
55
82
|
if (customDispatcher) {
|
|
56
83
|
customDispatcher({
|
|
57
84
|
id,
|
|
58
85
|
phase: Phase.End,
|
|
59
|
-
specifier
|
|
86
|
+
specifier,
|
|
87
|
+
metadata
|
|
60
88
|
});
|
|
61
89
|
} else if (isPerfSupported) {
|
|
62
|
-
const
|
|
63
|
-
const
|
|
64
|
-
const
|
|
65
|
-
perf.measure(measureName,
|
|
90
|
+
const markName = getMarkName(id, specifier, specifierIndex);
|
|
91
|
+
const measureName = getMeasureName(id, specifier);
|
|
92
|
+
const detail = getDetail(specifier, metadata);
|
|
93
|
+
perf.measure(measureName, {
|
|
94
|
+
start: markName,
|
|
95
|
+
detail
|
|
96
|
+
});
|
|
66
97
|
|
|
67
98
|
// Clear the created mark and measure to avoid filling the performance entry buffer
|
|
68
99
|
// Even if they get deleted, existing PerformanceObservers preserve copies of the entries
|
|
@@ -71,19 +102,27 @@
|
|
|
71
102
|
}
|
|
72
103
|
}
|
|
73
104
|
|
|
74
|
-
function createLoader(
|
|
105
|
+
function createLoader(
|
|
106
|
+
name,
|
|
107
|
+
definition,
|
|
108
|
+
config,
|
|
109
|
+
externalModules,
|
|
110
|
+
) {
|
|
75
111
|
if (!definition || typeof definition[2] !== 'function') {
|
|
76
112
|
throw new Error(`Expected loader with specifier "${name}" to be a module`);
|
|
77
113
|
}
|
|
114
|
+
|
|
78
115
|
// Create a Loader instance
|
|
79
116
|
const exports = {};
|
|
80
117
|
definition[2].call(null, exports);
|
|
81
118
|
const { Loader } = exports;
|
|
82
119
|
const loader = new Loader(config);
|
|
120
|
+
|
|
83
121
|
// register externally loaded modules
|
|
84
122
|
if (externalModules && externalModules.length) {
|
|
85
123
|
loader.registerExternalModules(externalModules);
|
|
86
124
|
}
|
|
125
|
+
|
|
87
126
|
// Define the loader module with public API: { define, load, services }
|
|
88
127
|
const exporter = (exports) => {
|
|
89
128
|
Object.assign(exports, {
|
|
@@ -94,10 +133,11 @@
|
|
|
94
133
|
return;
|
|
95
134
|
};
|
|
96
135
|
loader.define(name, ['exports'], exporter, definition[3]);
|
|
136
|
+
|
|
97
137
|
return loader;
|
|
98
138
|
}
|
|
99
139
|
|
|
100
|
-
const REQUIRED_MODULES_TIMEOUT =
|
|
140
|
+
const REQUIRED_MODULES_TIMEOUT = 60 * 1000; // 2m
|
|
101
141
|
|
|
102
142
|
// Check for errors with autoBoot and customInit
|
|
103
143
|
function validatePreInit(autoBoot, customInit) {
|
|
@@ -110,11 +150,18 @@
|
|
|
110
150
|
throw new Error('The customInit hook must not be defined when autoBoot is true');
|
|
111
151
|
}
|
|
112
152
|
}
|
|
153
|
+
|
|
113
154
|
// Process the customInit hook
|
|
114
|
-
function customInit(
|
|
155
|
+
function customInit(
|
|
156
|
+
config,
|
|
157
|
+
initializeApp,
|
|
158
|
+
define,
|
|
159
|
+
onBootstrapError,
|
|
160
|
+
) {
|
|
115
161
|
// Validate config
|
|
116
162
|
const { autoBoot, customInit } = config;
|
|
117
163
|
validatePreInit(autoBoot, customInit);
|
|
164
|
+
|
|
118
165
|
// Set up arguments and call the customInit hook, if available
|
|
119
166
|
if (customInit) {
|
|
120
167
|
const lwr = {
|
|
@@ -128,48 +175,74 @@
|
|
|
128
175
|
}
|
|
129
176
|
|
|
130
177
|
/* global document */
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
|
|
131
186
|
/* eslint-disable lwr/no-unguarded-apis */
|
|
132
187
|
const hasSetTimeout = typeof setTimeout === 'function';
|
|
133
188
|
const hasConsole = typeof console !== 'undefined';
|
|
134
189
|
/* eslint-enable lwr/no-unguarded-apis */
|
|
190
|
+
|
|
135
191
|
class LoaderShim {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
__init() {this.defineCache = {};}
|
|
197
|
+
__init2() {this.orderedDefs = [];}
|
|
198
|
+
|
|
199
|
+
// eslint-disable-line no-undef, lwr/no-unguarded-apis
|
|
200
|
+
|
|
201
|
+
constructor(global) {LoaderShim.prototype.__init.call(this);LoaderShim.prototype.__init2.call(this);
|
|
139
202
|
// Start watchdog timer
|
|
140
203
|
if (hasSetTimeout) {
|
|
141
204
|
this.watchdogTimerId = this.startWatchdogTimer();
|
|
142
205
|
}
|
|
206
|
+
|
|
143
207
|
// Parse configuration
|
|
144
208
|
this.global = global;
|
|
145
|
-
this.config = global.LWR;
|
|
146
|
-
this.loaderModule = 'lwr/loaderLegacy/v/0_10_0-
|
|
209
|
+
this.config = global.LWR ;
|
|
210
|
+
this.loaderModule = 'lwr/loaderLegacy/v/0_10_0-alpha_20';
|
|
211
|
+
|
|
147
212
|
// Set up error handler
|
|
148
213
|
this.errorHandler = this.config.onError;
|
|
214
|
+
|
|
149
215
|
// Set up the temporary LWR.define function and customInit hook
|
|
150
216
|
const tempDefine = this.tempDefine.bind(this);
|
|
151
217
|
global.LWR.define = tempDefine;
|
|
152
218
|
this.bootReady = this.config.autoBoot;
|
|
219
|
+
|
|
153
220
|
try {
|
|
154
221
|
this.createProfilerModule(this.config);
|
|
155
|
-
customInit(
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
222
|
+
customInit(
|
|
223
|
+
Object.freeze(this.config),
|
|
224
|
+
this.postCustomInit.bind(this),
|
|
225
|
+
tempDefine,
|
|
226
|
+
(e) => {
|
|
227
|
+
// customInit handlers can overwrite
|
|
228
|
+
// the error handler with onBootstrapError
|
|
229
|
+
this.errorHandler = e;
|
|
230
|
+
},
|
|
231
|
+
);
|
|
232
|
+
} catch (e) {
|
|
162
233
|
this.enterErrorState(e);
|
|
163
234
|
}
|
|
164
235
|
}
|
|
236
|
+
|
|
165
237
|
// Return true if the app can be initialized
|
|
166
|
-
|
|
238
|
+
canInit() {
|
|
167
239
|
// Initialize the app if:
|
|
168
240
|
// - bootReady: autoBoot is on OR customInit has finished
|
|
169
241
|
// - all required modules are defined
|
|
170
242
|
const allDefined = this.config.requiredModules.every((m) => this.orderedDefs.includes(m));
|
|
171
243
|
return this.bootReady && allDefined;
|
|
172
244
|
}
|
|
245
|
+
|
|
173
246
|
/**
|
|
174
247
|
* Create a temporary LWR.define() function which captures all
|
|
175
248
|
* calls that occur BEFORE the full loader module is available
|
|
@@ -179,7 +252,7 @@
|
|
|
179
252
|
* - each moduleName is pushed onto an array, to preserve
|
|
180
253
|
* the order in which the modules were defined
|
|
181
254
|
*/
|
|
182
|
-
|
|
255
|
+
tempDefine(...args) {
|
|
183
256
|
// Cache the incoming module
|
|
184
257
|
const moduleName = args[0];
|
|
185
258
|
this.defineCache[moduleName] = args;
|
|
@@ -193,19 +266,22 @@
|
|
|
193
266
|
this.initApp();
|
|
194
267
|
}
|
|
195
268
|
}
|
|
269
|
+
|
|
196
270
|
// Called by the customInit hook via lwr.initializeApp()
|
|
197
|
-
|
|
271
|
+
postCustomInit() {
|
|
198
272
|
this.bootReady = true;
|
|
199
273
|
if (this.canInit()) {
|
|
200
274
|
this.initApp();
|
|
201
275
|
}
|
|
202
276
|
}
|
|
277
|
+
|
|
203
278
|
// Create the loader and initialize the application
|
|
204
|
-
|
|
279
|
+
initApp() {
|
|
205
280
|
try {
|
|
206
281
|
const loaderConfig = {
|
|
207
282
|
baseUrl: this.config.baseUrl,
|
|
208
283
|
profiler: { logOperationStart, logOperationEnd },
|
|
284
|
+
|
|
209
285
|
// TODO: can be removed following https://github.com/salesforce-experience-platform-emu/lwr/issues/1087
|
|
210
286
|
appMetadata: {
|
|
211
287
|
appId: this.config.appId,
|
|
@@ -214,18 +290,24 @@
|
|
|
214
290
|
rootComponents: this.config.rootComponents,
|
|
215
291
|
},
|
|
216
292
|
};
|
|
217
|
-
const loader = createLoader(
|
|
293
|
+
const loader = createLoader(
|
|
294
|
+
this.loaderModule,
|
|
295
|
+
this.defineCache[this.loaderModule],
|
|
296
|
+
loaderConfig,
|
|
297
|
+
this.config.preloadModules,
|
|
298
|
+
);
|
|
218
299
|
this.mountApp(loader);
|
|
219
|
-
}
|
|
220
|
-
catch (e) {
|
|
300
|
+
} catch (e) {
|
|
221
301
|
this.enterErrorState(e);
|
|
222
302
|
}
|
|
223
303
|
}
|
|
224
|
-
|
|
304
|
+
|
|
305
|
+
waitForDOMContentLoaded() {
|
|
225
306
|
// eslint-disable-next-line lwr/no-unguarded-apis
|
|
226
307
|
if (typeof document === undefined) {
|
|
227
308
|
return Promise.resolve();
|
|
228
309
|
}
|
|
310
|
+
|
|
229
311
|
// Resolve if document is already "ready" https://developer.mozilla.org/en-US/docs/Web/API/Document/readyState
|
|
230
312
|
// eslint-disable-next-line lwr/no-unguarded-apis
|
|
231
313
|
if (document.readyState === 'interactive' || document.readyState === 'complete') {
|
|
@@ -238,17 +320,21 @@
|
|
|
238
320
|
});
|
|
239
321
|
});
|
|
240
322
|
}
|
|
323
|
+
|
|
241
324
|
// Create a module out of the profiler
|
|
242
325
|
// Note: The profiler is also available as a module through lwc module resolution (see package.json)
|
|
243
|
-
|
|
326
|
+
createProfilerModule(globalLWR) {
|
|
244
327
|
const exporter = (exports) => {
|
|
245
328
|
Object.assign(exports, { logOperationStart, logOperationEnd });
|
|
246
329
|
};
|
|
247
|
-
globalLWR.define('lwr/profiler/v/0_10_0-
|
|
330
|
+
globalLWR.define('lwr/profiler/v/0_10_0-alpha_20', ['exports'], exporter, {});
|
|
248
331
|
}
|
|
332
|
+
|
|
249
333
|
// Set up the application globals, import map, root custom element...
|
|
250
|
-
|
|
251
|
-
const { bootstrapModule, rootComponent, importMappings, rootComponents, ssrProps, endpoints } =
|
|
334
|
+
mountApp(loader) {
|
|
335
|
+
const { bootstrapModule, rootComponent, importMappings, rootComponents, ssrProps, endpoints } =
|
|
336
|
+
this.config;
|
|
337
|
+
|
|
252
338
|
// Set global LWR.define to loader.define
|
|
253
339
|
this.global.LWR = Object.freeze({
|
|
254
340
|
define: loader.define.bind(loader),
|
|
@@ -258,42 +344,50 @@
|
|
|
258
344
|
importMappings,
|
|
259
345
|
endpoints,
|
|
260
346
|
});
|
|
347
|
+
|
|
261
348
|
// Redefine all modules in the temporary cache
|
|
262
349
|
this.orderedDefs.forEach((specifier) => {
|
|
263
350
|
if (specifier !== this.loaderModule) {
|
|
264
351
|
loader.define(...this.defineCache[specifier]);
|
|
265
352
|
}
|
|
266
353
|
});
|
|
354
|
+
|
|
267
355
|
// by default, app initialization is gated on waiting for document to be parsed (via DOMContentLoaded)
|
|
268
356
|
const { disableInitDefer } = this.config;
|
|
357
|
+
|
|
269
358
|
// Load the import mappings and application bootstrap module
|
|
270
359
|
loader
|
|
271
360
|
.registerImportMappings(importMappings)
|
|
272
361
|
.then(() => {
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
362
|
+
if (!disableInitDefer) {
|
|
363
|
+
return this.waitForDOMContentLoaded();
|
|
364
|
+
}
|
|
365
|
+
})
|
|
277
366
|
.then(() => loader.load(bootstrapModule))
|
|
278
367
|
.catch((reason) => {
|
|
279
|
-
|
|
280
|
-
|
|
368
|
+
this.enterErrorState(
|
|
369
|
+
new Error(
|
|
370
|
+
`Application ${rootComponent || bootstrapModule} could not be loaded: ${reason}`,
|
|
371
|
+
),
|
|
372
|
+
);
|
|
373
|
+
});
|
|
281
374
|
}
|
|
375
|
+
|
|
282
376
|
// Trigger bootstrap error state, and call error handler if registered
|
|
283
|
-
|
|
377
|
+
enterErrorState(error) {
|
|
284
378
|
logOperationStart({ id: BOOTSTRAP_ERROR });
|
|
285
379
|
if (this.errorHandler) {
|
|
286
380
|
this.errorHandler(error);
|
|
287
|
-
}
|
|
288
|
-
else {
|
|
381
|
+
} else {
|
|
289
382
|
if (hasConsole) {
|
|
290
383
|
// eslint-disable-next-line lwr/no-unguarded-apis, no-undef
|
|
291
384
|
console.error(`An error occurred during LWR bootstrap. ${error.message}`, error.stack);
|
|
292
385
|
}
|
|
293
386
|
}
|
|
294
387
|
}
|
|
388
|
+
|
|
295
389
|
// eslint-disable-next-line no-undef, lwr/no-unguarded-apis
|
|
296
|
-
|
|
390
|
+
startWatchdogTimer() {
|
|
297
391
|
// eslint-disable-next-line lwr/no-unguarded-apis, no-undef
|
|
298
392
|
return setTimeout(() => {
|
|
299
393
|
this.enterErrorState(new Error('Failed to load required modules - timed out'));
|
|
@@ -302,16 +396,17 @@
|
|
|
302
396
|
}
|
|
303
397
|
|
|
304
398
|
// The loader module is ALWAYS required
|
|
305
|
-
const GLOBAL = globalThis;
|
|
399
|
+
const GLOBAL = globalThis ;
|
|
306
400
|
GLOBAL.LWR.requiredModules = GLOBAL.LWR.requiredModules || [];
|
|
307
|
-
if (GLOBAL.LWR.requiredModules.indexOf('lwr/loaderLegacy/v/0_10_0-
|
|
308
|
-
GLOBAL.LWR.requiredModules.push('lwr/loaderLegacy/v/0_10_0-
|
|
401
|
+
if (GLOBAL.LWR.requiredModules.indexOf('lwr/loaderLegacy/v/0_10_0-alpha_20') < 0) {
|
|
402
|
+
GLOBAL.LWR.requiredModules.push('lwr/loaderLegacy/v/0_10_0-alpha_20');
|
|
309
403
|
}
|
|
310
404
|
new LoaderShim(GLOBAL);
|
|
311
405
|
|
|
312
|
-
}()
|
|
406
|
+
})();
|
|
407
|
+
//# sourceMappingURL=lwr-loader-shim-legacy.js.map
|
|
313
408
|
|
|
314
|
-
LWR.define('lwr/loaderLegacy/v/0_10_0-
|
|
409
|
+
LWR.define('lwr/loaderLegacy/v/0_10_0-alpha_20', ['exports'], (function (exports) { 'use strict';
|
|
315
410
|
|
|
316
411
|
const templateRegex = /\{([0-9]+)\}/g;
|
|
317
412
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -326,17 +421,26 @@ LWR.define('lwr/loaderLegacy/v/0_10_0-alpha_2', ['exports'], function (exports)
|
|
|
326
421
|
const message = Array.isArray(args) ? templateString(errorInfo.message, args) : errorInfo.message;
|
|
327
422
|
return `LWR${errorInfo.code}: ${message}`;
|
|
328
423
|
}
|
|
424
|
+
|
|
329
425
|
class LoaderError extends Error {
|
|
330
426
|
constructor(errorInfo, errorArgs) {
|
|
331
427
|
super();
|
|
332
428
|
this.message = generateErrorMessage(errorInfo, errorArgs);
|
|
333
429
|
}
|
|
334
430
|
}
|
|
431
|
+
|
|
335
432
|
function invariant(condition, errorInfo) {
|
|
336
433
|
if (!condition) {
|
|
337
434
|
throw new LoaderError(errorInfo);
|
|
338
435
|
}
|
|
339
436
|
}
|
|
437
|
+
|
|
438
|
+
|
|
439
|
+
|
|
440
|
+
|
|
441
|
+
|
|
442
|
+
|
|
443
|
+
|
|
340
444
|
const MISSING_NAME = Object.freeze({
|
|
341
445
|
code: 3000,
|
|
342
446
|
message: 'A module name is required.',
|
|
@@ -417,6 +521,7 @@ LWR.define('lwr/loaderLegacy/v/0_10_0-alpha_2', ['exports'], function (exports)
|
|
|
417
521
|
level: 0,
|
|
418
522
|
message: 'Error loading "{0}" from hook',
|
|
419
523
|
});
|
|
524
|
+
|
|
420
525
|
/* importMap errors */
|
|
421
526
|
const BAD_IMPORT_MAP = Object.freeze({
|
|
422
527
|
code: 3011,
|
|
@@ -426,7 +531,9 @@ LWR.define('lwr/loaderLegacy/v/0_10_0-alpha_2', ['exports'], function (exports)
|
|
|
426
531
|
|
|
427
532
|
/* eslint-disable lwr/no-unguarded-apis */
|
|
428
533
|
const hasDocument = typeof document !== 'undefined';
|
|
534
|
+
|
|
429
535
|
const hasSetTimeout = typeof setTimeout === 'function';
|
|
536
|
+
|
|
430
537
|
const hasConsole = typeof console !== 'undefined';
|
|
431
538
|
/* eslint-enable lwr/no-unguarded-apis */
|
|
432
539
|
|
|
@@ -434,7 +541,7 @@ LWR.define('lwr/loaderLegacy/v/0_10_0-alpha_2', ['exports'], function (exports)
|
|
|
434
541
|
let baseUrl = undefined;
|
|
435
542
|
if (hasDocument) {
|
|
436
543
|
// eslint-disable-next-line lwr/no-unguarded-apis, no-undef
|
|
437
|
-
const baseEl = document.querySelector('base[href]');
|
|
544
|
+
const baseEl = document.querySelector('base[href]') ;
|
|
438
545
|
baseUrl = baseEl && baseEl.href;
|
|
439
546
|
}
|
|
440
547
|
// eslint-disable-next-line lwr/no-unguarded-apis
|
|
@@ -446,8 +553,10 @@ LWR.define('lwr/loaderLegacy/v/0_10_0-alpha_2', ['exports'], function (exports)
|
|
|
446
553
|
baseUrl = baseUrl.slice(0, lastSepIndex + 1);
|
|
447
554
|
}
|
|
448
555
|
}
|
|
556
|
+
|
|
449
557
|
return baseUrl;
|
|
450
558
|
}
|
|
559
|
+
|
|
451
560
|
/**
|
|
452
561
|
* Check if a string is a URL based on Common Internet Scheme Syntax
|
|
453
562
|
* https://www.ietf.org/rfc/rfc1738.txt
|
|
@@ -474,24 +583,26 @@ LWR.define('lwr/loaderLegacy/v/0_10_0-alpha_2', ['exports'], function (exports)
|
|
|
474
583
|
function isUrl(url) {
|
|
475
584
|
return url.indexOf('://') !== -1;
|
|
476
585
|
}
|
|
586
|
+
|
|
477
587
|
// Borrowed and adapted from https://github.com/systemjs/systemjs/blob/master/src/common.js
|
|
478
588
|
// Resolves the first path segment relative to the second/parent URL
|
|
479
589
|
// eg: resolveIfNotPlainOrUrl('../test', 'http://www.site.com/one/two') => 'http://www.site.com/test'
|
|
480
590
|
// eg: resolveIfNotPlainOrUrl('./x/y/z', 'https://my.com/segment')).toBe('https://my.com/x/y/z')
|
|
481
591
|
function resolveIfNotPlainOrUrl(relUrl, parentUrl) {
|
|
482
592
|
const backslashRegEx = /\\/g;
|
|
483
|
-
if (relUrl.indexOf('\\') !== -1)
|
|
484
|
-
relUrl = relUrl.replace(backslashRegEx, '/');
|
|
593
|
+
if (relUrl.indexOf('\\') !== -1) relUrl = relUrl.replace(backslashRegEx, '/');
|
|
485
594
|
// protocol-relative
|
|
486
595
|
if (relUrl[0] === '/' && relUrl[1] === '/') {
|
|
487
596
|
return parentUrl.slice(0, parentUrl.indexOf(':') + 1) + relUrl;
|
|
488
597
|
}
|
|
489
598
|
// relative-url
|
|
490
|
-
else if (
|
|
491
|
-
(relUrl[
|
|
492
|
-
(relUrl[1] === '
|
|
493
|
-
|
|
494
|
-
|
|
599
|
+
else if (
|
|
600
|
+
(relUrl[0] === '.' &&
|
|
601
|
+
(relUrl[1] === '/' ||
|
|
602
|
+
(relUrl[1] === '.' && (relUrl[2] === '/' || (relUrl.length === 2 && (relUrl += '/')))) ||
|
|
603
|
+
(relUrl.length === 1 && (relUrl += '/')))) ||
|
|
604
|
+
relUrl[0] === '/'
|
|
605
|
+
) {
|
|
495
606
|
const parentProtocol = parentUrl.slice(0, parentUrl.indexOf(':') + 1);
|
|
496
607
|
let pathname;
|
|
497
608
|
if (parentUrl[parentProtocol.length + 1] === '/') {
|
|
@@ -499,21 +610,23 @@ LWR.define('lwr/loaderLegacy/v/0_10_0-alpha_2', ['exports'], function (exports)
|
|
|
499
610
|
if (parentProtocol !== 'file:') {
|
|
500
611
|
pathname = parentUrl.slice(parentProtocol.length + 2);
|
|
501
612
|
pathname = pathname.slice(pathname.indexOf('/') + 1);
|
|
502
|
-
}
|
|
503
|
-
else {
|
|
613
|
+
} else {
|
|
504
614
|
pathname = parentUrl.slice(8);
|
|
505
615
|
}
|
|
506
|
-
}
|
|
507
|
-
else {
|
|
616
|
+
} else {
|
|
508
617
|
// resolving to :/ so pathname is the /... part
|
|
509
|
-
pathname = parentUrl.slice(
|
|
618
|
+
pathname = parentUrl.slice(
|
|
619
|
+
parentProtocol.length + (parentUrl[parentProtocol.length] === '/' ? 1 : 0),
|
|
620
|
+
);
|
|
510
621
|
}
|
|
511
|
-
|
|
512
|
-
|
|
622
|
+
|
|
623
|
+
if (relUrl[0] === '/') return parentUrl.slice(0, parentUrl.length - pathname.length - 1) + relUrl;
|
|
624
|
+
|
|
513
625
|
// join together and split for removal of .. and . segments
|
|
514
626
|
// looping the string instead of anything fancy for perf reasons
|
|
515
627
|
// '../../../../../z' resolved to 'x/y' is just 'z'
|
|
516
628
|
const segmented = pathname.slice(0, pathname.lastIndexOf('/') + 1) + relUrl;
|
|
629
|
+
|
|
517
630
|
const output = [];
|
|
518
631
|
let segmentIndex = -1;
|
|
519
632
|
for (let i = 0; i < segmented.length; i++) {
|
|
@@ -524,6 +637,7 @@ LWR.define('lwr/loaderLegacy/v/0_10_0-alpha_2', ['exports'], function (exports)
|
|
|
524
637
|
segmentIndex = -1;
|
|
525
638
|
}
|
|
526
639
|
}
|
|
640
|
+
|
|
527
641
|
// new segment - check if it is relative
|
|
528
642
|
else if (segmented[i] === '.') {
|
|
529
643
|
// ../ segment
|
|
@@ -534,8 +648,7 @@ LWR.define('lwr/loaderLegacy/v/0_10_0-alpha_2', ['exports'], function (exports)
|
|
|
534
648
|
// ./ segment
|
|
535
649
|
else if (segmented[i + 1] === '/' || i + 1 === segmented.length) {
|
|
536
650
|
i += 1;
|
|
537
|
-
}
|
|
538
|
-
else {
|
|
651
|
+
} else {
|
|
539
652
|
// the start of a new segment as below
|
|
540
653
|
segmentIndex = i;
|
|
541
654
|
}
|
|
@@ -546,13 +659,14 @@ LWR.define('lwr/loaderLegacy/v/0_10_0-alpha_2', ['exports'], function (exports)
|
|
|
546
659
|
}
|
|
547
660
|
}
|
|
548
661
|
// finish reading out the last segment
|
|
549
|
-
if (segmentIndex !== -1)
|
|
550
|
-
output.push(segmented.slice(segmentIndex));
|
|
662
|
+
if (segmentIndex !== -1) output.push(segmented.slice(segmentIndex));
|
|
551
663
|
return parentUrl.slice(0, parentUrl.length - pathname.length) + output.join('');
|
|
552
664
|
}
|
|
553
665
|
}
|
|
666
|
+
|
|
554
667
|
function resolveUrl(relUrl, parentUrl) {
|
|
555
|
-
const resolvedUrl =
|
|
668
|
+
const resolvedUrl =
|
|
669
|
+
resolveIfNotPlainOrUrl(relUrl, parentUrl) ||
|
|
556
670
|
(isUrl(relUrl) ? relUrl : resolveIfNotPlainOrUrl('./' + relUrl, parentUrl));
|
|
557
671
|
return resolvedUrl;
|
|
558
672
|
}
|
|
@@ -565,6 +679,7 @@ LWR.define('lwr/loaderLegacy/v/0_10_0-alpha_2', ['exports'], function (exports)
|
|
|
565
679
|
script.src = url;
|
|
566
680
|
return script;
|
|
567
681
|
}
|
|
682
|
+
|
|
568
683
|
let lastWindowError$1, lastWindowErrorUrl;
|
|
569
684
|
function loadModuleDef(url) {
|
|
570
685
|
return new Promise(function (resolve, reject) {
|
|
@@ -578,8 +693,7 @@ LWR.define('lwr/loaderLegacy/v/0_10_0-alpha_2', ['exports'], function (exports)
|
|
|
578
693
|
document.head.removeChild(script);
|
|
579
694
|
if (lastWindowErrorUrl === url) {
|
|
580
695
|
reject(lastWindowError$1);
|
|
581
|
-
}
|
|
582
|
-
else {
|
|
696
|
+
} else {
|
|
583
697
|
resolve();
|
|
584
698
|
}
|
|
585
699
|
});
|
|
@@ -588,6 +702,7 @@ LWR.define('lwr/loaderLegacy/v/0_10_0-alpha_2', ['exports'], function (exports)
|
|
|
588
702
|
}
|
|
589
703
|
});
|
|
590
704
|
}
|
|
705
|
+
|
|
591
706
|
if (hasDocument) {
|
|
592
707
|
// When a script is executed, runtime errors are on the global/window scope which are NOT caught by the script's onerror handler.
|
|
593
708
|
// eslint-disable-next-line lwr/no-unguarded-apis, no-undef
|
|
@@ -597,32 +712,76 @@ LWR.define('lwr/loaderLegacy/v/0_10_0-alpha_2', ['exports'], function (exports)
|
|
|
597
712
|
});
|
|
598
713
|
}
|
|
599
714
|
|
|
600
|
-
const MODULE_LOAD_TIMEOUT_TIMER =
|
|
715
|
+
const MODULE_LOAD_TIMEOUT_TIMER = 60 * 1000; // 1m
|
|
716
|
+
|
|
717
|
+
/*!
|
|
718
|
+
* Copyright (C) 2023 salesforce.com, inc.
|
|
719
|
+
*/
|
|
720
|
+
// @ts-ignore: Prevent cannot find name 'trustedTypes' error.
|
|
721
|
+
const SUPPORTS_TRUSTED_TYPES = typeof trustedTypes !== 'undefined';
|
|
722
|
+
function createTrustedTypesPolicy(name, options) {
|
|
723
|
+
// @ts-ignore: Prevent cannot find name 'trustedTypes' error.
|
|
724
|
+
return trustedTypes.createPolicy(name, options);
|
|
725
|
+
}
|
|
726
|
+
function createFallbackPolicy(_name, options) {
|
|
727
|
+
return options;
|
|
728
|
+
}
|
|
729
|
+
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/trusted-types
|
|
730
|
+
const createPolicy = SUPPORTS_TRUSTED_TYPES ? createTrustedTypesPolicy : createFallbackPolicy;
|
|
731
|
+
const policyOptions = {
|
|
732
|
+
createHTML(value) {
|
|
733
|
+
return value;
|
|
734
|
+
},
|
|
735
|
+
createScript(value) {
|
|
736
|
+
return value;
|
|
737
|
+
},
|
|
738
|
+
createScriptURL(value) {
|
|
739
|
+
return value;
|
|
740
|
+
}
|
|
741
|
+
};
|
|
742
|
+
const trusted = createPolicy('trusted', policyOptions);
|
|
743
|
+
/*! version: 0.19.4 */
|
|
601
744
|
|
|
602
745
|
/* global console,process */
|
|
746
|
+
|
|
747
|
+
|
|
603
748
|
let lastWindowError;
|
|
604
749
|
if (hasDocument) {
|
|
605
750
|
globalThis.addEventListener('error', (evt) => {
|
|
606
751
|
lastWindowError = evt.error;
|
|
607
752
|
});
|
|
608
753
|
}
|
|
754
|
+
|
|
609
755
|
if (process.env.NODE_ENV !== 'production') {
|
|
610
756
|
if (!hasSetTimeout && hasConsole) {
|
|
611
757
|
// eslint-disable-next-line lwr/no-unguarded-apis
|
|
612
758
|
console.warn('setTimeout API is not available, watchdog timer on load hook will not be set');
|
|
613
759
|
}
|
|
614
760
|
}
|
|
761
|
+
|
|
615
762
|
function isCustomResponse(response) {
|
|
616
|
-
return (
|
|
617
|
-
|
|
763
|
+
return (
|
|
764
|
+
Object.prototype.hasOwnProperty.call(response, 'data') &&
|
|
765
|
+
!Object.prototype.hasOwnProperty.call(response, 'blob')
|
|
766
|
+
);
|
|
618
767
|
}
|
|
619
|
-
function isFetchResponse(
|
|
768
|
+
function isFetchResponse(
|
|
769
|
+
response,
|
|
770
|
+
) {
|
|
620
771
|
// if it quacks like a duck...
|
|
621
|
-
return typeof response.blob === 'function';
|
|
772
|
+
return typeof (response ).blob === 'function';
|
|
622
773
|
}
|
|
623
|
-
|
|
624
|
-
|
|
774
|
+
|
|
775
|
+
function isResponseAPromise(
|
|
776
|
+
response
|
|
777
|
+
|
|
778
|
+
|
|
779
|
+
|
|
780
|
+
,
|
|
781
|
+
) {
|
|
782
|
+
return !!(response && (response ).then);
|
|
625
783
|
}
|
|
784
|
+
|
|
626
785
|
async function evaluateLoadHookResponse(response, id) {
|
|
627
786
|
return Promise.resolve().then(async () => {
|
|
628
787
|
if (!response.status) {
|
|
@@ -631,36 +790,41 @@ LWR.define('lwr/loaderLegacy/v/0_10_0-alpha_2', ['exports'], function (exports)
|
|
|
631
790
|
if (response.status !== 200) {
|
|
632
791
|
throw new LoaderError(HTTP_FAIL_LOAD, [id, `${response.status}`]);
|
|
633
792
|
}
|
|
793
|
+
|
|
634
794
|
const isResponse = isFetchResponse(response);
|
|
635
795
|
let code;
|
|
636
796
|
if (isCustomResponse(response)) {
|
|
637
797
|
code = response.data;
|
|
638
|
-
}
|
|
639
|
-
else if (isResponse) {
|
|
798
|
+
} else if (isResponse) {
|
|
640
799
|
// handle fetch response
|
|
641
|
-
code = await response.text();
|
|
642
|
-
}
|
|
643
|
-
else {
|
|
800
|
+
code = await (response ).text();
|
|
801
|
+
} else {
|
|
644
802
|
throw new LoaderError(INVALID_LOADER_SERVICE_RESPONSE);
|
|
645
803
|
}
|
|
804
|
+
|
|
646
805
|
if (!code) {
|
|
647
806
|
throw new LoaderError(FAIL_LOAD, [id]);
|
|
648
807
|
}
|
|
808
|
+
|
|
649
809
|
code = `${code}\n//# sourceURL=${id}`; // append sourceURL for debugging
|
|
650
810
|
try {
|
|
651
811
|
// TODO eval source maps for debugging
|
|
652
|
-
eval(code);
|
|
653
|
-
}
|
|
654
|
-
catch (e) {
|
|
812
|
+
eval(trusted.createScript(code));
|
|
813
|
+
} catch (e) {
|
|
655
814
|
throw new LoaderError(FAIL_LOAD, [id]);
|
|
656
815
|
}
|
|
816
|
+
|
|
657
817
|
if (lastWindowError) {
|
|
658
818
|
throw new LoaderError(FAIL_LOAD, [id]);
|
|
659
819
|
}
|
|
660
820
|
return true;
|
|
661
821
|
});
|
|
662
822
|
}
|
|
663
|
-
|
|
823
|
+
|
|
824
|
+
async function evaluateLoadHook(
|
|
825
|
+
id,
|
|
826
|
+
hookPromise,
|
|
827
|
+
) {
|
|
664
828
|
if (!hasSetTimeout) {
|
|
665
829
|
return hookPromise;
|
|
666
830
|
}
|
|
@@ -672,26 +836,28 @@ LWR.define('lwr/loaderLegacy/v/0_10_0-alpha_2', ['exports'], function (exports)
|
|
|
672
836
|
}, MODULE_LOAD_TIMEOUT_TIMER);
|
|
673
837
|
hookPromise
|
|
674
838
|
.then((response) => {
|
|
675
|
-
|
|
676
|
-
|
|
839
|
+
resolve(response);
|
|
840
|
+
})
|
|
677
841
|
.catch(() => {
|
|
678
|
-
|
|
679
|
-
|
|
842
|
+
reject(new LoaderError(FAIL_HOOK_LOAD, [id]));
|
|
843
|
+
})
|
|
680
844
|
.finally(() => {
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
845
|
+
// eslint-disable-next-line lwr/no-unguarded-apis, no-undef
|
|
846
|
+
clearTimeout(timer);
|
|
847
|
+
});
|
|
684
848
|
});
|
|
685
849
|
}
|
|
686
850
|
|
|
687
851
|
function reportError(error) {
|
|
688
852
|
// TODO eventually this should be configurable instrumentation to send this somewhere
|
|
689
853
|
// eslint-disable-next-line lwr/no-unguarded-apis, no-undef
|
|
690
|
-
if (hasConsole)
|
|
691
|
-
console.error(error);
|
|
854
|
+
if (hasConsole) console.error(error);
|
|
692
855
|
}
|
|
693
856
|
|
|
694
|
-
function evaluateHandleStaleModuleHooks(
|
|
857
|
+
function evaluateHandleStaleModuleHooks(
|
|
858
|
+
handleStaleModuleHooks,
|
|
859
|
+
hookArgs,
|
|
860
|
+
) {
|
|
695
861
|
const { name, oldHash, newHash } = hookArgs;
|
|
696
862
|
// keep evaluating hooks if return value is null
|
|
697
863
|
for (let i = 0; i < handleStaleModuleHooks.length; i++) {
|
|
@@ -701,8 +867,7 @@ LWR.define('lwr/loaderLegacy/v/0_10_0-alpha_2', ['exports'], function (exports)
|
|
|
701
867
|
if (hookResult !== null) {
|
|
702
868
|
break;
|
|
703
869
|
}
|
|
704
|
-
}
|
|
705
|
-
catch (e) {
|
|
870
|
+
} catch (e) {
|
|
706
871
|
reportError(new LoaderError(STALE_HOOK_ERROR));
|
|
707
872
|
}
|
|
708
873
|
}
|
|
@@ -717,32 +882,82 @@ LWR.define('lwr/loaderLegacy/v/0_10_0-alpha_2', ['exports'], function (exports)
|
|
|
717
882
|
const MODULE_ERROR = `${LOADER_PREFIX}module.error`;
|
|
718
883
|
|
|
719
884
|
/* global console,process */
|
|
885
|
+
|
|
886
|
+
|
|
887
|
+
|
|
888
|
+
|
|
889
|
+
|
|
890
|
+
|
|
891
|
+
|
|
892
|
+
|
|
893
|
+
|
|
894
|
+
|
|
895
|
+
|
|
896
|
+
|
|
897
|
+
|
|
898
|
+
|
|
899
|
+
|
|
900
|
+
|
|
901
|
+
|
|
902
|
+
|
|
903
|
+
|
|
904
|
+
|
|
905
|
+
|
|
906
|
+
|
|
907
|
+
|
|
908
|
+
|
|
909
|
+
|
|
910
|
+
|
|
911
|
+
|
|
912
|
+
|
|
913
|
+
|
|
914
|
+
|
|
915
|
+
|
|
916
|
+
|
|
917
|
+
|
|
918
|
+
|
|
919
|
+
|
|
920
|
+
|
|
921
|
+
|
|
922
|
+
|
|
923
|
+
|
|
924
|
+
|
|
925
|
+
|
|
926
|
+
|
|
927
|
+
|
|
928
|
+
|
|
929
|
+
|
|
930
|
+
|
|
931
|
+
|
|
932
|
+
|
|
933
|
+
|
|
934
|
+
|
|
935
|
+
|
|
936
|
+
|
|
720
937
|
class ModuleRegistry {
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
// The evaluated module registry where the module identifier (name or URL?) is the key
|
|
725
|
-
this.moduleRegistry = new Map();
|
|
726
|
-
// Aliases of modules in the registry
|
|
727
|
-
this.aliases = new Map();
|
|
938
|
+
|
|
939
|
+
|
|
940
|
+
constructor(config) {ModuleRegistry.prototype.__init.call(this);ModuleRegistry.prototype.__init2.call(this);ModuleRegistry.prototype.__init3.call(this);
|
|
728
941
|
this.baseUrl = config.baseUrl || '';
|
|
729
942
|
this.profiler = config.profiler;
|
|
730
943
|
}
|
|
944
|
+
|
|
731
945
|
async load(id, importer) {
|
|
732
946
|
const resolvedId = await this.resolve(id, importer);
|
|
733
947
|
const moduleRecord = this.getModuleRecord(resolvedId, id);
|
|
734
948
|
if (moduleRecord.evaluated) {
|
|
735
949
|
return moduleRecord.module;
|
|
736
|
-
}
|
|
737
|
-
else {
|
|
950
|
+
} else {
|
|
738
951
|
if (!moduleRecord.evaluationPromise) {
|
|
739
952
|
moduleRecord.evaluationPromise = this.topLevelEvaluation(moduleRecord);
|
|
740
953
|
}
|
|
741
954
|
return moduleRecord.evaluationPromise;
|
|
742
955
|
}
|
|
743
956
|
}
|
|
957
|
+
|
|
744
958
|
async resolve(id, importer) {
|
|
745
959
|
const parentUrl = this.baseUrl; // only support baseUrl for now
|
|
960
|
+
|
|
746
961
|
let resolved;
|
|
747
962
|
let aliasedId = id;
|
|
748
963
|
const resolveHooks = this.resolveHook;
|
|
@@ -755,6 +970,7 @@ LWR.define('lwr/loaderLegacy/v/0_10_0-alpha_2', ['exports'], function (exports)
|
|
|
755
970
|
// eslint-disable-next-line no-await-in-loop
|
|
756
971
|
result = isResponseAPromise(response) ? await response : response;
|
|
757
972
|
}
|
|
973
|
+
|
|
758
974
|
// if result is not null, attempt resolution
|
|
759
975
|
if (result !== null) {
|
|
760
976
|
if (typeof result === 'string') {
|
|
@@ -765,6 +981,7 @@ LWR.define('lwr/loaderLegacy/v/0_10_0-alpha_2', ['exports'], function (exports)
|
|
|
765
981
|
aliasedId = result; // the next hook will receive the new id
|
|
766
982
|
continue;
|
|
767
983
|
}
|
|
984
|
+
|
|
768
985
|
resolved =
|
|
769
986
|
result && result.url && (resolveIfNotPlainOrUrl(result.url, parentUrl) || result.url);
|
|
770
987
|
if (!resolved) {
|
|
@@ -774,34 +991,38 @@ LWR.define('lwr/loaderLegacy/v/0_10_0-alpha_2', ['exports'], function (exports)
|
|
|
774
991
|
break;
|
|
775
992
|
}
|
|
776
993
|
}
|
|
994
|
+
|
|
777
995
|
if (aliasedId !== id) {
|
|
778
996
|
// resolved module id is the aliased module if it has already been defined
|
|
779
997
|
if (!resolved && this.namedDefineRegistry.has(aliasedId)) {
|
|
780
998
|
return aliasedId;
|
|
781
|
-
}
|
|
782
|
-
else {
|
|
999
|
+
} else {
|
|
783
1000
|
id = aliasedId;
|
|
784
1001
|
}
|
|
785
1002
|
}
|
|
786
1003
|
}
|
|
1004
|
+
|
|
787
1005
|
if (!resolved) {
|
|
788
1006
|
const resolvedOrPlain = resolveIfNotPlainOrUrl(id, parentUrl) || id;
|
|
1007
|
+
|
|
789
1008
|
// if module registry already has named module the resolved id is the plain id
|
|
790
1009
|
if (this.moduleRegistry.has(resolvedOrPlain)) {
|
|
791
1010
|
return resolvedOrPlain;
|
|
792
1011
|
}
|
|
1012
|
+
|
|
793
1013
|
if (this.resolver) {
|
|
794
1014
|
resolved = this.resolver.resolve(resolvedOrPlain, parentUrl);
|
|
795
1015
|
// return the plain id if it is already defined && the resolvedUrl is NOT already in the module registry
|
|
796
|
-
if (
|
|
797
|
-
this.namedDefineRegistry.
|
|
1016
|
+
if (
|
|
1017
|
+
this.namedDefineRegistry.has(resolvedOrPlain) &&
|
|
1018
|
+
this.namedDefineRegistry.get(resolvedOrPlain).defined
|
|
1019
|
+
) {
|
|
798
1020
|
const record = this.moduleRegistry.get(resolved);
|
|
799
1021
|
if (!record || !this.aliases.has(resolvedOrPlain)) {
|
|
800
1022
|
return resolvedOrPlain;
|
|
801
1023
|
}
|
|
802
1024
|
}
|
|
803
|
-
}
|
|
804
|
-
else {
|
|
1025
|
+
} else {
|
|
805
1026
|
resolved = resolvedOrPlain;
|
|
806
1027
|
}
|
|
807
1028
|
}
|
|
@@ -809,6 +1030,7 @@ LWR.define('lwr/loaderLegacy/v/0_10_0-alpha_2', ['exports'], function (exports)
|
|
|
809
1030
|
if (this.namedDefineRegistry.has(id)) {
|
|
810
1031
|
return id;
|
|
811
1032
|
}
|
|
1033
|
+
|
|
812
1034
|
throw new LoaderError(UNRESOLVED, [id]);
|
|
813
1035
|
}
|
|
814
1036
|
if (importer && isUrl(resolved)) {
|
|
@@ -816,10 +1038,17 @@ LWR.define('lwr/loaderLegacy/v/0_10_0-alpha_2', ['exports'], function (exports)
|
|
|
816
1038
|
}
|
|
817
1039
|
return resolved;
|
|
818
1040
|
}
|
|
1041
|
+
|
|
819
1042
|
has(id) {
|
|
820
1043
|
return this.moduleRegistry.has(id);
|
|
821
1044
|
}
|
|
822
|
-
|
|
1045
|
+
|
|
1046
|
+
define(
|
|
1047
|
+
name,
|
|
1048
|
+
dependencies,
|
|
1049
|
+
exporter,
|
|
1050
|
+
signatures,
|
|
1051
|
+
) {
|
|
823
1052
|
const mod = this.namedDefineRegistry.get(name);
|
|
824
1053
|
// Don't allow redefining a module.
|
|
825
1054
|
if (mod && mod.defined) {
|
|
@@ -830,6 +1059,7 @@ LWR.define('lwr/loaderLegacy/v/0_10_0-alpha_2', ['exports'], function (exports)
|
|
|
830
1059
|
this.lastDefine = mod;
|
|
831
1060
|
return;
|
|
832
1061
|
}
|
|
1062
|
+
|
|
833
1063
|
const moduleDef = {
|
|
834
1064
|
name,
|
|
835
1065
|
dependencies,
|
|
@@ -841,9 +1071,11 @@ LWR.define('lwr/loaderLegacy/v/0_10_0-alpha_2', ['exports'], function (exports)
|
|
|
841
1071
|
// if module is "external", resolve the external promise to notify any dependees
|
|
842
1072
|
mod.external.resolveExternal(moduleDef);
|
|
843
1073
|
}
|
|
1074
|
+
|
|
844
1075
|
this.profiler.logOperationStart({ id: MODULE_DEFINE, specifier: name });
|
|
845
1076
|
this.namedDefineRegistry.set(name, moduleDef);
|
|
846
1077
|
this.lastDefine = moduleDef;
|
|
1078
|
+
|
|
847
1079
|
// Check signatures of dependencies against those in the namedDefineRegistry
|
|
848
1080
|
if (signatures.hashes) {
|
|
849
1081
|
Object.entries(signatures.hashes).forEach(([dep, sig]) => {
|
|
@@ -851,6 +1083,7 @@ LWR.define('lwr/loaderLegacy/v/0_10_0-alpha_2', ['exports'], function (exports)
|
|
|
851
1083
|
});
|
|
852
1084
|
}
|
|
853
1085
|
}
|
|
1086
|
+
|
|
854
1087
|
/**
|
|
855
1088
|
* Marks modules as "externally" loaded/provided, so that the loader does not attempt to fetch them.
|
|
856
1089
|
*
|
|
@@ -863,6 +1096,7 @@ LWR.define('lwr/loaderLegacy/v/0_10_0-alpha_2', ['exports'], function (exports)
|
|
|
863
1096
|
let timer;
|
|
864
1097
|
const moduleDefPromise = new Promise((resolve, reject) => {
|
|
865
1098
|
resolveExternal = resolve;
|
|
1099
|
+
|
|
866
1100
|
// watch the external for timeout
|
|
867
1101
|
// eslint-disable-next-line lwr/no-unguarded-apis, no-undef
|
|
868
1102
|
timer = setTimeout(() => {
|
|
@@ -880,15 +1114,15 @@ LWR.define('lwr/loaderLegacy/v/0_10_0-alpha_2', ['exports'], function (exports)
|
|
|
880
1114
|
moduleDefPromise,
|
|
881
1115
|
},
|
|
882
1116
|
};
|
|
883
|
-
this.namedDefineRegistry.set(id, moduleDef);
|
|
884
|
-
}
|
|
885
|
-
else if (process.env.NODE_ENV !== 'production' && hasConsole) {
|
|
1117
|
+
this.namedDefineRegistry.set(id, moduleDef );
|
|
1118
|
+
} else if (process.env.NODE_ENV !== 'production' && hasConsole) {
|
|
886
1119
|
// eslint-disable-next-line lwr/no-unguarded-apis
|
|
887
1120
|
console.warn(MODULE_ALREADY_LOADED.message, id);
|
|
888
1121
|
}
|
|
889
1122
|
});
|
|
890
1123
|
}
|
|
891
|
-
|
|
1124
|
+
|
|
1125
|
+
checkModuleSignature(name, signature) {
|
|
892
1126
|
const moduleDef = this.namedDefineRegistry.get(name);
|
|
893
1127
|
if (!moduleDef) {
|
|
894
1128
|
// Placeholder module definition entry for saving known signature
|
|
@@ -899,9 +1133,10 @@ LWR.define('lwr/loaderLegacy/v/0_10_0-alpha_2', ['exports'], function (exports)
|
|
|
899
1133
|
},
|
|
900
1134
|
defined: false,
|
|
901
1135
|
};
|
|
902
|
-
this.namedDefineRegistry.set(name, modDef);
|
|
1136
|
+
this.namedDefineRegistry.set(name, modDef );
|
|
903
1137
|
return;
|
|
904
1138
|
}
|
|
1139
|
+
|
|
905
1140
|
const currentSig = moduleDef.signatures ? moduleDef.signatures.ownHash : undefined;
|
|
906
1141
|
if (currentSig && signature !== currentSig) {
|
|
907
1142
|
const handleStaleModuleHooks = this.handleStaleModuleHook;
|
|
@@ -911,25 +1146,43 @@ LWR.define('lwr/loaderLegacy/v/0_10_0-alpha_2', ['exports'], function (exports)
|
|
|
911
1146
|
oldHash: currentSig,
|
|
912
1147
|
newHash: signature,
|
|
913
1148
|
});
|
|
914
|
-
}
|
|
915
|
-
else {
|
|
1149
|
+
} else {
|
|
916
1150
|
if (process.env.NODE_ENV !== 'production' && hasConsole) {
|
|
917
1151
|
// eslint-disable-next-line lwr/no-unguarded-apis, no-undef
|
|
918
|
-
console.warn(
|
|
1152
|
+
console.warn(
|
|
1153
|
+
`stale module detected ${name}, current sig:${currentSig}, new sig:${signature}`,
|
|
1154
|
+
);
|
|
919
1155
|
}
|
|
920
1156
|
}
|
|
921
1157
|
}
|
|
922
1158
|
}
|
|
1159
|
+
|
|
1160
|
+
|
|
923
1161
|
setImportResolver(resolver) {
|
|
924
1162
|
this.resolver = resolver;
|
|
925
1163
|
}
|
|
1164
|
+
|
|
1165
|
+
|
|
1166
|
+
|
|
1167
|
+
// A registry for named AMD defines containing the *metadata* of AMD module
|
|
1168
|
+
__init() {this.namedDefineRegistry = new Map();}
|
|
1169
|
+
|
|
1170
|
+
// The evaluated module registry where the module identifier (name or URL?) is the key
|
|
1171
|
+
__init2() {this.moduleRegistry = new Map();}
|
|
1172
|
+
|
|
1173
|
+
// Aliases of modules in the registry
|
|
1174
|
+
__init3() {this.aliases = new Map();}
|
|
1175
|
+
|
|
1176
|
+
|
|
1177
|
+
|
|
926
1178
|
// Returns an existing module record by the resolvedId or aliased id
|
|
927
|
-
|
|
1179
|
+
getExistingModuleRecord(resolvedId, aliasId) {
|
|
928
1180
|
const moduleRecord = this.moduleRegistry.get(resolvedId);
|
|
929
1181
|
if (moduleRecord) {
|
|
930
1182
|
this.storeModuleAlias(aliasId, resolvedId);
|
|
931
1183
|
return moduleRecord;
|
|
932
1184
|
}
|
|
1185
|
+
|
|
933
1186
|
// Check if this is a known alias
|
|
934
1187
|
if (resolvedId !== aliasId) {
|
|
935
1188
|
const alias = this.aliases.get(aliasId);
|
|
@@ -942,13 +1195,15 @@ LWR.define('lwr/loaderLegacy/v/0_10_0-alpha_2', ['exports'], function (exports)
|
|
|
942
1195
|
}
|
|
943
1196
|
return moduleRecord;
|
|
944
1197
|
}
|
|
945
|
-
|
|
1198
|
+
|
|
1199
|
+
getModuleRecord(resolvedId, id) {
|
|
946
1200
|
// Look for an existing record
|
|
947
1201
|
const existingRecord = this.getExistingModuleRecord(resolvedId, id);
|
|
948
1202
|
if (existingRecord) {
|
|
949
1203
|
// return existing
|
|
950
1204
|
return existingRecord;
|
|
951
1205
|
}
|
|
1206
|
+
|
|
952
1207
|
// Create a new Module Record
|
|
953
1208
|
const instantiation = this.getModuleDef(resolvedId, id);
|
|
954
1209
|
const dependencyRecords = instantiation.then((moduleDef) => {
|
|
@@ -956,15 +1211,17 @@ LWR.define('lwr/loaderLegacy/v/0_10_0-alpha_2', ['exports'], function (exports)
|
|
|
956
1211
|
// get dep and filter out exports
|
|
957
1212
|
const filtered = dependencies
|
|
958
1213
|
.map((dep) => {
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
.filter((depRecord) => depRecord !== undefined);
|
|
1214
|
+
if (dep === 'exports') {
|
|
1215
|
+
return;
|
|
1216
|
+
}
|
|
1217
|
+
invariant(dep !== 'require', NO_AMD_REQUIRE);
|
|
1218
|
+
return this.getModuleDependencyRecord.call(this, dep);
|
|
1219
|
+
})
|
|
1220
|
+
.filter((depRecord) => depRecord !== undefined) ;
|
|
1221
|
+
|
|
966
1222
|
return Promise.all(filtered);
|
|
967
1223
|
});
|
|
1224
|
+
|
|
968
1225
|
const newModuleRecord = {
|
|
969
1226
|
id: resolvedId,
|
|
970
1227
|
module: Object.create(null),
|
|
@@ -977,12 +1234,12 @@ LWR.define('lwr/loaderLegacy/v/0_10_0-alpha_2', ['exports'], function (exports)
|
|
|
977
1234
|
this.storeModuleAlias(id, resolvedId);
|
|
978
1235
|
return newModuleRecord;
|
|
979
1236
|
}
|
|
980
|
-
|
|
1237
|
+
|
|
1238
|
+
storeModuleAlias(aliasId, resolvedId) {
|
|
981
1239
|
if (aliasId !== resolvedId) {
|
|
982
1240
|
if (!this.aliases.has(aliasId)) {
|
|
983
1241
|
this.aliases.set(aliasId, resolvedId);
|
|
984
|
-
}
|
|
985
|
-
else if (hasConsole) {
|
|
1242
|
+
} else if (hasConsole) {
|
|
986
1243
|
// Warn the user if they were not aliasing to the resolvedId
|
|
987
1244
|
const currentResolvedId = this.aliases.get(aliasId);
|
|
988
1245
|
if (currentResolvedId !== resolvedId) {
|
|
@@ -992,17 +1249,23 @@ LWR.define('lwr/loaderLegacy/v/0_10_0-alpha_2', ['exports'], function (exports)
|
|
|
992
1249
|
}
|
|
993
1250
|
}
|
|
994
1251
|
}
|
|
995
|
-
|
|
1252
|
+
|
|
1253
|
+
async getModuleDependencyRecord(dependency) {
|
|
996
1254
|
const resolvedDepId = await this.resolve(dependency);
|
|
997
1255
|
return this.getModuleRecord(resolvedDepId, dependency);
|
|
998
1256
|
}
|
|
1257
|
+
|
|
999
1258
|
// execute the "top-level code" (the code outside of functions) of a module
|
|
1000
|
-
|
|
1259
|
+
async topLevelEvaluation(moduleRecord) {
|
|
1001
1260
|
await this.instantiateAll(moduleRecord, {});
|
|
1002
1261
|
return this.evaluateModule(moduleRecord, {});
|
|
1003
1262
|
}
|
|
1263
|
+
|
|
1004
1264
|
// Returns a promise when a module and all of it's dependencies have finished instantiation
|
|
1005
|
-
|
|
1265
|
+
async instantiateAll(
|
|
1266
|
+
moduleRecord,
|
|
1267
|
+
instantiatedMap,
|
|
1268
|
+
) {
|
|
1006
1269
|
if (!instantiatedMap[moduleRecord.id]) {
|
|
1007
1270
|
instantiatedMap[moduleRecord.id] = true;
|
|
1008
1271
|
const dependencyModuleRecords = await moduleRecord.dependencyRecords;
|
|
@@ -1015,46 +1278,61 @@ LWR.define('lwr/loaderLegacy/v/0_10_0-alpha_2', ['exports'], function (exports)
|
|
|
1015
1278
|
}
|
|
1016
1279
|
}
|
|
1017
1280
|
}
|
|
1018
|
-
|
|
1281
|
+
|
|
1282
|
+
async evaluateModule(
|
|
1283
|
+
moduleRecord,
|
|
1284
|
+
evaluationMap,
|
|
1285
|
+
) {
|
|
1019
1286
|
const dependencyModuleRecords = await moduleRecord.dependencyRecords;
|
|
1020
1287
|
if (dependencyModuleRecords.length > 0) {
|
|
1021
1288
|
evaluationMap[moduleRecord.id] = true;
|
|
1022
1289
|
// evaluate dependencies first
|
|
1023
1290
|
await this.evaluateModuleDependencies(dependencyModuleRecords, evaluationMap);
|
|
1024
1291
|
}
|
|
1292
|
+
|
|
1025
1293
|
const { exporter, dependencies } = await moduleRecord.instantiation;
|
|
1026
1294
|
// The exports object automatically gets filled in by the exporter evaluation
|
|
1027
1295
|
const exports = {};
|
|
1028
|
-
const depsMapped = await Promise.all(
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1296
|
+
const depsMapped = await Promise.all(
|
|
1297
|
+
dependencies.map(async (dep) => {
|
|
1298
|
+
if (dep === 'exports') {
|
|
1299
|
+
return exports;
|
|
1300
|
+
}
|
|
1301
|
+
const resolvedDepId = await this.resolve(dep);
|
|
1302
|
+
|
|
1303
|
+
const moduleRecord = this.moduleRegistry.get(resolvedDepId) ;
|
|
1304
|
+
if (!moduleRecord) {
|
|
1305
|
+
throw new LoaderError(FAILED_DEP, [resolvedDepId]);
|
|
1306
|
+
}
|
|
1307
|
+
|
|
1308
|
+
const module = moduleRecord.module;
|
|
1309
|
+
|
|
1310
|
+
/**
|
|
1311
|
+
* Circular dependencies are handled properly when named exports are used,
|
|
1312
|
+
* however, for default exports there is a bug: https://github.com/rollup/rollup/issues/3384
|
|
1313
|
+
*
|
|
1314
|
+
* The workaround below applies for circular dependencies (!moduleRecord.evaluated)
|
|
1315
|
+
*/
|
|
1316
|
+
if (!moduleRecord.evaluated) {
|
|
1317
|
+
return this.getCircularDependencyWrapper(module);
|
|
1318
|
+
}
|
|
1319
|
+
|
|
1320
|
+
if (module) {
|
|
1321
|
+
return module.__defaultInterop ? module.default : module;
|
|
1322
|
+
}
|
|
1323
|
+
|
|
1035
1324
|
throw new LoaderError(FAILED_DEP, [resolvedDepId]);
|
|
1036
|
-
}
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
* Circular dependencies are handled properly when named exports are used,
|
|
1040
|
-
* however, for default exports there is a bug: https://github.com/rollup/rollup/issues/3384
|
|
1041
|
-
*
|
|
1042
|
-
* The workaround below applies for circular dependencies (!moduleRecord.evaluated)
|
|
1043
|
-
*/
|
|
1044
|
-
if (!moduleRecord.evaluated) {
|
|
1045
|
-
return this.getCircularDependencyWrapper(module);
|
|
1046
|
-
}
|
|
1047
|
-
if (module) {
|
|
1048
|
-
return module.__defaultInterop ? module.default : module;
|
|
1049
|
-
}
|
|
1050
|
-
throw new LoaderError(FAILED_DEP, [resolvedDepId]);
|
|
1051
|
-
}));
|
|
1325
|
+
}),
|
|
1326
|
+
);
|
|
1327
|
+
|
|
1052
1328
|
// W-10029836 - In the case where we could be instantiating multiple graphs at the same time lets make sure the module have not already been evaluated
|
|
1053
1329
|
if (moduleRecord.evaluated) {
|
|
1054
1330
|
return moduleRecord.module;
|
|
1055
1331
|
}
|
|
1332
|
+
|
|
1056
1333
|
// evaluates the module function
|
|
1057
1334
|
let moduleDefault = exporter(...depsMapped);
|
|
1335
|
+
|
|
1058
1336
|
// value is returned from exporter, then we are not using named exports
|
|
1059
1337
|
if (moduleDefault !== undefined) {
|
|
1060
1338
|
moduleDefault = { default: moduleDefault };
|
|
@@ -1070,7 +1348,9 @@ LWR.define('lwr/loaderLegacy/v/0_10_0-alpha_2', ['exports'], function (exports)
|
|
|
1070
1348
|
Object.defineProperty(exports, '__useDefault', { value: true });
|
|
1071
1349
|
}
|
|
1072
1350
|
}
|
|
1351
|
+
|
|
1073
1352
|
const moduleExports = moduleDefault || exports;
|
|
1353
|
+
|
|
1074
1354
|
// update the module record
|
|
1075
1355
|
// copy over enumerable public methods to module
|
|
1076
1356
|
for (const key in moduleExports) {
|
|
@@ -1084,6 +1364,7 @@ LWR.define('lwr/loaderLegacy/v/0_10_0-alpha_2', ['exports'], function (exports)
|
|
|
1084
1364
|
},
|
|
1085
1365
|
});
|
|
1086
1366
|
}
|
|
1367
|
+
|
|
1087
1368
|
// copy non-enumerable to module
|
|
1088
1369
|
if (moduleExports.__useDefault) {
|
|
1089
1370
|
Object.defineProperty(moduleRecord.module, '__useDefault', { value: true });
|
|
@@ -1094,27 +1375,36 @@ LWR.define('lwr/loaderLegacy/v/0_10_0-alpha_2', ['exports'], function (exports)
|
|
|
1094
1375
|
if (moduleExports.__esModule) {
|
|
1095
1376
|
Object.defineProperty(moduleRecord.module, '__esModule', { value: true });
|
|
1096
1377
|
}
|
|
1378
|
+
|
|
1097
1379
|
moduleRecord.evaluated = true;
|
|
1098
1380
|
Object.freeze(moduleRecord.module);
|
|
1099
1381
|
return moduleRecord.module;
|
|
1100
1382
|
}
|
|
1383
|
+
|
|
1101
1384
|
// Determines if named exports module has only default export
|
|
1102
|
-
|
|
1103
|
-
return (
|
|
1385
|
+
isNamedExportDefaultOnly(exports) {
|
|
1386
|
+
return (
|
|
1387
|
+
exports !== undefined &&
|
|
1104
1388
|
Object.getOwnPropertyNames(exports).length === 2 &&
|
|
1105
1389
|
Object.prototype.hasOwnProperty.call(exports, 'default') &&
|
|
1106
|
-
Object.prototype.hasOwnProperty.call(exports, '__esModule')
|
|
1390
|
+
Object.prototype.hasOwnProperty.call(exports, '__esModule')
|
|
1391
|
+
);
|
|
1107
1392
|
}
|
|
1393
|
+
|
|
1108
1394
|
// Wrap the dependency in a function that can be called and detected by __circular__ property.
|
|
1109
1395
|
// The LWC engine checks for __circular__ to detect circular dependencies.
|
|
1110
|
-
|
|
1396
|
+
getCircularDependencyWrapper(module) {
|
|
1111
1397
|
const tmp = () => {
|
|
1112
1398
|
return module.__useDefault || module.__defaultInterop ? module.default : module;
|
|
1113
1399
|
};
|
|
1114
1400
|
tmp.__circular__ = true;
|
|
1115
1401
|
return tmp;
|
|
1116
1402
|
}
|
|
1117
|
-
|
|
1403
|
+
|
|
1404
|
+
async evaluateModuleDependencies(
|
|
1405
|
+
dependencyModuleRecords,
|
|
1406
|
+
evaluationMap,
|
|
1407
|
+
) {
|
|
1118
1408
|
for (let i = 0; i < dependencyModuleRecords.length; i++) {
|
|
1119
1409
|
const depRecord = dependencyModuleRecords[i];
|
|
1120
1410
|
if (!depRecord.evaluated && !evaluationMap[depRecord.id]) {
|
|
@@ -1124,15 +1414,17 @@ LWR.define('lwr/loaderLegacy/v/0_10_0-alpha_2', ['exports'], function (exports)
|
|
|
1124
1414
|
}
|
|
1125
1415
|
}
|
|
1126
1416
|
}
|
|
1127
|
-
|
|
1417
|
+
|
|
1418
|
+
async getModuleDef(resolvedId, originalId) {
|
|
1128
1419
|
// reset lastDefine
|
|
1129
1420
|
this.lastDefine = undefined;
|
|
1421
|
+
|
|
1130
1422
|
// the module name can be the resolved ID or the original ID if neither are URL's.
|
|
1131
1423
|
const moduleName = !isUrl(resolvedId)
|
|
1132
1424
|
? resolvedId
|
|
1133
1425
|
: originalId !== resolvedId
|
|
1134
|
-
|
|
1135
|
-
|
|
1426
|
+
? originalId
|
|
1427
|
+
: undefined;
|
|
1136
1428
|
let moduleDef = moduleName && this.namedDefineRegistry.get(moduleName);
|
|
1137
1429
|
if (moduleDef && moduleDef.external) {
|
|
1138
1430
|
return moduleDef.external.moduleDefPromise;
|
|
@@ -1145,76 +1437,84 @@ LWR.define('lwr/loaderLegacy/v/0_10_0-alpha_2', ['exports'], function (exports)
|
|
|
1145
1437
|
this.profiler.logOperationStart({ id: MODULE_FETCH, specifier });
|
|
1146
1438
|
return Promise.resolve()
|
|
1147
1439
|
.then(async () => {
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1440
|
+
const loadHooks = this.loadHook;
|
|
1441
|
+
if (loadHooks) {
|
|
1442
|
+
for (let i = 0; i < loadHooks.length; i++) {
|
|
1443
|
+
const loadHook = loadHooks[i];
|
|
1444
|
+
const response = loadHook(resolvedId, parentUrl);
|
|
1445
|
+
const result = (
|
|
1446
|
+
isResponseAPromise(response)
|
|
1447
|
+
? // eslint-disable-next-line no-await-in-loop
|
|
1448
|
+
await evaluateLoadHook(resolvedId, response)
|
|
1449
|
+
: response
|
|
1450
|
+
) ;
|
|
1451
|
+
if (result === undefined) {
|
|
1452
|
+
throw new LoaderError(INVALID_LOADER_SERVICE_RESPONSE);
|
|
1453
|
+
}
|
|
1454
|
+
if (result && result !== null) {
|
|
1455
|
+
return evaluateLoadHookResponse(result, resolvedId);
|
|
1456
|
+
}
|
|
1162
1457
|
}
|
|
1163
1458
|
}
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
})
|
|
1459
|
+
return false;
|
|
1460
|
+
})
|
|
1167
1461
|
.then((result) => {
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1462
|
+
if (result !== true && hasDocument) {
|
|
1463
|
+
return loadModuleDef(resolvedId);
|
|
1464
|
+
}
|
|
1465
|
+
})
|
|
1172
1466
|
.then(() => {
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
moduleDef
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1467
|
+
// Attempt to retrieve the module definition by name first
|
|
1468
|
+
moduleDef = moduleName && this.namedDefineRegistry.get(moduleName);
|
|
1469
|
+
|
|
1470
|
+
// Fallback to the last loader.define call
|
|
1471
|
+
if (!moduleDef) {
|
|
1472
|
+
moduleDef = this.lastDefine;
|
|
1473
|
+
}
|
|
1474
|
+
|
|
1475
|
+
// This should not happen
|
|
1476
|
+
if (!moduleDef) {
|
|
1477
|
+
throw new LoaderError(FAIL_INSTANTIATE, [resolvedId]);
|
|
1478
|
+
}
|
|
1479
|
+
|
|
1480
|
+
this.profiler.logOperationEnd({ id: MODULE_FETCH, specifier });
|
|
1481
|
+
return moduleDef;
|
|
1482
|
+
})
|
|
1186
1483
|
.catch((e) => {
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1484
|
+
this.profiler.logOperationStart({ id: MODULE_ERROR, specifier });
|
|
1485
|
+
throw e;
|
|
1486
|
+
});
|
|
1190
1487
|
}
|
|
1488
|
+
|
|
1489
|
+
|
|
1490
|
+
|
|
1191
1491
|
addLoaderPlugin(hooks) {
|
|
1192
1492
|
if (typeof hooks !== 'object') {
|
|
1193
1493
|
throw new LoaderError(INVALID_HOOK);
|
|
1194
1494
|
}
|
|
1195
1495
|
const { loadModule: loadHook, resolveModule: resolveHook } = hooks;
|
|
1496
|
+
|
|
1196
1497
|
if (resolveHook) {
|
|
1197
1498
|
if (this.resolveHook) {
|
|
1198
1499
|
this.resolveHook.push(resolveHook);
|
|
1199
|
-
}
|
|
1200
|
-
else {
|
|
1500
|
+
} else {
|
|
1201
1501
|
this.resolveHook = [resolveHook];
|
|
1202
1502
|
}
|
|
1203
1503
|
}
|
|
1204
1504
|
if (loadHook) {
|
|
1205
1505
|
if (this.loadHook) {
|
|
1206
1506
|
this.loadHook.push(loadHook);
|
|
1207
|
-
}
|
|
1208
|
-
else {
|
|
1507
|
+
} else {
|
|
1209
1508
|
this.loadHook = [loadHook];
|
|
1210
1509
|
}
|
|
1211
1510
|
}
|
|
1212
1511
|
}
|
|
1512
|
+
|
|
1513
|
+
|
|
1213
1514
|
registerHandleStaleModuleHook(handleStaleModule) {
|
|
1214
1515
|
if (this.handleStaleModuleHook) {
|
|
1215
1516
|
this.handleStaleModuleHook.push(handleStaleModule);
|
|
1216
|
-
}
|
|
1217
|
-
else {
|
|
1517
|
+
} else {
|
|
1218
1518
|
this.handleStaleModuleHook = [handleStaleModule];
|
|
1219
1519
|
}
|
|
1220
1520
|
}
|
|
@@ -1246,6 +1546,19 @@ LWR.define('lwr/loaderLegacy/v/0_10_0-alpha_2', ['exports'], function (exports)
|
|
|
1246
1546
|
*
|
|
1247
1547
|
* This implementation is adapted from https://github.com/systemjs/systemjs/blob/master/src/features/import-map.js
|
|
1248
1548
|
*/
|
|
1549
|
+
|
|
1550
|
+
// Spec based import map object https://github.com/WICG/import-maps
|
|
1551
|
+
|
|
1552
|
+
|
|
1553
|
+
|
|
1554
|
+
|
|
1555
|
+
|
|
1556
|
+
|
|
1557
|
+
|
|
1558
|
+
|
|
1559
|
+
|
|
1560
|
+
|
|
1561
|
+
|
|
1249
1562
|
// Resolves an import map package entry
|
|
1250
1563
|
function applyPackages(id, packages, defaultUri) {
|
|
1251
1564
|
const pkgName = getMatch(id, packages);
|
|
@@ -1256,9 +1569,9 @@ LWR.define('lwr/loaderLegacy/v/0_10_0-alpha_2', ['exports'], function (exports)
|
|
|
1256
1569
|
}
|
|
1257
1570
|
if (id.length > pkgName.length && pkg[pkg.length - 1] !== '/') {
|
|
1258
1571
|
targetWarning(pkgName, pkg, "should have a trailing '/'");
|
|
1259
|
-
}
|
|
1260
|
-
|
|
1261
|
-
|
|
1572
|
+
} else {
|
|
1573
|
+
const isPackage =
|
|
1574
|
+
id.length > pkgName.length &&
|
|
1262
1575
|
pkg[pkg.length - 1] === '/' &&
|
|
1263
1576
|
pkg.lastIndexOf(pkgName) === pkg.length - pkgName.length;
|
|
1264
1577
|
if (isPackage) {
|
|
@@ -1267,8 +1580,7 @@ LWR.define('lwr/loaderLegacy/v/0_10_0-alpha_2', ['exports'], function (exports)
|
|
|
1267
1580
|
}
|
|
1268
1581
|
return pkg + id.slice(pkgName.length);
|
|
1269
1582
|
}
|
|
1270
|
-
}
|
|
1271
|
-
else if (defaultUri) {
|
|
1583
|
+
} else if (defaultUri) {
|
|
1272
1584
|
// When a specifier's URI cannot be resolved via the imports, fallback to "default".
|
|
1273
1585
|
// -> https://rfcs.lwc.dev/rfcs/lwr/0000-import-metadata#json-schema
|
|
1274
1586
|
// However, if `id` is already a fully resolved url,
|
|
@@ -1279,8 +1591,13 @@ LWR.define('lwr/loaderLegacy/v/0_10_0-alpha_2', ['exports'], function (exports)
|
|
|
1279
1591
|
}
|
|
1280
1592
|
}
|
|
1281
1593
|
}
|
|
1594
|
+
|
|
1282
1595
|
// Resolves an entry in the import map
|
|
1283
|
-
function resolveImportMapEntry(
|
|
1596
|
+
function resolveImportMapEntry(
|
|
1597
|
+
importMap,
|
|
1598
|
+
resolvedOrPlain,
|
|
1599
|
+
parentUrl,
|
|
1600
|
+
) {
|
|
1284
1601
|
if (!importMap.scopes) {
|
|
1285
1602
|
importMap.scopes = {};
|
|
1286
1603
|
}
|
|
@@ -1296,12 +1613,21 @@ LWR.define('lwr/loaderLegacy/v/0_10_0-alpha_2', ['exports'], function (exports)
|
|
|
1296
1613
|
}
|
|
1297
1614
|
scopeUrl = getMatch(scopeUrl.slice(0, scopeUrl.lastIndexOf('/')), scopes);
|
|
1298
1615
|
}
|
|
1299
|
-
return (
|
|
1616
|
+
return (
|
|
1617
|
+
applyPackages(resolvedOrPlain, importMap.imports, importMap.default) ||
|
|
1300
1618
|
(isUrl(resolvedOrPlain) && resolvedOrPlain) ||
|
|
1301
|
-
undefined
|
|
1619
|
+
undefined
|
|
1620
|
+
);
|
|
1302
1621
|
}
|
|
1622
|
+
|
|
1303
1623
|
// In place transformation of the ImportMap object
|
|
1304
|
-
function resolveAndComposePackages(
|
|
1624
|
+
function resolveAndComposePackages(
|
|
1625
|
+
packages,
|
|
1626
|
+
outPackages,
|
|
1627
|
+
baseUrl,
|
|
1628
|
+
parentMap,
|
|
1629
|
+
parentUrl,
|
|
1630
|
+
) {
|
|
1305
1631
|
for (const p in packages) {
|
|
1306
1632
|
const resolvedLhs = resolveIfNotPlainOrUrl(p, baseUrl) || p;
|
|
1307
1633
|
const rhs = packages[p];
|
|
@@ -1309,42 +1635,62 @@ LWR.define('lwr/loaderLegacy/v/0_10_0-alpha_2', ['exports'], function (exports)
|
|
|
1309
1635
|
if (typeof rhs !== 'string') {
|
|
1310
1636
|
continue;
|
|
1311
1637
|
}
|
|
1312
|
-
const mapped = resolveImportMapEntry(
|
|
1638
|
+
const mapped = resolveImportMapEntry(
|
|
1639
|
+
parentMap,
|
|
1640
|
+
resolveIfNotPlainOrUrl(rhs, baseUrl) || rhs,
|
|
1641
|
+
parentUrl,
|
|
1642
|
+
);
|
|
1313
1643
|
if (!mapped) {
|
|
1314
1644
|
targetWarning(p, rhs, 'bare specifier did not resolve');
|
|
1315
|
-
}
|
|
1316
|
-
else {
|
|
1645
|
+
} else {
|
|
1317
1646
|
outPackages[resolvedLhs] = mapped;
|
|
1318
1647
|
}
|
|
1319
1648
|
}
|
|
1320
1649
|
}
|
|
1650
|
+
|
|
1321
1651
|
// Composes a single import map object given a child and parent import map
|
|
1322
|
-
function resolveAndComposeImportMap(
|
|
1652
|
+
function resolveAndComposeImportMap(
|
|
1653
|
+
json,
|
|
1654
|
+
baseUrl,
|
|
1655
|
+
parentMap = { imports: {}, scopes: {} },
|
|
1656
|
+
) {
|
|
1323
1657
|
const outMap = {
|
|
1324
1658
|
imports: Object.assign({}, parentMap.imports),
|
|
1325
1659
|
scopes: Object.assign({}, parentMap.scopes),
|
|
1326
1660
|
default: json.default,
|
|
1327
1661
|
};
|
|
1662
|
+
|
|
1328
1663
|
if (json.imports) {
|
|
1329
1664
|
resolveAndComposePackages(json.imports, outMap.imports, baseUrl, parentMap);
|
|
1330
1665
|
}
|
|
1666
|
+
|
|
1331
1667
|
if (json.scopes) {
|
|
1332
1668
|
for (const s in json.scopes) {
|
|
1333
1669
|
const resolvedScope = resolveUrl(s, baseUrl);
|
|
1334
|
-
resolveAndComposePackages(
|
|
1670
|
+
resolveAndComposePackages(
|
|
1671
|
+
json.scopes[s],
|
|
1672
|
+
outMap.scopes[resolvedScope] || (outMap.scopes[resolvedScope] = {}),
|
|
1673
|
+
baseUrl,
|
|
1674
|
+
parentMap,
|
|
1675
|
+
resolvedScope,
|
|
1676
|
+
);
|
|
1335
1677
|
}
|
|
1336
1678
|
}
|
|
1679
|
+
|
|
1337
1680
|
if (json.default) {
|
|
1338
1681
|
outMap.default = resolveIfNotPlainOrUrl(json.default, baseUrl);
|
|
1339
1682
|
}
|
|
1683
|
+
|
|
1340
1684
|
return outMap;
|
|
1341
1685
|
}
|
|
1342
1686
|
|
|
1343
1687
|
/* spec based import map resolver */
|
|
1344
|
-
class ImportMapResolver
|
|
1688
|
+
class ImportMapResolver {
|
|
1689
|
+
|
|
1345
1690
|
constructor(importMap) {
|
|
1346
1691
|
this.importMap = importMap;
|
|
1347
1692
|
}
|
|
1693
|
+
|
|
1348
1694
|
resolve(resolvedOrPlain, parentUrl) {
|
|
1349
1695
|
return resolveImportMapEntry(this.importMap, resolvedOrPlain, parentUrl);
|
|
1350
1696
|
}
|
|
@@ -1355,26 +1701,33 @@ LWR.define('lwr/loaderLegacy/v/0_10_0-alpha_2', ['exports'], function (exports)
|
|
|
1355
1701
|
*
|
|
1356
1702
|
* This implementation is adapted from https://github.com/systemjs/systemjs/blob/master/src/features/import-map.js
|
|
1357
1703
|
*/
|
|
1704
|
+
|
|
1358
1705
|
const IMPORTMAP_SCRIPT_TYPE = 'lwr-importmap';
|
|
1706
|
+
|
|
1359
1707
|
// iterates on the any <script type="${IMPORTMAP_SCRIPT_TYPE}", invoking the given callback for each
|
|
1360
|
-
function iterateDocumentImportMaps(
|
|
1708
|
+
function iterateDocumentImportMaps(
|
|
1709
|
+
callBack,
|
|
1710
|
+
extraSelector,
|
|
1711
|
+
) {
|
|
1361
1712
|
// eslint-disable-next-line lwr/no-unguarded-apis, no-undef
|
|
1362
1713
|
const nodeList = document.querySelectorAll(`script[type="${IMPORTMAP_SCRIPT_TYPE}"]` + extraSelector);
|
|
1363
1714
|
const filtered = Array.from(nodeList).filter((node) => {
|
|
1364
|
-
if (node.src) {
|
|
1715
|
+
if ((node ).src) {
|
|
1365
1716
|
// eslint-disable-next-line lwr/no-unguarded-apis, no-undef
|
|
1366
|
-
if (hasConsole)
|
|
1367
|
-
console.warn('LWR does not support import maps from script src');
|
|
1717
|
+
if (hasConsole) console.warn('LWR does not support import maps from script src');
|
|
1368
1718
|
return false;
|
|
1369
1719
|
}
|
|
1370
1720
|
return true;
|
|
1371
1721
|
});
|
|
1722
|
+
|
|
1372
1723
|
Array.prototype.forEach.call(filtered, callBack);
|
|
1373
1724
|
}
|
|
1725
|
+
|
|
1374
1726
|
// retrives the import map text from a <script type="${IMPORTMAP_SCRIPT_TYPE}"
|
|
1375
1727
|
async function getImportMapFromScript(script) {
|
|
1376
1728
|
return Promise.resolve(script.innerHTML);
|
|
1377
1729
|
}
|
|
1730
|
+
|
|
1378
1731
|
// get importMap from <script type="lwr-importmap">
|
|
1379
1732
|
async function evaluateImportMaps(baseUrl) {
|
|
1380
1733
|
let importMap = { imports: {}, scopes: {} };
|
|
@@ -1386,23 +1739,27 @@ LWR.define('lwr/loaderLegacy/v/0_10_0-alpha_2', ['exports'], function (exports)
|
|
|
1386
1739
|
if (!baseUrl) {
|
|
1387
1740
|
throw new LoaderError(NO_BASE_URL);
|
|
1388
1741
|
}
|
|
1742
|
+
|
|
1389
1743
|
iterateDocumentImportMaps((script) => {
|
|
1390
1744
|
importMapPromise = importMapPromise
|
|
1391
1745
|
.then(() => {
|
|
1392
|
-
|
|
1393
|
-
|
|
1746
|
+
return getImportMapFromScript(script);
|
|
1747
|
+
})
|
|
1394
1748
|
.then((importMapTxt) => {
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
}
|
|
1401
|
-
})
|
|
1749
|
+
try {
|
|
1750
|
+
return JSON.parse(importMapTxt);
|
|
1751
|
+
} catch (e) {
|
|
1752
|
+
throw new LoaderError(BAD_IMPORT_MAP);
|
|
1753
|
+
}
|
|
1754
|
+
})
|
|
1402
1755
|
.then((jsonImportMap) => {
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1756
|
+
importMap = resolveAndComposeImportMap(
|
|
1757
|
+
jsonImportMap,
|
|
1758
|
+
script.src || (baseUrl ),
|
|
1759
|
+
importMap,
|
|
1760
|
+
);
|
|
1761
|
+
return importMap;
|
|
1762
|
+
});
|
|
1406
1763
|
}, '');
|
|
1407
1764
|
}
|
|
1408
1765
|
return importMapPromise;
|
|
@@ -1412,6 +1769,10 @@ LWR.define('lwr/loaderLegacy/v/0_10_0-alpha_2', ['exports'], function (exports)
|
|
|
1412
1769
|
* The LWR loader is inspired and borrows from the algorithms and native browser principles of https://github.com/systemjs/systemjs
|
|
1413
1770
|
*/
|
|
1414
1771
|
class Loader {
|
|
1772
|
+
|
|
1773
|
+
|
|
1774
|
+
|
|
1775
|
+
|
|
1415
1776
|
constructor(config) {
|
|
1416
1777
|
config = config || {};
|
|
1417
1778
|
let baseUrl = config.baseUrl;
|
|
@@ -1427,6 +1788,7 @@ LWR.define('lwr/loaderLegacy/v/0_10_0-alpha_2', ['exports'], function (exports)
|
|
|
1427
1788
|
throw new LoaderError(NO_BASE_URL);
|
|
1428
1789
|
}
|
|
1429
1790
|
this.baseUrl = baseUrl;
|
|
1791
|
+
|
|
1430
1792
|
if (!profiler) {
|
|
1431
1793
|
// default noop profiler
|
|
1432
1794
|
profiler = {
|
|
@@ -1438,7 +1800,9 @@ LWR.define('lwr/loaderLegacy/v/0_10_0-alpha_2', ['exports'], function (exports)
|
|
|
1438
1800
|
},
|
|
1439
1801
|
};
|
|
1440
1802
|
}
|
|
1803
|
+
|
|
1441
1804
|
this.registry = new ModuleRegistry({ baseUrl, profiler });
|
|
1805
|
+
|
|
1442
1806
|
// TODO: https://github.com/salesforce-experience-platform-emu/lwr/issues/1087
|
|
1443
1807
|
this.services = Object.freeze({
|
|
1444
1808
|
addLoaderPlugin: this.registry.addLoaderPlugin.bind(this.registry),
|
|
@@ -1446,6 +1810,7 @@ LWR.define('lwr/loaderLegacy/v/0_10_0-alpha_2', ['exports'], function (exports)
|
|
|
1446
1810
|
appMetadata: config.appMetadata,
|
|
1447
1811
|
});
|
|
1448
1812
|
}
|
|
1813
|
+
|
|
1449
1814
|
/**
|
|
1450
1815
|
* Defines/registers a single named AMD module definition.
|
|
1451
1816
|
*
|
|
@@ -1455,21 +1820,31 @@ LWR.define('lwr/loaderLegacy/v/0_10_0-alpha_2', ['exports'], function (exports)
|
|
|
1455
1820
|
* @param {ModuleDefinitionSignatures} signatures Object containing the module signature and the signatures of its dependencies
|
|
1456
1821
|
* @return {void}
|
|
1457
1822
|
*/
|
|
1458
|
-
define(
|
|
1823
|
+
define(
|
|
1824
|
+
name,
|
|
1825
|
+
dependencies,
|
|
1826
|
+
execute,
|
|
1827
|
+
signatures,
|
|
1828
|
+
) {
|
|
1459
1829
|
invariant(typeof name === 'string', MISSING_NAME);
|
|
1460
1830
|
let ctor = execute;
|
|
1461
1831
|
let deps = dependencies;
|
|
1462
1832
|
let sigs = signatures;
|
|
1833
|
+
|
|
1463
1834
|
// Convert no dependencies form `define('name', function(){}, {});` to: `define('name', [], function(){}, {})`
|
|
1464
1835
|
if (typeof deps === 'function') {
|
|
1465
1836
|
ctor = dependencies;
|
|
1466
1837
|
deps = [];
|
|
1467
1838
|
sigs = execute;
|
|
1468
1839
|
}
|
|
1840
|
+
|
|
1469
1841
|
sigs = sigs || {};
|
|
1842
|
+
|
|
1470
1843
|
invariant(Array.isArray(deps), INVALID_DEPS);
|
|
1471
|
-
|
|
1844
|
+
|
|
1845
|
+
this.registry.define(name, deps, ctor , sigs );
|
|
1472
1846
|
}
|
|
1847
|
+
|
|
1473
1848
|
/**
|
|
1474
1849
|
* Retrieves/loads a module, returning it from the registry if it exists and fetching it if it doesn't.
|
|
1475
1850
|
*
|
|
@@ -1481,6 +1856,7 @@ LWR.define('lwr/loaderLegacy/v/0_10_0-alpha_2', ['exports'], function (exports)
|
|
|
1481
1856
|
async load(id, importer) {
|
|
1482
1857
|
return this.registry.load(id, importer);
|
|
1483
1858
|
}
|
|
1859
|
+
|
|
1484
1860
|
/**
|
|
1485
1861
|
* Checks if a Module exists in the registry. Note, returns false even if the ModuleDefinition exists but the Module has not been instantiated yet (executed).
|
|
1486
1862
|
*
|
|
@@ -1490,6 +1866,7 @@ LWR.define('lwr/loaderLegacy/v/0_10_0-alpha_2', ['exports'], function (exports)
|
|
|
1490
1866
|
has(id) {
|
|
1491
1867
|
return this.registry.has(id);
|
|
1492
1868
|
}
|
|
1869
|
+
|
|
1493
1870
|
/**
|
|
1494
1871
|
* Resolves the module identifier or URL. Returns the module identifier if the moduleDefinition exists, or the full resolved URL if a URL is given.
|
|
1495
1872
|
*
|
|
@@ -1501,13 +1878,14 @@ LWR.define('lwr/loaderLegacy/v/0_10_0-alpha_2', ['exports'], function (exports)
|
|
|
1501
1878
|
async resolve(id, importer) {
|
|
1502
1879
|
return this.registry.resolve(id, importer);
|
|
1503
1880
|
}
|
|
1881
|
+
|
|
1882
|
+
|
|
1504
1883
|
async registerImportMappings(mappings) {
|
|
1505
1884
|
let importMap;
|
|
1506
1885
|
if (!mappings) {
|
|
1507
1886
|
// If no mappings given, check for lwr-importmap on the document
|
|
1508
1887
|
importMap = await evaluateImportMaps(this.baseUrl);
|
|
1509
|
-
}
|
|
1510
|
-
else {
|
|
1888
|
+
} else {
|
|
1511
1889
|
// merge the new mappings with the base import map - note this goes against
|
|
1512
1890
|
// import maps spec if we do this after resolving any imports
|
|
1513
1891
|
importMap = resolveAndComposeImportMap(mappings, this.baseUrl, this.parentImportMap);
|
|
@@ -1518,6 +1896,7 @@ LWR.define('lwr/loaderLegacy/v/0_10_0-alpha_2', ['exports'], function (exports)
|
|
|
1518
1896
|
this.registry.setImportResolver(importMapResolver);
|
|
1519
1897
|
}
|
|
1520
1898
|
}
|
|
1899
|
+
|
|
1521
1900
|
/**
|
|
1522
1901
|
* Marks modules as "externally" loaded/provided (e.g. preloaded), so that the loader does not attempt to load them.
|
|
1523
1902
|
*
|
|
@@ -1532,4 +1911,5 @@ LWR.define('lwr/loaderLegacy/v/0_10_0-alpha_2', ['exports'], function (exports)
|
|
|
1532
1911
|
|
|
1533
1912
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
1534
1913
|
|
|
1535
|
-
});
|
|
1914
|
+
}));
|
|
1915
|
+
//# sourceMappingURL=lwr-loader-shim-legacy.bundle.js.map
|