@lwrjs/loader 0.19.2 → 0.19.4

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.
@@ -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.19.2 */
7
+ /* LWR Module Loader Shim v0.19.4 */
8
8
  (function () {
9
9
  'use strict';
10
10
 
@@ -213,7 +213,7 @@
213
213
  // Parse configuration
214
214
  this.global = global;
215
215
  this.config = global.LWR ;
216
- this.loaderSpecifier = 'lwr/loader/v/0_19_2';
216
+ this.loaderSpecifier = 'lwr/loader/v/0_19_4';
217
217
 
218
218
  // Set up error handler
219
219
  this.errorHandler = this.config.onError ;
@@ -364,7 +364,7 @@
364
364
  const exporter = (exports) => {
365
365
  Object.assign(exports, { logOperationStart, logOperationEnd });
366
366
  };
367
- define('lwr/profiler/v/0_19_2', ['exports'], exporter);
367
+ define('lwr/profiler/v/0_19_4', ['exports'], exporter);
368
368
  }
369
369
 
370
370
  // Set up the application globals, import map, root custom element...
@@ -456,8 +456,8 @@
456
456
  // The loader module is ALWAYS required
457
457
  const GLOBAL = globalThis ;
458
458
  GLOBAL.LWR.requiredModules = GLOBAL.LWR.requiredModules || [];
459
- if (GLOBAL.LWR.requiredModules.indexOf('lwr/loader/v/0_19_2') < 0) {
460
- GLOBAL.LWR.requiredModules.push('lwr/loader/v/0_19_2');
459
+ if (GLOBAL.LWR.requiredModules.indexOf('lwr/loader/v/0_19_4') < 0) {
460
+ GLOBAL.LWR.requiredModules.push('lwr/loader/v/0_19_4');
461
461
  }
462
462
  new LoaderShim(GLOBAL);
463
463
 
@@ -208,14 +208,30 @@ var ModuleRegistry = class {
208
208
  getImportMetadataResolver() {
209
209
  return this.resolver;
210
210
  }
211
- getExistingModuleRecord(resolvedId, aliasId) {
212
- const moduleRecord = this.moduleRegistry.get(resolvedId);
213
- if (moduleRecord) {
214
- this.storeModuleAlias(aliasId, resolvedId);
215
- return moduleRecord;
216
- }
217
- if (resolvedId !== aliasId) {
218
- const alias = this.aliases.get(aliasId);
211
+ async getModuleRecord(resolvedId, originalId) {
212
+ const existingRecord = this.moduleRegistry.get(resolvedId);
213
+ if (existingRecord) {
214
+ if ((0, import_url.isUrl)(resolvedId)) {
215
+ const moduleDef = await existingRecord.instantiation;
216
+ const reResolvedId = await this.resolve(originalId);
217
+ if ((0, import_url.isUrl)(reResolvedId) || moduleDef.name === reResolvedId) {
218
+ this.storeModuleAlias(originalId, reResolvedId);
219
+ return existingRecord;
220
+ } else {
221
+ resolvedId = reResolvedId;
222
+ const reExistingRecord = this.moduleRegistry.get(resolvedId);
223
+ if (reExistingRecord) {
224
+ this.storeModuleAlias(originalId, reResolvedId);
225
+ return reExistingRecord;
226
+ }
227
+ }
228
+ } else if (existingRecord) {
229
+ this.storeModuleAlias(originalId, resolvedId);
230
+ return existingRecord;
231
+ }
232
+ }
233
+ if (resolvedId !== originalId) {
234
+ const alias = this.aliases.get(originalId);
219
235
  if (alias) {
220
236
  const aliasedModule = this.moduleRegistry.get(alias);
221
237
  if (aliasedModule) {
@@ -223,14 +239,7 @@ var ModuleRegistry = class {
223
239
  }
224
240
  }
225
241
  }
226
- return moduleRecord;
227
- }
228
- async getModuleRecord(resolvedId, id) {
229
- const existingRecord = this.getExistingModuleRecord(resolvedId, id);
230
- if (existingRecord) {
231
- return existingRecord;
232
- }
233
- const instantiation = this.getModuleDef(resolvedId, id);
242
+ const instantiation = this.getModuleDef(resolvedId, originalId);
234
243
  const dependencyRecords = instantiation.then((moduleDef) => {
235
244
  const dependencies = moduleDef.dependencies || [];
236
245
  const filtered = dependencies.map((dep) => {
@@ -244,6 +253,7 @@ var ModuleRegistry = class {
244
253
  });
245
254
  const newModuleRecord = {
246
255
  id: resolvedId,
256
+ originalId,
247
257
  module: Object.create(null),
248
258
  dependencyRecords,
249
259
  instantiation,
@@ -251,7 +261,9 @@ var ModuleRegistry = class {
251
261
  evaluationPromise: null
252
262
  };
253
263
  this.moduleRegistry.set(resolvedId, newModuleRecord);
254
- this.storeModuleAlias(id, resolvedId);
264
+ if (resolvedId !== originalId) {
265
+ this.storeModuleAlias(originalId, resolvedId);
266
+ }
255
267
  return dependencyRecords.then(() => newModuleRecord);
256
268
  }
257
269
  storeModuleAlias(aliasId, resolvedId) {
@@ -30,6 +30,7 @@ __export(exports, {
30
30
  FAIL_HOOK_LOAD: () => FAIL_HOOK_LOAD,
31
31
  FAIL_INSTANTIATE: () => FAIL_INSTANTIATE,
32
32
  FAIL_LOAD: () => FAIL_LOAD,
33
+ FAIL_LOAD_EMPTY_CODE: () => FAIL_LOAD_EMPTY_CODE,
33
34
  HOOK_ALREADY_SET: () => HOOK_ALREADY_SET,
34
35
  HTTP_FAIL_LOAD: () => HTTP_FAIL_LOAD,
35
36
  INVALID_DEPS: () => INVALID_DEPS,
@@ -94,6 +95,11 @@ var FAIL_LOAD = Object.freeze({
94
95
  level: 0,
95
96
  message: "Error loading {0}"
96
97
  });
98
+ var FAIL_LOAD_EMPTY_CODE = Object.freeze({
99
+ code: 3008,
100
+ level: 0,
101
+ message: "Error loading empty code for {0}"
102
+ });
97
103
  var UNRESOLVED = Object.freeze({
98
104
  code: 3009,
99
105
  level: 0,
@@ -72,7 +72,7 @@ async function evaluateLoadHookResponse(response, id) {
72
72
  throw new import_messages.LoaderError(import_messages.INVALID_LOADER_SERVICE_RESPONSE);
73
73
  }
74
74
  if (!code) {
75
- throw new import_messages.LoaderError(import_messages.FAIL_LOAD, [id]);
75
+ throw new import_messages.LoaderError(import_messages.FAIL_LOAD, [`empty code for ${id}`]);
76
76
  }
77
77
  code = `${code}
78
78
  //# sourceURL=${id}`;
@@ -82,10 +82,12 @@ async function evaluateLoadHookResponse(response, id) {
82
82
  if (process.env.NODE_ENV !== "production" && import_dom.hasConsole) {
83
83
  console.error(e);
84
84
  }
85
- throw new import_messages.LoaderError(import_messages.FAIL_LOAD, [id]);
85
+ throw new import_messages.LoaderError(import_messages.FAIL_LOAD, [`"${id}": ${e instanceof Error ? e.message : String(e)}`]);
86
86
  }
87
87
  if (lastWindowError) {
88
- throw new import_messages.LoaderError(import_messages.FAIL_LOAD, [id]);
88
+ throw new import_messages.LoaderError(import_messages.FAIL_LOAD, [
89
+ `"${id}": window error ${lastWindowError instanceof Error ? lastWindowError.message : String(lastWindowError)}`
90
+ ]);
89
91
  }
90
92
  return true;
91
93
  });
@@ -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 ESM Module Loader v0.19.2 */
7
+ /* LWR ESM Module Loader v0.19.4 */
8
8
  function _optionalChain$1(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
9
9
 
10
10
 
@@ -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 v0.19.2 */
7
+ /* LWR Module Loader v0.19.4 */
8
8
  const templateRegex = /\{([0-9]+)\}/g;
9
9
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
10
10
  function templateString(template, args) {
@@ -693,7 +693,7 @@ try {
693
693
  // swallow
694
694
  }
695
695
  const trusted = createPolicy('trusted', policyOptions);
696
- /*! version: 0.24.6 */
696
+ /*! version: 0.25.3 */
697
697
 
698
698
  /* global console,process */
699
699
 
@@ -850,6 +850,7 @@ async function evaluateLoadHook(
850
850
 
851
851
 
852
852
 
853
+
853
854
 
854
855
 
855
856
  class ModuleRegistry {
@@ -1089,46 +1090,78 @@ class ModuleRegistry {
1089
1090
  return this.resolver;
1090
1091
  }
1091
1092
 
1092
- // Returns an existing module record by the resolvedId or aliased id
1093
- getExistingModuleRecord(resolvedId, aliasId) {
1094
- const moduleRecord = this.moduleRegistry.get(resolvedId);
1095
- if (moduleRecord) {
1096
- this.storeModuleAlias(aliasId, resolvedId);
1097
- return moduleRecord;
1093
+ /**
1094
+ * Gets or creates a module record for the given resolved ID and original ID.
1095
+ *
1096
+ * This function handles the complex logic of module resolution and ensures that:
1097
+ * 1. Modules loaded via different paths (aliases, direct specifiers, URLs) return the same instance
1098
+ * 2. Bundle URLs are properly resolved to their final specifier names after instantiation
1099
+ * 3. Alias mappings are maintained for future lookups
1100
+ *
1101
+ * @param resolvedId - The resolved module identifier (could be a URL or specifier)
1102
+ * @param originalId - The original module specifer that was requested
1103
+ * @returns Promise<ModuleRecord> - The module record for the module
1104
+ */
1105
+ async getModuleRecord(resolvedId, originalId) {
1106
+ // Step 1: Check if we already have a module record for the resolved ID
1107
+ const existingRecord = this.moduleRegistry.get(resolvedId);
1108
+ if (existingRecord) {
1109
+ if (isUrl(resolvedId)) {
1110
+ // Special case: The resolved ID is a URL (likely a bundle URL)
1111
+ // We need to wait for instantiation to complete, then re-resolve to get the final specifier
1112
+ const moduleDef = await existingRecord.instantiation;
1113
+
1114
+ const reResolvedId = await this.resolve(originalId);
1115
+
1116
+ // If the re-resolved ID is still a URL OR matches the module definition name,
1117
+ // then this is an internally mapped module (e.g., bundle -> specifier)
1118
+ if (isUrl(reResolvedId) || moduleDef.name === reResolvedId) {
1119
+ // Store the alias mapping and return the existing record
1120
+ this.storeModuleAlias(originalId, reResolvedId);
1121
+ return existingRecord;
1122
+ } else {
1123
+ // The re-resolved ID is now a specifier, check if we have a record for it
1124
+ resolvedId = reResolvedId;
1125
+ const reExistingRecord = this.moduleRegistry.get(resolvedId);
1126
+ if (reExistingRecord) {
1127
+ // Found a record for the specifier, store alias and return it
1128
+ this.storeModuleAlias(originalId, reResolvedId);
1129
+ return reExistingRecord;
1130
+ }
1131
+ }
1132
+ } else if (existingRecord) {
1133
+ // Simple case: resolved ID is a specifier and we have a record for it
1134
+ this.storeModuleAlias(originalId, resolvedId);
1135
+ return existingRecord;
1136
+ }
1098
1137
  }
1099
1138
 
1100
- // Check if this is a known alias
1101
- if (resolvedId !== aliasId) {
1102
- const alias = this.aliases.get(aliasId);
1139
+ // Step 2: Check if the original ID is a known alias that maps to an existing module
1140
+ if (resolvedId !== originalId) {
1141
+ const alias = this.aliases.get(originalId);
1103
1142
  if (alias) {
1104
1143
  const aliasedModule = this.moduleRegistry.get(alias);
1105
1144
  if (aliasedModule) {
1145
+ // Found an existing module via alias, return it
1106
1146
  return aliasedModule;
1107
1147
  }
1108
1148
  }
1109
1149
  }
1110
- return moduleRecord;
1111
- }
1112
1150
 
1113
- async getModuleRecord(resolvedId, id) {
1114
- // Look for an existing record
1115
- const existingRecord = this.getExistingModuleRecord(resolvedId, id);
1116
- if (existingRecord) {
1117
- // return existing
1118
- return existingRecord;
1119
- }
1151
+ // Step 3: No existing record found, create a new module record
1152
+ const instantiation = this.getModuleDef(resolvedId, originalId);
1120
1153
 
1121
- // Create a new Module Record
1122
- const instantiation = this.getModuleDef(resolvedId, id);
1154
+ // Create dependency records for all module dependencies
1123
1155
  const dependencyRecords = instantiation.then((moduleDef) => {
1124
1156
  const dependencies = moduleDef.dependencies || [];
1125
- // get dep and filter out exports
1157
+
1158
+ // Map dependencies to module records, filtering out 'exports' and 'require'
1126
1159
  const filtered = dependencies
1127
1160
  .map((dep) => {
1128
1161
  if (dep === 'exports') {
1129
- return;
1162
+ return; // 'exports' is a special AMD dependency, not a real module
1130
1163
  }
1131
- invariant(dep !== 'require', NO_AMD_REQUIRE);
1164
+ invariant(dep !== 'require', NO_AMD_REQUIRE); // 'require' is not allowed
1132
1165
  return this.getModuleDependencyRecord.call(this, dep);
1133
1166
  })
1134
1167
  .filter((depRecord) => depRecord !== undefined) ;
@@ -1136,19 +1169,23 @@ class ModuleRegistry {
1136
1169
  return Promise.all(filtered);
1137
1170
  });
1138
1171
 
1172
+ // Create the new module record
1139
1173
  const newModuleRecord = {
1140
- id: resolvedId,
1141
- module: Object.create(null),
1142
- dependencyRecords,
1143
- instantiation,
1144
- evaluated: false,
1145
- evaluationPromise: null,
1174
+ id: resolvedId, // Use resolved ID as the record identifier
1175
+ originalId: originalId, // Keep track of the original requested ID
1176
+ module: Object.create(null), // Empty object for module exports
1177
+ dependencyRecords, // Promise for dependency module records
1178
+ instantiation, // Promise for module definition
1179
+ evaluated: false, // Track if module has been evaluated
1180
+ evaluationPromise: null, // Promise for module evaluation
1146
1181
  };
1147
1182
 
1183
+ // Store the module record and create alias mapping
1148
1184
  this.moduleRegistry.set(resolvedId, newModuleRecord);
1149
- this.storeModuleAlias(id, resolvedId);
1150
-
1151
- // Wait for the dependencies to resolve the return the moduleRecord
1185
+ if (resolvedId !== originalId) {
1186
+ this.storeModuleAlias(originalId, resolvedId);
1187
+ }
1188
+ // Wait for dependencies to resolve before returning the module record
1152
1189
  return dependencyRecords.then(() => newModuleRecord);
1153
1190
  }
1154
1191
 
@@ -1444,7 +1481,6 @@ class ModuleRegistry {
1444
1481
 
1445
1482
 
1446
1483
 
1447
-
1448
1484
  addLoaderPlugin(hooks) {
1449
1485
  if (typeof hooks !== 'object') {
1450
1486
  throw new LoaderError(INVALID_HOOK);
@@ -26,7 +26,18 @@ export declare class ModuleRegistry {
26
26
  aliases: Map<string, string>;
27
27
  private lastDefine;
28
28
  getImportMetadataResolver(): ImportMetadataResolver;
29
- private getExistingModuleRecord;
29
+ /**
30
+ * Gets or creates a module record for the given resolved ID and original ID.
31
+ *
32
+ * This function handles the complex logic of module resolution and ensures that:
33
+ * 1. Modules loaded via different paths (aliases, direct specifiers, URLs) return the same instance
34
+ * 2. Bundle URLs are properly resolved to their final specifier names after instantiation
35
+ * 3. Alias mappings are maintained for future lookups
36
+ *
37
+ * @param resolvedId - The resolved module identifier (could be a URL or specifier)
38
+ * @param originalId - The original module specifer that was requested
39
+ * @returns Promise<ModuleRecord> - The module record for the module
40
+ */
30
41
  private getModuleRecord;
31
42
  private storeModuleAlias;
32
43
  private getModuleDependencyRecord;
@@ -39,7 +50,6 @@ export declare class ModuleRegistry {
39
50
  private getModuleDef;
40
51
  private resolveHook?;
41
52
  private loadHook?;
42
- private loadMappingHooks?;
43
53
  addLoaderPlugin(hooks: LoaderHooks): void;
44
54
  private importMetadataInvalidationCallback;
45
55
  private handleStaleModuleHook?;
@@ -214,59 +214,95 @@ export class ModuleRegistry {
214
214
  getImportMetadataResolver() {
215
215
  return this.resolver;
216
216
  }
217
- // Returns an existing module record by the resolvedId or aliased id
218
- getExistingModuleRecord(resolvedId, aliasId) {
219
- const moduleRecord = this.moduleRegistry.get(resolvedId);
220
- if (moduleRecord) {
221
- this.storeModuleAlias(aliasId, resolvedId);
222
- return moduleRecord;
223
- }
224
- // Check if this is a known alias
225
- if (resolvedId !== aliasId) {
226
- const alias = this.aliases.get(aliasId);
217
+ /**
218
+ * Gets or creates a module record for the given resolved ID and original ID.
219
+ *
220
+ * This function handles the complex logic of module resolution and ensures that:
221
+ * 1. Modules loaded via different paths (aliases, direct specifiers, URLs) return the same instance
222
+ * 2. Bundle URLs are properly resolved to their final specifier names after instantiation
223
+ * 3. Alias mappings are maintained for future lookups
224
+ *
225
+ * @param resolvedId - The resolved module identifier (could be a URL or specifier)
226
+ * @param originalId - The original module specifer that was requested
227
+ * @returns Promise<ModuleRecord> - The module record for the module
228
+ */
229
+ async getModuleRecord(resolvedId, originalId) {
230
+ // Step 1: Check if we already have a module record for the resolved ID
231
+ const existingRecord = this.moduleRegistry.get(resolvedId);
232
+ if (existingRecord) {
233
+ if (isUrl(resolvedId)) {
234
+ // Special case: The resolved ID is a URL (likely a bundle URL)
235
+ // We need to wait for instantiation to complete, then re-resolve to get the final specifier
236
+ const moduleDef = await existingRecord.instantiation;
237
+ const reResolvedId = await this.resolve(originalId);
238
+ // If the re-resolved ID is still a URL OR matches the module definition name,
239
+ // then this is an internally mapped module (e.g., bundle -> specifier)
240
+ if (isUrl(reResolvedId) || moduleDef.name === reResolvedId) {
241
+ // Store the alias mapping and return the existing record
242
+ this.storeModuleAlias(originalId, reResolvedId);
243
+ return existingRecord;
244
+ }
245
+ else {
246
+ // The re-resolved ID is now a specifier, check if we have a record for it
247
+ resolvedId = reResolvedId;
248
+ const reExistingRecord = this.moduleRegistry.get(resolvedId);
249
+ if (reExistingRecord) {
250
+ // Found a record for the specifier, store alias and return it
251
+ this.storeModuleAlias(originalId, reResolvedId);
252
+ return reExistingRecord;
253
+ }
254
+ }
255
+ }
256
+ else if (existingRecord) {
257
+ // Simple case: resolved ID is a specifier and we have a record for it
258
+ this.storeModuleAlias(originalId, resolvedId);
259
+ return existingRecord;
260
+ }
261
+ }
262
+ // Step 2: Check if the original ID is a known alias that maps to an existing module
263
+ if (resolvedId !== originalId) {
264
+ const alias = this.aliases.get(originalId);
227
265
  if (alias) {
228
266
  const aliasedModule = this.moduleRegistry.get(alias);
229
267
  if (aliasedModule) {
268
+ // Found an existing module via alias, return it
230
269
  return aliasedModule;
231
270
  }
232
271
  }
233
272
  }
234
- return moduleRecord;
235
- }
236
- async getModuleRecord(resolvedId, id) {
237
- // Look for an existing record
238
- const existingRecord = this.getExistingModuleRecord(resolvedId, id);
239
- if (existingRecord) {
240
- // return existing
241
- return existingRecord;
242
- }
243
- // Create a new Module Record
244
- const instantiation = this.getModuleDef(resolvedId, id);
273
+ // Step 3: No existing record found, create a new module record
274
+ const instantiation = this.getModuleDef(resolvedId, originalId);
275
+ // Create dependency records for all module dependencies
245
276
  const dependencyRecords = instantiation.then((moduleDef) => {
246
277
  const dependencies = moduleDef.dependencies || [];
247
- // get dep and filter out exports
278
+ // Map dependencies to module records, filtering out 'exports' and 'require'
248
279
  const filtered = dependencies
249
280
  .map((dep) => {
250
281
  if (dep === 'exports') {
251
- return;
282
+ return; // 'exports' is a special AMD dependency, not a real module
252
283
  }
253
- invariant(dep !== 'require', NO_AMD_REQUIRE);
284
+ invariant(dep !== 'require', NO_AMD_REQUIRE); // 'require' is not allowed
254
285
  return this.getModuleDependencyRecord.call(this, dep);
255
286
  })
256
287
  .filter((depRecord) => depRecord !== undefined);
257
288
  return Promise.all(filtered);
258
289
  });
290
+ // Create the new module record
259
291
  const newModuleRecord = {
260
292
  id: resolvedId,
293
+ originalId: originalId,
261
294
  module: Object.create(null),
262
295
  dependencyRecords,
263
296
  instantiation,
264
297
  evaluated: false,
265
- evaluationPromise: null,
298
+ evaluationPromise: null, // Promise for module evaluation
266
299
  };
300
+ // Store the module record and create alias mapping
267
301
  this.moduleRegistry.set(resolvedId, newModuleRecord);
268
- this.storeModuleAlias(id, resolvedId);
269
- // Wait for the dependencies to resolve the return the moduleRecord
302
+ if (resolvedId !== originalId) {
303
+ this.storeModuleAlias(originalId, resolvedId);
304
+ }
305
+ // Wait for dependencies to resolve before returning the module record
270
306
  return dependencyRecords.then(() => newModuleRecord);
271
307
  }
272
308
  storeModuleAlias(aliasId, resolvedId) {
@@ -13,6 +13,7 @@ declare const NO_AMD_REQUIRE: ErrorInfo;
13
13
  declare const FAILED_DEP: ErrorInfo;
14
14
  declare const INVALID_DEPS: ErrorInfo;
15
15
  declare const FAIL_LOAD: ErrorInfo;
16
+ declare const FAIL_LOAD_EMPTY_CODE: ErrorInfo;
16
17
  declare const UNRESOLVED: ErrorInfo;
17
18
  declare const NO_BASE_URL: ErrorInfo;
18
19
  declare const HOOK_ALREADY_SET: ErrorInfo;
@@ -28,6 +29,6 @@ declare const NO_IMPORT_LWC: ErrorInfo;
28
29
  declare const NO_BLOB_IMPORT: ErrorInfo;
29
30
  declare const NO_IMPORT_LOADER: ErrorInfo;
30
31
  declare const BAD_IMPORT_MAP: ErrorInfo;
31
- export { MISSING_NAME, FAIL_INSTANTIATE, NO_AMD_REQUIRE, FAILED_DEP, INVALID_DEPS, FAIL_LOAD, UNRESOLVED, NO_BASE_URL, BAD_IMPORT_MAP, HOOK_ALREADY_SET, INVALID_HOOK, INVALID_LOADER_SERVICE_RESPONSE, MODULE_LOAD_TIMEOUT, HTTP_FAIL_LOAD, STALE_HOOK_ERROR, MODULE_ALREADY_LOADED, FAIL_HOOK_LOAD, EXPORTER_ERROR, NO_IMPORT_LWC, NO_BLOB_IMPORT, NO_IMPORT_LOADER, };
32
+ export { MISSING_NAME, FAIL_INSTANTIATE, NO_AMD_REQUIRE, FAILED_DEP, INVALID_DEPS, FAIL_LOAD, FAIL_LOAD_EMPTY_CODE, UNRESOLVED, NO_BASE_URL, BAD_IMPORT_MAP, HOOK_ALREADY_SET, INVALID_HOOK, INVALID_LOADER_SERVICE_RESPONSE, MODULE_LOAD_TIMEOUT, HTTP_FAIL_LOAD, STALE_HOOK_ERROR, MODULE_ALREADY_LOADED, FAIL_HOOK_LOAD, EXPORTER_ERROR, NO_IMPORT_LWC, NO_BLOB_IMPORT, NO_IMPORT_LOADER, };
32
33
  export { invariant, LoaderError };
33
34
  //# sourceMappingURL=messages.d.ts.map
@@ -45,6 +45,11 @@ const FAIL_LOAD = Object.freeze({
45
45
  level: 0,
46
46
  message: 'Error loading {0}',
47
47
  });
48
+ const FAIL_LOAD_EMPTY_CODE = Object.freeze({
49
+ code: 3008,
50
+ level: 0,
51
+ message: 'Error loading empty code for {0}',
52
+ });
48
53
  const UNRESOLVED = Object.freeze({
49
54
  code: 3009,
50
55
  level: 0,
@@ -122,7 +127,7 @@ const BAD_IMPORT_MAP = Object.freeze({
122
127
  message: 'import map is not valid',
123
128
  });
124
129
  /* Errors */
125
- export { MISSING_NAME, FAIL_INSTANTIATE, NO_AMD_REQUIRE, FAILED_DEP, INVALID_DEPS, FAIL_LOAD, UNRESOLVED, NO_BASE_URL, BAD_IMPORT_MAP, HOOK_ALREADY_SET, INVALID_HOOK, INVALID_LOADER_SERVICE_RESPONSE, MODULE_LOAD_TIMEOUT, HTTP_FAIL_LOAD, STALE_HOOK_ERROR, MODULE_ALREADY_LOADED, FAIL_HOOK_LOAD, EXPORTER_ERROR, NO_IMPORT_LWC, NO_BLOB_IMPORT, NO_IMPORT_LOADER, };
130
+ export { MISSING_NAME, FAIL_INSTANTIATE, NO_AMD_REQUIRE, FAILED_DEP, INVALID_DEPS, FAIL_LOAD, FAIL_LOAD_EMPTY_CODE, UNRESOLVED, NO_BASE_URL, BAD_IMPORT_MAP, HOOK_ALREADY_SET, INVALID_HOOK, INVALID_LOADER_SERVICE_RESPONSE, MODULE_LOAD_TIMEOUT, HTTP_FAIL_LOAD, STALE_HOOK_ERROR, MODULE_ALREADY_LOADED, FAIL_HOOK_LOAD, EXPORTER_ERROR, NO_IMPORT_LWC, NO_BLOB_IMPORT, NO_IMPORT_LOADER, };
126
131
  /* API */
127
132
  export { invariant, LoaderError };
128
133
  //# sourceMappingURL=messages.js.map
@@ -49,7 +49,7 @@ export async function evaluateLoadHookResponse(response, id) {
49
49
  throw new LoaderError(INVALID_LOADER_SERVICE_RESPONSE);
50
50
  }
51
51
  if (!code) {
52
- throw new LoaderError(FAIL_LOAD, [id]);
52
+ throw new LoaderError(FAIL_LOAD, [`empty code for ${id}`]);
53
53
  }
54
54
  code = `${code}\n//# sourceURL=${id}`; // append sourceURL for debugging
55
55
  try {
@@ -62,10 +62,12 @@ export async function evaluateLoadHookResponse(response, id) {
62
62
  // eslint-disable-next-line lwr/no-unguarded-apis
63
63
  console.error(e);
64
64
  }
65
- throw new LoaderError(FAIL_LOAD, [id]);
65
+ throw new LoaderError(FAIL_LOAD, [`"${id}": ${e instanceof Error ? e.message : String(e)}`]);
66
66
  }
67
67
  if (lastWindowError) {
68
- throw new LoaderError(FAIL_LOAD, [id]);
68
+ throw new LoaderError(FAIL_LOAD, [
69
+ `"${id}": window error ${lastWindowError instanceof Error ? lastWindowError.message : String(lastWindowError)}`,
70
+ ]);
69
71
  }
70
72
  return true;
71
73
  });
@@ -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 v0.19.2 */
7
+ /* LWR Legacy Module Loader v0.19.4 */
8
8
  const templateRegex = /\{([0-9]+)\}/g;
9
9
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
10
10
  function templateString(template, args) {
@@ -68,6 +68,11 @@ const FAIL_LOAD = Object.freeze({
68
68
  level: 0,
69
69
  message: 'Error loading {0}',
70
70
  });
71
+ Object.freeze({
72
+ code: 3008,
73
+ level: 0,
74
+ message: 'Error loading empty code for {0}',
75
+ });
71
76
  const UNRESOLVED = Object.freeze({
72
77
  code: 3009,
73
78
  level: 0,
@@ -415,7 +420,7 @@ try {
415
420
  // swallow
416
421
  }
417
422
  const trusted = createPolicy('trusted', policyOptions);
418
- /*! version: 0.24.6 */
423
+ /*! version: 0.25.3 */
419
424
 
420
425
  /* global console,process */
421
426
 
@@ -479,7 +484,7 @@ async function evaluateLoadHookResponse(response, id) {
479
484
  }
480
485
 
481
486
  if (!code) {
482
- throw new LoaderError(FAIL_LOAD, [id]);
487
+ throw new LoaderError(FAIL_LOAD, [`empty code for ${id}`]);
483
488
  }
484
489
 
485
490
  code = `${code}\n//# sourceURL=${id}`; // append sourceURL for debugging
@@ -492,11 +497,13 @@ async function evaluateLoadHookResponse(response, id) {
492
497
  // eslint-disable-next-line lwr/no-unguarded-apis
493
498
  console.error(e);
494
499
  }
495
- throw new LoaderError(FAIL_LOAD, [id]);
500
+ throw new LoaderError(FAIL_LOAD, [`"${id}": ${e instanceof Error ? e.message : String(e)}`]);
496
501
  }
497
502
 
498
503
  if (lastWindowError) {
499
- throw new LoaderError(FAIL_LOAD, [id]);
504
+ throw new LoaderError(FAIL_LOAD, [
505
+ `"${id}": window error ${lastWindowError instanceof Error ? lastWindowError.message : String(lastWindowError)}`,
506
+ ]);
500
507
  }
501
508
  return true;
502
509
  });
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
8
- "version": "0.19.2",
8
+ "version": "0.19.4",
9
9
  "homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
10
10
  "repository": {
11
11
  "type": "git",
@@ -60,17 +60,17 @@
60
60
  "build": "yarn build:ts && yarn build:error-shim && yarn build:shim && yarn build:loader && yarn build:shim:bundle && yarn build:shim:bundle:minify"
61
61
  },
62
62
  "devDependencies": {
63
- "@locker/trusted-types": "0.24.6",
64
- "@lwrjs/diagnostics": "0.19.2",
65
- "@lwrjs/types": "0.19.2",
63
+ "@locker/trusted-types": "0.25.3",
64
+ "@lwrjs/diagnostics": "0.19.4",
65
+ "@lwrjs/types": "0.19.4",
66
66
  "@rollup/plugin-node-resolve": "^15.2.3",
67
67
  "@rollup/plugin-sucrase": "^5.0.2",
68
68
  "@rollup/plugin-terser": "^0.4.4",
69
69
  "rollup": "^2.79.2"
70
70
  },
71
71
  "dependencies": {
72
- "@lwrjs/client-modules": "0.19.2",
73
- "@lwrjs/shared-utils": "0.19.2"
72
+ "@lwrjs/client-modules": "0.19.4",
73
+ "@lwrjs/shared-utils": "0.19.4"
74
74
  },
75
75
  "lwc": {
76
76
  "modules": [
@@ -90,5 +90,5 @@
90
90
  "volta": {
91
91
  "extends": "../../../package.json"
92
92
  },
93
- "gitHead": "2f44f011c2e66056c5961d6fbfd6d4a8d08d99cb"
93
+ "gitHead": "b74a453f5523487f83b7b1ef9b73971949a606a7"
94
94
  }