@lwrjs/loader 0.12.0-alpha.9 → 0.13.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/assets/prod/lwr-error-shim.js +1 -1
- package/build/assets/prod/lwr-loader-shim-legacy.bundle.js +168 -133
- package/build/assets/prod/lwr-loader-shim-legacy.bundle.min.js +3 -3
- package/build/assets/prod/lwr-loader-shim-legacy.js +6 -5
- package/build/assets/prod/lwr-loader-shim.bundle.js +167 -134
- package/build/assets/prod/lwr-loader-shim.bundle.min.js +3 -3
- package/build/assets/prod/lwr-loader-shim.js +6 -5
- package/build/cjs/modules/lwr/loader/moduleRegistry/moduleRegistry.cjs +88 -68
- package/build/cjs/modules/lwr/loaderLegacy/moduleRegistry/moduleRegistry.cjs +88 -68
- package/build/modules/lwr/esmLoader/esmLoader.js +1 -1
- package/build/modules/lwr/loader/loader.js +161 -129
- package/build/modules/lwr/loaderLegacy/loaderLegacy.js +162 -128
- package/package.json +7 -7
|
@@ -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.
|
|
7
|
+
/* LWR Legacy Module Loader Shim v0.13.0-alpha.0 */
|
|
8
8
|
(function () {
|
|
9
9
|
'use strict';
|
|
10
10
|
|
|
@@ -207,7 +207,7 @@
|
|
|
207
207
|
// Parse configuration
|
|
208
208
|
this.global = global;
|
|
209
209
|
this.config = global.LWR ;
|
|
210
|
-
this.loaderModule = 'lwr/loaderLegacy/v/
|
|
210
|
+
this.loaderModule = 'lwr/loaderLegacy/v/0_13_0-alpha_0';
|
|
211
211
|
|
|
212
212
|
// Set up error handler
|
|
213
213
|
this.errorHandler = this.config.onError;
|
|
@@ -327,7 +327,7 @@
|
|
|
327
327
|
const exporter = (exports) => {
|
|
328
328
|
Object.assign(exports, { logOperationStart, logOperationEnd });
|
|
329
329
|
};
|
|
330
|
-
globalLWR.define('lwr/profiler/v/
|
|
330
|
+
globalLWR.define('lwr/profiler/v/0_13_0-alpha_0', ['exports'], exporter, {});
|
|
331
331
|
}
|
|
332
332
|
|
|
333
333
|
// Set up the application globals, import map, root custom element...
|
|
@@ -343,6 +343,7 @@
|
|
|
343
343
|
serverData,
|
|
344
344
|
importMappings,
|
|
345
345
|
endpoints,
|
|
346
|
+
env: this.global.LWR.env,
|
|
346
347
|
});
|
|
347
348
|
|
|
348
349
|
// Redefine all modules in the temporary cache
|
|
@@ -398,8 +399,8 @@
|
|
|
398
399
|
// The loader module is ALWAYS required
|
|
399
400
|
const GLOBAL = globalThis ;
|
|
400
401
|
GLOBAL.LWR.requiredModules = GLOBAL.LWR.requiredModules || [];
|
|
401
|
-
if (GLOBAL.LWR.requiredModules.indexOf('lwr/loaderLegacy/v/
|
|
402
|
-
GLOBAL.LWR.requiredModules.push('lwr/loaderLegacy/v/
|
|
402
|
+
if (GLOBAL.LWR.requiredModules.indexOf('lwr/loaderLegacy/v/0_13_0-alpha_0') < 0) {
|
|
403
|
+
GLOBAL.LWR.requiredModules.push('lwr/loaderLegacy/v/0_13_0-alpha_0');
|
|
403
404
|
}
|
|
404
405
|
new LoaderShim(GLOBAL);
|
|
405
406
|
|
|
@@ -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 Module Loader Shim v0.
|
|
7
|
+
/* LWR Module Loader Shim v0.13.0-alpha.0 */
|
|
8
8
|
(function () {
|
|
9
9
|
'use strict';
|
|
10
10
|
|
|
@@ -205,7 +205,7 @@
|
|
|
205
205
|
// Parse configuration
|
|
206
206
|
this.global = global;
|
|
207
207
|
this.config = global.LWR ;
|
|
208
|
-
this.loaderSpecifier = 'lwr/loader/v/
|
|
208
|
+
this.loaderSpecifier = 'lwr/loader/v/0_13_0-alpha_0';
|
|
209
209
|
|
|
210
210
|
// Set up error handler
|
|
211
211
|
this.errorHandler = this.config.onError;
|
|
@@ -326,7 +326,7 @@
|
|
|
326
326
|
const exporter = (exports) => {
|
|
327
327
|
Object.assign(exports, { logOperationStart, logOperationEnd });
|
|
328
328
|
};
|
|
329
|
-
globalLWR.define('lwr/profiler/v/
|
|
329
|
+
globalLWR.define('lwr/profiler/v/0_13_0-alpha_0', ['exports'], exporter);
|
|
330
330
|
}
|
|
331
331
|
|
|
332
332
|
// Set up the application globals, import map, root custom element...
|
|
@@ -343,6 +343,7 @@
|
|
|
343
343
|
endpoints,
|
|
344
344
|
imports: imports || {},
|
|
345
345
|
index: index || {},
|
|
346
|
+
env: this.global.LWR.env,
|
|
346
347
|
});
|
|
347
348
|
|
|
348
349
|
// Redefine all modules in the temporary cache
|
|
@@ -398,14 +399,14 @@
|
|
|
398
399
|
// The loader module is ALWAYS required
|
|
399
400
|
const GLOBAL = globalThis ;
|
|
400
401
|
GLOBAL.LWR.requiredModules = GLOBAL.LWR.requiredModules || [];
|
|
401
|
-
if (GLOBAL.LWR.requiredModules.indexOf('lwr/loader/v/
|
|
402
|
-
GLOBAL.LWR.requiredModules.push('lwr/loader/v/
|
|
402
|
+
if (GLOBAL.LWR.requiredModules.indexOf('lwr/loader/v/0_13_0-alpha_0') < 0) {
|
|
403
|
+
GLOBAL.LWR.requiredModules.push('lwr/loader/v/0_13_0-alpha_0');
|
|
403
404
|
}
|
|
404
405
|
new LoaderShim(GLOBAL);
|
|
405
406
|
|
|
406
407
|
})();
|
|
407
408
|
|
|
408
|
-
LWR.define('lwr/loader/v/
|
|
409
|
+
LWR.define('lwr/loader/v/0_13_0-alpha_0', ['exports'], (function (exports) { 'use strict';
|
|
409
410
|
|
|
410
411
|
const templateRegex = /\{([0-9]+)\}/g;
|
|
411
412
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -1048,7 +1049,7 @@ LWR.define('lwr/loader/v/0_12_0-alpha_9', ['exports'], (function (exports) { 'us
|
|
|
1048
1049
|
// swallow
|
|
1049
1050
|
}
|
|
1050
1051
|
const trusted = createPolicy('trusted', policyOptions);
|
|
1051
|
-
/*! version: 0.21.
|
|
1052
|
+
/*! version: 0.21.4 */
|
|
1052
1053
|
|
|
1053
1054
|
/* global console,process */
|
|
1054
1055
|
|
|
@@ -1200,22 +1201,13 @@ LWR.define('lwr/loader/v/0_12_0-alpha_9', ['exports'], (function (exports) { 'us
|
|
|
1200
1201
|
|
|
1201
1202
|
|
|
1202
1203
|
|
|
1204
|
+
|
|
1205
|
+
|
|
1203
1206
|
|
|
1204
1207
|
|
|
1205
1208
|
|
|
1206
1209
|
class ModuleRegistry {
|
|
1207
1210
|
|
|
1208
|
-
|
|
1209
|
-
// A registry for named AMD defines containing the *metadata* of AMD module
|
|
1210
|
-
__init() {this.namedDefineRegistry = new Map();}
|
|
1211
|
-
// The evaluated module registry where the module identifier (name or URL?) is the key
|
|
1212
|
-
__init2() {this.moduleRegistry = new Map();}
|
|
1213
|
-
// Aliases of modules in the registry
|
|
1214
|
-
__init3() {this.aliases = new Map();}
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
1211
|
|
|
1220
1212
|
constructor(config) {ModuleRegistry.prototype.__init.call(this);ModuleRegistry.prototype.__init2.call(this);ModuleRegistry.prototype.__init3.call(this);
|
|
1221
1213
|
this.profiler = config.profiler;
|
|
@@ -1225,9 +1217,6 @@ LWR.define('lwr/loader/v/0_12_0-alpha_9', ['exports'], (function (exports) { 'us
|
|
|
1225
1217
|
);
|
|
1226
1218
|
}
|
|
1227
1219
|
|
|
1228
|
-
/**
|
|
1229
|
-
* Module import
|
|
1230
|
-
*/
|
|
1231
1220
|
async load(id, importer) {
|
|
1232
1221
|
const metadata = importer ? { importer } : {};
|
|
1233
1222
|
this.profiler.logOperationStart({
|
|
@@ -1235,23 +1224,18 @@ LWR.define('lwr/loader/v/0_12_0-alpha_9', ['exports'], (function (exports) { 'us
|
|
|
1235
1224
|
specifier: id,
|
|
1236
1225
|
metadata,
|
|
1237
1226
|
});
|
|
1238
|
-
|
|
1239
1227
|
const resolvedId = await this.resolve(id, importer);
|
|
1240
|
-
const moduleRecord = this.getModuleRecord(resolvedId, id);
|
|
1241
|
-
|
|
1228
|
+
const moduleRecord = await this.getModuleRecord(resolvedId, id);
|
|
1242
1229
|
if (moduleRecord.evaluated) {
|
|
1243
1230
|
return moduleRecord.module;
|
|
1244
1231
|
} else {
|
|
1245
1232
|
if (!moduleRecord.evaluationPromise) {
|
|
1246
|
-
moduleRecord.evaluationPromise = this.
|
|
1233
|
+
moduleRecord.evaluationPromise = this.topLevelEvaluation(moduleRecord);
|
|
1247
1234
|
}
|
|
1248
1235
|
return moduleRecord.evaluationPromise;
|
|
1249
1236
|
}
|
|
1250
1237
|
}
|
|
1251
1238
|
|
|
1252
|
-
/**
|
|
1253
|
-
* Resolve id for a module
|
|
1254
|
-
*/
|
|
1255
1239
|
async resolve(id, importer) {
|
|
1256
1240
|
const parentUrl = this.resolver.getBaseUrl(); // only support baseUrl for now
|
|
1257
1241
|
|
|
@@ -1267,7 +1251,7 @@ LWR.define('lwr/loader/v/0_12_0-alpha_9', ['exports'], (function (exports) { 'us
|
|
|
1267
1251
|
// eslint-disable-next-line no-await-in-loop
|
|
1268
1252
|
result = isResponseAPromise(response) ? await response : response;
|
|
1269
1253
|
}
|
|
1270
|
-
if (!isValidResolveResponse(result)) {
|
|
1254
|
+
if (!this.isValidResolveResponse(result)) {
|
|
1271
1255
|
throw new LoaderError(INVALID_LOADER_SERVICE_RESPONSE);
|
|
1272
1256
|
}
|
|
1273
1257
|
|
|
@@ -1353,9 +1337,6 @@ LWR.define('lwr/loader/v/0_12_0-alpha_9', ['exports'], (function (exports) { 'us
|
|
|
1353
1337
|
return this.moduleRegistry.has(id);
|
|
1354
1338
|
}
|
|
1355
1339
|
|
|
1356
|
-
/**
|
|
1357
|
-
* Module entry point LWR.define()
|
|
1358
|
-
*/
|
|
1359
1340
|
define(name, dependencies, exporter) {
|
|
1360
1341
|
const mod = this.namedDefineRegistry.get(name);
|
|
1361
1342
|
// Don't allow redefining a module.
|
|
@@ -1422,6 +1403,19 @@ LWR.define('lwr/loader/v/0_12_0-alpha_9', ['exports'], (function (exports) { 'us
|
|
|
1422
1403
|
});
|
|
1423
1404
|
}
|
|
1424
1405
|
|
|
1406
|
+
|
|
1407
|
+
|
|
1408
|
+
// A registry for named AMD defines containing the *metadata* of AMD module
|
|
1409
|
+
__init() {this.namedDefineRegistry = new Map();}
|
|
1410
|
+
|
|
1411
|
+
// The evaluated module registry where the module identifier (name or URL?) is the key
|
|
1412
|
+
__init2() {this.moduleRegistry = new Map();}
|
|
1413
|
+
|
|
1414
|
+
// Aliases of modules in the registry
|
|
1415
|
+
__init3() {this.aliases = new Map();}
|
|
1416
|
+
|
|
1417
|
+
|
|
1418
|
+
|
|
1425
1419
|
getImportMetadataResolver() {
|
|
1426
1420
|
return this.resolver;
|
|
1427
1421
|
}
|
|
@@ -1447,7 +1441,7 @@ LWR.define('lwr/loader/v/0_12_0-alpha_9', ['exports'], (function (exports) { 'us
|
|
|
1447
1441
|
return moduleRecord;
|
|
1448
1442
|
}
|
|
1449
1443
|
|
|
1450
|
-
getModuleRecord(resolvedId, id) {
|
|
1444
|
+
async getModuleRecord(resolvedId, id) {
|
|
1451
1445
|
// Look for an existing record
|
|
1452
1446
|
const existingRecord = this.getExistingModuleRecord(resolvedId, id);
|
|
1453
1447
|
if (existingRecord) {
|
|
@@ -1455,10 +1449,29 @@ LWR.define('lwr/loader/v/0_12_0-alpha_9', ['exports'], (function (exports) { 'us
|
|
|
1455
1449
|
return existingRecord;
|
|
1456
1450
|
}
|
|
1457
1451
|
|
|
1452
|
+
// Create a new Module Record
|
|
1453
|
+
const instantiation = this.getModuleDef(resolvedId, id);
|
|
1454
|
+
const dependencyRecords = instantiation.then((moduleDef) => {
|
|
1455
|
+
const dependencies = moduleDef.dependencies || [];
|
|
1456
|
+
// get dep and filter out exports
|
|
1457
|
+
const filtered = dependencies
|
|
1458
|
+
.map((dep) => {
|
|
1459
|
+
if (dep === 'exports') {
|
|
1460
|
+
return;
|
|
1461
|
+
}
|
|
1462
|
+
invariant(dep !== 'require', NO_AMD_REQUIRE);
|
|
1463
|
+
return this.getModuleDependencyRecord.call(this, dep);
|
|
1464
|
+
})
|
|
1465
|
+
.filter((depRecord) => depRecord !== undefined) ;
|
|
1466
|
+
|
|
1467
|
+
return Promise.all(filtered);
|
|
1468
|
+
});
|
|
1469
|
+
|
|
1458
1470
|
const newModuleRecord = {
|
|
1459
1471
|
id: resolvedId,
|
|
1460
1472
|
module: Object.create(null),
|
|
1461
|
-
|
|
1473
|
+
dependencyRecords,
|
|
1474
|
+
instantiation,
|
|
1462
1475
|
evaluated: false,
|
|
1463
1476
|
evaluationPromise: null,
|
|
1464
1477
|
};
|
|
@@ -1466,7 +1479,8 @@ LWR.define('lwr/loader/v/0_12_0-alpha_9', ['exports'], (function (exports) { 'us
|
|
|
1466
1479
|
this.moduleRegistry.set(resolvedId, newModuleRecord);
|
|
1467
1480
|
this.storeModuleAlias(id, resolvedId);
|
|
1468
1481
|
|
|
1469
|
-
return
|
|
1482
|
+
// Wait for the dependencies to resolve the return the moduleRecord
|
|
1483
|
+
return dependencyRecords.then(() => newModuleRecord);
|
|
1470
1484
|
}
|
|
1471
1485
|
|
|
1472
1486
|
storeModuleAlias(aliasId, resolvedId) {
|
|
@@ -1487,87 +1501,95 @@ LWR.define('lwr/loader/v/0_12_0-alpha_9', ['exports'], (function (exports) { 'us
|
|
|
1487
1501
|
}
|
|
1488
1502
|
}
|
|
1489
1503
|
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
async evaluateDependencies(
|
|
1494
|
-
dependencies,
|
|
1495
|
-
evaluationMap,
|
|
1496
|
-
) {
|
|
1497
|
-
const exports = {};
|
|
1498
|
-
const promiseArray = [];
|
|
1499
|
-
|
|
1500
|
-
if (dependencies) {
|
|
1501
|
-
for (const dep of dependencies) {
|
|
1502
|
-
if (dep === 'exports') {
|
|
1503
|
-
promiseArray.push(Promise.resolve(exports));
|
|
1504
|
-
} else {
|
|
1505
|
-
invariant(dep !== 'require', NO_AMD_REQUIRE);
|
|
1506
|
-
promiseArray.push(this.evaluateDependent(dep, evaluationMap));
|
|
1507
|
-
}
|
|
1508
|
-
}
|
|
1509
|
-
}
|
|
1510
|
-
|
|
1511
|
-
return Promise.all(promiseArray).then((results) => {
|
|
1512
|
-
const depsMapped = results.filter((result) => result !== undefined);
|
|
1513
|
-
return { depsMapped, exports };
|
|
1514
|
-
});
|
|
1504
|
+
async getModuleDependencyRecord(dependency) {
|
|
1505
|
+
const resolvedDepId = await this.resolve(dependency);
|
|
1506
|
+
return this.getModuleRecord(resolvedDepId, dependency);
|
|
1515
1507
|
}
|
|
1516
1508
|
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
const handleReturn = (module) => {
|
|
1524
|
-
if (module) {
|
|
1525
|
-
return module.__defaultInterop ? module.default : module;
|
|
1526
|
-
}
|
|
1527
|
-
throw new LoaderError(FAILED_DEP, [resolvedDepId]);
|
|
1528
|
-
};
|
|
1509
|
+
// execute the "top-level code" (the code outside of functions) of a module
|
|
1510
|
+
async topLevelEvaluation(moduleRecord) {
|
|
1511
|
+
await this.instantiateAll(moduleRecord, {});
|
|
1512
|
+
return this.evaluateModule(moduleRecord, {});
|
|
1513
|
+
}
|
|
1529
1514
|
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1515
|
+
// Returns a promise when a module and all of it's dependencies have finished instantiation
|
|
1516
|
+
async instantiateAll(
|
|
1517
|
+
moduleRecord,
|
|
1518
|
+
instantiatedMap,
|
|
1519
|
+
) {
|
|
1520
|
+
if (!instantiatedMap[moduleRecord.id]) {
|
|
1521
|
+
instantiatedMap[moduleRecord.id] = true;
|
|
1522
|
+
const dependencyModuleRecords = await moduleRecord.dependencyRecords;
|
|
1523
|
+
if (dependencyModuleRecords) {
|
|
1524
|
+
for (let i = 0; i < dependencyModuleRecords.length; i++) {
|
|
1525
|
+
const depRecord = dependencyModuleRecords[i];
|
|
1526
|
+
// eslint-disable-next-line no-await-in-loop
|
|
1527
|
+
await this.instantiateAll(depRecord, instantiatedMap);
|
|
1528
|
+
}
|
|
1544
1529
|
}
|
|
1545
|
-
return depModuleRecord.evaluationPromise.then((module) => {
|
|
1546
|
-
return handleReturn(module);
|
|
1547
|
-
});
|
|
1548
|
-
} else {
|
|
1549
|
-
// Otherwise return a dummy circular module wrapper
|
|
1550
|
-
module = getCircularDependencyWrapper(module);
|
|
1551
1530
|
}
|
|
1552
|
-
return handleReturn(module);
|
|
1553
1531
|
}
|
|
1554
1532
|
|
|
1555
1533
|
async evaluateModule(
|
|
1556
1534
|
moduleRecord,
|
|
1557
1535
|
evaluationMap,
|
|
1558
1536
|
) {
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1537
|
+
const dependencyModuleRecords = await moduleRecord.dependencyRecords;
|
|
1538
|
+
if (dependencyModuleRecords.length > 0) {
|
|
1539
|
+
evaluationMap[moduleRecord.id] = true;
|
|
1540
|
+
// evaluate dependencies first
|
|
1541
|
+
await this.evaluateModuleDependencies(dependencyModuleRecords, evaluationMap);
|
|
1542
|
+
}
|
|
1562
1543
|
|
|
1563
|
-
// Wait for load to finish
|
|
1564
1544
|
const { exporter, dependencies } = await moduleRecord.instantiation;
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
const
|
|
1545
|
+
// The exports object automatically gets filled in by the exporter evaluation
|
|
1546
|
+
const exports = {};
|
|
1547
|
+
const depsMapped = dependencies
|
|
1548
|
+
? await Promise.all(
|
|
1549
|
+
dependencies.map(async (dep) => {
|
|
1550
|
+
if (dep === 'exports') {
|
|
1551
|
+
return exports;
|
|
1552
|
+
}
|
|
1553
|
+
const resolvedDepId = await this.resolve(dep);
|
|
1554
|
+
|
|
1555
|
+
const moduleRecord = this.moduleRegistry.get(resolvedDepId) ;
|
|
1556
|
+
if (!moduleRecord) {
|
|
1557
|
+
throw new LoaderError(FAILED_DEP, [resolvedDepId]);
|
|
1558
|
+
}
|
|
1559
|
+
|
|
1560
|
+
const module = moduleRecord.module;
|
|
1561
|
+
|
|
1562
|
+
/**
|
|
1563
|
+
* Circular dependencies are handled properly when named exports are used,
|
|
1564
|
+
* however, for default exports there is a bug: https://github.com/rollup/rollup/issues/3384
|
|
1565
|
+
*
|
|
1566
|
+
* The workaround below applies for circular dependencies (!moduleRecord.evaluated)
|
|
1567
|
+
*/
|
|
1568
|
+
if (!moduleRecord.evaluated) {
|
|
1569
|
+
return this.getCircularDependencyWrapper(module);
|
|
1570
|
+
}
|
|
1571
|
+
|
|
1572
|
+
if (module) {
|
|
1573
|
+
return module.__defaultInterop ? module.default : module;
|
|
1574
|
+
}
|
|
1575
|
+
|
|
1576
|
+
throw new LoaderError(FAILED_DEP, [resolvedDepId]);
|
|
1577
|
+
}),
|
|
1578
|
+
)
|
|
1579
|
+
: [];
|
|
1580
|
+
|
|
1581
|
+
// 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
|
|
1582
|
+
if (moduleRecord.evaluated) {
|
|
1583
|
+
return moduleRecord.module;
|
|
1584
|
+
}
|
|
1568
1585
|
|
|
1569
1586
|
// evaluates the module function
|
|
1570
|
-
let moduleDefault
|
|
1587
|
+
let moduleDefault;
|
|
1588
|
+
try {
|
|
1589
|
+
moduleDefault = exporter(...depsMapped);
|
|
1590
|
+
} catch (e) {
|
|
1591
|
+
throw new LoaderError(EXPORTER_ERROR, [moduleRecord.id, e.message || e]);
|
|
1592
|
+
}
|
|
1571
1593
|
// value is returned from exporter, then we are not using named exports
|
|
1572
1594
|
if (moduleDefault !== undefined) {
|
|
1573
1595
|
moduleDefault = { default: moduleDefault };
|
|
@@ -1579,7 +1601,7 @@ LWR.define('lwr/loader/v/0_12_0-alpha_9', ['exports'], (function (exports) { 'us
|
|
|
1579
1601
|
// if no return value, then we are using the exports object
|
|
1580
1602
|
else {
|
|
1581
1603
|
// handle only default export with Rollup forced named exports
|
|
1582
|
-
if (isNamedExportDefaultOnly(exports)) {
|
|
1604
|
+
if (this.isNamedExportDefaultOnly(exports)) {
|
|
1583
1605
|
Object.defineProperty(exports, '__useDefault', { value: true });
|
|
1584
1606
|
}
|
|
1585
1607
|
}
|
|
@@ -1611,17 +1633,42 @@ LWR.define('lwr/loader/v/0_12_0-alpha_9', ['exports'], (function (exports) { 'us
|
|
|
1611
1633
|
Object.defineProperty(moduleRecord.module, '__esModule', { value: true });
|
|
1612
1634
|
}
|
|
1613
1635
|
|
|
1614
|
-
Object.freeze(moduleRecord.module);
|
|
1615
1636
|
moduleRecord.evaluated = true;
|
|
1616
|
-
moduleRecord.
|
|
1637
|
+
Object.freeze(moduleRecord.module);
|
|
1617
1638
|
return moduleRecord.module;
|
|
1618
1639
|
}
|
|
1619
1640
|
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1641
|
+
// Determines if named exports module has only default export
|
|
1642
|
+
isNamedExportDefaultOnly(exports) {
|
|
1643
|
+
return (
|
|
1644
|
+
exports !== undefined &&
|
|
1645
|
+
Object.getOwnPropertyNames(exports).length === 2 &&
|
|
1646
|
+
Object.prototype.hasOwnProperty.call(exports, 'default') &&
|
|
1647
|
+
Object.prototype.hasOwnProperty.call(exports, '__esModule')
|
|
1648
|
+
);
|
|
1649
|
+
}
|
|
1650
|
+
|
|
1651
|
+
// Wrap the dependency in a function that can be called and detected by __circular__ property.
|
|
1652
|
+
// The LWC engine checks for __circular__ to detect circular dependencies.
|
|
1653
|
+
getCircularDependencyWrapper(module) {
|
|
1654
|
+
const tmp = () => {
|
|
1655
|
+
return module.__useDefault || module.__defaultInterop ? module.default : module;
|
|
1656
|
+
};
|
|
1657
|
+
tmp.__circular__ = true;
|
|
1658
|
+
return tmp;
|
|
1659
|
+
}
|
|
1660
|
+
|
|
1661
|
+
async evaluateModuleDependencies(
|
|
1662
|
+
dependencyModuleRecords,
|
|
1663
|
+
evaluationMap,
|
|
1664
|
+
) {
|
|
1665
|
+
for (let i = 0; i < dependencyModuleRecords.length; i++) {
|
|
1666
|
+
const depRecord = dependencyModuleRecords[i];
|
|
1667
|
+
if (!depRecord.evaluated && !evaluationMap[depRecord.id]) {
|
|
1668
|
+
evaluationMap[depRecord.id] = true;
|
|
1669
|
+
// eslint-disable-next-line no-await-in-loop
|
|
1670
|
+
await this.evaluateModule(depRecord, evaluationMap);
|
|
1671
|
+
}
|
|
1625
1672
|
}
|
|
1626
1673
|
}
|
|
1627
1674
|
|
|
@@ -1633,8 +1680,8 @@ LWR.define('lwr/loader/v/0_12_0-alpha_9', ['exports'], (function (exports) { 'us
|
|
|
1633
1680
|
const moduleName = !isUrl(resolvedId)
|
|
1634
1681
|
? resolvedId
|
|
1635
1682
|
: originalId !== resolvedId
|
|
1636
|
-
|
|
1637
|
-
|
|
1683
|
+
? originalId
|
|
1684
|
+
: undefined;
|
|
1638
1685
|
let moduleDef = moduleName && this.namedDefineRegistry.get(moduleName);
|
|
1639
1686
|
if (moduleDef && moduleDef.external) {
|
|
1640
1687
|
return moduleDef.external.moduleDefPromise;
|
|
@@ -1701,6 +1748,9 @@ LWR.define('lwr/loader/v/0_12_0-alpha_9', ['exports'], (function (exports) { 'us
|
|
|
1701
1748
|
});
|
|
1702
1749
|
}
|
|
1703
1750
|
|
|
1751
|
+
|
|
1752
|
+
|
|
1753
|
+
|
|
1704
1754
|
addLoaderPlugin(hooks) {
|
|
1705
1755
|
if (typeof hooks !== 'object') {
|
|
1706
1756
|
throw new LoaderError(INVALID_HOOK);
|
|
@@ -1742,6 +1792,7 @@ LWR.define('lwr/loader/v/0_12_0-alpha_9', ['exports'], (function (exports) { 'us
|
|
|
1742
1792
|
}
|
|
1743
1793
|
}
|
|
1744
1794
|
|
|
1795
|
+
|
|
1745
1796
|
registerHandleStaleModuleHook(handleStaleModule) {
|
|
1746
1797
|
if (this.handleStaleModuleHook) {
|
|
1747
1798
|
this.handleStaleModuleHook.push(handleStaleModule);
|
|
@@ -1749,30 +1800,12 @@ LWR.define('lwr/loader/v/0_12_0-alpha_9', ['exports'], (function (exports) { 'us
|
|
|
1749
1800
|
this.handleStaleModuleHook = [handleStaleModule];
|
|
1750
1801
|
}
|
|
1751
1802
|
}
|
|
1752
|
-
}
|
|
1753
1803
|
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
Object.prototype.hasOwnProperty.call(exports, 'default') &&
|
|
1760
|
-
Object.prototype.hasOwnProperty.call(exports, '__esModule')
|
|
1761
|
-
);
|
|
1762
|
-
}
|
|
1763
|
-
|
|
1764
|
-
// Wrap the dependency in a function that can be called and detected by __circular__ property.
|
|
1765
|
-
// The LWC engine checks for __circular__ to detect circular dependencies.
|
|
1766
|
-
function getCircularDependencyWrapper(module) {
|
|
1767
|
-
const tmp = () => {
|
|
1768
|
-
return module.__useDefault || module.__defaultInterop ? module.default : module;
|
|
1769
|
-
};
|
|
1770
|
-
tmp.__circular__ = true;
|
|
1771
|
-
return tmp;
|
|
1772
|
-
}
|
|
1773
|
-
|
|
1774
|
-
function isValidResolveResponse(res) {
|
|
1775
|
-
return res === null || typeof res === 'string' || (res && typeof (res ).url === 'string');
|
|
1804
|
+
isValidResolveResponse(res) {
|
|
1805
|
+
return (
|
|
1806
|
+
res === null || typeof res === 'string' || (res && typeof (res ).url === 'string')
|
|
1807
|
+
);
|
|
1808
|
+
}
|
|
1776
1809
|
}
|
|
1777
1810
|
|
|
1778
1811
|
/**
|