@lwrjs/loader 0.22.9 → 0.22.11
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/README.md +33 -1
- package/build/assets/prod/lwr-error-shim.js +1 -1
- package/build/assets/prod/lwr-loader-shim-legacy.bundle.js +530 -25
- package/build/assets/prod/lwr-loader-shim-legacy.bundle.min.js +3 -3
- package/build/assets/prod/lwr-loader-shim-legacy.js +317 -14
- package/build/assets/prod/lwr-loader-shim.bundle.js +123 -12
- package/build/assets/prod/lwr-loader-shim.bundle.min.js +3 -3
- package/build/assets/prod/lwr-loader-shim.js +105 -8
- package/build/cjs/modules/lwr/loader/validateLoadSpecifier.cjs +4 -1
- package/build/cjs/modules/lwr/loaderLegacy/importMap/importMap.cjs +1 -1
- package/build/cjs/modules/lwr/loaderLegacy/importMap/importMapResolver.cjs +12 -0
- package/build/cjs/modules/lwr/loaderLegacy/importMap/utils.cjs +13 -1
- package/build/cjs/modules/lwr/loaderLegacy/utils/validation.cjs +93 -0
- package/build/modules/lwr/esmLoader/esmLoader.js +1 -1
- package/build/modules/lwr/loader/loader.js +18 -4
- package/build/modules/lwr/loader/validateLoadSpecifier.d.ts +2 -1
- package/build/modules/lwr/loader/validateLoadSpecifier.js +11 -2
- package/build/modules/lwr/loaderLegacy/importMap/importMap.js +3 -2
- package/build/modules/lwr/loaderLegacy/importMap/importMapResolver.d.ts +1 -0
- package/build/modules/lwr/loaderLegacy/importMap/importMapResolver.js +13 -0
- package/build/modules/lwr/loaderLegacy/importMap/utils.d.ts +12 -1
- package/build/modules/lwr/loaderLegacy/importMap/utils.js +24 -2
- package/build/modules/lwr/loaderLegacy/loaderLegacy.d.ts +11 -1
- package/build/modules/lwr/loaderLegacy/loaderLegacy.js +213 -11
- package/build/modules/lwr/loaderLegacy/utils/validation.d.ts +50 -0
- package/build/modules/lwr/loaderLegacy/utils/validation.js +114 -0
- package/build/shim/defineCacheResolver.d.ts +10 -0
- package/build/shim/defineCacheResolver.js +78 -0
- package/build/shim/loader.d.ts +5 -1
- package/build/shim/loader.js +14 -3
- package/build/shim/shim.js +3 -2
- package/build/shim-legacy/loaderLegacy.d.ts +7 -2
- package/build/shim-legacy/loaderLegacy.js +15 -4
- package/build/shim-legacy/shimLegacy.d.ts +14 -0
- package/build/shim-legacy/shimLegacy.js +53 -4
- package/build/types.d.ts +22 -0
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -83,6 +83,38 @@ LWR.define('foo/bar', ['exports'], (exports) => {
|
|
|
83
83
|
});
|
|
84
84
|
```
|
|
85
85
|
|
|
86
|
+
### `loader.importMap()`
|
|
87
|
+
|
|
88
|
+
```ts
|
|
89
|
+
interface LwrImportMapUpdateMethod {
|
|
90
|
+
(importMapUpdate: ImportMapUpdate): void;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
type ImportMapUpdate = Record<string, string[]>;
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Apply update of import mappings at runtime. This allows dynamically registering new module mappings after the loader has been initialized. This is a synchronous operation.
|
|
97
|
+
|
|
98
|
+
**parameters**
|
|
99
|
+
|
|
100
|
+
- `importMapUpdate` - Import Map Update object containing:
|
|
101
|
+
- [moduleScriptURL] - Script URL containing LWR define statements
|
|
102
|
+
- string[] - array of module names which are included in the given script
|
|
103
|
+
|
|
104
|
+
**Important**: Import map entries are **write-once** — once a specifier is mapped, it cannot be overridden. This ensures deterministic module resolution and prevents runtime mutation of previously resolved dependencies. If a conflicting mapping is provided for an existing specifier, the new mapping is ignored and a warning is logged.
|
|
105
|
+
|
|
106
|
+
**Important**: Protected modules (`lwc`, `lwr/*`) cannot be remapped for security reasons. Attempting to remap these modules will throw an error.
|
|
107
|
+
|
|
108
|
+
**Example**
|
|
109
|
+
|
|
110
|
+
```js
|
|
111
|
+
// Register a runtime import mapping
|
|
112
|
+
// ONLY AVAILABLE WHEN USING THE GLOBAL API (AMD / Legacy Mode):
|
|
113
|
+
LWR.importMap({
|
|
114
|
+
'/bundles/my-module.js': ['my/module'],
|
|
115
|
+
});
|
|
116
|
+
```
|
|
117
|
+
|
|
86
118
|
### `loader.load()`
|
|
87
119
|
|
|
88
120
|
```ts
|
|
@@ -280,7 +312,7 @@ console.log(result); // 'abc'
|
|
|
280
312
|
The Client Runtime Loader Shim bootstraps the [Loader instance](#api) and other required modules for LWR applications in AMD format. The AMD Loader Shim is responsible for:
|
|
281
313
|
|
|
282
314
|
- defining and executing the [`@lwr/loader`](#api)
|
|
283
|
-
- exposure of the loader's `define`
|
|
315
|
+
- exposure of the loader's `define` and `importMap` APIs at `globalThis.LWR.define` and `globalThis.LWR.importMap`
|
|
284
316
|
- client-side orchestration for the generated application bootstrap module
|
|
285
317
|
|
|
286
318
|
### LWR Application Document
|
|
@@ -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.22.
|
|
7
|
+
/* LWR Error Shim v0.22.11 */
|
|
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)}}();
|