@lwc/dev-server-plugin-lex 7.2.0-6.7.0 → 8.0.0
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.
|
@@ -31,6 +31,8 @@ const path = __importStar(require("node:path"));
|
|
|
31
31
|
const magic_string_1 = __importDefault(require("magic-string"));
|
|
32
32
|
const errors_1 = require("@lwc/errors");
|
|
33
33
|
const IMPLICIT_DEFAULT_HTML_PATH = '@lwc/resources/empty_html.js';
|
|
34
|
+
const REGISTER_COMPONENT_MARKER = 'const __lwc_component_class_internal = ';
|
|
35
|
+
const COMPONENT_CLASS_ID = '__lwc_component_class_internal';
|
|
34
36
|
/**
|
|
35
37
|
* Transform a javascript(.js or .ts) file to add Hot Module Replacement related tranformations.
|
|
36
38
|
* Note 1: Transform the file using the `@lwc/compiler` before invoking this transformer.
|
|
@@ -50,37 +52,22 @@ function scriptTransformer(src, id, options, hmrModuleContext) {
|
|
|
50
52
|
if (src.trim() === '' || id === IMPLICIT_DEFAULT_HTML_PATH) {
|
|
51
53
|
return;
|
|
52
54
|
}
|
|
53
|
-
|
|
55
|
+
// Add hmr hooks only for entry js file and modules that represent a component
|
|
56
|
+
if (path.parse(id).name !== options.name || !src.includes(REGISTER_COMPONENT_MARKER)) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
54
59
|
try {
|
|
55
|
-
|
|
56
|
-
// Add hmr hooks only for entry js file
|
|
57
|
-
if (path.parse(id).name === options.name) {
|
|
58
|
-
// For an entry file, accept self-updates
|
|
59
|
-
hotAccept = `
|
|
60
|
-
__lwc_hmr_hot.accept('${hmrModuleContext.modulePath}', (mod) => {
|
|
61
|
-
const { __lwc_hmr_context: new__lwc_hmr_context } = mod;
|
|
62
|
-
if (__lwc_hmr_context.moduleHash !== new__lwc_hmr_context.moduleHash) {
|
|
63
|
-
__lwc_hmr_hot.invalidate("JS change requires hot swapping at module boundary.")
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
`;
|
|
67
|
-
}
|
|
68
|
-
else {
|
|
69
|
-
// For a relative import, the entry module will accept hot update of dependencies
|
|
70
|
-
hotAccept = `
|
|
71
|
-
__lwc_hmr_hot.acceptDeps('${hmrModuleContext.ownerPath}', ['${hmrModuleContext.modulePath}'], (mod) => {
|
|
72
|
-
const { __lwc_hmr_context: new__lwc_hmr_context } = mod;
|
|
73
|
-
if (__lwc_hmr_context.moduleHash !== new__lwc_hmr_context.moduleHash) {
|
|
74
|
-
__lwc_hmr_hot.invalidate("JS change requires hot swapping at module boundary.");
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
`;
|
|
78
|
-
}
|
|
60
|
+
const pre = `import { hot as __lwc_hmr_hot, swapComponent as __lwc_hmr_swapComponent } from 'lwc';\n`;
|
|
79
61
|
const post = `
|
|
80
62
|
export const __lwc_hmr_context = { moduleHash : '${hmrModuleContext.moduleHash}' };
|
|
81
63
|
if (__lwc_hmr_hot) {
|
|
82
64
|
__lwc_hmr_hot.register('${hmrModuleContext.modulePath}', '${hmrModuleContext.moduleHash}', ${JSON.stringify(options)});
|
|
83
|
-
${
|
|
65
|
+
__lwc_hmr_hot.accept('${hmrModuleContext.modulePath}', (mod) => {
|
|
66
|
+
const { __lwc_hmr_context: __new__lwc_hmr_context, default: __new_component } = mod;
|
|
67
|
+
if (__lwc_hmr_context.moduleHash !== __new__lwc_hmr_context.moduleHash) {
|
|
68
|
+
__lwc_hmr_swapComponent(${COMPONENT_CLASS_ID}, __new_component);
|
|
69
|
+
}
|
|
70
|
+
});
|
|
84
71
|
}
|
|
85
72
|
`;
|
|
86
73
|
const magicString = new magic_string_1.default(src);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"script.js","sourceRoot":"","sources":["../../src/transformers/script.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAAkC;AAClC,gEAAuC;AACvC,wCAA0E;AAK1E,MAAM,0BAA0B,GAAG,8BAA8B,CAAC;
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SAChD,CAAC;IACN,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACT,MAAM,IAAA,iCAAwB,EAAC,0BAAiB,CAAC,oBAAoB,EAAE,CAAC,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,CAAC;IAChG,CAAC;AACL,CAAC;AAtCD,8CAsCC"}
|
|
@@ -23,7 +23,7 @@ function templateTransformer(src, id, options, hmrModuleContext) {
|
|
|
23
23
|
|
|
24
24
|
${src}
|
|
25
25
|
export const __lwc_hmr_context = { moduleHash : '${hmrModuleContext.moduleHash}' };
|
|
26
|
-
if(typeof tmpl === 'function' && __lwc_hmr_hot) {
|
|
26
|
+
if (typeof tmpl === 'function' && __lwc_hmr_hot) {
|
|
27
27
|
__lwc_hmr_hot.register('${hmrModuleContext.modulePath}', '${hmrModuleContext.moduleHash}', ${JSON.stringify(options)});
|
|
28
28
|
__lwc_hmr_hot.accept('${hmrModuleContext.modulePath}', (mod) => {
|
|
29
29
|
const { __lwc_hmr_context: __new__lwc_hmr_context, default: __new_template } = mod;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lwc/dev-server-plugin-lex",
|
|
3
3
|
"description": "A rollup plugin to add Hot Module Replacement transformation to LWC components used in LEX.",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "8.0.0",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"lwc dev server",
|
|
7
7
|
"lwc hmr plugin"
|
|
@@ -18,10 +18,10 @@
|
|
|
18
18
|
"clean": "rimraf dist/ && rimraf node_modules/"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@lwc/errors": "6.7.0",
|
|
22
21
|
"magic-string": "~0.30.10"
|
|
23
22
|
},
|
|
24
|
-
"
|
|
25
|
-
"@lwc/compiler": "6
|
|
23
|
+
"peerDependencies": {
|
|
24
|
+
"@lwc/compiler": ">=6",
|
|
25
|
+
"@lwc/errors": ">=6"
|
|
26
26
|
}
|
|
27
|
-
}
|
|
27
|
+
}
|