@lwrjs/loader 0.11.0-alpha.4 → 0.11.0-alpha.7

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.
@@ -46,8 +46,14 @@ var ModuleRegistry = class {
46
46
  this.profiler = config.profiler;
47
47
  }
48
48
  async load(id, importer) {
49
+ const metadata = importer ? {importer} : {};
50
+ this.profiler.logOperationStart({
51
+ id: import_metrics.MODULE_DYNAMIC_LOAD,
52
+ specifier: id,
53
+ metadata
54
+ });
49
55
  const resolvedId = await this.resolve(id, importer);
50
- const moduleRecord = this.getModuleRecord(resolvedId, id);
56
+ const moduleRecord = await this.getModuleRecord(resolvedId, id);
51
57
  if (moduleRecord.evaluated) {
52
58
  return moduleRecord.module;
53
59
  } else {
@@ -234,14 +240,14 @@ var ModuleRegistry = class {
234
240
  }
235
241
  return moduleRecord;
236
242
  }
237
- getModuleRecord(resolvedId, id) {
243
+ async getModuleRecord(resolvedId, id) {
238
244
  const existingRecord = this.getExistingModuleRecord(resolvedId, id);
239
245
  if (existingRecord) {
240
246
  return existingRecord;
241
247
  }
242
248
  const instantiation = this.getModuleDef(resolvedId, id);
243
249
  const dependencyRecords = instantiation.then((moduleDef) => {
244
- const dependencies = moduleDef.dependencies;
250
+ const dependencies = moduleDef && moduleDef.dependencies || [];
245
251
  const filtered = dependencies.map((dep) => {
246
252
  if (dep === "exports") {
247
253
  return;
@@ -261,7 +267,7 @@ var ModuleRegistry = class {
261
267
  };
262
268
  this.moduleRegistry.set(resolvedId, newModuleRecord);
263
269
  this.storeModuleAlias(id, resolvedId);
264
- return newModuleRecord;
270
+ return dependencyRecords.then(() => newModuleRecord);
265
271
  }
266
272
  storeModuleAlias(aliasId, resolvedId) {
267
273
  if (aliasId !== resolvedId) {
@@ -270,7 +276,9 @@ var ModuleRegistry = class {
270
276
  } else if (import_dom.hasConsole) {
271
277
  const currentResolvedId = this.aliases.get(aliasId);
272
278
  if (currentResolvedId !== resolvedId) {
273
- console.warn(`Alias update attempt: ${aliasId}=>${currentResolvedId}, ${resolvedId}`);
279
+ if (process.env.NODE_ENV !== "production" && import_dom.hasConsole) {
280
+ console.warn(`Alias update attempt: ${aliasId}=>${currentResolvedId}, ${resolvedId}`);
281
+ }
274
282
  }
275
283
  }
276
284
  }
@@ -303,7 +311,7 @@ var ModuleRegistry = class {
303
311
  }
304
312
  const {exporter, dependencies} = await moduleRecord.instantiation;
305
313
  const exports2 = {};
306
- const depsMapped = await Promise.all(dependencies.map(async (dep) => {
314
+ const depsMapped = dependencies ? await Promise.all(dependencies.map(async (dep) => {
307
315
  if (dep === "exports") {
308
316
  return exports2;
309
317
  }
@@ -320,11 +328,16 @@ var ModuleRegistry = class {
320
328
  return module2.__defaultInterop ? module2.default : module2;
321
329
  }
322
330
  throw new import_messages.LoaderError(import_messages.FAILED_DEP, [resolvedDepId]);
323
- }));
331
+ })) : [];
324
332
  if (moduleRecord.evaluated) {
325
333
  return moduleRecord.module;
326
334
  }
327
- let moduleDefault = exporter(...depsMapped);
335
+ let moduleDefault;
336
+ try {
337
+ moduleDefault = exporter(...depsMapped);
338
+ } catch (e) {
339
+ throw new import_messages.LoaderError(import_messages.EXPORTER_ERROR, [moduleRecord.id, e.message || e]);
340
+ }
328
341
  if (moduleDefault !== void 0) {
329
342
  moduleDefault = {default: moduleDefault};
330
343
  Object.defineProperty(moduleDefault, "__defaultInterop", {value: true});
@@ -421,7 +434,9 @@ var ModuleRegistry = class {
421
434
  this.profiler.logOperationEnd({id: import_metrics.MODULE_FETCH, specifier});
422
435
  return moduleDef;
423
436
  }).catch((e) => {
424
- this.profiler.logOperationStart({id: import_metrics.MODULE_ERROR, specifier});
437
+ if (!(e instanceof import_messages.LoaderError)) {
438
+ this.profiler.logOperationStart({id: import_metrics.MODULE_ERROR, specifier});
439
+ }
425
440
  throw e;
426
441
  });
427
442
  }
@@ -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.11.0-alpha.4 */
7
+ /* LWR ESM Module Loader v0.11.0-alpha.7 */
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.11.0-alpha.4 */
7
+ /* LWR Module Loader v0.11.0-alpha.7 */
8
8
  const templateRegex = /\{([0-9]+)\}/g;
9
9
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
10
10
  function templateString(template, args) {
@@ -128,6 +128,11 @@ const BAD_IMPORT_METADATA = Object.freeze({
128
128
  level: 0,
129
129
  message: 'Invalid import metadata: {0} {1}',
130
130
  });
131
+ const EXPORTER_ERROR = Object.freeze({
132
+ code: 3021,
133
+ level: 0,
134
+ message: 'Error evaluating module "{0}", error was "{1}"',
135
+ });
131
136
 
132
137
  /* importMap errors */
133
138
  Object.freeze({
@@ -324,6 +329,7 @@ if (hasDocument) {
324
329
  // Loader: modules
325
330
  const LOADER_PREFIX = 'lwr.loader.';
326
331
  const MODULE_DEFINE = `${LOADER_PREFIX}module.define`;
332
+ const MODULE_DYNAMIC_LOAD = `${LOADER_PREFIX}moduleRegistry.dynamicLoad`;
327
333
  const MODULE_FETCH = `${LOADER_PREFIX}module.fetch`;
328
334
  const MODULE_ERROR = `${LOADER_PREFIX}module.error`;
329
335
 
@@ -684,7 +690,7 @@ function isResponseAPromise(
684
690
 
685
691
  async function evaluateLoadHookResponse(response, id) {
686
692
  return Promise.resolve().then(async () => {
687
- if (!response.status) {
693
+ if (!response || !response.status) {
688
694
  throw new LoaderError(INVALID_LOADER_SERVICE_RESPONSE);
689
695
  }
690
696
  if (response.status !== 200) {
@@ -711,6 +717,10 @@ async function evaluateLoadHookResponse(response, id) {
711
717
  // TODO eval source maps for debugging
712
718
  eval(trusted.createScript(code));
713
719
  } catch (e) {
720
+ if (process.env.NODE_ENV !== 'production' && hasConsole) {
721
+ // eslint-disable-next-line lwr/no-unguarded-apis
722
+ console.error(e);
723
+ }
714
724
  throw new LoaderError(FAIL_LOAD, [id]);
715
725
  }
716
726
 
@@ -791,7 +801,6 @@ async function evaluateLoadHook(
791
801
 
792
802
 
793
803
 
794
-
795
804
 
796
805
 
797
806
  class ModuleRegistry {
@@ -806,8 +815,14 @@ class ModuleRegistry {
806
815
  }
807
816
 
808
817
  async load(id, importer) {
818
+ const metadata = importer ? { importer } : {};
819
+ this.profiler.logOperationStart({
820
+ id: MODULE_DYNAMIC_LOAD,
821
+ specifier: id,
822
+ metadata,
823
+ });
809
824
  const resolvedId = await this.resolve(id, importer);
810
- const moduleRecord = this.getModuleRecord(resolvedId, id);
825
+ const moduleRecord = await this.getModuleRecord(resolvedId, id);
811
826
  if (moduleRecord.evaluated) {
812
827
  return moduleRecord.module;
813
828
  } else {
@@ -881,6 +896,8 @@ class ModuleRegistry {
881
896
  // return the plain id if it is already defined && the resolvedUrl is NOT already in the module registry
882
897
  if (
883
898
  this.namedDefineRegistry.has(resolvedOrPlain) &&
899
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
900
+ // @ts-ignore has check right above
884
901
  this.namedDefineRegistry.get(resolvedOrPlain).defined
885
902
  ) {
886
903
  const record = this.moduleRegistry.get(resolvedUrl);
@@ -1021,7 +1038,7 @@ class ModuleRegistry {
1021
1038
  return moduleRecord;
1022
1039
  }
1023
1040
 
1024
- getModuleRecord(resolvedId, id) {
1041
+ async getModuleRecord(resolvedId, id) {
1025
1042
  // Look for an existing record
1026
1043
  const existingRecord = this.getExistingModuleRecord(resolvedId, id);
1027
1044
  if (existingRecord) {
@@ -1032,7 +1049,7 @@ class ModuleRegistry {
1032
1049
  // Create a new Module Record
1033
1050
  const instantiation = this.getModuleDef(resolvedId, id);
1034
1051
  const dependencyRecords = instantiation.then((moduleDef) => {
1035
- const dependencies = moduleDef.dependencies;
1052
+ const dependencies = moduleDef.dependencies || [];
1036
1053
  // get dep and filter out exports
1037
1054
  const filtered = dependencies
1038
1055
  .map((dep) => {
@@ -1058,7 +1075,9 @@ class ModuleRegistry {
1058
1075
 
1059
1076
  this.moduleRegistry.set(resolvedId, newModuleRecord);
1060
1077
  this.storeModuleAlias(id, resolvedId);
1061
- return newModuleRecord;
1078
+
1079
+ // Wait for the dependencies to resolve the return the moduleRecord
1080
+ return dependencyRecords.then(() => newModuleRecord);
1062
1081
  }
1063
1082
 
1064
1083
  storeModuleAlias(aliasId, resolvedId) {
@@ -1070,7 +1089,10 @@ class ModuleRegistry {
1070
1089
  const currentResolvedId = this.aliases.get(aliasId);
1071
1090
  if (currentResolvedId !== resolvedId) {
1072
1091
  // eslint-disable-next-line lwr/no-unguarded-apis, no-undef
1073
- console.warn(`Alias update attempt: ${aliasId}=>${currentResolvedId}, ${resolvedId}`);
1092
+ if (process.env.NODE_ENV !== 'production' && hasConsole) {
1093
+ // eslint-disable-next-line lwr/no-unguarded-apis, no-undef
1094
+ console.warn(`Alias update attempt: ${aliasId}=>${currentResolvedId}, ${resolvedId}`);
1095
+ }
1074
1096
  }
1075
1097
  }
1076
1098
  }
@@ -1119,37 +1141,39 @@ class ModuleRegistry {
1119
1141
  const { exporter, dependencies } = await moduleRecord.instantiation;
1120
1142
  // The exports object automatically gets filled in by the exporter evaluation
1121
1143
  const exports = {};
1122
- const depsMapped = await Promise.all(
1123
- dependencies.map(async (dep) => {
1124
- if (dep === 'exports') {
1125
- return exports;
1126
- }
1127
- const resolvedDepId = await this.resolve(dep);
1128
-
1129
- const moduleRecord = this.moduleRegistry.get(resolvedDepId) ;
1130
- if (!moduleRecord) {
1131
- throw new LoaderError(FAILED_DEP, [resolvedDepId]);
1132
- }
1133
-
1134
- const module = moduleRecord.module;
1135
-
1136
- /**
1137
- * Circular dependencies are handled properly when named exports are used,
1138
- * however, for default exports there is a bug: https://github.com/rollup/rollup/issues/3384
1139
- *
1140
- * The workaround below applies for circular dependencies (!moduleRecord.evaluated)
1141
- */
1142
- if (!moduleRecord.evaluated) {
1143
- return this.getCircularDependencyWrapper(module);
1144
- }
1145
-
1146
- if (module) {
1147
- return module.__defaultInterop ? module.default : module;
1148
- }
1149
-
1150
- throw new LoaderError(FAILED_DEP, [resolvedDepId]);
1151
- }),
1152
- );
1144
+ const depsMapped = dependencies
1145
+ ? await Promise.all(
1146
+ dependencies.map(async (dep) => {
1147
+ if (dep === 'exports') {
1148
+ return exports;
1149
+ }
1150
+ const resolvedDepId = await this.resolve(dep);
1151
+
1152
+ const moduleRecord = this.moduleRegistry.get(resolvedDepId) ;
1153
+ if (!moduleRecord) {
1154
+ throw new LoaderError(FAILED_DEP, [resolvedDepId]);
1155
+ }
1156
+
1157
+ const module = moduleRecord.module;
1158
+
1159
+ /**
1160
+ * Circular dependencies are handled properly when named exports are used,
1161
+ * however, for default exports there is a bug: https://github.com/rollup/rollup/issues/3384
1162
+ *
1163
+ * The workaround below applies for circular dependencies (!moduleRecord.evaluated)
1164
+ */
1165
+ if (!moduleRecord.evaluated) {
1166
+ return this.getCircularDependencyWrapper(module);
1167
+ }
1168
+
1169
+ if (module) {
1170
+ return module.__defaultInterop ? module.default : module;
1171
+ }
1172
+
1173
+ throw new LoaderError(FAILED_DEP, [resolvedDepId]);
1174
+ }),
1175
+ )
1176
+ : [];
1153
1177
 
1154
1178
  // 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
1155
1179
  if (moduleRecord.evaluated) {
@@ -1157,8 +1181,12 @@ class ModuleRegistry {
1157
1181
  }
1158
1182
 
1159
1183
  // evaluates the module function
1160
- let moduleDefault = exporter(...depsMapped);
1161
-
1184
+ let moduleDefault;
1185
+ try {
1186
+ moduleDefault = exporter(...depsMapped);
1187
+ } catch (e) {
1188
+ throw new LoaderError(EXPORTER_ERROR, [moduleRecord.id, e.message || e]);
1189
+ }
1162
1190
  // value is returned from exporter, then we are not using named exports
1163
1191
  if (moduleDefault !== undefined) {
1164
1192
  moduleDefault = { default: moduleDefault };
@@ -1307,7 +1335,12 @@ class ModuleRegistry {
1307
1335
  return moduleDef;
1308
1336
  })
1309
1337
  .catch((e) => {
1310
- this.profiler.logOperationStart({ id: MODULE_ERROR, specifier });
1338
+ // Create module error marks for all errors caused by the loader
1339
+ // Note: these marks do not include errors caused by invalid server responses or loader hooks
1340
+ if (!(e instanceof LoaderError)) {
1341
+ this.profiler.logOperationStart({ id: MODULE_ERROR, specifier });
1342
+ }
1343
+
1311
1344
  throw e;
1312
1345
  });
1313
1346
  }
@@ -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.11.0-alpha.4 */
7
+ /* LWR Legacy Module Loader v0.11.0-alpha.7 */
8
8
  const templateRegex = /\{([0-9]+)\}/g;
9
9
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
10
10
  function templateString(template, args) {
@@ -118,6 +118,11 @@ const FAIL_HOOK_LOAD = Object.freeze({
118
118
  level: 0,
119
119
  message: 'Error loading "{0}" from hook',
120
120
  });
121
+ const EXPORTER_ERROR = Object.freeze({
122
+ code: 3021,
123
+ level: 0,
124
+ message: 'Error evaluating module "{0}", error was {1}',
125
+ });
121
126
 
122
127
  /* importMap errors */
123
128
  const BAD_IMPORT_MAP = Object.freeze({
@@ -416,7 +421,7 @@ function isResponseAPromise(
416
421
 
417
422
  async function evaluateLoadHookResponse(response, id) {
418
423
  return Promise.resolve().then(async () => {
419
- if (!response.status) {
424
+ if (!response || !response.status) {
420
425
  throw new LoaderError(INVALID_LOADER_SERVICE_RESPONSE);
421
426
  }
422
427
  if (response.status !== 200) {
@@ -443,6 +448,10 @@ async function evaluateLoadHookResponse(response, id) {
443
448
  // TODO eval source maps for debugging
444
449
  eval(trusted.createScript(code));
445
450
  } catch (e) {
451
+ if (process.env.NODE_ENV !== 'production' && hasConsole) {
452
+ // eslint-disable-next-line lwr/no-unguarded-apis
453
+ console.error(e);
454
+ }
446
455
  throw new LoaderError(FAIL_LOAD, [id]);
447
456
  }
448
457
 
@@ -510,6 +519,7 @@ function evaluateHandleStaleModuleHooks(
510
519
  // Loader: modules
511
520
  const LOADER_PREFIX = 'lwr.loader.';
512
521
  const MODULE_DEFINE = `${LOADER_PREFIX}module.define`;
522
+ const MODULE_DYNAMIC_LOAD = `${LOADER_PREFIX}moduleRegistry.dynamicLoad`;
513
523
  const MODULE_FETCH = `${LOADER_PREFIX}module.fetch`;
514
524
  const MODULE_ERROR = `${LOADER_PREFIX}module.error`;
515
525
 
@@ -564,6 +574,7 @@ const MODULE_ERROR = `${LOADER_PREFIX}module.error`;
564
574
 
565
575
 
566
576
 
577
+
567
578
 
568
579
 
569
580
  class ModuleRegistry {
@@ -575,8 +586,14 @@ class ModuleRegistry {
575
586
  }
576
587
 
577
588
  async load(id, importer) {
589
+ const metadata = importer ? { importer } : {};
590
+ this.profiler.logOperationStart({
591
+ id: MODULE_DYNAMIC_LOAD,
592
+ specifier: id,
593
+ metadata,
594
+ });
578
595
  const resolvedId = await this.resolve(id, importer);
579
- const moduleRecord = this.getModuleRecord(resolvedId, id);
596
+ const moduleRecord = await this.getModuleRecord(resolvedId, id);
580
597
  if (moduleRecord.evaluated) {
581
598
  return moduleRecord.module;
582
599
  } else {
@@ -653,6 +670,8 @@ class ModuleRegistry {
653
670
  // return the plain id if it is already defined && the resolvedUrl is NOT already in the module registry
654
671
  if (
655
672
  this.namedDefineRegistry.has(resolvedOrPlain) &&
673
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
674
+ // @ts-ignore has check right above
656
675
  this.namedDefineRegistry.get(resolvedOrPlain).defined
657
676
  ) {
658
677
  const record = this.moduleRegistry.get(resolved);
@@ -706,7 +725,7 @@ class ModuleRegistry {
706
725
  defined: true,
707
726
  };
708
727
  if (mod && mod.external) {
709
- // if module is "external", resolve the external promise to notify any dependees
728
+ // if module is "external", resolve the external promise to notify any dependencies
710
729
  mod.external.resolveExternal(moduleDef);
711
730
  }
712
731
 
@@ -834,7 +853,7 @@ class ModuleRegistry {
834
853
  return moduleRecord;
835
854
  }
836
855
 
837
- getModuleRecord(resolvedId, id) {
856
+ async getModuleRecord(resolvedId, id) {
838
857
  // Look for an existing record
839
858
  const existingRecord = this.getExistingModuleRecord(resolvedId, id);
840
859
  if (existingRecord) {
@@ -845,7 +864,7 @@ class ModuleRegistry {
845
864
  // Create a new Module Record
846
865
  const instantiation = this.getModuleDef(resolvedId, id);
847
866
  const dependencyRecords = instantiation.then((moduleDef) => {
848
- const dependencies = moduleDef.dependencies;
867
+ const dependencies = (moduleDef && moduleDef.dependencies) || [];
849
868
  // get dep and filter out exports
850
869
  const filtered = dependencies
851
870
  .map((dep) => {
@@ -870,7 +889,9 @@ class ModuleRegistry {
870
889
  };
871
890
  this.moduleRegistry.set(resolvedId, newModuleRecord);
872
891
  this.storeModuleAlias(id, resolvedId);
873
- return newModuleRecord;
892
+
893
+ // Wait for the dependencies to resolve the return the moduleRecord
894
+ return dependencyRecords.then(() => newModuleRecord);
874
895
  }
875
896
 
876
897
  storeModuleAlias(aliasId, resolvedId) {
@@ -881,8 +902,10 @@ class ModuleRegistry {
881
902
  // Warn the user if they were not aliasing to the resolvedId
882
903
  const currentResolvedId = this.aliases.get(aliasId);
883
904
  if (currentResolvedId !== resolvedId) {
884
- // eslint-disable-next-line lwr/no-unguarded-apis, no-undef
885
- console.warn(`Alias update attempt: ${aliasId}=>${currentResolvedId}, ${resolvedId}`);
905
+ if (process.env.NODE_ENV !== 'production' && hasConsole) {
906
+ // eslint-disable-next-line lwr/no-unguarded-apis, no-undef
907
+ console.warn(`Alias update attempt: ${aliasId}=>${currentResolvedId}, ${resolvedId}`);
908
+ }
886
909
  }
887
910
  }
888
911
  }
@@ -931,37 +954,39 @@ class ModuleRegistry {
931
954
  const { exporter, dependencies } = await moduleRecord.instantiation;
932
955
  // The exports object automatically gets filled in by the exporter evaluation
933
956
  const exports = {};
934
- const depsMapped = await Promise.all(
935
- dependencies.map(async (dep) => {
936
- if (dep === 'exports') {
937
- return exports;
938
- }
939
- const resolvedDepId = await this.resolve(dep);
940
-
941
- const moduleRecord = this.moduleRegistry.get(resolvedDepId) ;
942
- if (!moduleRecord) {
943
- throw new LoaderError(FAILED_DEP, [resolvedDepId]);
944
- }
945
-
946
- const module = moduleRecord.module;
947
-
948
- /**
949
- * Circular dependencies are handled properly when named exports are used,
950
- * however, for default exports there is a bug: https://github.com/rollup/rollup/issues/3384
951
- *
952
- * The workaround below applies for circular dependencies (!moduleRecord.evaluated)
953
- */
954
- if (!moduleRecord.evaluated) {
955
- return this.getCircularDependencyWrapper(module);
956
- }
957
-
958
- if (module) {
959
- return module.__defaultInterop ? module.default : module;
960
- }
961
-
962
- throw new LoaderError(FAILED_DEP, [resolvedDepId]);
963
- }),
964
- );
957
+ const depsMapped = dependencies
958
+ ? await Promise.all(
959
+ dependencies.map(async (dep) => {
960
+ if (dep === 'exports') {
961
+ return exports;
962
+ }
963
+ const resolvedDepId = await this.resolve(dep);
964
+
965
+ const moduleRecord = this.moduleRegistry.get(resolvedDepId) ;
966
+ if (!moduleRecord) {
967
+ throw new LoaderError(FAILED_DEP, [resolvedDepId]);
968
+ }
969
+
970
+ const module = moduleRecord.module;
971
+
972
+ /**
973
+ * Circular dependencies are handled properly when named exports are used,
974
+ * however, for default exports there is a bug: https://github.com/rollup/rollup/issues/3384
975
+ *
976
+ * The workaround below applies for circular dependencies (!moduleRecord.evaluated)
977
+ */
978
+ if (!moduleRecord.evaluated) {
979
+ return this.getCircularDependencyWrapper(module);
980
+ }
981
+
982
+ if (module) {
983
+ return module.__defaultInterop ? module.default : module;
984
+ }
985
+
986
+ throw new LoaderError(FAILED_DEP, [resolvedDepId]);
987
+ }),
988
+ )
989
+ : [];
965
990
 
966
991
  // 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
967
992
  if (moduleRecord.evaluated) {
@@ -969,7 +994,12 @@ class ModuleRegistry {
969
994
  }
970
995
 
971
996
  // evaluates the module function
972
- let moduleDefault = exporter(...depsMapped);
997
+ let moduleDefault;
998
+ try {
999
+ moduleDefault = exporter(...depsMapped);
1000
+ } catch (e) {
1001
+ throw new LoaderError(EXPORTER_ERROR, [moduleRecord.id, e.message || e]);
1002
+ }
973
1003
 
974
1004
  // value is returned from exporter, then we are not using named exports
975
1005
  if (moduleDefault !== undefined) {
@@ -1119,7 +1149,12 @@ class ModuleRegistry {
1119
1149
  return moduleDef;
1120
1150
  })
1121
1151
  .catch((e) => {
1122
- this.profiler.logOperationStart({ id: MODULE_ERROR, specifier });
1152
+ // Create module error marks for all errors caused by the loader
1153
+ // Note: these marks do not include errors caused by invalid server responses or loader hooks
1154
+ if (!(e instanceof LoaderError)) {
1155
+ this.profiler.logOperationStart({ id: MODULE_ERROR, specifier });
1156
+ }
1157
+
1123
1158
  throw e;
1124
1159
  });
1125
1160
  }
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
8
- "version": "0.11.0-alpha.4",
8
+ "version": "0.11.0-alpha.7",
9
9
  "homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
10
10
  "repository": {
11
11
  "type": "git",
@@ -62,16 +62,16 @@
62
62
  },
63
63
  "devDependencies": {
64
64
  "@locker/trusted-types": "0.20.0",
65
- "@lwrjs/diagnostics": "0.11.0-alpha.4",
66
- "@lwrjs/types": "0.11.0-alpha.4",
65
+ "@lwrjs/diagnostics": "0.11.0-alpha.7",
66
+ "@lwrjs/types": "0.11.0-alpha.7",
67
67
  "@rollup/plugin-node-resolve": "^15.0.2",
68
68
  "@rollup/plugin-sucrase": "^5.0.1",
69
69
  "@rollup/plugin-terser": "^0.4.3",
70
70
  "rollup": "^2.78.0"
71
71
  },
72
72
  "dependencies": {
73
- "@lwrjs/client-modules": "0.11.0-alpha.4",
74
- "@lwrjs/shared-utils": "0.11.0-alpha.4"
73
+ "@lwrjs/client-modules": "0.11.0-alpha.7",
74
+ "@lwrjs/shared-utils": "0.11.0-alpha.7"
75
75
  },
76
76
  "lwc": {
77
77
  "modules": [
@@ -91,5 +91,5 @@
91
91
  "volta": {
92
92
  "extends": "../../../package.json"
93
93
  },
94
- "gitHead": "89a7e9815e0e381d9fd67212f0471d9a11f73985"
94
+ "gitHead": "872180fbd00df214ab91971d7ec80ba138a73756"
95
95
  }