@lwrjs/lwc-module-provider 0.24.2 → 0.24.3
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 +35 -28
- package/build/cjs/compiler.cjs +41 -30
- package/build/cjs/index.cjs +71 -56
- package/build/cjs/lwc-cjs-entry.d.cjs +1 -0
- package/build/cjs/utils.cjs +40 -27
- package/package.json +6 -6
package/build/cjs/cache.cjs
CHANGED
|
@@ -1,29 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
3
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
4
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
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
9
|
for (var name in all)
|
|
10
|
-
__defProp(target, name, {get: all[name], enumerable: true});
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
11
|
};
|
|
12
|
-
var
|
|
13
|
-
if (
|
|
14
|
-
for (let key of __getOwnPropNames(
|
|
15
|
-
if (!__hasOwnProp.call(
|
|
16
|
-
__defProp(
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
17
|
}
|
|
18
|
-
return
|
|
19
|
-
};
|
|
20
|
-
var __toModule = (module2) => {
|
|
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);
|
|
18
|
+
return to;
|
|
22
19
|
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
23
29
|
|
|
24
30
|
// packages/@lwrjs/lwc-module-provider/src/cache.ts
|
|
25
|
-
|
|
26
|
-
__export(
|
|
31
|
+
var cache_exports = {};
|
|
32
|
+
__export(cache_exports, {
|
|
27
33
|
DEFAULT_CACHE_FOLDER: () => DEFAULT_CACHE_FOLDER,
|
|
28
34
|
DEFAULT_CACHE_INDEX: () => DEFAULT_CACHE_INDEX,
|
|
29
35
|
DEFAULT_COMPILED_DIR: () => DEFAULT_COMPILED_DIR,
|
|
@@ -31,10 +37,11 @@ __export(exports, {
|
|
|
31
37
|
getCompiledModuleCacheEntry: () => getCompiledModuleCacheEntry,
|
|
32
38
|
setupModuleCache: () => setupModuleCache
|
|
33
39
|
});
|
|
34
|
-
|
|
35
|
-
var
|
|
36
|
-
var
|
|
37
|
-
var
|
|
40
|
+
module.exports = __toCommonJS(cache_exports);
|
|
41
|
+
var import_path = __toESM(require("path"), 1);
|
|
42
|
+
var import_shared_utils = require("@lwrjs/shared-utils");
|
|
43
|
+
var import_fs_extra = __toESM(require("fs-extra"), 1);
|
|
44
|
+
var import_diagnostics = require("@lwrjs/diagnostics");
|
|
38
45
|
var DEFAULT_COMPILED_DIR = "lwc_compiled_modules";
|
|
39
46
|
var DEFAULT_CACHE_FOLDER = "cache";
|
|
40
47
|
var DEFAULT_CACHE_INDEX = `compiled.json`;
|
|
@@ -42,17 +49,17 @@ var NORMALIZE_PATH_REGEX = /[@\/#\.\?<>\\:\*\|"]/gm;
|
|
|
42
49
|
function setupModuleCache(cacheDir) {
|
|
43
50
|
const lwcCacheDir = (0, import_shared_utils.toForwardSlash)(import_path.default.join(cacheDir, DEFAULT_COMPILED_DIR));
|
|
44
51
|
const lwcCacheIndexPath = import_path.default.join(lwcCacheDir, DEFAULT_CACHE_INDEX);
|
|
45
|
-
import_fs_extra.default.mkdirSync(`${lwcCacheDir}/${DEFAULT_CACHE_FOLDER}`, {recursive: true});
|
|
52
|
+
import_fs_extra.default.mkdirSync(`${lwcCacheDir}/${DEFAULT_CACHE_FOLDER}`, { recursive: true });
|
|
46
53
|
if (!import_fs_extra.default.existsSync(lwcCacheIndexPath)) {
|
|
47
54
|
import_fs_extra.default.writeFileSync(lwcCacheIndexPath, "[]");
|
|
48
|
-
return {lwcCacheDir, lwcCacheIndex: new Map()};
|
|
55
|
+
return { lwcCacheDir, lwcCacheIndex: /* @__PURE__ */ new Map() };
|
|
49
56
|
} else {
|
|
50
57
|
const cacheIndexJson = import_fs_extra.default.readJSONSync(lwcCacheIndexPath, "utf-8");
|
|
51
|
-
return {lwcCacheDir, lwcCacheIndex: new Map(cacheIndexJson)};
|
|
58
|
+
return { lwcCacheDir, lwcCacheIndex: new Map(cacheIndexJson) };
|
|
52
59
|
}
|
|
53
60
|
}
|
|
54
61
|
var IndexPersister = class {
|
|
55
|
-
async persist({lwcCacheIndex, lwcCacheDir}) {
|
|
62
|
+
async persist({ lwcCacheIndex, lwcCacheDir }) {
|
|
56
63
|
if (this.updateTimer) {
|
|
57
64
|
clearTimeout(this.updateTimer);
|
|
58
65
|
}
|
|
@@ -79,11 +86,11 @@ function getCacheKey(specifier, version, targetSSR) {
|
|
|
79
86
|
return `${specifier}@${version}|${getEnvVariant(targetSSR)}`;
|
|
80
87
|
}
|
|
81
88
|
var moduleCount = 0;
|
|
82
|
-
async function addCompiledModuleCacheEntry(moduleSource, compilerResult, targetSSR, {lwcCacheIndex, lwcCacheDir}) {
|
|
83
|
-
const {specifier, version, ownHash} = moduleSource;
|
|
89
|
+
async function addCompiledModuleCacheEntry(moduleSource, compilerResult, targetSSR, { lwcCacheIndex, lwcCacheDir }) {
|
|
90
|
+
const { specifier, version, ownHash } = moduleSource;
|
|
84
91
|
const cacheKey = getCacheKey(specifier, version, targetSSR);
|
|
85
92
|
if (++moduleCount % 1e3 === 0) {
|
|
86
|
-
import_diagnostics.logger.debug({label: `lwc-module-provider`, message: `Compiled Modules >${moduleCount}`});
|
|
93
|
+
import_diagnostics.logger.debug({ label: `lwc-module-provider`, message: `Compiled Modules >${moduleCount}` });
|
|
87
94
|
}
|
|
88
95
|
const normalizedSpecifier = specifier.replace(NORMALIZE_PATH_REGEX, "_");
|
|
89
96
|
const normalizedVersion = version.replace(NORMALIZE_PATH_REGEX, "_");
|
|
@@ -99,10 +106,10 @@ async function addCompiledModuleCacheEntry(moduleSource, compilerResult, targetS
|
|
|
99
106
|
module: `./${DEFAULT_CACHE_FOLDER}/${moduleFileName}`,
|
|
100
107
|
moduleMeta: `./${DEFAULT_CACHE_FOLDER}/${moduleMetaFileName}`
|
|
101
108
|
});
|
|
102
|
-
const writeMetadata = INDEX_PERSISTER.persist({lwcCacheIndex, lwcCacheDir});
|
|
109
|
+
const writeMetadata = INDEX_PERSISTER.persist({ lwcCacheIndex, lwcCacheDir });
|
|
103
110
|
return Promise.all([writeModulePromise, writeMetadataPromise, writeMetadata]);
|
|
104
111
|
}
|
|
105
|
-
function getCompiledModuleCacheEntry({specifier, version, ownHash}, targetSSR, {lwcCacheIndex, lwcCacheDir}) {
|
|
112
|
+
function getCompiledModuleCacheEntry({ specifier, version, ownHash }, targetSSR, { lwcCacheIndex, lwcCacheDir }) {
|
|
106
113
|
const cacheKey = getCacheKey(specifier, version, targetSSR);
|
|
107
114
|
const cacheEntry = lwcCacheIndex.get(cacheKey);
|
|
108
115
|
if (!cacheEntry) {
|
package/build/cjs/compiler.cjs
CHANGED
|
@@ -1,46 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
3
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
4
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
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
9
|
for (var name in all)
|
|
10
|
-
__defProp(target, name, {get: all[name], enumerable: true});
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
11
|
};
|
|
12
|
-
var
|
|
13
|
-
if (
|
|
14
|
-
for (let key of __getOwnPropNames(
|
|
15
|
-
if (!__hasOwnProp.call(
|
|
16
|
-
__defProp(
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
17
|
}
|
|
18
|
-
return
|
|
19
|
-
};
|
|
20
|
-
var __toModule = (module2) => {
|
|
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);
|
|
18
|
+
return to;
|
|
22
19
|
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
23
29
|
|
|
24
30
|
// packages/@lwrjs/lwc-module-provider/src/compiler.ts
|
|
25
|
-
|
|
26
|
-
__export(
|
|
31
|
+
var compiler_exports = {};
|
|
32
|
+
__export(compiler_exports, {
|
|
27
33
|
LwcCompiler: () => LwcCompiler
|
|
28
34
|
});
|
|
29
|
-
|
|
30
|
-
var
|
|
31
|
-
var
|
|
32
|
-
var
|
|
33
|
-
var
|
|
35
|
+
module.exports = __toCommonJS(compiler_exports);
|
|
36
|
+
var import_core = require("@babel/core");
|
|
37
|
+
var lwcCompilerCjs = __toESM(require("@lwc/compiler/dist/index.cjs"), 1);
|
|
38
|
+
var import_shared_utils = require("@lwrjs/shared-utils");
|
|
39
|
+
var import_utils = require("./utils.cjs");
|
|
40
|
+
var import_diagnostics = require("@lwrjs/diagnostics");
|
|
34
41
|
var DEFAULT_BABEL_CONFIG = {
|
|
35
42
|
babelrc: false,
|
|
36
43
|
configFile: false,
|
|
37
44
|
sourceMaps: true,
|
|
38
45
|
parserOpts: {
|
|
39
|
-
plugins: [["decorators", {decoratorsBeforeExport: true}]]
|
|
46
|
+
plugins: [["decorators", { decoratorsBeforeExport: true }]]
|
|
40
47
|
}
|
|
41
48
|
};
|
|
42
49
|
function skipCompilation(namespace, theName) {
|
|
43
|
-
if (!namespace && theName === "lwc" ||
|
|
50
|
+
if (!namespace && theName === "lwc" || // LWC framework
|
|
51
|
+
namespace === "@lwc" || // other LWC framework packages
|
|
52
|
+
namespace === "lwr" && theName === "hmr") {
|
|
44
53
|
return true;
|
|
45
54
|
}
|
|
46
55
|
return false;
|
|
@@ -49,8 +58,9 @@ var LwcCompiler = class {
|
|
|
49
58
|
constructor(compiler) {
|
|
50
59
|
this.compiler = compiler;
|
|
51
60
|
}
|
|
61
|
+
// compileFile takes a html, css, typescript, etc, and transforms it to a es6 module
|
|
52
62
|
async compileFile(source, config, targetSSR = false) {
|
|
53
|
-
const {enableLightningWebSecurityTransforms, filename, name, namespace, scopedStyles} = config;
|
|
63
|
+
const { enableLightningWebSecurityTransforms, filename, name, namespace, scopedStyles } = config;
|
|
54
64
|
if (source.startsWith(import_utils.EXPLICIT_CONSTANT)) {
|
|
55
65
|
return {
|
|
56
66
|
code: source,
|
|
@@ -61,13 +71,13 @@ var LwcCompiler = class {
|
|
|
61
71
|
if (filename.endsWith("ts")) {
|
|
62
72
|
const babelConfig = {
|
|
63
73
|
...DEFAULT_BABEL_CONFIG,
|
|
64
|
-
presets: [["@babel/preset-typescript", {onlyRemoveTypeImports: false}]],
|
|
74
|
+
presets: [["@babel/preset-typescript", { onlyRemoveTypeImports: false }]],
|
|
65
75
|
filename
|
|
66
76
|
};
|
|
67
77
|
import_diagnostics.logger.debug({
|
|
68
78
|
label: "LwcCompiler",
|
|
69
79
|
message: "babelTransform",
|
|
70
|
-
additionalInfo: {babelConfig}
|
|
80
|
+
additionalInfo: { babelConfig }
|
|
71
81
|
});
|
|
72
82
|
let result;
|
|
73
83
|
try {
|
|
@@ -83,13 +93,13 @@ var LwcCompiler = class {
|
|
|
83
93
|
import_diagnostics.logger.verbose({
|
|
84
94
|
label: "LwcCompiler",
|
|
85
95
|
message: "babelTransform result",
|
|
86
|
-
additionalInfo: {result}
|
|
96
|
+
additionalInfo: { result }
|
|
87
97
|
});
|
|
88
98
|
if (!result || !result.code) {
|
|
89
99
|
import_diagnostics.logger.debug({
|
|
90
100
|
label: "LwcCompiler",
|
|
91
101
|
message: "babelTransform invalid result",
|
|
92
|
-
additionalInfo: {result}
|
|
102
|
+
additionalInfo: { result }
|
|
93
103
|
});
|
|
94
104
|
throw new Error(`Error TS compiling ${filename}`);
|
|
95
105
|
}
|
|
@@ -105,14 +115,15 @@ var LwcCompiler = class {
|
|
|
105
115
|
const transformConfig = {
|
|
106
116
|
namespace: namespace || "",
|
|
107
117
|
name,
|
|
108
|
-
experimentalDynamicComponent: {strictSpecifier: false},
|
|
109
|
-
dynamicImports: {strictSpecifier: false},
|
|
118
|
+
experimentalDynamicComponent: { strictSpecifier: false },
|
|
119
|
+
dynamicImports: { strictSpecifier: false },
|
|
110
120
|
scopedStyles,
|
|
111
121
|
enableDynamicComponents: true,
|
|
112
122
|
enableLightningWebSecurityTransforms,
|
|
113
123
|
enablePrivateMethods: true,
|
|
114
124
|
enableSyntheticElementInternals: true,
|
|
115
125
|
enableScopedSlots: true,
|
|
126
|
+
// this flag turns on an additive feature and is backwards compatible
|
|
116
127
|
targetSSR: (0, import_shared_utils.getFeatureFlags)().SSR_COMPILER_ENABLED && targetSSR,
|
|
117
128
|
enableLwcOn: true
|
|
118
129
|
};
|
|
@@ -130,7 +141,7 @@ var LwcCompiler = class {
|
|
|
130
141
|
import_diagnostics.logger.verbose({
|
|
131
142
|
label: "LwcCompiler",
|
|
132
143
|
message: "transformSync result",
|
|
133
|
-
additionalInfo: {compilerResult}
|
|
144
|
+
additionalInfo: { compilerResult }
|
|
134
145
|
});
|
|
135
146
|
return {
|
|
136
147
|
code: compilerResult.code,
|
package/build/cjs/index.cjs
CHANGED
|
@@ -1,56 +1,56 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
|
-
var
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __export = (target, all) => {
|
|
9
7
|
for (var name in all)
|
|
10
|
-
__defProp(target, name, {get: all[name], enumerable: true});
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
9
|
};
|
|
12
|
-
var
|
|
13
|
-
if (
|
|
14
|
-
for (let key of __getOwnPropNames(
|
|
15
|
-
if (!__hasOwnProp.call(
|
|
16
|
-
__defProp(
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
15
|
}
|
|
18
|
-
return
|
|
19
|
-
};
|
|
20
|
-
var __toModule = (module2) => {
|
|
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);
|
|
16
|
+
return to;
|
|
22
17
|
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
23
19
|
|
|
24
20
|
// packages/@lwrjs/lwc-module-provider/src/index.ts
|
|
25
|
-
|
|
26
|
-
__export(
|
|
27
|
-
default: () =>
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
default: () => LwcModuleProvider
|
|
28
24
|
});
|
|
29
|
-
|
|
30
|
-
var
|
|
31
|
-
var
|
|
32
|
-
var
|
|
33
|
-
var
|
|
34
|
-
var
|
|
25
|
+
module.exports = __toCommonJS(index_exports);
|
|
26
|
+
var import_path = require("path");
|
|
27
|
+
var import_shared_utils = require("@lwrjs/shared-utils");
|
|
28
|
+
var import_diagnostics = require("@lwrjs/diagnostics");
|
|
29
|
+
var import_utils = require("./utils.cjs");
|
|
30
|
+
var import_cache = require("./cache.cjs");
|
|
31
|
+
var import_compiler = require("./compiler.cjs");
|
|
35
32
|
function getModuleEntryCacheKey(specifier, version, targetSSR) {
|
|
36
33
|
return `${specifier}@${version}|${targetSSR ? "server" : "client"}`;
|
|
37
34
|
}
|
|
38
35
|
var LwcModuleProvider = class {
|
|
39
36
|
constructor(options = {}, {
|
|
40
37
|
appEmitter,
|
|
41
|
-
config: {modules, rootDir, cacheDir, environment},
|
|
42
|
-
runtimeEnvironment: {watchFiles},
|
|
38
|
+
config: { modules, rootDir, cacheDir, environment },
|
|
39
|
+
runtimeEnvironment: { watchFiles },
|
|
43
40
|
watcherFactory
|
|
44
41
|
}) {
|
|
45
42
|
this.name = "lwc-module-provider";
|
|
46
|
-
this.moduleSourceCache = new Map();
|
|
47
|
-
|
|
48
|
-
this.
|
|
49
|
-
this.
|
|
50
|
-
|
|
43
|
+
this.moduleSourceCache = /* @__PURE__ */ new Map();
|
|
44
|
+
// key = filepath
|
|
45
|
+
this.packageVersionCache = /* @__PURE__ */ new Map();
|
|
46
|
+
this.watchedModuleContextMap = /* @__PURE__ */ new Map();
|
|
47
|
+
// key = filepath
|
|
48
|
+
this.moduleEntryVersionCache = /* @__PURE__ */ new Map();
|
|
49
|
+
// key = moduleEntry.id
|
|
50
|
+
this.importerMappingCache = /* @__PURE__ */ new Map();
|
|
51
51
|
this.inflightGetModuleJobs = new import_shared_utils.InflightTasks();
|
|
52
52
|
this.inflightGetModuleEntryJobs = new import_shared_utils.InflightTasks();
|
|
53
|
-
const {disableCaching} = options;
|
|
53
|
+
const { disableCaching } = options;
|
|
54
54
|
this.emitter = appEmitter;
|
|
55
55
|
this.modules = modules;
|
|
56
56
|
this.rootDir = rootDir;
|
|
@@ -59,7 +59,7 @@ var LwcModuleProvider = class {
|
|
|
59
59
|
this.interchangeableModulesEnabled = !!environment?.default;
|
|
60
60
|
this.lwcCompiler = new import_compiler.LwcCompiler(options.lwcCompiler);
|
|
61
61
|
if (this.moduleFsCacheEnabled) {
|
|
62
|
-
const {lwcCacheDir, lwcCacheIndex} = (0, import_cache.setupModuleCache)(cacheDir);
|
|
62
|
+
const { lwcCacheDir, lwcCacheIndex } = (0, import_cache.setupModuleCache)(cacheDir);
|
|
63
63
|
this.lwcCacheDir = lwcCacheDir;
|
|
64
64
|
this.lwcCacheIndex = lwcCacheIndex;
|
|
65
65
|
}
|
|
@@ -73,7 +73,7 @@ var LwcModuleProvider = class {
|
|
|
73
73
|
const hasClient = this.moduleEntryVersionCache.get(moduleEntry.id.replace("|server", "|client"));
|
|
74
74
|
const hasServer = this.moduleEntryVersionCache.get(moduleEntry.id.replace("|client", "|server"));
|
|
75
75
|
const recompiledClientModule = hasClient && await this.getModule(moduleEntry);
|
|
76
|
-
const recompiledServerModule = hasServer && await this.getModule(moduleEntry, {ssr: true});
|
|
76
|
+
const recompiledServerModule = hasServer && await this.getModule(moduleEntry, { ssr: true });
|
|
77
77
|
if (recompiledClientModule) {
|
|
78
78
|
this.emitter.notifyModuleSourceChanged(recompiledClientModule);
|
|
79
79
|
}
|
|
@@ -87,31 +87,36 @@ var LwcModuleProvider = class {
|
|
|
87
87
|
}
|
|
88
88
|
async getModule(moduleId, runtimeParams = {}) {
|
|
89
89
|
const id = (0, import_shared_utils.getSpecifier)(moduleId);
|
|
90
|
-
import_diagnostics.logger.debug({label: this.name, message: `getModule ${id}`});
|
|
90
|
+
import_diagnostics.logger.debug({ label: this.name, message: `getModule ${id}` });
|
|
91
91
|
return this.inflightGetModuleJobs.execute(id, () => {
|
|
92
92
|
return this.createGetModuleJob(moduleId, runtimeParams);
|
|
93
93
|
});
|
|
94
94
|
}
|
|
95
|
+
/**
|
|
96
|
+
* Create a new Job to fetch a module by id so we are not duplicating effort when multiple requests come in
|
|
97
|
+
* @param moduleId Id of module in question
|
|
98
|
+
* @returns Compiled Module
|
|
99
|
+
*/
|
|
95
100
|
async createGetModuleJob(moduleId, runtimeParams) {
|
|
96
|
-
const {watcher, watchedModuleContextMap, lwcCacheDir, lwcCacheIndex, moduleFsCacheEnabled} = this;
|
|
101
|
+
const { watcher, watchedModuleContextMap, lwcCacheDir, lwcCacheIndex, moduleFsCacheEnabled } = this;
|
|
97
102
|
import_diagnostics.logger.debug({
|
|
98
103
|
label: this.name,
|
|
99
104
|
message: "fetch module",
|
|
100
|
-
additionalInfo: {moduleId, moduleFsCacheEnabled}
|
|
105
|
+
additionalInfo: { moduleId, moduleFsCacheEnabled }
|
|
101
106
|
});
|
|
102
107
|
const moduleEntry = await this.getModuleEntry(moduleId, runtimeParams);
|
|
103
108
|
if (!moduleEntry) {
|
|
104
109
|
return;
|
|
105
110
|
}
|
|
106
111
|
const moduleSource = await this.getModuleSource(moduleId, moduleEntry);
|
|
107
|
-
const {namespace, name: rawName, originalSource} = moduleSource;
|
|
112
|
+
const { namespace, name: rawName, originalSource } = moduleSource;
|
|
108
113
|
const targetSSR = !!runtimeParams.ssr;
|
|
109
|
-
const cacheConfig = {lwcCacheDir, lwcCacheIndex};
|
|
114
|
+
const cacheConfig = { lwcCacheDir, lwcCacheIndex };
|
|
110
115
|
let compiledModule = moduleFsCacheEnabled && (0, import_cache.getCompiledModuleCacheEntry)(moduleSource, targetSSR, cacheConfig);
|
|
111
116
|
import_diagnostics.logger.debug({
|
|
112
117
|
label: this.name,
|
|
113
118
|
message: "module source",
|
|
114
|
-
additionalInfo: {moduleId, isPreCompiled: compiledModule != void 0}
|
|
119
|
+
additionalInfo: { moduleId, isPreCompiled: compiledModule != void 0 }
|
|
115
120
|
});
|
|
116
121
|
if (!compiledModule) {
|
|
117
122
|
const [name] = rawName.split("#");
|
|
@@ -127,12 +132,16 @@ var LwcModuleProvider = class {
|
|
|
127
132
|
targetSSR
|
|
128
133
|
}
|
|
129
134
|
});
|
|
130
|
-
compiledModule = await this.lwcCompiler.compileFile(
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
135
|
+
compiledModule = await this.lwcCompiler.compileFile(
|
|
136
|
+
originalSource,
|
|
137
|
+
{
|
|
138
|
+
namespace,
|
|
139
|
+
name,
|
|
140
|
+
filename: moduleEntry.entry,
|
|
141
|
+
scopedStyles
|
|
142
|
+
},
|
|
143
|
+
targetSSR
|
|
144
|
+
);
|
|
136
145
|
import_diagnostics.logger.verbose({
|
|
137
146
|
label: this.name,
|
|
138
147
|
message: "createGetModuleJob:compile compiledModule",
|
|
@@ -158,8 +167,8 @@ var LwcModuleProvider = class {
|
|
|
158
167
|
compiledMetadata: compiledModule.metadata
|
|
159
168
|
};
|
|
160
169
|
}
|
|
161
|
-
async getModuleSource({name, namespace, specifier}, moduleEntry) {
|
|
162
|
-
const {entry, version, id} = moduleEntry;
|
|
170
|
+
async getModuleSource({ name, namespace, specifier }, moduleEntry) {
|
|
171
|
+
const { entry, version, id } = moduleEntry;
|
|
163
172
|
name = name || (0, import_shared_utils.explodeSpecifier)(specifier).name;
|
|
164
173
|
let originalSource, ownHash;
|
|
165
174
|
if (this.moduleSourceCache.has(entry)) {
|
|
@@ -170,7 +179,7 @@ var LwcModuleProvider = class {
|
|
|
170
179
|
const implicitLwc = (0, import_utils.isImplicitLwcImport)(entry, specifier);
|
|
171
180
|
originalSource = implicitLwc ? import_utils.DEFAULT_IMPLICIT_DEP : (0, import_shared_utils.readFile)(entry);
|
|
172
181
|
ownHash = (0, import_shared_utils.hashContent)(originalSource);
|
|
173
|
-
this.moduleSourceCache.set(entry, {originalSource, ownHash});
|
|
182
|
+
this.moduleSourceCache.set(entry, { originalSource, ownHash });
|
|
174
183
|
}
|
|
175
184
|
return {
|
|
176
185
|
id,
|
|
@@ -183,7 +192,7 @@ var LwcModuleProvider = class {
|
|
|
183
192
|
originalSource
|
|
184
193
|
};
|
|
185
194
|
}
|
|
186
|
-
async getModuleEntry({specifier, importer, version}, runtimeParams = {}) {
|
|
195
|
+
async getModuleEntry({ specifier, importer, version }, runtimeParams = {}) {
|
|
187
196
|
const targetSSR = !!runtimeParams.ssr;
|
|
188
197
|
const jobKey = `${specifier}@${version}@${importer}|${targetSSR ? "server" : "client"}`;
|
|
189
198
|
import_diagnostics.logger.debug({
|
|
@@ -195,10 +204,10 @@ var LwcModuleProvider = class {
|
|
|
195
204
|
return moduleEntry;
|
|
196
205
|
}
|
|
197
206
|
return this.inflightGetModuleEntryJobs.execute(jobKey, async () => {
|
|
198
|
-
return this.createModuleEntry({specifier, importer, version}, runtimeParams);
|
|
207
|
+
return this.createModuleEntry({ specifier, importer, version }, runtimeParams);
|
|
199
208
|
});
|
|
200
209
|
}
|
|
201
|
-
async createModuleEntry({specifier, importer, version}, runtimeParams) {
|
|
210
|
+
async createModuleEntry({ specifier, importer, version }, runtimeParams) {
|
|
202
211
|
const targetSSR = !!runtimeParams.ssr;
|
|
203
212
|
import_diagnostics.logger.debug({
|
|
204
213
|
label: `${this.name}`,
|
|
@@ -228,11 +237,17 @@ var LwcModuleProvider = class {
|
|
|
228
237
|
rootDir: this.rootDir
|
|
229
238
|
}
|
|
230
239
|
});
|
|
231
|
-
const registryEntry = (0, import_utils.resolveModuleSpecifier)(
|
|
240
|
+
const registryEntry = (0, import_utils.resolveModuleSpecifier)(
|
|
241
|
+
baseSpecifier,
|
|
242
|
+
this.rootDir,
|
|
243
|
+
this.modules,
|
|
244
|
+
this.packageVersionCache,
|
|
245
|
+
importer
|
|
246
|
+
);
|
|
232
247
|
import_diagnostics.logger.debug({
|
|
233
248
|
label: `${this.name}`,
|
|
234
249
|
message: "createModuleEntry:registryEntry",
|
|
235
|
-
additionalInfo: {registryEntry}
|
|
250
|
+
additionalInfo: { registryEntry }
|
|
236
251
|
});
|
|
237
252
|
moduleEntry = {
|
|
238
253
|
id: getModuleEntryCacheKey(registryEntry.specifier, registryEntry.version, targetSSR),
|
|
@@ -264,11 +279,12 @@ var LwcModuleProvider = class {
|
|
|
264
279
|
moduleEntry = {
|
|
265
280
|
...moduleEntry,
|
|
266
281
|
entry: (0, import_shared_utils.resolveFileExtension)(filePath),
|
|
282
|
+
// TODO: LWC implicit/explicit html hack
|
|
267
283
|
specifier
|
|
268
284
|
};
|
|
269
285
|
}
|
|
270
286
|
const cacheKey = getModuleEntryCacheKey(specifier, moduleEntry.version, targetSSR);
|
|
271
|
-
const finalModuleEntry = {...moduleEntry, id: cacheKey};
|
|
287
|
+
const finalModuleEntry = { ...moduleEntry, id: cacheKey };
|
|
272
288
|
this.moduleEntryVersionCache.set(cacheKey, finalModuleEntry);
|
|
273
289
|
if (!version) {
|
|
274
290
|
const importerCacheKey = getModuleEntryCacheKey(specifier, importer || this.rootDir, targetSSR);
|
|
@@ -292,4 +308,3 @@ var LwcModuleProvider = class {
|
|
|
292
308
|
return moduleEntry;
|
|
293
309
|
}
|
|
294
310
|
};
|
|
295
|
-
var src_default = LwcModuleProvider;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
package/build/cjs/utils.cjs
CHANGED
|
@@ -1,47 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
3
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
4
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
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
9
|
for (var name in all)
|
|
10
|
-
__defProp(target, name, {get: all[name], enumerable: true});
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
11
|
};
|
|
12
|
-
var
|
|
13
|
-
if (
|
|
14
|
-
for (let key of __getOwnPropNames(
|
|
15
|
-
if (!__hasOwnProp.call(
|
|
16
|
-
__defProp(
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
17
|
}
|
|
18
|
-
return
|
|
19
|
-
};
|
|
20
|
-
var __toModule = (module2) => {
|
|
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);
|
|
18
|
+
return to;
|
|
22
19
|
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
23
29
|
|
|
24
30
|
// packages/@lwrjs/lwc-module-provider/src/utils.ts
|
|
25
|
-
|
|
26
|
-
__export(
|
|
31
|
+
var utils_exports = {};
|
|
32
|
+
__export(utils_exports, {
|
|
27
33
|
DEFAULT_IMPLICIT_DEP: () => DEFAULT_IMPLICIT_DEP,
|
|
28
34
|
EXPLICIT_CONSTANT: () => EXPLICIT_CONSTANT,
|
|
29
35
|
isImplicitLwcImport: () => isImplicitLwcImport,
|
|
30
36
|
resolveModuleSpecifier: () => resolveModuleSpecifier,
|
|
31
37
|
setUpWatcher: () => setUpWatcher
|
|
32
38
|
});
|
|
33
|
-
|
|
34
|
-
var
|
|
35
|
-
var
|
|
36
|
-
var
|
|
37
|
-
var
|
|
39
|
+
module.exports = __toCommonJS(utils_exports);
|
|
40
|
+
var import_fs = __toESM(require("fs"), 1);
|
|
41
|
+
var import_path = __toESM(require("path"), 1);
|
|
42
|
+
var import_diagnostics = require("@lwrjs/diagnostics");
|
|
43
|
+
var import_shared_utils = require("@lwrjs/shared-utils");
|
|
44
|
+
var import_dist = require("@lwc/module-resolver/dist/index.cjs");
|
|
38
45
|
var EXPLICIT_CONSTANT = "/* _implicit_dependency_ */";
|
|
39
46
|
var DEFAULT_IMPLICIT_DEP = `${EXPLICIT_CONSTANT} export default void 0`;
|
|
40
47
|
function resolveModuleSpecifier(specifier, rootDir, modules = [], packageVersionCache, importer) {
|
|
41
48
|
import_diagnostics.logger.debug({
|
|
42
49
|
label: `lwc-module-provider`,
|
|
43
50
|
message: "resolveModuleSpecifier",
|
|
44
|
-
additionalInfo: {specifier, importer}
|
|
51
|
+
additionalInfo: { specifier, importer }
|
|
45
52
|
});
|
|
46
53
|
let resolvedModule;
|
|
47
54
|
try {
|
|
@@ -62,7 +69,7 @@ function resolveModuleSpecifier(specifier, rootDir, modules = [], packageVersion
|
|
|
62
69
|
import_diagnostics.logger.debug({
|
|
63
70
|
label: `lwc-module-provider`,
|
|
64
71
|
message: "resolveModuleSpecifier:resolvedModule",
|
|
65
|
-
additionalInfo: {resolvedModule}
|
|
72
|
+
additionalInfo: { resolvedModule }
|
|
66
73
|
});
|
|
67
74
|
const moduleEntry = resolvedModule.entry;
|
|
68
75
|
let version;
|
|
@@ -74,13 +81,13 @@ function resolveModuleSpecifier(specifier, rootDir, modules = [], packageVersion
|
|
|
74
81
|
version = JSON.parse(json).version;
|
|
75
82
|
packageVersionCache.set(moduleEntry, version);
|
|
76
83
|
}
|
|
77
|
-
return {...resolvedModule, version};
|
|
84
|
+
return { ...resolvedModule, version };
|
|
78
85
|
}
|
|
79
86
|
function findClosestPackageJsonPath(filepath) {
|
|
80
87
|
let curDir = import_path.default.dirname(filepath);
|
|
81
88
|
while (true) {
|
|
82
89
|
const possiblePath = import_path.default.join(curDir, "package.json");
|
|
83
|
-
const stats = import_fs.default.statSync(possiblePath, {throwIfNoEntry: false});
|
|
90
|
+
const stats = import_fs.default.statSync(possiblePath, { throwIfNoEntry: false });
|
|
84
91
|
if (stats?.isFile()) {
|
|
85
92
|
return possiblePath;
|
|
86
93
|
} else {
|
|
@@ -123,8 +130,14 @@ function isImplicitLwcImport(entry, specifier) {
|
|
|
123
130
|
}
|
|
124
131
|
function setUpWatcher(watcherFactory, onModuleChange) {
|
|
125
132
|
const watcher = watcherFactory.createFileWatcher();
|
|
126
|
-
watcher.on(
|
|
127
|
-
|
|
128
|
-
|
|
133
|
+
watcher.on(
|
|
134
|
+
"change",
|
|
135
|
+
(0, import_shared_utils.debounce)((file) => onModuleChange(file), 500)
|
|
136
|
+
);
|
|
137
|
+
watcher.on(
|
|
138
|
+
"unlink",
|
|
139
|
+
(0, import_shared_utils.debounce)((file) => onModuleChange(file), 500)
|
|
140
|
+
);
|
|
141
|
+
watcher.on("add", (file) => import_diagnostics.logger.info({ label: `lwc-module-provider`, message: `Watching: ${file}` }));
|
|
129
142
|
return watcher;
|
|
130
143
|
}
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
|
-
"version": "0.24.
|
|
7
|
+
"version": "0.24.3",
|
|
8
8
|
"homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
@@ -35,13 +35,13 @@
|
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"@babel/core": "^7.29.7",
|
|
37
37
|
"@babel/preset-typescript": "^7.28.5",
|
|
38
|
-
"@lwrjs/diagnostics": "0.24.
|
|
39
|
-
"@lwrjs/fs-watch": "0.24.
|
|
40
|
-
"@lwrjs/shared-utils": "0.24.
|
|
38
|
+
"@lwrjs/diagnostics": "0.24.3",
|
|
39
|
+
"@lwrjs/fs-watch": "0.24.3",
|
|
40
|
+
"@lwrjs/shared-utils": "0.24.3",
|
|
41
41
|
"fs-extra": "^11.2.0"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@lwrjs/types": "0.24.
|
|
44
|
+
"@lwrjs/types": "0.24.3",
|
|
45
45
|
"memfs": "^4.13.0",
|
|
46
46
|
"typescript": "5.0.4"
|
|
47
47
|
},
|
|
@@ -55,5 +55,5 @@
|
|
|
55
55
|
"volta": {
|
|
56
56
|
"extends": "../../../package.json"
|
|
57
57
|
},
|
|
58
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "ed415a8f04d5558cac756fbc2a0e454a373e31c1"
|
|
59
59
|
}
|