@lwrjs/everywhere 0.19.1 → 0.19.3

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.
Files changed (22) hide show
  1. package/build/__generated_site_amd_modules__/1/application/amd/l/en-US/ai/amd-bootstrap/configuration/ci/-/-/s/02ae7930358df627b93ecbd3eb99f9df/config.js +12 -0
  2. package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/@lwrjs/app-service/amd-bootstrap/module/amd/v/{0_19_1 → 0_19_3}/s/3aba11034f11c8d5598c93bfca4d4690/@lwrjs_app-service_amd-bootstrap_module_amd.js +5 -5
  3. package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/lwr/everywhereAmd/v/{0_19_1 → 0_19_3}/s/cb931ebef2b89dcf8ab51456e3a68864/lwr_everywhereAmd.js +3 -3
  4. package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/lwr/init/v/{0_19_1 → 0_19_3}/s/ba081ae41570981325062377381a1ea2/lwr_init.js +19 -19
  5. package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/lwr/loader/v/{0_19_1/s/40df7eea64ee1a15a4401af8c93249f1 → 0_19_3/s/ba599b27c9302da4641024ef27bbad90}/lwr_loader.js +84 -29
  6. package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/lwr/metrics/v/{0_19_1 → 0_19_3}/s/fb8c5dd340c69fdf7ded52d3eba633b9/lwr_metrics.js +1 -1
  7. package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/lwr/preInit/v/{0_19_1 → 0_19_3}/s/7d064ec3a80dbbccaa4845ea5eaef125/lwr_preInit.js +1 -1
  8. package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/lwr/profiler/v/{0_19_1 → 0_19_3}/s/9f74c8370534ce02c6e7637abdcffedf/lwr_profiler.js +1 -1
  9. package/build/__generated_site_amd_modules__/1/module/amd/1/l/en-US/mi/lwr/vault/v/{0_19_1 → 0_19_3}/s/c92abd8c1fec2d7eff62e4b097abbe14/lwr_vault.js +1 -1
  10. package/build/__generated_site_amd_modules__/1/resource/amd/lwr-error-shim.js/v/{0_19_1 → 0_19_3}/lwr-error-shim.js +1 -1
  11. package/build/__generated_site_amd_modules__/1/resource/amd/lwr-loader-shim.bundle.js/v/{0_19_1 → 0_19_3}/lwr-loader-shim.bundle.js +86 -39
  12. package/build/assets/amd/lwr-everywhere-debug.js +88 -41
  13. package/build/assets/amd/lwr-everywhere-min.js +2 -2
  14. package/build/assets/amd/lwr-everywhere.js +88 -41
  15. package/build/assets/core/lwr-everywhere-debug.js +84 -37
  16. package/build/assets/core/lwr-everywhere-min.js +2 -2
  17. package/build/assets/core/lwr-everywhere.js +84 -37
  18. package/build/assets/esm/lwr-everywhere-debug.js +1 -1
  19. package/build/assets/esm/lwr-everywhere-min.js +1 -1
  20. package/build/assets/esm/lwr-everywhere.js +1 -1
  21. package/package.json +6 -6
  22. package/build/__generated_site_amd_modules__/1/application/amd/l/en-US/ai/amd-bootstrap/configuration/ci/-/-/s/ebc1ae6d4684719fbf896f5a11b848b7/config.js +0 -12
