@lwrjs/lwc-module-provider 0.9.0-alpha.14 → 0.9.0-alpha.16
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 +17 -8
- package/build/cjs/utils.cjs +12 -3
- package/build/es/index.js +17 -8
- package/build/es/utils.js +15 -4
- package/package.json +6 -6
package/build/cjs/index.cjs
CHANGED
|
@@ -76,13 +76,14 @@ var LwcModuleProvider = class {
|
|
|
76
76
|
}
|
|
77
77
|
async getModule(moduleId) {
|
|
78
78
|
const id = (0, import_shared_utils.getSpecifier)(moduleId);
|
|
79
|
+
import_shared_utils.logger.debug(`[lwc-module-provider ] getModule ${id}`);
|
|
79
80
|
return this.inflightGetModuleJobs.execute(id, () => {
|
|
80
81
|
return this.createGetModuleJob(moduleId);
|
|
81
82
|
});
|
|
82
83
|
}
|
|
83
84
|
async createGetModuleJob(moduleId) {
|
|
84
85
|
const {watcher, watchedModuleContextMap, lwcCacheDir, lwcCacheIndex, moduleFsCacheEnabled} = this;
|
|
85
|
-
import_shared_utils.logger.debug("
|
|
86
|
+
import_shared_utils.logger.debug("[lwc-module-provider ] fetch module", {moduleId, moduleFsCacheEnabled});
|
|
86
87
|
const moduleEntry = await this.getModuleEntry(moduleId);
|
|
87
88
|
if (!moduleEntry) {
|
|
88
89
|
return;
|
|
@@ -91,10 +92,14 @@ var LwcModuleProvider = class {
|
|
|
91
92
|
const {id, namespace, name: rawName, originalSource} = moduleSource;
|
|
92
93
|
const cacheConfig = {lwcCacheDir, lwcCacheIndex};
|
|
93
94
|
let compiledModule = moduleFsCacheEnabled && (0, import_cache.getCompiledModuleCacheEntry)(moduleSource, cacheConfig);
|
|
95
|
+
import_shared_utils.logger.debug("[lwc-module-provider ] module source ", {
|
|
96
|
+
moduleId,
|
|
97
|
+
isPreCompiled: compiledModule != void 0
|
|
98
|
+
});
|
|
94
99
|
if (!compiledModule) {
|
|
95
100
|
const [name] = rawName.split("#");
|
|
96
101
|
const scopedStyles = moduleEntry.entry.endsWith(".css") && moduleEntry.specifier.endsWith("?scoped=true");
|
|
97
|
-
import_shared_utils.logger.debug("
|
|
102
|
+
import_shared_utils.logger.debug("[lwc-module-provider] compile", {
|
|
98
103
|
namespace,
|
|
99
104
|
name,
|
|
100
105
|
filename: moduleEntry.entry,
|
|
@@ -106,7 +111,7 @@ var LwcModuleProvider = class {
|
|
|
106
111
|
filename: moduleEntry.entry,
|
|
107
112
|
scopedStyles
|
|
108
113
|
});
|
|
109
|
-
import_shared_utils.logger.verbose("createGetModuleJob:compile compiledModule", {
|
|
114
|
+
import_shared_utils.logger.verbose("[lwc-module-provider] createGetModuleJob:compile compiledModule", {
|
|
110
115
|
namespace,
|
|
111
116
|
name,
|
|
112
117
|
filename: moduleEntry.entry,
|
|
@@ -153,7 +158,7 @@ var LwcModuleProvider = class {
|
|
|
153
158
|
importer,
|
|
154
159
|
version
|
|
155
160
|
}) {
|
|
156
|
-
import_shared_utils.logger.debug(
|
|
161
|
+
import_shared_utils.logger.debug(`[lwc-module-provider] getModuleEntry ${specifier}@${version}@${importer}`);
|
|
157
162
|
const versionId = version || importer;
|
|
158
163
|
if (versionId) {
|
|
159
164
|
const cacheKey2 = getModuleEntryCacheKey(specifier, versionId);
|
|
@@ -162,7 +167,6 @@ var LwcModuleProvider = class {
|
|
|
162
167
|
}
|
|
163
168
|
}
|
|
164
169
|
const cacheKey = `${specifier}@${version}@${importer}`;
|
|
165
|
-
import_shared_utils.logger.debug("getModuleEntry:cacheKey", {cacheKey});
|
|
166
170
|
return this.inflightGetModuleEntryJobs.execute(cacheKey, async () => {
|
|
167
171
|
return this.createModuleEntry({specifier, importer, version});
|
|
168
172
|
});
|
|
@@ -172,7 +176,12 @@ var LwcModuleProvider = class {
|
|
|
172
176
|
importer,
|
|
173
177
|
version
|
|
174
178
|
}) {
|
|
175
|
-
import_shared_utils.logger.debug("createModuleEntry", {
|
|
179
|
+
import_shared_utils.logger.debug("[lwc-module-provider] createModuleEntry", {
|
|
180
|
+
specifier,
|
|
181
|
+
importer,
|
|
182
|
+
rootDir: this.rootDir,
|
|
183
|
+
version
|
|
184
|
+
});
|
|
176
185
|
const [baseSpecifier, fileRelativePathRaw] = specifier.split("#");
|
|
177
186
|
const fileRelativePath = fileRelativePathRaw?.split("?")[0];
|
|
178
187
|
let moduleEntry;
|
|
@@ -182,14 +191,14 @@ var LwcModuleProvider = class {
|
|
|
182
191
|
}
|
|
183
192
|
if (!moduleEntry) {
|
|
184
193
|
try {
|
|
185
|
-
import_shared_utils.logger.debug("createModuleEntry:resolveModuleSpecifier", {
|
|
194
|
+
import_shared_utils.logger.debug("[lwc-module-provider] createModuleEntry:resolveModuleSpecifier", {
|
|
186
195
|
baseSpecifier,
|
|
187
196
|
importer,
|
|
188
197
|
rootDir: this.rootDir,
|
|
189
198
|
modules: this.modules
|
|
190
199
|
});
|
|
191
200
|
const registryEntry = (0, import_utils.resolveModuleSpecifier)(baseSpecifier, importer || this.rootDir, this.modules, this.packageVersionCache);
|
|
192
|
-
import_shared_utils.logger.debug("createModuleEntry:registryEntry", {registryEntry});
|
|
201
|
+
import_shared_utils.logger.debug("[lwc-module-provider] createModuleEntry:registryEntry", {registryEntry});
|
|
193
202
|
moduleEntry = {
|
|
194
203
|
id: getModuleEntryCacheKey(registryEntry.specifier, registryEntry.version),
|
|
195
204
|
...registryEntry
|
package/build/cjs/utils.cjs
CHANGED
|
@@ -37,9 +37,18 @@ var import_module_resolver = __toModule(require("@lwc/module-resolver"));
|
|
|
37
37
|
var EXPLICIT_CONSTANT = "/* _implicit_dependency_ */";
|
|
38
38
|
var DEFAULT_IMPLICIT_DEP = `${EXPLICIT_CONSTANT} export default void 0`;
|
|
39
39
|
function resolveModuleSpecifier(specifier, importer, modules = [], packageVersionCache) {
|
|
40
|
-
import_shared_utils.logger.debug("resolveModuleSpecifier", {specifier, importer, modules});
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
import_shared_utils.logger.debug("[lwc-module-provider] resolveModuleSpecifier", {specifier, importer, modules});
|
|
41
|
+
let resolvedModule;
|
|
42
|
+
try {
|
|
43
|
+
resolvedModule = (0, import_module_resolver.resolveModule)(specifier, importer, {modules});
|
|
44
|
+
} catch (error) {
|
|
45
|
+
if (import_shared_utils.logger.currentLevel == import_shared_utils.DEBUG || import_shared_utils.logger.currentLevel == import_shared_utils.VERBOSE) {
|
|
46
|
+
import_shared_utils.logger.debug(`[lwc-module-provider] @lwc/module-resolver/resolveModule ${specifier}`);
|
|
47
|
+
import_shared_utils.logger.error(error);
|
|
48
|
+
}
|
|
49
|
+
throw error;
|
|
50
|
+
}
|
|
51
|
+
import_shared_utils.logger.debug("[lwc-module-provider] resolveModuleSpecifier:resolvedModule", {resolvedModule});
|
|
43
52
|
const moduleScope = resolvedModule.scope;
|
|
44
53
|
let version;
|
|
45
54
|
if (packageVersionCache.has(moduleScope)) {
|
package/build/es/index.js
CHANGED
|
@@ -47,6 +47,7 @@ export default class LwcModuleProvider {
|
|
|
47
47
|
}
|
|
48
48
|
async getModule(moduleId) {
|
|
49
49
|
const id = getSpecifier(moduleId);
|
|
50
|
+
logger.debug(`[lwc-module-provider ] getModule ${id}`);
|
|
50
51
|
return this.inflightGetModuleJobs.execute(id, () => {
|
|
51
52
|
return this.createGetModuleJob(moduleId);
|
|
52
53
|
});
|
|
@@ -58,7 +59,7 @@ export default class LwcModuleProvider {
|
|
|
58
59
|
*/
|
|
59
60
|
async createGetModuleJob(moduleId) {
|
|
60
61
|
const { watcher, watchedModuleContextMap, lwcCacheDir, lwcCacheIndex, moduleFsCacheEnabled } = this;
|
|
61
|
-
logger.debug('
|
|
62
|
+
logger.debug('[lwc-module-provider ] fetch module', { moduleId, moduleFsCacheEnabled });
|
|
62
63
|
const moduleEntry = await this.getModuleEntry(moduleId);
|
|
63
64
|
if (!moduleEntry) {
|
|
64
65
|
return;
|
|
@@ -67,10 +68,14 @@ export default class LwcModuleProvider {
|
|
|
67
68
|
const { id, namespace, name: rawName, originalSource } = moduleSource;
|
|
68
69
|
const cacheConfig = { lwcCacheDir, lwcCacheIndex };
|
|
69
70
|
let compiledModule = moduleFsCacheEnabled && getCompiledModuleCacheEntry(moduleSource, cacheConfig);
|
|
71
|
+
logger.debug('[lwc-module-provider ] module source ', {
|
|
72
|
+
moduleId,
|
|
73
|
+
isPreCompiled: compiledModule != undefined,
|
|
74
|
+
});
|
|
70
75
|
if (!compiledModule) {
|
|
71
76
|
const [name] = rawName.split('#');
|
|
72
77
|
const scopedStyles = moduleEntry.entry.endsWith('.css') && moduleEntry.specifier.endsWith('?scoped=true');
|
|
73
|
-
logger.debug('
|
|
78
|
+
logger.debug('[lwc-module-provider] compile', {
|
|
74
79
|
namespace,
|
|
75
80
|
name,
|
|
76
81
|
filename: moduleEntry.entry,
|
|
@@ -83,7 +88,7 @@ export default class LwcModuleProvider {
|
|
|
83
88
|
filename: moduleEntry.entry,
|
|
84
89
|
scopedStyles,
|
|
85
90
|
});
|
|
86
|
-
logger.verbose('createGetModuleJob:compile compiledModule', {
|
|
91
|
+
logger.verbose('[lwc-module-provider] createGetModuleJob:compile compiledModule', {
|
|
87
92
|
namespace,
|
|
88
93
|
name,
|
|
89
94
|
filename: moduleEntry.entry,
|
|
@@ -126,7 +131,7 @@ export default class LwcModuleProvider {
|
|
|
126
131
|
return moduleSource;
|
|
127
132
|
}
|
|
128
133
|
async getModuleEntry({ specifier, importer, version, }) {
|
|
129
|
-
logger.debug(
|
|
134
|
+
logger.debug(`[lwc-module-provider] getModuleEntry ${specifier}@${version}@${importer}`);
|
|
130
135
|
// Check cache
|
|
131
136
|
const versionId = version || importer;
|
|
132
137
|
if (versionId) {
|
|
@@ -136,13 +141,17 @@ export default class LwcModuleProvider {
|
|
|
136
141
|
}
|
|
137
142
|
}
|
|
138
143
|
const cacheKey = `${specifier}@${version}@${importer}`;
|
|
139
|
-
logger.debug('getModuleEntry:cacheKey', { cacheKey });
|
|
140
144
|
return this.inflightGetModuleEntryJobs.execute(cacheKey, async () => {
|
|
141
145
|
return this.createModuleEntry({ specifier, importer, version });
|
|
142
146
|
});
|
|
143
147
|
}
|
|
144
148
|
async createModuleEntry({ specifier, importer, version, }) {
|
|
145
|
-
logger.debug('createModuleEntry', {
|
|
149
|
+
logger.debug('[lwc-module-provider] createModuleEntry', {
|
|
150
|
+
specifier,
|
|
151
|
+
importer,
|
|
152
|
+
rootDir: this.rootDir,
|
|
153
|
+
version,
|
|
154
|
+
});
|
|
146
155
|
// Strip any filenames out of the specifier
|
|
147
156
|
// eg: 'c/myApp#myApp.css' => 'c/myApp' and 'myApp.css'
|
|
148
157
|
// eg: 'some/where#lib/util' => 'some/where' and 'lib/util'
|
|
@@ -157,14 +166,14 @@ export default class LwcModuleProvider {
|
|
|
157
166
|
// Nothing from cache, let's try to resolve it first from lwc then from npm
|
|
158
167
|
if (!moduleEntry) {
|
|
159
168
|
try {
|
|
160
|
-
logger.debug('createModuleEntry:resolveModuleSpecifier', {
|
|
169
|
+
logger.debug('[lwc-module-provider] createModuleEntry:resolveModuleSpecifier', {
|
|
161
170
|
baseSpecifier,
|
|
162
171
|
importer,
|
|
163
172
|
rootDir: this.rootDir,
|
|
164
173
|
modules: this.modules,
|
|
165
174
|
});
|
|
166
175
|
const registryEntry = resolveModuleSpecifier(baseSpecifier, importer || this.rootDir, this.modules, this.packageVersionCache);
|
|
167
|
-
logger.debug('createModuleEntry:registryEntry', { registryEntry });
|
|
176
|
+
logger.debug('[lwc-module-provider] createModuleEntry:registryEntry', { registryEntry });
|
|
168
177
|
moduleEntry = {
|
|
169
178
|
id: getModuleEntryCacheKey(registryEntry.specifier, registryEntry.version),
|
|
170
179
|
...registryEntry,
|
package/build/es/utils.js
CHANGED
|
@@ -1,13 +1,24 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
import path from 'path';
|
|
3
|
-
import { readFile, debounce, logger } from '@lwrjs/shared-utils';
|
|
3
|
+
import { readFile, debounce, logger, DEBUG, VERBOSE } from '@lwrjs/shared-utils';
|
|
4
4
|
import { resolveModule } from '@lwc/module-resolver';
|
|
5
5
|
export const EXPLICIT_CONSTANT = '/* _implicit_dependency_ */';
|
|
6
6
|
export const DEFAULT_IMPLICIT_DEP = `${EXPLICIT_CONSTANT} export default void 0`;
|
|
7
7
|
export function resolveModuleSpecifier(specifier, importer, modules = [], packageVersionCache) {
|
|
8
|
-
logger.debug('resolveModuleSpecifier', { specifier, importer, modules });
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
logger.debug('[lwc-module-provider] resolveModuleSpecifier', { specifier, importer, modules });
|
|
9
|
+
let resolvedModule;
|
|
10
|
+
try {
|
|
11
|
+
resolvedModule = resolveModule(specifier, importer, { modules });
|
|
12
|
+
}
|
|
13
|
+
catch (error) {
|
|
14
|
+
if (logger.currentLevel == DEBUG || logger.currentLevel == VERBOSE) {
|
|
15
|
+
// If log level is debug or greater. Otherwise error will be swalloed and resolved by npm-resolver
|
|
16
|
+
logger.debug(`[lwc-module-provider] @lwc/module-resolver/resolveModule ${specifier}`);
|
|
17
|
+
logger.error(error);
|
|
18
|
+
}
|
|
19
|
+
throw error;
|
|
20
|
+
}
|
|
21
|
+
logger.debug('[lwc-module-provider] resolveModuleSpecifier:resolvedModule', { resolvedModule });
|
|
11
22
|
const moduleScope = resolvedModule.scope;
|
|
12
23
|
let version;
|
|
13
24
|
if (packageVersionCache.has(moduleScope)) {
|
package/package.json
CHANGED
|
@@ -4,15 +4,15 @@
|
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
|
-
"version": "0.9.0-alpha.
|
|
7
|
+
"version": "0.9.0-alpha.16",
|
|
8
8
|
"homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
11
|
-
"url": "https://github.com/salesforce/lwr.git",
|
|
11
|
+
"url": "https://github.com/salesforce-experience-platform-emu/lwr.git",
|
|
12
12
|
"directory": "packages/@lwrjs/fs-service"
|
|
13
13
|
},
|
|
14
14
|
"bugs": {
|
|
15
|
-
"url": "https://github.com/salesforce/lwr/issues"
|
|
15
|
+
"url": "https://github.com/salesforce-experience-platform-emu/lwr/issues"
|
|
16
16
|
},
|
|
17
17
|
"type": "module",
|
|
18
18
|
"types": "build/es/index.d.ts",
|
|
@@ -32,14 +32,14 @@
|
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@babel/preset-typescript": "^7.9.0",
|
|
34
34
|
"@lwc/module-resolver": "2.33.0",
|
|
35
|
-
"@lwrjs/shared-utils": "0.9.0-alpha.
|
|
35
|
+
"@lwrjs/shared-utils": "0.9.0-alpha.16",
|
|
36
36
|
"es-module-lexer": "^0.3.18"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@lwrjs/types": "0.9.0-alpha.
|
|
39
|
+
"@lwrjs/types": "0.9.0-alpha.16"
|
|
40
40
|
},
|
|
41
41
|
"engines": {
|
|
42
42
|
"node": ">=14.15.4 <19"
|
|
43
43
|
},
|
|
44
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "03fe3982780e7c63b96ef0733b58529057db61fa"
|
|
45
45
|
}
|