@lwrjs/lwc-module-provider 0.6.0-alpha.2 → 0.6.0-alpha.6
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/cache.cjs +15 -15
- package/build/cjs/compiler.cjs +11 -11
- package/build/cjs/index.cjs +40 -21
- package/build/cjs/utils.cjs +10 -10
- package/build/es/cache.js +1 -1
- package/build/es/index.d.ts +9 -0
- package/build/es/index.js +20 -1
- package/package.json +5 -5
package/build/cjs/cache.cjs
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
var __create = Object.create;
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
3
|
var __getProtoOf = Object.getPrototypeOf;
|
|
6
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", {value: true});
|
|
8
8
|
var __export = (target, all) => {
|
|
9
|
-
__markAsModule(target);
|
|
10
9
|
for (var name in all)
|
|
11
|
-
__defProp(target, name, {
|
|
10
|
+
__defProp(target, name, {get: all[name], enumerable: true});
|
|
12
11
|
};
|
|
13
|
-
var
|
|
12
|
+
var __exportStar = (target, module2, desc) => {
|
|
14
13
|
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
15
14
|
for (let key of __getOwnPropNames(module2))
|
|
16
15
|
if (!__hasOwnProp.call(target, key) && key !== "default")
|
|
17
|
-
__defProp(target, key, {
|
|
16
|
+
__defProp(target, key, {get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable});
|
|
18
17
|
}
|
|
19
18
|
return target;
|
|
20
19
|
};
|
|
21
20
|
var __toModule = (module2) => {
|
|
22
|
-
return
|
|
21
|
+
return __exportStar(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? {get: () => module2.default, enumerable: true} : {value: module2, enumerable: true})), module2);
|
|
23
22
|
};
|
|
24
23
|
|
|
25
24
|
// packages/@lwrjs/lwc-module-provider/src/cache.ts
|
|
25
|
+
__markAsModule(exports);
|
|
26
26
|
__export(exports, {
|
|
27
27
|
DEFAULT_CACHE_FOLDER: () => DEFAULT_CACHE_FOLDER,
|
|
28
28
|
DEFAULT_CACHE_INDEX: () => DEFAULT_CACHE_INDEX,
|
|
@@ -36,19 +36,19 @@ var import_fs = __toModule(require("fs"));
|
|
|
36
36
|
var DEFAULT_COMPILED_DIR = "lwc_compiled_modules";
|
|
37
37
|
var DEFAULT_CACHE_FOLDER = "cache";
|
|
38
38
|
var DEFAULT_CACHE_INDEX = `compiled.json`;
|
|
39
|
-
var NORMALIZE_PATH_REGEX = /[
|
|
39
|
+
var NORMALIZE_PATH_REGEX = /[@\/#\.\?<>\\:\*\|"]/gm;
|
|
40
40
|
function setupModuleCache(cacheDir) {
|
|
41
41
|
const lwcCacheDir = import_path.default.join(cacheDir, `${DEFAULT_COMPILED_DIR}`);
|
|
42
42
|
const lwcCacheIndexPath = import_path.default.join(lwcCacheDir, DEFAULT_CACHE_INDEX);
|
|
43
|
-
import_fs.default.mkdirSync(`${lwcCacheDir}/${DEFAULT_CACHE_FOLDER}`, {
|
|
43
|
+
import_fs.default.mkdirSync(`${lwcCacheDir}/${DEFAULT_CACHE_FOLDER}`, {recursive: true});
|
|
44
44
|
if (!import_fs.default.existsSync(lwcCacheIndexPath)) {
|
|
45
45
|
import_fs.default.writeFileSync(lwcCacheIndexPath, "[]");
|
|
46
|
-
return {
|
|
46
|
+
return {lwcCacheDir, lwcCacheIndex: new Map()};
|
|
47
47
|
} else {
|
|
48
48
|
const rawIndex = import_fs.default.readFileSync(lwcCacheIndexPath, "utf-8");
|
|
49
49
|
try {
|
|
50
50
|
const cacheIndexJson = JSON.parse(rawIndex);
|
|
51
|
-
return {
|
|
51
|
+
return {lwcCacheDir, lwcCacheIndex: new Map(cacheIndexJson)};
|
|
52
52
|
} catch (err) {
|
|
53
53
|
const newErr = new Error("Invalid LWC Index: " + rawIndex);
|
|
54
54
|
if (err.stack) {
|
|
@@ -58,8 +58,8 @@ function setupModuleCache(cacheDir) {
|
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
|
-
function addCompiledModuleCacheEntry(moduleSource, compilerResult, {
|
|
62
|
-
const {
|
|
61
|
+
function addCompiledModuleCacheEntry(moduleSource, compilerResult, {lwcCacheIndex, lwcCacheDir}) {
|
|
62
|
+
const {specifier, version, ownHash} = moduleSource;
|
|
63
63
|
const lwcCacheIndexPath = import_path.default.join(lwcCacheDir, DEFAULT_CACHE_INDEX);
|
|
64
64
|
const cacheKey = `${specifier}@${version}`;
|
|
65
65
|
const normalizedSpecifier = specifier.replace(NORMALIZE_PATH_REGEX, "_");
|
|
@@ -77,7 +77,7 @@ function addCompiledModuleCacheEntry(moduleSource, compilerResult, { lwcCacheInd
|
|
|
77
77
|
});
|
|
78
78
|
import_fs.default.writeFileSync(lwcCacheIndexPath, JSON.stringify([...lwcCacheIndex], null, " "));
|
|
79
79
|
}
|
|
80
|
-
function getCompiledModuleCacheEntry({
|
|
80
|
+
function getCompiledModuleCacheEntry({specifier, version, ownHash}, {lwcCacheIndex, lwcCacheDir}) {
|
|
81
81
|
const cacheKey = `${specifier}@${version}`;
|
|
82
82
|
const cacheEntry = lwcCacheIndex.get(cacheKey);
|
|
83
83
|
if (!cacheEntry) {
|
package/build/cjs/compiler.cjs
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
var __create = Object.create;
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
3
|
var __getProtoOf = Object.getPrototypeOf;
|
|
6
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", {value: true});
|
|
8
8
|
var __export = (target, all) => {
|
|
9
|
-
__markAsModule(target);
|
|
10
9
|
for (var name in all)
|
|
11
|
-
__defProp(target, name, {
|
|
10
|
+
__defProp(target, name, {get: all[name], enumerable: true});
|
|
12
11
|
};
|
|
13
|
-
var
|
|
12
|
+
var __exportStar = (target, module2, desc) => {
|
|
14
13
|
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
15
14
|
for (let key of __getOwnPropNames(module2))
|
|
16
15
|
if (!__hasOwnProp.call(target, key) && key !== "default")
|
|
17
|
-
__defProp(target, key, {
|
|
16
|
+
__defProp(target, key, {get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable});
|
|
18
17
|
}
|
|
19
18
|
return target;
|
|
20
19
|
};
|
|
21
20
|
var __toModule = (module2) => {
|
|
22
|
-
return
|
|
21
|
+
return __exportStar(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? {get: () => module2.default, enumerable: true} : {value: module2, enumerable: true})), module2);
|
|
23
22
|
};
|
|
24
23
|
|
|
25
24
|
// packages/@lwrjs/lwc-module-provider/src/compiler.ts
|
|
25
|
+
__markAsModule(exports);
|
|
26
26
|
__export(exports, {
|
|
27
27
|
LwcCompiler: () => LwcCompiler
|
|
28
28
|
});
|
|
@@ -34,12 +34,12 @@ var DEFAULT_BABEL_CONFIG = {
|
|
|
34
34
|
configFile: false,
|
|
35
35
|
sourceMaps: true,
|
|
36
36
|
parserOpts: {
|
|
37
|
-
plugins: [["decorators", {
|
|
37
|
+
plugins: [["decorators", {decoratorsBeforeExport: true}]]
|
|
38
38
|
}
|
|
39
39
|
};
|
|
40
40
|
var LwcCompiler = class {
|
|
41
41
|
async compileFile(source, config) {
|
|
42
|
-
const {
|
|
42
|
+
const {name, namespace, filename} = config;
|
|
43
43
|
if (source.startsWith(import_utils.EXPLICIT_CONSTANT)) {
|
|
44
44
|
return {
|
|
45
45
|
code: source,
|
|
@@ -50,7 +50,7 @@ var LwcCompiler = class {
|
|
|
50
50
|
if (filename.endsWith("ts")) {
|
|
51
51
|
const result = (0, import_core.transformSync)(source, {
|
|
52
52
|
...DEFAULT_BABEL_CONFIG,
|
|
53
|
-
presets: [["@babel/preset-typescript", {
|
|
53
|
+
presets: [["@babel/preset-typescript", {onlyRemoveTypeImports: false}]],
|
|
54
54
|
filename
|
|
55
55
|
});
|
|
56
56
|
if (!result || !result.code) {
|
package/build/cjs/index.cjs
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
var __create = Object.create;
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
3
|
var __getProtoOf = Object.getPrototypeOf;
|
|
6
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", {value: true});
|
|
8
8
|
var __export = (target, all) => {
|
|
9
|
-
__markAsModule(target);
|
|
10
9
|
for (var name in all)
|
|
11
|
-
__defProp(target, name, {
|
|
10
|
+
__defProp(target, name, {get: all[name], enumerable: true});
|
|
12
11
|
};
|
|
13
|
-
var
|
|
12
|
+
var __exportStar = (target, module2, desc) => {
|
|
14
13
|
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
15
14
|
for (let key of __getOwnPropNames(module2))
|
|
16
15
|
if (!__hasOwnProp.call(target, key) && key !== "default")
|
|
17
|
-
__defProp(target, key, {
|
|
16
|
+
__defProp(target, key, {get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable});
|
|
18
17
|
}
|
|
19
18
|
return target;
|
|
20
19
|
};
|
|
21
20
|
var __toModule = (module2) => {
|
|
22
|
-
return
|
|
21
|
+
return __exportStar(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? {get: () => module2.default, enumerable: true} : {value: module2, enumerable: true})), module2);
|
|
23
22
|
};
|
|
24
23
|
|
|
25
24
|
// packages/@lwrjs/lwc-module-provider/src/index.ts
|
|
25
|
+
__markAsModule(exports);
|
|
26
26
|
__export(exports, {
|
|
27
|
-
default: () =>
|
|
27
|
+
default: () => src_default
|
|
28
28
|
});
|
|
29
29
|
var import_path = __toModule(require("path"));
|
|
30
30
|
var import_shared_utils = __toModule(require("@lwrjs/shared-utils"));
|
|
@@ -37,15 +37,17 @@ function getModuleEntryCacheKey(specifier, version) {
|
|
|
37
37
|
var LwcModuleProvider = class {
|
|
38
38
|
constructor(options = {}, {
|
|
39
39
|
appEmitter,
|
|
40
|
-
config: {
|
|
41
|
-
runtimeEnvironment: {
|
|
40
|
+
config: {modules, rootDir, cacheDir, environment},
|
|
41
|
+
runtimeEnvironment: {watchFiles}
|
|
42
42
|
}) {
|
|
43
43
|
this.name = "lwc-module-provider";
|
|
44
44
|
this.moduleSourceCache = new Map();
|
|
45
45
|
this.watchedModuleContextMap = new Map();
|
|
46
46
|
this.moduleEntryVersionCache = new Map();
|
|
47
47
|
this.lwcCompiler = new import_compiler.LwcCompiler();
|
|
48
|
-
|
|
48
|
+
this.inflightGetModuleJobs = new import_shared_utils.InflightTasks();
|
|
49
|
+
this.inflightGetModuleEntryJobs = new import_shared_utils.InflightTasks();
|
|
50
|
+
const {disableCaching} = options;
|
|
49
51
|
this.emitter = appEmitter;
|
|
50
52
|
this.modules = modules;
|
|
51
53
|
this.rootDir = rootDir;
|
|
@@ -53,7 +55,7 @@ var LwcModuleProvider = class {
|
|
|
53
55
|
this.moduleFsCacheEnabled = disableCaching !== void 0 ? !disableCaching : true;
|
|
54
56
|
this.interchangeableModulesEnabled = !!environment?.default;
|
|
55
57
|
if (this.moduleFsCacheEnabled) {
|
|
56
|
-
const {
|
|
58
|
+
const {lwcCacheDir, lwcCacheIndex} = (0, import_cache.setupModuleCache)(cacheDir);
|
|
57
59
|
this.lwcCacheDir = lwcCacheDir;
|
|
58
60
|
this.lwcCacheIndex = lwcCacheIndex;
|
|
59
61
|
}
|
|
@@ -63,7 +65,7 @@ var LwcModuleProvider = class {
|
|
|
63
65
|
if (!moduleContext) {
|
|
64
66
|
throw new Error("We are observing a file we have not yet processed, this should not happen...");
|
|
65
67
|
}
|
|
66
|
-
const {
|
|
68
|
+
const {moduleId, id} = moduleContext;
|
|
67
69
|
this.moduleSourceCache.delete(id);
|
|
68
70
|
const recompiledModule = await this.getModule(moduleId);
|
|
69
71
|
if (recompiledModule) {
|
|
@@ -71,14 +73,20 @@ var LwcModuleProvider = class {
|
|
|
71
73
|
}
|
|
72
74
|
}
|
|
73
75
|
async getModule(moduleId) {
|
|
74
|
-
const
|
|
76
|
+
const id = (0, import_shared_utils.getSpecifier)(moduleId);
|
|
77
|
+
return this.inflightGetModuleJobs.execute(id, () => {
|
|
78
|
+
return this.createGetModuleJob(moduleId);
|
|
79
|
+
}, this);
|
|
80
|
+
}
|
|
81
|
+
async createGetModuleJob(moduleId) {
|
|
82
|
+
const {watcher, watchedModuleContextMap, lwcCacheDir, lwcCacheIndex, moduleFsCacheEnabled} = this;
|
|
75
83
|
const moduleEntry = await this.getModuleEntry(moduleId);
|
|
76
84
|
if (!moduleEntry) {
|
|
77
85
|
return;
|
|
78
86
|
}
|
|
79
87
|
const moduleSource = await this.getModuleSource(moduleId, moduleEntry);
|
|
80
|
-
const {
|
|
81
|
-
const cacheConfig = {
|
|
88
|
+
const {id, namespace, name: rawName, originalSource} = moduleSource;
|
|
89
|
+
const cacheConfig = {lwcCacheDir, lwcCacheIndex};
|
|
82
90
|
let compiledModule = moduleFsCacheEnabled && (0, import_cache.getCompiledModuleCacheEntry)(moduleSource, cacheConfig);
|
|
83
91
|
if (!compiledModule) {
|
|
84
92
|
const [name] = rawName.split("#");
|
|
@@ -93,7 +101,7 @@ var LwcModuleProvider = class {
|
|
|
93
101
|
}
|
|
94
102
|
if (watcher && !watchedModuleContextMap.has(moduleEntry.entry)) {
|
|
95
103
|
watcher.add(moduleEntry.entry);
|
|
96
|
-
watchedModuleContextMap.set(moduleEntry.entry, {
|
|
104
|
+
watchedModuleContextMap.set(moduleEntry.entry, {id, moduleId});
|
|
97
105
|
}
|
|
98
106
|
return {
|
|
99
107
|
...moduleSource,
|
|
@@ -101,8 +109,8 @@ var LwcModuleProvider = class {
|
|
|
101
109
|
compiledMetadata: compiledModule.metadata
|
|
102
110
|
};
|
|
103
111
|
}
|
|
104
|
-
async getModuleSource({
|
|
105
|
-
const {
|
|
112
|
+
async getModuleSource({name, namespace, specifier}, moduleEntry) {
|
|
113
|
+
const {entry, version, id} = moduleEntry;
|
|
106
114
|
const implicitLwc = (0, import_utils.isImplicitLwcImport)(entry, specifier);
|
|
107
115
|
if (this.moduleSourceCache.has(id)) {
|
|
108
116
|
return this.moduleSourceCache.get(id);
|
|
@@ -135,6 +143,16 @@ var LwcModuleProvider = class {
|
|
|
135
143
|
return this.moduleEntryVersionCache.get(cacheKey2);
|
|
136
144
|
}
|
|
137
145
|
}
|
|
146
|
+
const cacheKey = `${specifier}@${version}@${importer}`;
|
|
147
|
+
return this.inflightGetModuleEntryJobs.execute(cacheKey, async () => {
|
|
148
|
+
return this.createModuleEntry({specifier, importer, version});
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
async createModuleEntry({
|
|
152
|
+
specifier,
|
|
153
|
+
importer,
|
|
154
|
+
version
|
|
155
|
+
}) {
|
|
138
156
|
const [baseSpecifier, fileRelativePathRaw] = specifier.split("#");
|
|
139
157
|
const fileRelativePath = fileRelativePathRaw?.split("?")[0];
|
|
140
158
|
let moduleEntry;
|
|
@@ -174,7 +192,7 @@ var LwcModuleProvider = class {
|
|
|
174
192
|
};
|
|
175
193
|
}
|
|
176
194
|
const cacheKey = getModuleEntryCacheKey(specifier, moduleEntry.version);
|
|
177
|
-
const finalModuleEntry = {
|
|
195
|
+
const finalModuleEntry = {...moduleEntry, id: cacheKey};
|
|
178
196
|
this.moduleEntryVersionCache.set(cacheKey, finalModuleEntry);
|
|
179
197
|
if (!version && importer) {
|
|
180
198
|
const importerCacheKey = getModuleEntryCacheKey(specifier, importer);
|
|
@@ -183,3 +201,4 @@ var LwcModuleProvider = class {
|
|
|
183
201
|
return finalModuleEntry;
|
|
184
202
|
}
|
|
185
203
|
};
|
|
204
|
+
var src_default = LwcModuleProvider;
|
package/build/cjs/utils.cjs
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
var __create = Object.create;
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
3
|
var __getProtoOf = Object.getPrototypeOf;
|
|
6
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", {value: true});
|
|
8
8
|
var __export = (target, all) => {
|
|
9
|
-
__markAsModule(target);
|
|
10
9
|
for (var name in all)
|
|
11
|
-
__defProp(target, name, {
|
|
10
|
+
__defProp(target, name, {get: all[name], enumerable: true});
|
|
12
11
|
};
|
|
13
|
-
var
|
|
12
|
+
var __exportStar = (target, module2, desc) => {
|
|
14
13
|
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
15
14
|
for (let key of __getOwnPropNames(module2))
|
|
16
15
|
if (!__hasOwnProp.call(target, key) && key !== "default")
|
|
17
|
-
__defProp(target, key, {
|
|
16
|
+
__defProp(target, key, {get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable});
|
|
18
17
|
}
|
|
19
18
|
return target;
|
|
20
19
|
};
|
|
21
20
|
var __toModule = (module2) => {
|
|
22
|
-
return
|
|
21
|
+
return __exportStar(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? {get: () => module2.default, enumerable: true} : {value: module2, enumerable: true})), module2);
|
|
23
22
|
};
|
|
24
23
|
|
|
25
24
|
// packages/@lwrjs/lwc-module-provider/src/utils.ts
|
|
25
|
+
__markAsModule(exports);
|
|
26
26
|
__export(exports, {
|
|
27
27
|
DEFAULT_IMPLICIT_DEP: () => DEFAULT_IMPLICIT_DEP,
|
|
28
28
|
EXPLICIT_CONSTANT: () => EXPLICIT_CONSTANT,
|
|
@@ -37,10 +37,10 @@ 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 = []) {
|
|
40
|
-
const resolvedModule = (0, import_module_resolver.resolveModule)(specifier, importer, {
|
|
40
|
+
const resolvedModule = (0, import_module_resolver.resolveModule)(specifier, importer, {modules});
|
|
41
41
|
const json = (0, import_shared_utils.readFile)(import_path.default.join(resolvedModule.scope, "package.json"));
|
|
42
42
|
const version = JSON.parse(json).version;
|
|
43
|
-
return {
|
|
43
|
+
return {...resolvedModule, version};
|
|
44
44
|
}
|
|
45
45
|
function isImplicitLwcImport(entry, specifier) {
|
|
46
46
|
const [, fileRelativePathQs] = specifier.split("#");
|
package/build/es/cache.js
CHANGED
|
@@ -4,7 +4,7 @@ export const DEFAULT_COMPILED_DIR = 'lwc_compiled_modules';
|
|
|
4
4
|
export const DEFAULT_CACHE_FOLDER = 'cache';
|
|
5
5
|
export const DEFAULT_CACHE_INDEX = `compiled.json`;
|
|
6
6
|
// eslint-disable-next-line no-useless-escape
|
|
7
|
-
const NORMALIZE_PATH_REGEX = /[
|
|
7
|
+
const NORMALIZE_PATH_REGEX = /[@\/#\.\?<>\\:\*\|"]/gm;
|
|
8
8
|
/**
|
|
9
9
|
* The module cache allow us to recover modules compiled across server restart
|
|
10
10
|
* We store an index file and the compiler modules individually
|
package/build/es/index.d.ts
CHANGED
|
@@ -16,11 +16,20 @@ export default class LwcModuleProvider implements ModuleProvider {
|
|
|
16
16
|
private watchedModuleContextMap;
|
|
17
17
|
private moduleEntryVersionCache;
|
|
18
18
|
private lwcCompiler;
|
|
19
|
+
private inflightGetModuleJobs;
|
|
20
|
+
private inflightGetModuleEntryJobs;
|
|
19
21
|
constructor(options: LwcModuleProviderOptions | undefined, { appEmitter, config: { modules, rootDir, cacheDir, environment }, runtimeEnvironment: { watchFiles }, }: ProviderContext);
|
|
20
22
|
onModuleChange(fileChanged: string): Promise<void>;
|
|
21
23
|
getModule(moduleId: AbstractModuleId): Promise<ModuleCompiled | undefined>;
|
|
24
|
+
/**
|
|
25
|
+
* Create a new Job to fetch a module by id so we are not duplicating effort when multiple requests come in
|
|
26
|
+
* @param moduleId Id of module in question
|
|
27
|
+
* @returns Compiled Module
|
|
28
|
+
*/
|
|
29
|
+
createGetModuleJob(moduleId: AbstractModuleId): Promise<ModuleCompiled | undefined>;
|
|
22
30
|
getModuleSource({ name, namespace, specifier }: AbstractModuleId, moduleEntry: FsModuleEntry): Promise<ModuleSource>;
|
|
23
31
|
getModuleEntry({ specifier, importer, version, }: AbstractModuleId): Promise<FsModuleEntry | undefined>;
|
|
32
|
+
createModuleEntry({ specifier, importer, version, }: AbstractModuleId): Promise<FsModuleEntry | undefined>;
|
|
24
33
|
}
|
|
25
34
|
export {};
|
|
26
35
|
//# sourceMappingURL=index.d.ts.map
|
package/build/es/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { dirname, join } from 'path';
|
|
2
|
-
import { explodeSpecifier, hashContent, readFile, resolveFileExtension, resolveCustomLWCMetadata, } from '@lwrjs/shared-utils';
|
|
2
|
+
import { explodeSpecifier, getSpecifier, hashContent, InflightTasks, readFile, resolveFileExtension, resolveCustomLWCMetadata, } from '@lwrjs/shared-utils';
|
|
3
3
|
import { DEFAULT_IMPLICIT_DEP, isImplicitLwcImport, resolveModuleSpecifier, setUpWatcher } from './utils.js';
|
|
4
4
|
import { addCompiledModuleCacheEntry, getCompiledModuleCacheEntry, setupModuleCache, } from './cache.js';
|
|
5
5
|
import { LwcCompiler } from './compiler.js';
|
|
@@ -13,6 +13,8 @@ export default class LwcModuleProvider {
|
|
|
13
13
|
this.watchedModuleContextMap = new Map();
|
|
14
14
|
this.moduleEntryVersionCache = new Map();
|
|
15
15
|
this.lwcCompiler = new LwcCompiler();
|
|
16
|
+
this.inflightGetModuleJobs = new InflightTasks();
|
|
17
|
+
this.inflightGetModuleEntryJobs = new InflightTasks();
|
|
16
18
|
const { disableCaching } = options;
|
|
17
19
|
this.emitter = appEmitter;
|
|
18
20
|
this.modules = modules;
|
|
@@ -40,6 +42,17 @@ export default class LwcModuleProvider {
|
|
|
40
42
|
}
|
|
41
43
|
}
|
|
42
44
|
async getModule(moduleId) {
|
|
45
|
+
const id = getSpecifier(moduleId);
|
|
46
|
+
return this.inflightGetModuleJobs.execute(id, () => {
|
|
47
|
+
return this.createGetModuleJob(moduleId);
|
|
48
|
+
}, this);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Create a new Job to fetch a module by id so we are not duplicating effort when multiple requests come in
|
|
52
|
+
* @param moduleId Id of module in question
|
|
53
|
+
* @returns Compiled Module
|
|
54
|
+
*/
|
|
55
|
+
async createGetModuleJob(moduleId) {
|
|
43
56
|
const { watcher, watchedModuleContextMap, lwcCacheDir, lwcCacheIndex, moduleFsCacheEnabled } = this;
|
|
44
57
|
const moduleEntry = await this.getModuleEntry(moduleId);
|
|
45
58
|
if (!moduleEntry) {
|
|
@@ -102,6 +115,12 @@ export default class LwcModuleProvider {
|
|
|
102
115
|
return this.moduleEntryVersionCache.get(cacheKey);
|
|
103
116
|
}
|
|
104
117
|
}
|
|
118
|
+
const cacheKey = `${specifier}@${version}@${importer}`;
|
|
119
|
+
return this.inflightGetModuleEntryJobs.execute(cacheKey, async () => {
|
|
120
|
+
return this.createModuleEntry({ specifier, importer, version });
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
async createModuleEntry({ specifier, importer, version, }) {
|
|
105
124
|
// Strip any filenames out of the specifier
|
|
106
125
|
// eg: 'c/myApp#myApp.css' => 'c/myApp' and 'myApp.css'
|
|
107
126
|
// eg: 'some/where#lib/util' => 'some/where' and 'lib/util'
|
package/package.json
CHANGED
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
|
-
"version": "0.6.0-alpha.
|
|
8
|
-
"homepage": "https://
|
|
7
|
+
"version": "0.6.0-alpha.6",
|
|
8
|
+
"homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
11
11
|
"url": "https://github.com/salesforce/lwr.git",
|
|
@@ -32,14 +32,14 @@
|
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@babel/preset-typescript": "^7.9.0",
|
|
34
34
|
"@lwc/module-resolver": "2.5.8",
|
|
35
|
-
"@lwrjs/shared-utils": "0.6.0-alpha.
|
|
35
|
+
"@lwrjs/shared-utils": "0.6.0-alpha.6",
|
|
36
36
|
"es-module-lexer": "^0.3.18"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@lwrjs/types": "0.6.0-alpha.
|
|
39
|
+
"@lwrjs/types": "0.6.0-alpha.6"
|
|
40
40
|
},
|
|
41
41
|
"engines": {
|
|
42
42
|
"node": ">=14.15.4 <17"
|
|
43
43
|
},
|
|
44
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "5d624e196dd46787399e6a269479508abe236081"
|
|
45
45
|
}
|