@lwrjs/module-registry 0.8.0-alpha.0 → 0.8.0-alpha.10
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 +40 -46
- package/build/cjs/signature.cjs +14 -3
- package/build/es/index.js +33 -44
- package/build/es/signature.js +19 -5
- package/package.json +5 -5
package/build/cjs/index.cjs
CHANGED
|
@@ -94,15 +94,13 @@ var LwrModuleRegistry = class {
|
|
|
94
94
|
if (cacheDisabled === false && this.moduleDefCache.has(moduleEntry.id)) {
|
|
95
95
|
return this.moduleDefCache.get(moduleEntry.id);
|
|
96
96
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
};
|
|
105
|
-
return this.inflightModuleDefinitions.execute(moduleEntry.id, createModulePromiseCtor, this);
|
|
97
|
+
return this.inflightModuleDefinitions.execute(moduleEntry.id, async () => {
|
|
98
|
+
const moduleDef = await this.createModuleDefinition(moduleId, runtimeParams);
|
|
99
|
+
if (cacheDisabled === false) {
|
|
100
|
+
this.moduleDefCache.set(moduleDef.id, moduleDef);
|
|
101
|
+
}
|
|
102
|
+
return moduleDef;
|
|
103
|
+
});
|
|
106
104
|
}
|
|
107
105
|
async createModuleDefinition(moduleId, runtimeParams) {
|
|
108
106
|
const {locker} = this.globalConfig;
|
|
@@ -120,7 +118,14 @@ var LwrModuleRegistry = class {
|
|
|
120
118
|
async getLinkedModule(moduleId, runtimeEnvironment, runtimeParams) {
|
|
121
119
|
const moduleEntry = await this.getModuleEntry(moduleId, runtimeParams);
|
|
122
120
|
const id = moduleEntry.id;
|
|
123
|
-
const {
|
|
121
|
+
const {
|
|
122
|
+
format,
|
|
123
|
+
compat,
|
|
124
|
+
debug,
|
|
125
|
+
minify,
|
|
126
|
+
bundle,
|
|
127
|
+
env: {NODE_ENV: envMode}
|
|
128
|
+
} = runtimeEnvironment;
|
|
124
129
|
const locale = runtimeParams?.["locale"];
|
|
125
130
|
const environment = runtimeParams?.["environment"];
|
|
126
131
|
const {
|
|
@@ -146,6 +151,18 @@ var LwrModuleRegistry = class {
|
|
|
146
151
|
}
|
|
147
152
|
const moduleDef = await this.getModule(moduleId, runtimeParams);
|
|
148
153
|
const moduleLinked = await this.createLinkedModuleDefinition(moduleDef, runtimeEnvironment, runtimeParams);
|
|
154
|
+
if (format === "amd" && !bundle) {
|
|
155
|
+
moduleLinked.linkedSource = (await this.context.compiler.convertToAmd(moduleLinked.linkedSource, {
|
|
156
|
+
id: moduleLinked.id
|
|
157
|
+
})).code;
|
|
158
|
+
}
|
|
159
|
+
const minified = !!minify && !debug;
|
|
160
|
+
if (minified && !bundle) {
|
|
161
|
+
moduleLinked.linkedSource = (await this.context.compiler.minifyJavascript(moduleLinked.linkedSource)).code;
|
|
162
|
+
moduleLinked.linkedConfig.minified = true;
|
|
163
|
+
} else {
|
|
164
|
+
moduleLinked.linkedSource = (await this.context.compiler.parseJavascript(moduleLinked.linkedSource, {envMode})).code;
|
|
165
|
+
}
|
|
149
166
|
if (cacheDisabled === false) {
|
|
150
167
|
const linkedMap = this.moduleLinkedCache.get(id) || new Map();
|
|
151
168
|
linkedMap.set((0, import_shared_utils.getCacheKeyFromJson)({
|
|
@@ -163,42 +180,24 @@ var LwrModuleRegistry = class {
|
|
|
163
180
|
return moduleLinked;
|
|
164
181
|
}
|
|
165
182
|
async createLinkedModuleDefinition(moduleDef, runtimeEnvironment, runtimeParams) {
|
|
166
|
-
const {
|
|
167
|
-
format,
|
|
168
|
-
minify,
|
|
169
|
-
debug,
|
|
170
|
-
env: {NODE_ENV: envMode}
|
|
171
|
-
} = runtimeEnvironment;
|
|
172
|
-
const minified = !!minify && !debug;
|
|
183
|
+
const {format} = runtimeEnvironment;
|
|
173
184
|
const {amdLoader, esmLoader} = this.globalConfig;
|
|
174
185
|
if (format === "amd") {
|
|
175
186
|
const loaderModuleEntry = await this.getModuleEntry({specifier: amdLoader}, runtimeParams);
|
|
176
187
|
const {
|
|
177
188
|
id,
|
|
178
|
-
code:
|
|
189
|
+
code: linkedSource,
|
|
179
190
|
linkedModuleRecord
|
|
180
191
|
} = await (0, import_linker.link)(this, moduleDef, import_amd_strategy.default, import_esm_strategy.default, runtimeEnvironment, runtimeParams, {
|
|
181
192
|
amdLoaderModule: loaderModuleEntry
|
|
182
193
|
}, this.interchangeableModules);
|
|
183
|
-
const {code: amdSource} = await this.context.compiler.convertToAmd(linkedES6, {
|
|
184
|
-
id
|
|
185
|
-
});
|
|
186
|
-
let linkedAmdSource = amdSource;
|
|
187
|
-
if (minified) {
|
|
188
|
-
const {code: minifiedCode} = await this.context.compiler.minifyJavascript(amdSource);
|
|
189
|
-
linkedAmdSource = minifiedCode;
|
|
190
|
-
} else {
|
|
191
|
-
const {code: minifiedCode} = await this.context.compiler.parseJavascript(amdSource, {
|
|
192
|
-
envMode
|
|
193
|
-
});
|
|
194
|
-
linkedAmdSource = minifiedCode;
|
|
195
|
-
}
|
|
196
194
|
linkedModuleRecord.dynamicImports = linkedModuleRecord.dynamicImports?.filter((imp) => imp.moduleNameType !== import_shared_utils.ModuleNameType.unresolved);
|
|
197
195
|
return {
|
|
198
196
|
...moduleDef,
|
|
199
|
-
|
|
197
|
+
id,
|
|
198
|
+
linkedSource,
|
|
200
199
|
linkedConfig: {
|
|
201
|
-
minified
|
|
200
|
+
minified: false
|
|
202
201
|
},
|
|
203
202
|
linkedModuleRecord,
|
|
204
203
|
runtimeEnvironment
|
|
@@ -209,26 +208,21 @@ var LwrModuleRegistry = class {
|
|
|
209
208
|
if (moduleDef.moduleEntry.specifier !== esmLoader && dynamicImports) {
|
|
210
209
|
loaderModuleEntry = await this.getModuleEntry({specifier: esmLoader}, runtimeParams);
|
|
211
210
|
}
|
|
212
|
-
const {
|
|
211
|
+
const {
|
|
212
|
+
id,
|
|
213
|
+
code: linkedSource,
|
|
214
|
+
linkedModuleRecord
|
|
215
|
+
} = await (0, import_linker.link)(this, moduleDef, import_amd_strategy.default, import_esm_strategy.default, runtimeEnvironment, runtimeParams, loaderModuleEntry && {
|
|
213
216
|
esmLoaderModule: loaderModuleEntry
|
|
214
217
|
}, this.interchangeableModules, this.globalConfig.bundleConfig?.exclude);
|
|
215
|
-
let transformedEsmCode = esmLinkedSource;
|
|
216
|
-
if (minified) {
|
|
217
|
-
const {code: minifiedEsm} = await this.context.compiler.minifyJavascript(transformedEsmCode);
|
|
218
|
-
transformedEsmCode = minifiedEsm;
|
|
219
|
-
} else {
|
|
220
|
-
const {code: parsedEsm} = await this.context.compiler.parseJavascript(transformedEsmCode, {
|
|
221
|
-
envMode
|
|
222
|
-
});
|
|
223
|
-
transformedEsmCode = parsedEsm;
|
|
224
|
-
}
|
|
225
218
|
linkedModuleRecord.dynamicImports = linkedModuleRecord.dynamicImports?.filter((imp) => imp.moduleNameType !== import_shared_utils.ModuleNameType.unresolved);
|
|
226
219
|
return {
|
|
227
220
|
...moduleDef,
|
|
221
|
+
id,
|
|
222
|
+
linkedSource,
|
|
228
223
|
linkedConfig: {
|
|
229
|
-
minified
|
|
224
|
+
minified: false
|
|
230
225
|
},
|
|
231
|
-
linkedSource: transformedEsmCode,
|
|
232
226
|
linkedModuleRecord,
|
|
233
227
|
runtimeEnvironment,
|
|
234
228
|
runtimeParams
|
package/build/cjs/signature.cjs
CHANGED
|
@@ -60,7 +60,18 @@ async function getBundleSignature(moduleId, registry, exclude) {
|
|
|
60
60
|
return hash.digest("hex");
|
|
61
61
|
}
|
|
62
62
|
function getLWCVersion() {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
63
|
+
let lwcVersion;
|
|
64
|
+
try {
|
|
65
|
+
if (LWR?.LWC_VERSION) {
|
|
66
|
+
lwcVersion = LWR.LWC_VERSION;
|
|
67
|
+
}
|
|
68
|
+
} catch (err) {
|
|
69
|
+
}
|
|
70
|
+
if (!lwcVersion) {
|
|
71
|
+
const require2 = (0, import_module.createRequire)(import_path.default.join((0, import_process.cwd)(), "./env-config.js"));
|
|
72
|
+
const {version} = require2("lwc/package.json");
|
|
73
|
+
lwcVersion = version;
|
|
74
|
+
}
|
|
75
|
+
import_shared_utils.logger.debug(`Signature LWC Version: ${lwcVersion}`);
|
|
76
|
+
return lwcVersion;
|
|
66
77
|
}
|
package/build/es/index.js
CHANGED
|
@@ -80,15 +80,13 @@ export class LwrModuleRegistry {
|
|
|
80
80
|
// console.log('[INFO] Module Cache Hit: %s', moduleEntry.id);
|
|
81
81
|
return this.moduleDefCache.get(moduleEntry.id);
|
|
82
82
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
};
|
|
91
|
-
return this.inflightModuleDefinitions.execute(moduleEntry.id, createModulePromiseCtor, this);
|
|
83
|
+
return this.inflightModuleDefinitions.execute(moduleEntry.id, async () => {
|
|
84
|
+
const moduleDef = await this.createModuleDefinition(moduleId, runtimeParams);
|
|
85
|
+
if (cacheDisabled === false) {
|
|
86
|
+
this.moduleDefCache.set(moduleDef.id, moduleDef);
|
|
87
|
+
}
|
|
88
|
+
return moduleDef;
|
|
89
|
+
});
|
|
92
90
|
}
|
|
93
91
|
async createModuleDefinition(moduleId, runtimeParams) {
|
|
94
92
|
const { locker } = this.globalConfig;
|
|
@@ -110,7 +108,7 @@ export class LwrModuleRegistry {
|
|
|
110
108
|
const moduleEntry = await this.getModuleEntry(moduleId, runtimeParams);
|
|
111
109
|
const id = moduleEntry.id;
|
|
112
110
|
// cache key pivots from the runtimeEnvironment
|
|
113
|
-
const { format, compat, debug, minify, bundle } = runtimeEnvironment;
|
|
111
|
+
const { format, compat, debug, minify, bundle, env: { NODE_ENV: envMode }, } = runtimeEnvironment;
|
|
114
112
|
const locale = runtimeParams?.['locale'];
|
|
115
113
|
const environment = runtimeParams?.['environment'];
|
|
116
114
|
const { locker: { enabled: lockerEnabled }, } = this.globalConfig;
|
|
@@ -134,6 +132,22 @@ export class LwrModuleRegistry {
|
|
|
134
132
|
}
|
|
135
133
|
const moduleDef = await this.getModule(moduleId, runtimeParams);
|
|
136
134
|
const moduleLinked = await this.createLinkedModuleDefinition(moduleDef, runtimeEnvironment, runtimeParams);
|
|
135
|
+
// the bundler will convert the linked source to AMD when bundling is enabled
|
|
136
|
+
if (format === 'amd' && !bundle) {
|
|
137
|
+
// convert the linkedSource to the transport AMD format
|
|
138
|
+
moduleLinked.linkedSource = (await this.context.compiler.convertToAmd(moduleLinked.linkedSource, {
|
|
139
|
+
id: moduleLinked.id,
|
|
140
|
+
})).code;
|
|
141
|
+
}
|
|
142
|
+
const minified = !!minify && !debug;
|
|
143
|
+
// the bundler will minify when bundling is enabled
|
|
144
|
+
if (minified && !bundle) {
|
|
145
|
+
moduleLinked.linkedSource = (await this.context.compiler.minifyJavascript(moduleLinked.linkedSource)).code;
|
|
146
|
+
moduleLinked.linkedConfig.minified = true;
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
moduleLinked.linkedSource = (await this.context.compiler.parseJavascript(moduleLinked.linkedSource, { envMode })).code;
|
|
150
|
+
}
|
|
137
151
|
// Add to cache
|
|
138
152
|
if (cacheDisabled === false) {
|
|
139
153
|
const linkedMap = this.moduleLinkedCache.get(id) || new Map();
|
|
@@ -152,39 +166,24 @@ export class LwrModuleRegistry {
|
|
|
152
166
|
return moduleLinked;
|
|
153
167
|
}
|
|
154
168
|
async createLinkedModuleDefinition(moduleDef, runtimeEnvironment, runtimeParams) {
|
|
155
|
-
const { format
|
|
156
|
-
const minified = !!minify && !debug;
|
|
169
|
+
const { format } = runtimeEnvironment;
|
|
157
170
|
const { amdLoader, esmLoader } = this.globalConfig;
|
|
158
171
|
// TODO: compat transformation based on runtimeEnvironment.compat
|
|
159
172
|
if (format === 'amd') {
|
|
160
173
|
// Resolve the loader entry
|
|
161
174
|
const loaderModuleEntry = await this.getModuleEntry({ specifier: amdLoader }, runtimeParams);
|
|
162
175
|
// transforms compiledModule into linkedModule (which means the imports may have changed)
|
|
163
|
-
const { id, code:
|
|
176
|
+
const { id, code: linkedSource, linkedModuleRecord, } = await link(this, moduleDef, amdLinkingStrategy, esmLinkingStrategy, runtimeEnvironment, runtimeParams, {
|
|
164
177
|
amdLoaderModule: loaderModuleEntry,
|
|
165
178
|
}, this.interchangeableModules);
|
|
166
|
-
// convert the linkedSource to the transport AMD format.
|
|
167
|
-
const { code: amdSource } = await this.context.compiler.convertToAmd(linkedES6, {
|
|
168
|
-
id,
|
|
169
|
-
});
|
|
170
|
-
let linkedAmdSource = amdSource;
|
|
171
|
-
if (minified) {
|
|
172
|
-
const { code: minifiedCode } = await this.context.compiler.minifyJavascript(amdSource);
|
|
173
|
-
linkedAmdSource = minifiedCode;
|
|
174
|
-
}
|
|
175
|
-
else {
|
|
176
|
-
const { code: minifiedCode } = await this.context.compiler.parseJavascript(amdSource, {
|
|
177
|
-
envMode,
|
|
178
|
-
});
|
|
179
|
-
linkedAmdSource = minifiedCode;
|
|
180
|
-
}
|
|
181
179
|
// Filter out variable dynamic imports
|
|
182
180
|
linkedModuleRecord.dynamicImports = linkedModuleRecord.dynamicImports?.filter((imp) => imp.moduleNameType !== ModuleNameType.unresolved);
|
|
183
181
|
return {
|
|
184
182
|
...moduleDef,
|
|
185
|
-
|
|
183
|
+
id,
|
|
184
|
+
linkedSource,
|
|
186
185
|
linkedConfig: {
|
|
187
|
-
minified,
|
|
186
|
+
minified: false,
|
|
188
187
|
},
|
|
189
188
|
linkedModuleRecord,
|
|
190
189
|
runtimeEnvironment,
|
|
@@ -199,28 +198,18 @@ export class LwrModuleRegistry {
|
|
|
199
198
|
// AND this is not the ESM loader itself (it uses a variable dynamic import we DO NOT want to link)
|
|
200
199
|
loaderModuleEntry = await this.getModuleEntry({ specifier: esmLoader }, runtimeParams);
|
|
201
200
|
}
|
|
202
|
-
const { code:
|
|
201
|
+
const { id, code: linkedSource, linkedModuleRecord, } = await link(this, moduleDef, amdLinkingStrategy, esmLinkingStrategy, runtimeEnvironment, runtimeParams, loaderModuleEntry && {
|
|
203
202
|
esmLoaderModule: loaderModuleEntry,
|
|
204
203
|
}, this.interchangeableModules, this.globalConfig.bundleConfig?.exclude);
|
|
205
|
-
let transformedEsmCode = esmLinkedSource;
|
|
206
|
-
if (minified) {
|
|
207
|
-
const { code: minifiedEsm } = await this.context.compiler.minifyJavascript(transformedEsmCode);
|
|
208
|
-
transformedEsmCode = minifiedEsm;
|
|
209
|
-
}
|
|
210
|
-
else {
|
|
211
|
-
const { code: parsedEsm } = await this.context.compiler.parseJavascript(transformedEsmCode, {
|
|
212
|
-
envMode,
|
|
213
|
-
});
|
|
214
|
-
transformedEsmCode = parsedEsm;
|
|
215
|
-
}
|
|
216
204
|
// Filter out variable dynamic imports
|
|
217
205
|
linkedModuleRecord.dynamicImports = linkedModuleRecord.dynamicImports?.filter((imp) => imp.moduleNameType !== ModuleNameType.unresolved);
|
|
218
206
|
return {
|
|
219
207
|
...moduleDef,
|
|
208
|
+
id,
|
|
209
|
+
linkedSource,
|
|
220
210
|
linkedConfig: {
|
|
221
|
-
minified,
|
|
211
|
+
minified: false,
|
|
222
212
|
},
|
|
223
|
-
linkedSource: transformedEsmCode,
|
|
224
213
|
linkedModuleRecord,
|
|
225
214
|
runtimeEnvironment,
|
|
226
215
|
runtimeParams,
|
package/build/es/signature.js
CHANGED
|
@@ -2,7 +2,7 @@ import crypto from 'crypto';
|
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import { cwd } from 'process';
|
|
4
4
|
import { createRequire } from 'module';
|
|
5
|
-
import { getFeatureFlags, getSpecifier } from '@lwrjs/shared-utils';
|
|
5
|
+
import { getFeatureFlags, getSpecifier, logger } from '@lwrjs/shared-utils';
|
|
6
6
|
const LWC_VERSION = getLWCVersion();
|
|
7
7
|
const ENABLED_FINGERPRINTS = !getFeatureFlags().LEGACY_LOADER;
|
|
8
8
|
const ENV_KEY = `LWC:${LWC_VERSION},FINGERPRINTS:${ENABLED_FINGERPRINTS}`;
|
|
@@ -60,9 +60,23 @@ export async function getBundleSignature(moduleId, registry, exclude) {
|
|
|
60
60
|
* Get the configured LWC version
|
|
61
61
|
*/
|
|
62
62
|
function getLWCVersion() {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
63
|
+
let lwcVersion;
|
|
64
|
+
try {
|
|
65
|
+
// check if it is set on the global shim
|
|
66
|
+
if (LWR?.LWC_VERSION) {
|
|
67
|
+
lwcVersion = LWR.LWC_VERSION;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
catch (err) {
|
|
71
|
+
// No-op throws an error in cli when LWR versison not set in global
|
|
72
|
+
}
|
|
73
|
+
if (!lwcVersion) {
|
|
74
|
+
const require = createRequire(path.join(cwd(), './env-config.js'));
|
|
75
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
76
|
+
const { version } = require('lwc/package.json');
|
|
77
|
+
lwcVersion = version;
|
|
78
|
+
}
|
|
79
|
+
logger.debug(`Signature LWC Version: ${lwcVersion}`);
|
|
80
|
+
return lwcVersion;
|
|
67
81
|
}
|
|
68
82
|
//# sourceMappingURL=signature.js.map
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
|
-
"version": "0.8.0-alpha.
|
|
7
|
+
"version": "0.8.0-alpha.10",
|
|
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.8.0-alpha.
|
|
34
|
-
"@lwrjs/shared-utils": "0.8.0-alpha.
|
|
33
|
+
"@lwrjs/diagnostics": "0.8.0-alpha.10",
|
|
34
|
+
"@lwrjs/shared-utils": "0.8.0-alpha.10",
|
|
35
35
|
"es-module-lexer": "^0.3.18",
|
|
36
36
|
"ws": "^7.2.5"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@lwrjs/types": "0.8.0-alpha.
|
|
39
|
+
"@lwrjs/types": "0.8.0-alpha.10",
|
|
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 <19"
|
|
45
45
|
},
|
|
46
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "55922351f484d77784d86ef7b03ebe788fa3e12c"
|
|
47
47
|
}
|