@@ -0,0 +1,12 @@
1
+ /* This script is generated */
2
+ /* Client Bootstrap configuration */
3
+ globalThis.LWR = globalThis.LWR || {};
4
+ Object.assign(globalThis.LWR, {"appId":"amd-bootstrap","bootstrapModule":"@lwrjs/app-service/amd-bootstrap/module/amd/v/0_19_3","autoBoot":true,"imports":{"/1/module/amd/1/l/en-US/mi/%40lwrjs%2Fapp-service%2Famd-bootstrap%2Fmodule%2Famd%2Fv%2F0_19_3/s/3aba11034f11c8d5598c93bfca4d4690/@lwrjs_app-service_amd-bootstrap_module_amd.js":["@lwrjs/app-service/amd-bootstrap/module/amd/v/0_19_3"],"/1/module/amd/1/l/en-US/mi/lwr%2FpreInit%2Fv%2F0_19_3/s/7d064ec3a80dbbccaa4845ea5eaef125/lwr_preInit.js":["lwr/preInit/v/0_19_3"],"/1/module/amd/1/l/en-US/mi/lwr%2Finit%2Fv%2F0_19_3/s/ba081ae41570981325062377381a1ea2/lwr_init.js":["lwr/init/v/0_19_3"],"/1/module/amd/1/l/en-US/mi/lwr%2Fmetrics%2Fv%2F0_19_3/s/fb8c5dd340c69fdf7ded52d3eba633b9/lwr_metrics.js":["lwr/metrics/v/0_19_3"],"/1/module/amd/1/l/en-US/mi/lwc%2Fv%2F8_20_1/s/13f9f9934fd3a3c9f52760160b464d00/lwc.js":["lwc/v/8_20_1"],"/1/module/amd/1/l/en-US/mi/lwr%2FeverywhereAmd%2Fv%2F0_19_3/s/cb931ebef2b89dcf8ab51456e3a68864/lwr_everywhereAmd.js":["lwr/everywhereAmd/v/0_19_3"],"/1/module/amd/1/l/en-US/mi/lwr%2Fvault%2Fv%2F0_19_3/s/c92abd8c1fec2d7eff62e4b097abbe14/lwr_vault.js":["lwr/vault/v/0_19_3"]},"index":{"@lwrjs/app-service/amd-bootstrap/module/amd/v/0_19_3":"/1/module/amd/1/l/en-US/mi/%40lwrjs%2Fapp-service%2Famd-bootstrap%2Fmodule%2Famd%2Fv%2F0_19_3/s/3aba11034f11c8d5598c93bfca4d4690/@lwrjs_app-service_amd-bootstrap_module_amd.js","lwr/preInit/v/0_19_3":"/1/module/amd/1/l/en-US/mi/lwr%2FpreInit%2Fv%2F0_19_3/s/7d064ec3a80dbbccaa4845ea5eaef125/lwr_preInit.js","lwr/init/v/0_19_3":"/1/module/amd/1/l/en-US/mi/lwr%2Finit%2Fv%2F0_19_3/s/ba081ae41570981325062377381a1ea2/lwr_init.js","lwr/metrics/v/0_19_3":"/1/module/amd/1/l/en-US/mi/lwr%2Fmetrics%2Fv%2F0_19_3/s/fb8c5dd340c69fdf7ded52d3eba633b9/lwr_metrics.js","lwc/v/8_20_1":"/1/module/amd/1/l/en-US/mi/lwc%2Fv%2F8_20_1/s/13f9f9934fd3a3c9f52760160b464d00/lwc.js","lwr/everywhereAmd/v/0_19_3":"/1/module/amd/1/l/en-US/mi/lwr%2FeverywhereAmd%2Fv%2F0_19_3/s/cb931ebef2b89dcf8ab51456e3a68864/lwr_everywhereAmd.js","lwr/vault/v/0_19_3":"/1/module/amd/1/l/en-US/mi/lwr%2Fvault%2Fv%2F0_19_3/s/c92abd8c1fec2d7eff62e4b097abbe14/lwr_vault.js"},"rootComponents":["lwr/everywhereAmd/v/0_19_3"],"serverData":{},"requiredModules":["@lwrjs/app-service/amd-bootstrap/module/amd/v/0_19_3"],"preloadModules":["lwr/preInit/v/0_19_3","lwr/init/v/0_19_3","lwr/metrics/v/0_19_3","lwc/v/8_20_1","lwr/everywhereAmd/v/0_19_3"],"endpoints":{"uris":{"mapping":"/1/mapping/amd/1/l/en-US/mp/"}}});
5
+ globalThis.LWR = {...globalThis.LWR, env: {"SSR":false,"SSREnabled":false,"basePath":"","locale":"en-US","assetBasePath":"","uiBasePath":""}};
6
+ globalThis.process={...globalThis.process,env:{...globalThis.process?.env,...{"NODE_ENV":"compat"}}};
7
+ globalThis.lwcRuntimeFlags = { ENABLE_MIXED_SHADOW_MODE: false, ENABLE_WIRE_SYNC_EMIT: false };
8
+ // Appended by Static Site Generator
9
+ if (!globalThis.LWR.imports) { globalThis.LWR.imports = {}; }
10
+ Object.assign(globalThis.LWR.imports, {"/1/module/amd/1/l/en-US/mi/lwr%2Fprofiler%2Fv%2F0_19_3/s/9f74c8370534ce02c6e7637abdcffedf/lwr_profiler.js":["lwr/profiler/v/0_19_3"],"/1/module/amd/1/l/en-US/mi/lwr%2Floader%2Fv%2F0_19_3/s/ba599b27c9302da4641024ef27bbad90/lwr_loader.js":["lwr/loader/v/0_19_3"]})
11
+ if (!globalThis.LWR.index) { globalThis.LWR.index = {}; }
12
+ Object.assign(globalThis.LWR.index, {"lwr/profiler/v/0_19_3":"/1/module/amd/1/l/en-US/mi/lwr%2Fprofiler%2Fv%2F0_19_3/s/9f74c8370534ce02c6e7637abdcffedf/lwr_profiler.js","lwr/loader/v/0_19_3":"/1/module/amd/1/l/en-US/mi/lwr%2Floader%2Fv%2F0_19_3/s/ba599b27c9302da4641024ef27bbad90/lwr_loader.js"})
@@ -1,15 +1,15 @@
1
- LWR.define('@lwrjs/app-service/amd-bootstrap/module/amd/v/0_19_1', ['lwr/loader/v/0_19_1', 'lwr/preInit/v/0_19_1', 'lwr/init/v/0_19_1'], (function (_0_19_1$2, _0_19_1, _0_19_1$1) { 'use strict';
1
+ LWR.define('@lwrjs/app-service/amd-bootstrap/module/amd/v/0_19_3', ['lwr/loader/v/0_19_3', 'lwr/preInit/v/0_19_3', 'lwr/init/v/0_19_3'], (function (_0_19_3$2, _0_19_3, _0_19_3$1) { 'use strict';
2
2
 
3
- const clientBootstrapConfig = _0_19_1.getClientBootstrapConfig();
3
+ const clientBootstrapConfig = _0_19_3.getClientBootstrapConfig();
4
4
  const { serverData, rootComponents } = clientBootstrapConfig;
5
5
 
6
6
  // initialize additional non-configured root components
7
7
  Promise.all(rootComponents.map(async (rootSpecifier) => {
8
- const element = _0_19_1$1.toKebabCase(rootSpecifier);
9
- const { default: Ctor } = await _0_19_1$2.load(rootSpecifier, '@lwrjs/app-service/amd-bootstrap/module/amd/v/0_19_1');
8
+ const element = _0_19_3$1.toKebabCase(rootSpecifier);
9
+ const { default: Ctor } = await _0_19_3$2.load(rootSpecifier, '@lwrjs/app-service/amd-bootstrap/module/amd/v/0_19_3');
10
10
  return [element, Ctor];
11
11
  })).then((rootModules) => {
12
- return _0_19_1$1.init(rootModules, serverData);
12
+ return _0_19_3$1.init(rootModules, serverData);
13
13
  }).then(() => {
14
14
  globalThis?.lwcRuntimeFlags?.ENABLE_WIRE_SYNC_EMIT &&
15
15
  (globalThis.lwcRuntimeFlags = {
@@ -1,10 +1,10 @@
1
- LWR.define('lwr/everywhereAmd/v/0_19_1', ['exports', 'lwr/vault/v/0_19_1'], (function (exports, _0_19_1) { 'use strict';
1
+ LWR.define('lwr/everywhereAmd/v/0_19_3', ['exports', 'lwr/vault/v/0_19_3'], (function (exports, _0_19_3) { 'use strict';
2
2
 
3
3
  // IMPORTANT: Do not add any static imports to this file that are not bundled with the amd-client
4
4
 
5
5
  // Do an OAuthed fetch
6
6
  async function authFetch(url, accept = 'javascript') {
7
- const authInfo = _0_19_1.getAuthInfo();
7
+ const authInfo = _0_19_3.getAuthInfo();
8
8
  if (authInfo) {
9
9
  return fetch(url, {
10
10
  headers: {
@@ -53,7 +53,7 @@ LWR.define('lwr/everywhereAmd/v/0_19_1', ['exports', 'lwr/vault/v/0_19_1'], (fun
53
53
  function authenticate(authInfo) {
54
54
  // Put OAuth info into the vault
55
55
  if (authInfo) {
56
- _0_19_1.setAuthInfo(authInfo);
56
+ _0_19_3.setAuthInfo(authInfo);
57
57
  }
58
58
  }
59
59
 
@@ -1,4 +1,4 @@
1
- LWR.define('lwr/init/v/0_19_1', ['exports', 'lwr/metrics/v/0_19_1', 'lwr/profiler/v/0_19_1', 'lwc/v/8_20_1'], (function (exports, _0_19_1$1, _0_19_1, _8_20_1) { 'use strict';
1
+ LWR.define('lwr/init/v/0_19_3', ['exports', 'lwr/metrics/v/0_19_3', 'lwr/profiler/v/0_19_3', 'lwc/v/8_20_1'], (function (exports, _0_19_3$1, _0_19_3, _8_20_1) { 'use strict';
2
2
 
3
3
  // eslint-disable-next-line lwr/only-allowed-type-imports
4
4
 
@@ -76,13 +76,13 @@ LWR.define('lwr/init/v/0_19_1', ['exports', 'lwr/metrics/v/0_19_1', 'lwr/profile
76
76
  function init(rootModules, serverData = {}) {
77
77
  // eslint-disable-next-line lwr/no-unguarded-apis
78
78
  if (typeof globalThis.customElements === 'undefined' || typeof globalThis.document === 'undefined') {
79
- _0_19_1.logOperationStart({
80
- id: _0_19_1$1.BOOTSTRAP_END
79
+ _0_19_3.logOperationStart({
80
+ id: _0_19_3$1.BOOTSTRAP_END
81
81
  });
82
82
  return;
83
83
  }
84
- _0_19_1.logOperationStart({
85
- id: _0_19_1$1.INIT
84
+ _0_19_3.logOperationStart({
85
+ id: _0_19_3$1.INIT
86
86
  });
87
87
  (async () => {
88
88
  let index = 0;
@@ -100,8 +100,8 @@ LWR.define('lwr/init/v/0_19_1', ['exports', 'lwr/metrics/v/0_19_1', 'lwr/profile
100
100
  // initialize and inject the root module into the LWR Root or DOM if it is missing
101
101
  // eslint-disable-next-line lwr/no-unguarded-apis
102
102
  if (!document.body.querySelector(elementName)) {
103
- _0_19_1.logOperationStart({
104
- id: _0_19_1$1.INIT_MODULE,
103
+ _0_19_3.logOperationStart({
104
+ id: _0_19_3$1.INIT_MODULE,
105
105
  specifier,
106
106
  specifierIndex
107
107
  });
@@ -112,8 +112,8 @@ LWR.define('lwr/init/v/0_19_1', ['exports', 'lwr/metrics/v/0_19_1', 'lwr/profile
112
112
  const container = document.querySelector('[lwr-root]');
113
113
  // eslint-disable-next-line lwr/no-unguarded-apis
114
114
  container ? container.appendChild(component) : document.body.appendChild(component);
115
- _0_19_1.logOperationEnd({
116
- id: _0_19_1$1.INIT_MODULE,
115
+ _0_19_3.logOperationEnd({
116
+ id: _0_19_3$1.INIT_MODULE,
117
117
  specifier,
118
118
  specifierIndex,
119
119
  metadata: {
@@ -127,8 +127,8 @@ LWR.define('lwr/init/v/0_19_1', ['exports', 'lwr/metrics/v/0_19_1', 'lwr/profile
127
127
  // eslint-disable-next-line lwr/no-unguarded-apis
128
128
  const elements = document.querySelectorAll(elementName);
129
129
  for (const element of elements) {
130
- _0_19_1.logOperationStart({
131
- id: _0_19_1$1.INIT_MODULE,
130
+ _0_19_3.logOperationStart({
131
+ id: _0_19_3$1.INIT_MODULE,
132
132
  specifier,
133
133
  specifierIndex
134
134
  });
@@ -137,8 +137,8 @@ LWR.define('lwr/init/v/0_19_1', ['exports', 'lwr/metrics/v/0_19_1', 'lwr/profile
137
137
  // hydrate SSR'd components
138
138
  if (propsId) {
139
139
  hydrateComponentProxy(element, ctor, serverData[propsId] || {});
140
- _0_19_1.logOperationEnd({
141
- id: _0_19_1$1.INIT_MODULE,
140
+ _0_19_3.logOperationEnd({
141
+ id: _0_19_3$1.INIT_MODULE,
142
142
  specifier,
143
143
  specifierIndex,
144
144
  metadata: {
@@ -176,8 +176,8 @@ LWR.define('lwr/init/v/0_19_1', ['exports', 'lwr/metrics/v/0_19_1', 'lwr/profile
176
176
  if (parent) {
177
177
  parent.replaceChild(component, element);
178
178
  }
179
- _0_19_1.logOperationEnd({
180
- id: _0_19_1$1.INIT_MODULE,
179
+ _0_19_3.logOperationEnd({
180
+ id: _0_19_3$1.INIT_MODULE,
181
181
  specifier,
182
182
  specifierIndex,
183
183
  metadata: {
@@ -187,11 +187,11 @@ LWR.define('lwr/init/v/0_19_1', ['exports', 'lwr/metrics/v/0_19_1', 'lwr/profile
187
187
  }
188
188
  }
189
189
  })();
190
- _0_19_1.logOperationEnd({
191
- id: _0_19_1$1.INIT
190
+ _0_19_3.logOperationEnd({
191
+ id: _0_19_3$1.INIT
192
192
  });
193
- _0_19_1.logOperationStart({
194
- id: _0_19_1$1.BOOTSTRAP_END
193
+ _0_19_3.logOperationStart({
194
+ id: _0_19_3$1.BOOTSTRAP_END
195
195
  });
196
196
  }
197
197
 
@@ -1,4 +1,4 @@
1
- LWR.define('lwr/loader/v/0_19_1', ['exports'], (function (exports) { 'use strict';
1
+ LWR.define('lwr/loader/v/0_19_3', ['exports'], (function (exports) { 'use strict';
2
2
 
3
3
  /**
4
4
  * Copyright (c) 2021, salesforce.com, inc.
@@ -6,7 +6,7 @@ LWR.define('lwr/loader/v/0_19_1', ['exports'], (function (exports) { 'use strict
6
6
  * SPDX-License-Identifier: MIT
7
7
  * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
8
8
  */
9
- /* LWR Module Loader v0.19.1 */
9
+ /* LWR Module Loader v0.19.3 */
10
10
  const templateRegex = /\{([0-9]+)\}/g;
11
11
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
12
12
  function templateString(template, args) {
@@ -137,6 +137,11 @@ LWR.define('lwr/loader/v/0_19_1', ['exports'], (function (exports) { 'use strict
137
137
  level: 0,
138
138
  message: 'Cannot dynamically import "lwc" with importer "{0}"'
139
139
  });
140
+ const NO_IMPORT_LOADER = Object.freeze({
141
+ code: 3024,
142
+ level: 0,
143
+ message: 'Cannot dynamically import the LWR loader with importer "{0}"'
144
+ });
140
145
  const NO_BLOB_IMPORT = Object.freeze({
141
146
  code: 3024,
142
147
  level: 0,
@@ -970,60 +975,104 @@ LWR.define('lwr/loader/v/0_19_1', ['exports'], (function (exports) { 'use strict
970
975
  return this.resolver;
971
976
  }
972
977
 
973
- // Returns an existing module record by the resolvedId or aliased id
974
- getExistingModuleRecord(resolvedId, aliasId) {
975
- const moduleRecord = this.moduleRegistry.get(resolvedId);
976
- if (moduleRecord) {
977
- this.storeModuleAlias(aliasId, resolvedId);
978
- return moduleRecord;
978
+ /**
979
+ * Gets or creates a module record for the given resolved ID and original ID.
980
+ *
981
+ * This function handles the complex logic of module resolution and ensures that:
982
+ * 1. Modules loaded via different paths (aliases, direct specifiers, URLs) return the same instance
983
+ * 2. Bundle URLs are properly resolved to their final specifier names after instantiation
984
+ * 3. Alias mappings are maintained for future lookups
985
+ *
986
+ * @param resolvedId - The resolved module identifier (could be a URL or specifier)
987
+ * @param originalId - The original module specifer that was requested
988
+ * @returns Promise<ModuleRecord> - The module record for the module
989
+ */
990
+ async getModuleRecord(resolvedId, originalId) {
991
+ // Step 1: Check if we already have a module record for the resolved ID
992
+ const existingRecord = this.moduleRegistry.get(resolvedId);
993
+ if (existingRecord) {
994
+ if (isUrl(resolvedId)) {
995
+ // Special case: The resolved ID is a URL (likely a bundle URL)
996
+ // We need to wait for instantiation to complete, then re-resolve to get the final specifier
997
+ const moduleDef = await existingRecord.instantiation;
998
+ const reResolvedId = await this.resolve(originalId);
999
+
1000
+ // If the re-resolved ID is still a URL OR matches the module definition name,
1001
+ // then this is an internally mapped module (e.g., bundle -> specifier)
1002
+ if (isUrl(reResolvedId) || moduleDef.name === reResolvedId) {
1003
+ // Store the alias mapping and return the existing record
1004
+ this.storeModuleAlias(originalId, reResolvedId);
1005
+ return existingRecord;
1006
+ } else {
1007
+ // The re-resolved ID is now a specifier, check if we have a record for it
1008
+ resolvedId = reResolvedId;
1009
+ const reExistingRecord = this.moduleRegistry.get(resolvedId);
1010
+ if (reExistingRecord) {
1011
+ // Found a record for the specifier, store alias and return it
1012
+ this.storeModuleAlias(originalId, reResolvedId);
1013
+ return reExistingRecord;
1014
+ }
1015
+ }
1016
+ } else if (existingRecord) {
1017
+ // Simple case: resolved ID is a specifier and we have a record for it
1018
+ this.storeModuleAlias(originalId, resolvedId);
1019
+ return existingRecord;
1020
+ }
979
1021
  }
980
1022
 
981
- // Check if this is a known alias
982
- if (resolvedId !== aliasId) {
983
- const alias = this.aliases.get(aliasId);
1023
+ // Step 2: Check if the original ID is a known alias that maps to an existing module
1024
+ if (resolvedId !== originalId) {
1025
+ const alias = this.aliases.get(originalId);
984
1026
  if (alias) {
985
1027
  const aliasedModule = this.moduleRegistry.get(alias);
986
1028
  if (aliasedModule) {
1029
+ // Found an existing module via alias, return it
987
1030
  return aliasedModule;
988
1031
  }
989
1032
  }
990
1033
  }
991
- return moduleRecord;
992
- }
993
- async getModuleRecord(resolvedId, id) {
994
- // Look for an existing record
995
- const existingRecord = this.getExistingModuleRecord(resolvedId, id);
996
- if (existingRecord) {
997
- // return existing
998
- return existingRecord;
999
- }
1000
1034
 
1001
- // Create a new Module Record
1002
- const instantiation = this.getModuleDef(resolvedId, id);
1035
+ // Step 3: No existing record found, create a new module record
1036
+ const instantiation = this.getModuleDef(resolvedId, originalId);
1037
+
1038
+ // Create dependency records for all module dependencies
1003
1039
  const dependencyRecords = instantiation.then(moduleDef => {
1004
1040
  const dependencies = moduleDef.dependencies || [];
1005
- // get dep and filter out exports
1041
+
1042
+ // Map dependencies to module records, filtering out 'exports' and 'require'
1006
1043
  const filtered = dependencies.map(dep => {
1007
1044
  if (dep === 'exports') {
1008
- return;
1045
+ return; // 'exports' is a special AMD dependency, not a real module
1009
1046
  }
1010
- invariant(dep !== 'require', NO_AMD_REQUIRE);
1047
+ invariant(dep !== 'require', NO_AMD_REQUIRE); // 'require' is not allowed
1011
1048
  return this.getModuleDependencyRecord.call(this, dep);
1012
1049
  }).filter(depRecord => depRecord !== undefined);
1013
1050
  return Promise.all(filtered);
1014
1051
  });
1052
+
1053
+ // Create the new module record
1015
1054
  const newModuleRecord = {
1016
1055
  id: resolvedId,
1056
+ // Use resolved ID as the record identifier
1057
+ originalId: originalId,
1058
+ // Keep track of the original requested ID
1017
1059
  module: Object.create(null),
1060
+ // Empty object for module exports
1018
1061
  dependencyRecords,
1062
+ // Promise for dependency module records
1019
1063
  instantiation,
1064
+ // Promise for module definition
1020
1065
  evaluated: false,
1021
- evaluationPromise: null
1066
+ // Track if module has been evaluated
1067
+ evaluationPromise: null // Promise for module evaluation
1022
1068
  };
1023
- this.moduleRegistry.set(resolvedId, newModuleRecord);
1024
- this.storeModuleAlias(id, resolvedId);
1025
1069
 
1026
- // Wait for the dependencies to resolve the return the moduleRecord
1070
+ // Store the module record and create alias mapping
1071
+ this.moduleRegistry.set(resolvedId, newModuleRecord);
1072
+ if (resolvedId !== originalId) {
1073
+ this.storeModuleAlias(originalId, resolvedId);
1074
+ }
1075
+ // Wait for dependencies to resolve before returning the module record
1027
1076
  return dependencyRecords.then(() => newModuleRecord);
1028
1077
  }
1029
1078
  storeModuleAlias(aliasId, resolvedId) {
@@ -1467,6 +1516,12 @@ LWR.define('lwr/loader/v/0_19_1', ['exports'], (function (exports) { 'use strict
1467
1516
  throw new LoaderError(NO_IMPORT_LWC, [importer]);
1468
1517
  }
1469
1518
 
1519
+ // Throw an error if the specifier is "lwr/loader" and the importer is defined
1520
+ // Nobody should be dynamically importing the LWR loader; it is an app-level API
1521
+ if (id === 'lwr/loader' && importer !== undefined) {
1522
+ throw new LoaderError(NO_IMPORT_LOADER, [importer]);
1523
+ }
1524
+
1470
1525
  // Throw an error if the specifier is a blob URL
1471
1526
  if (id.startsWith('blob:')) {
1472
1527
  throw new LoaderError(NO_BLOB_IMPORT);
@@ -1,4 +1,4 @@
1
- LWR.define('lwr/metrics/v/0_19_1', ['exports'], (function (exports) { 'use strict';
1
+ LWR.define('lwr/metrics/v/0_19_3', ['exports'], (function (exports) { 'use strict';
2
2
 
3
3
  // Bootstrap / shim
4
4
  const BOOTSTRAP_PREFIX = 'lwr.bootstrap.';
@@ -1,4 +1,4 @@
1
- LWR.define('lwr/preInit/v/0_19_1', ['exports'], (function (exports) { 'use strict';
1
+ LWR.define('lwr/preInit/v/0_19_3', ['exports'], (function (exports) { 'use strict';
2
2
 
3
3
  /**
4
4
  * This module is called in the ABS module (app bootstrap module) to perform neccesary pre initialization steps for an LWR app.
@@ -1,4 +1,4 @@
1
- LWR.define('lwr/profiler/v/0_19_1', ['exports'], (function (exports) { 'use strict';
1
+ LWR.define('lwr/profiler/v/0_19_3', ['exports'], (function (exports) { 'use strict';
2
2
 
3
3
  var Phase = /*#__PURE__*/function (Phase) {
4
4
  Phase[Phase["Start"] = 0] = "Start";
@@ -1,4 +1,4 @@
1
- LWR.define('lwr/vault/v/0_19_1', ['exports'], (function (exports) { 'use strict';
1
+ LWR.define('lwr/vault/v/0_19_3', ['exports'], (function (exports) { 'use strict';
2
2
 
3
3
  // Credential vault for storing setters and subscribers for OAuth info
4
4
  // This module is a SINGLETON and must be excluded from ESM bundling
@@ -4,5 +4,5 @@
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 Error Shim v0.19.1 */
7
+ /* LWR Error Shim v0.19.3 */
8
8
  !function(){"use strict";const o=globalThis;if(!(o.LWR&&o.LWR.define)){const r=new Error("The LWR application failed to bootstrap");if(!o.LWR||!o.LWR.onError)throw r;o.LWR.onError(r)}}();
@@ -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.1 */
7
+ /* LWR Module Loader Shim v0.19.3 */
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_1';
216
+ this.loaderSpecifier = 'lwr/loader/v/0_19_3';
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_1', ['exports'], exporter);
367
+ define('lwr/profiler/v/0_19_3', ['exports'], exporter);
368
368
  }
369
369
 
370
370
  // Set up the application globals, import map, root custom element...
@@ -456,14 +456,14 @@
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_1') < 0) {
460
- GLOBAL.LWR.requiredModules.push('lwr/loader/v/0_19_1');
459
+ if (GLOBAL.LWR.requiredModules.indexOf('lwr/loader/v/0_19_3') < 0) {
460
+ GLOBAL.LWR.requiredModules.push('lwr/loader/v/0_19_3');
461
461
  }
462
462
  new LoaderShim(GLOBAL);
463
463
 
464
464
  })();
465
465
 
466
- LWR.define('lwr/loader/v/0_19_1', ['exports'], (function (exports) { 'use strict';
466
+ LWR.define('lwr/loader/v/0_19_3', ['exports'], (function (exports) { 'use strict';
467
467
 
468
468
  const templateRegex = /\{([0-9]+)\}/g;
469
469
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -603,6 +603,11 @@ LWR.define('lwr/loader/v/0_19_1', ['exports'], (function (exports) { 'use strict
603
603
  level: 0,
604
604
  message: 'Cannot dynamically import "lwc" with importer "{0}"',
605
605
  });
606
+ const NO_IMPORT_LOADER = Object.freeze({
607
+ code: 3024,
608
+ level: 0,
609
+ message: 'Cannot dynamically import the LWR loader with importer "{0}"',
610
+ });
606
611
  const NO_BLOB_IMPORT = Object.freeze({
607
612
  code: 3024,
608
613
  level: 0,
@@ -1305,6 +1310,7 @@ LWR.define('lwr/loader/v/0_19_1', ['exports'], (function (exports) { 'use strict
1305
1310
 
1306
1311
 
1307
1312
 
1313
+
1308
1314
 
1309
1315
 
1310
1316
  class ModuleRegistry {
@@ -1543,46 +1549,78 @@ LWR.define('lwr/loader/v/0_19_1', ['exports'], (function (exports) { 'use strict
1543
1549
  return this.resolver;
1544
1550
  }
1545
1551
 
1546
- // Returns an existing module record by the resolvedId or aliased id
1547
- getExistingModuleRecord(resolvedId, aliasId) {
1548
- const moduleRecord = this.moduleRegistry.get(resolvedId);
1549
- if (moduleRecord) {
1550
- this.storeModuleAlias(aliasId, resolvedId);
1551
- return moduleRecord;
1552
+ /**
1553
+ * Gets or creates a module record for the given resolved ID and original ID.
1554
+ *
1555
+ * This function handles the complex logic of module resolution and ensures that:
1556
+ * 1. Modules loaded via different paths (aliases, direct specifiers, URLs) return the same instance
1557
+ * 2. Bundle URLs are properly resolved to their final specifier names after instantiation
1558
+ * 3. Alias mappings are maintained for future lookups
1559
+ *
1560
+ * @param resolvedId - The resolved module identifier (could be a URL or specifier)
1561
+ * @param originalId - The original module specifer that was requested
1562
+ * @returns Promise<ModuleRecord> - The module record for the module
1563
+ */
1564
+ async getModuleRecord(resolvedId, originalId) {
1565
+ // Step 1: Check if we already have a module record for the resolved ID
1566
+ const existingRecord = this.moduleRegistry.get(resolvedId);
1567
+ if (existingRecord) {
1568
+ if (isUrl(resolvedId)) {
1569
+ // Special case: The resolved ID is a URL (likely a bundle URL)
1570
+ // We need to wait for instantiation to complete, then re-resolve to get the final specifier
1571
+ const moduleDef = await existingRecord.instantiation;
1572
+
1573
+ const reResolvedId = await this.resolve(originalId);
1574
+
1575
+ // If the re-resolved ID is still a URL OR matches the module definition name,
1576
+ // then this is an internally mapped module (e.g., bundle -> specifier)
1577
+ if (isUrl(reResolvedId) || moduleDef.name === reResolvedId) {
1578
+ // Store the alias mapping and return the existing record
1579
+ this.storeModuleAlias(originalId, reResolvedId);
1580
+ return existingRecord;
1581
+ } else {
1582
+ // The re-resolved ID is now a specifier, check if we have a record for it
1583
+ resolvedId = reResolvedId;
1584
+ const reExistingRecord = this.moduleRegistry.get(resolvedId);
1585
+ if (reExistingRecord) {
1586
+ // Found a record for the specifier, store alias and return it
1587
+ this.storeModuleAlias(originalId, reResolvedId);
1588
+ return reExistingRecord;
1589
+ }
1590
+ }
1591
+ } else if (existingRecord) {
1592
+ // Simple case: resolved ID is a specifier and we have a record for it
1593
+ this.storeModuleAlias(originalId, resolvedId);
1594
+ return existingRecord;
1595
+ }
1552
1596
  }
1553
1597
 
1554
- // Check if this is a known alias
1555
- if (resolvedId !== aliasId) {
1556
- const alias = this.aliases.get(aliasId);
1598
+ // Step 2: Check if the original ID is a known alias that maps to an existing module
1599
+ if (resolvedId !== originalId) {
1600
+ const alias = this.aliases.get(originalId);
1557
1601
  if (alias) {
1558
1602
  const aliasedModule = this.moduleRegistry.get(alias);
1559
1603
  if (aliasedModule) {
1604
+ // Found an existing module via alias, return it
1560
1605
  return aliasedModule;
1561
1606
  }
1562
1607
  }
1563
1608
  }
1564
- return moduleRecord;
1565
- }
1566
1609
 
1567
- async getModuleRecord(resolvedId, id) {
1568
- // Look for an existing record
1569
- const existingRecord = this.getExistingModuleRecord(resolvedId, id);
1570
- if (existingRecord) {
1571
- // return existing
1572
- return existingRecord;
1573
- }
1610
+ // Step 3: No existing record found, create a new module record
1611
+ const instantiation = this.getModuleDef(resolvedId, originalId);
1574
1612
 
1575
- // Create a new Module Record
1576
- const instantiation = this.getModuleDef(resolvedId, id);
1613
+ // Create dependency records for all module dependencies
1577
1614
  const dependencyRecords = instantiation.then((moduleDef) => {
1578
1615
  const dependencies = moduleDef.dependencies || [];
1579
- // get dep and filter out exports
1616
+
1617
+ // Map dependencies to module records, filtering out 'exports' and 'require'
1580
1618
  const filtered = dependencies
1581
1619
  .map((dep) => {
1582
1620
  if (dep === 'exports') {
1583
- return;
1621
+ return; // 'exports' is a special AMD dependency, not a real module
1584
1622
  }
1585
- invariant(dep !== 'require', NO_AMD_REQUIRE);
1623
+ invariant(dep !== 'require', NO_AMD_REQUIRE); // 'require' is not allowed
1586
1624
  return this.getModuleDependencyRecord.call(this, dep);
1587
1625
  })
1588
1626
  .filter((depRecord) => depRecord !== undefined) ;
@@ -1590,19 +1628,23 @@ LWR.define('lwr/loader/v/0_19_1', ['exports'], (function (exports) { 'use strict
1590
1628
  return Promise.all(filtered);
1591
1629
  });
1592
1630
 
1631
+ // Create the new module record
1593
1632
  const newModuleRecord = {
1594
- id: resolvedId,
1595
- module: Object.create(null),
1596
- dependencyRecords,
1597
- instantiation,
1598
- evaluated: false,
1599
- evaluationPromise: null,
1633
+ id: resolvedId, // Use resolved ID as the record identifier
1634
+ originalId: originalId, // Keep track of the original requested ID
1635
+ module: Object.create(null), // Empty object for module exports
1636
+ dependencyRecords, // Promise for dependency module records
1637
+ instantiation, // Promise for module definition
1638
+ evaluated: false, // Track if module has been evaluated
1639
+ evaluationPromise: null, // Promise for module evaluation
1600
1640
  };
1601
1641
 
1642
+ // Store the module record and create alias mapping
1602
1643
  this.moduleRegistry.set(resolvedId, newModuleRecord);
1603
- this.storeModuleAlias(id, resolvedId);
1604
-
1605
- // Wait for the dependencies to resolve the return the moduleRecord
1644
+ if (resolvedId !== originalId) {
1645
+ this.storeModuleAlias(originalId, resolvedId);
1646
+ }
1647
+ // Wait for dependencies to resolve before returning the module record
1606
1648
  return dependencyRecords.then(() => newModuleRecord);
1607
1649
  }
1608
1650
 
@@ -1898,7 +1940,6 @@ LWR.define('lwr/loader/v/0_19_1', ['exports'], (function (exports) { 'use strict
1898
1940
 
1899
1941
 
1900
1942
 
1901
-
1902
1943
  addLoaderPlugin(hooks) {
1903
1944
  if (typeof hooks !== 'object') {
1904
1945
  throw new LoaderError(INVALID_HOOK);
@@ -2080,6 +2121,12 @@ LWR.define('lwr/loader/v/0_19_1', ['exports'], (function (exports) { 'use strict
2080
2121
  throw new LoaderError(NO_IMPORT_LWC, [importer]);
2081
2122
  }
2082
2123
 
2124
+ // Throw an error if the specifier is "lwr/loader" and the importer is defined
2125
+ // Nobody should be dynamically importing the LWR loader; it is an app-level API
2126
+ if (id === 'lwr/loader' && importer !== undefined) {
2127
+ throw new LoaderError(NO_IMPORT_LOADER, [importer]);
2128
+ }
2129
+
2083
2130
  // Throw an error if the specifier is a blob URL
2084
2131
  if (id.startsWith('blob:')) {
2085
2132
  throw new LoaderError(NO_BLOB_IMPORT);