@lwrjs/module-registry 0.6.0-alpha.10 → 0.6.0-alpha.14
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/cjs/index.cjs +1 -1
- package/build/cjs/linker/linker.cjs +4 -4
- package/build/es/index.js +2 -4
- package/build/es/linker/linker.js +11 -9
- package/package.json +5 -5
package/build/cjs/index.cjs
CHANGED
|
@@ -185,7 +185,7 @@ var LwrModuleRegistry = class {
|
|
|
185
185
|
} else {
|
|
186
186
|
let loaderModuleEntry;
|
|
187
187
|
const dynamicImports = moduleDef.moduleRecord.dynamicImports;
|
|
188
|
-
if (moduleDef.moduleEntry.specifier !== esmLoader && dynamicImports
|
|
188
|
+
if (moduleDef.moduleEntry.specifier !== esmLoader && dynamicImports) {
|
|
189
189
|
loaderModuleEntry = await this.getModuleEntry({specifier: esmLoader}, runtimeParams);
|
|
190
190
|
}
|
|
191
191
|
const {code: esmLinkedSource, linkedModuleRecord} = await (0, import_linker.link)(this, moduleDef, import_esm_strategy.default, runtimeEnvironment, runtimeParams, loaderModuleEntry && {
|
|
@@ -84,17 +84,17 @@ async function link(moduleRegistry, moduleDef, strategy, runtimeEnvironment, run
|
|
|
84
84
|
if (isStringLiteral && runtimeEnvironment.bundle && runtimeEnvironment.format === "esm") {
|
|
85
85
|
signature = await (0, import_signature.getBundleSignature)(importRef, moduleRegistry);
|
|
86
86
|
}
|
|
87
|
-
const link2 = isStringLiteral ? strategy(importRef, runtimeEnvironment, runtimeParams, signature) : importRef.specifier;
|
|
87
|
+
const link2 = isStringLiteral && amdLoaderModule ? strategy(importRef, runtimeEnvironment, runtimeParams, signature) : importRef.specifier;
|
|
88
88
|
const linkedLocations = locations.map(({location, importLocation}) => {
|
|
89
89
|
const {startColumn, endColumn} = location;
|
|
90
90
|
const {startColumn: importStart, endColumn: importEnd} = importLocation;
|
|
91
|
-
if (isStringLiteral) {
|
|
91
|
+
if (isStringLiteral && amdLoaderModule) {
|
|
92
92
|
codeStringBuilder.overwrite(startColumn + 1, endColumn - 1, link2);
|
|
93
93
|
}
|
|
94
|
-
if (amdLoaderModule || esmLoaderModule
|
|
94
|
+
if (amdLoaderModule || esmLoaderModule) {
|
|
95
95
|
codeStringBuilder.overwrite(importStart, importEnd, "load(");
|
|
96
96
|
loaderSizeOffset = 2;
|
|
97
|
-
if (!isStringLiteral) {
|
|
97
|
+
if (!(amdLoaderModule && isStringLiteral)) {
|
|
98
98
|
const importerSpecifier = (0, import_shared_utils2.getSpecifier)({specifier, version});
|
|
99
99
|
codeStringBuilder.overwrite(endColumn, endColumn + 1, `, '${importerSpecifier}')`);
|
|
100
100
|
loaderSizeOffset = -1 * importerSpecifier.length - 2;
|
package/build/es/index.js
CHANGED
|
@@ -175,10 +175,8 @@ export class LwrModuleRegistry {
|
|
|
175
175
|
// resolve the loader entry if there are VARIABLE dynamic imports
|
|
176
176
|
let loaderModuleEntry;
|
|
177
177
|
const dynamicImports = moduleDef.moduleRecord.dynamicImports;
|
|
178
|
-
if (moduleDef.moduleEntry.specifier !== esmLoader &&
|
|
179
|
-
|
|
180
|
-
dynamicImports.some((d) => d.moduleNameType === ModuleNameType.unresolved)) {
|
|
181
|
-
// ONLY include the ESM loader if there are VARIABLE dynamic imports
|
|
178
|
+
if (moduleDef.moduleEntry.specifier !== esmLoader && dynamicImports) {
|
|
179
|
+
// ONLY include the ESM loader if there are dynamic imports
|
|
182
180
|
// AND this is not the ESM loader itself (it uses a variable dynamic import we DO NOT want to link)
|
|
183
181
|
loaderModuleEntry = await this.getModuleEntry({ specifier: esmLoader }, runtimeParams);
|
|
184
182
|
}
|
|
@@ -70,26 +70,28 @@ export async function link(moduleRegistry, moduleDef, strategy, runtimeEnvironme
|
|
|
70
70
|
if (isStringLiteral && runtimeEnvironment.bundle && runtimeEnvironment.format === 'esm') {
|
|
71
71
|
signature = await getBundleSignature(importRef, moduleRegistry);
|
|
72
72
|
}
|
|
73
|
-
const link = isStringLiteral
|
|
74
|
-
? strategy(importRef, runtimeEnvironment, runtimeParams, signature) // dynamic import of a static string
|
|
75
|
-
: importRef.specifier; // variable dynamic import
|
|
73
|
+
const link = isStringLiteral && amdLoaderModule
|
|
74
|
+
? strategy(importRef, runtimeEnvironment, runtimeParams, signature) // dynamic import of a static string in AMD
|
|
75
|
+
: importRef.specifier; // in ESM or a variable dynamic import in AMD: keep the variable name as-is
|
|
76
76
|
// transform locations
|
|
77
77
|
// replace all locations of importee with the link
|
|
78
78
|
const linkedLocations = locations.map(({ location, importLocation }) => {
|
|
79
79
|
const { startColumn, endColumn } = location;
|
|
80
80
|
const { startColumn: importStart, endColumn: importEnd } = importLocation;
|
|
81
|
-
// rewrite the importee link if it is a static string
|
|
82
|
-
|
|
81
|
+
// rewrite the importee link if it is a static string in AMD
|
|
82
|
+
// do not rewrite ANY dynamic import importee links in ESM (no signatures or URIs prevents caching issues)
|
|
83
|
+
if (isStringLiteral && amdLoaderModule) {
|
|
83
84
|
codeStringBuilder.overwrite(startColumn + 1, endColumn - 1, link);
|
|
84
85
|
}
|
|
85
|
-
if (amdLoaderModule ||
|
|
86
|
+
if (amdLoaderModule || esmLoaderModule) {
|
|
86
87
|
// replace the dynamic import with a configured loader
|
|
87
|
-
// ONLY do this in ESM if the dynamic import is VARIABLE
|
|
88
88
|
// e.g. - await import('dynamic/module'); -> await load('dynamic/module');
|
|
89
89
|
codeStringBuilder.overwrite(importStart, importEnd, 'load(');
|
|
90
90
|
loaderSizeOffset = 2;
|
|
91
|
-
if (!isStringLiteral) {
|
|
92
|
-
// add the importer specifier as the 2nd arg to load() for
|
|
91
|
+
if (!(amdLoaderModule && isStringLiteral)) {
|
|
92
|
+
// add the importer specifier as the 2nd arg to load() for:
|
|
93
|
+
// - VARIABLE dynamic imports in AMD
|
|
94
|
+
// - ALL dynamic imports in ESM
|
|
93
95
|
const importerSpecifier = getSpecifier({ specifier, version });
|
|
94
96
|
codeStringBuilder.overwrite(endColumn, endColumn + 1, `, '${importerSpecifier}')`);
|
|
95
97
|
loaderSizeOffset = -1 * importerSpecifier.length - 2;
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
|
-
"version": "0.6.0-alpha.
|
|
7
|
+
"version": "0.6.0-alpha.14",
|
|
8
8
|
"homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
@@ -30,18 +30,18 @@
|
|
|
30
30
|
"build/**/*.d.ts"
|
|
31
31
|
],
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@lwrjs/diagnostics": "0.6.0-alpha.
|
|
34
|
-
"@lwrjs/shared-utils": "0.6.0-alpha.
|
|
33
|
+
"@lwrjs/diagnostics": "0.6.0-alpha.14",
|
|
34
|
+
"@lwrjs/shared-utils": "0.6.0-alpha.14",
|
|
35
35
|
"es-module-lexer": "^0.3.18",
|
|
36
36
|
"ws": "^7.2.5"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@lwrjs/types": "0.6.0-alpha.
|
|
39
|
+
"@lwrjs/types": "0.6.0-alpha.14",
|
|
40
40
|
"@types/es-module-lexer": "^0.3.0",
|
|
41
41
|
"@types/ws": "^7.2.4"
|
|
42
42
|
},
|
|
43
43
|
"engines": {
|
|
44
44
|
"node": ">=14.15.4 <17"
|
|
45
45
|
},
|
|
46
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "2850ceddcf17cdc561abbdbeb465edc5d5391cfa"
|
|
47
47
|
}
|