@lwc/ssr-compiler 9.0.4-alpha.0 → 9.0.4-alpha.2
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/dist/compile-js/types.d.ts +1 -1
- package/dist/{index.cjs → index.cjs.js} +12 -11
- package/dist/index.js +10 -9
- package/dist/shared.d.ts +3 -1
- package/package.json +7 -12
|
@@ -40,7 +40,7 @@ export interface ComponentMetaState {
|
|
|
40
40
|
/** indicates whether the LightningElement has any wired props */
|
|
41
41
|
wireAdapters: WireAdapter[];
|
|
42
42
|
/** dynamic imports configuration */
|
|
43
|
-
|
|
43
|
+
experimentalDynamicComponent: ComponentTransformOptions['experimentalDynamicComponent'];
|
|
44
44
|
/** imports to add to the top of the program after parsing */
|
|
45
45
|
importManager: ImportManager;
|
|
46
46
|
/** identifiers starting with __lwc that we added */
|
|
@@ -16,7 +16,7 @@ var node_path = require('node:path');
|
|
|
16
16
|
var templateCompiler = require('@lwc/template-compiler');
|
|
17
17
|
var builders = require('estree-toolkit/dist/builders');
|
|
18
18
|
var types = require('@babel/types');
|
|
19
|
-
var
|
|
19
|
+
var util = require('util');
|
|
20
20
|
|
|
21
21
|
/*
|
|
22
22
|
* Copyright (c) 2024, salesforce.com, inc.
|
|
@@ -837,11 +837,12 @@ function addGenerateMarkupFunction(program, state, tagName, filename) {
|
|
|
837
837
|
// At the time of generation, the invoker does not have reference to its tag name to pass as an argument.
|
|
838
838
|
const defaultTagName = estreeToolkit.builders.literal(tagName);
|
|
839
839
|
const classIdentifier = estreeToolkit.builders.identifier(state.lwcClassName);
|
|
840
|
+
let exposeTemplateBlock = null;
|
|
840
841
|
const defaultTmplPath = `./${node_path.parse(filename).name}.html`;
|
|
841
842
|
const tmplVar = estreeToolkit.builders.identifier('__lwcTmpl');
|
|
842
843
|
program.body.unshift(bImportDeclaration({ default: tmplVar.name }, defaultTmplPath));
|
|
843
844
|
program.body.unshift(bImportDeclaration({ SYMBOL__DEFAULT_TEMPLATE: '__SYMBOL__DEFAULT_TEMPLATE' }));
|
|
844
|
-
|
|
845
|
+
exposeTemplateBlock = bExposeTemplate(tmplVar, classIdentifier);
|
|
845
846
|
// If no wire adapters are detected on the component, we don't bother injecting the wire-related code.
|
|
846
847
|
let connectWireAdapterCode = [];
|
|
847
848
|
if (state.wireAdapters.length) {
|
|
@@ -995,17 +996,17 @@ const visitors = {
|
|
|
995
996
|
removeDecoratorImport(path);
|
|
996
997
|
},
|
|
997
998
|
ImportExpression(path, state) {
|
|
998
|
-
const {
|
|
999
|
-
if (!
|
|
1000
|
-
// if no `
|
|
999
|
+
const { experimentalDynamicComponent, importManager } = state;
|
|
1000
|
+
if (!experimentalDynamicComponent) {
|
|
1001
|
+
// if no `experimentalDynamicComponent` config, then leave dynamic `import()`s as-is
|
|
1001
1002
|
return;
|
|
1002
1003
|
}
|
|
1003
|
-
if (
|
|
1004
|
+
if (experimentalDynamicComponent.strictSpecifier) {
|
|
1004
1005
|
if (!estreeToolkit.is.literal(path.node?.source) || typeof path.node.source.value !== 'string') {
|
|
1005
1006
|
throw generateError(path.node, errors.LWCClassErrors.INVALID_DYNAMIC_IMPORT_SOURCE_STRICT, estreeToolkit.is.literal(path.node?.source) ? String(path.node.source.value) : 'undefined');
|
|
1006
1007
|
}
|
|
1007
1008
|
}
|
|
1008
|
-
const loader =
|
|
1009
|
+
const loader = experimentalDynamicComponent.loader;
|
|
1009
1010
|
if (!loader) {
|
|
1010
1011
|
// if no `loader` defined, then leave dynamic `import()`s as-is
|
|
1011
1012
|
return;
|
|
@@ -1213,7 +1214,7 @@ function compileJS(src, filename, tagName, options, compilationMode) {
|
|
|
1213
1214
|
publicProperties: new Map(),
|
|
1214
1215
|
privateProperties: new Set(),
|
|
1215
1216
|
wireAdapters: [],
|
|
1216
|
-
|
|
1217
|
+
experimentalDynamicComponent: options.experimentalDynamicComponent,
|
|
1217
1218
|
importManager: new ImportManager(),
|
|
1218
1219
|
trustedLwcIdentifiers: new WeakSet(),
|
|
1219
1220
|
};
|
|
@@ -2500,7 +2501,7 @@ const Root = function Root(node, cxt) {
|
|
|
2500
2501
|
return irChildrenToEs(node.children, cxt);
|
|
2501
2502
|
};
|
|
2502
2503
|
const defaultTransformer = (node) => {
|
|
2503
|
-
throw new Error(`Unimplemented IR node: ${
|
|
2504
|
+
throw new Error(`Unimplemented IR node: ${util.inspect(node)}`);
|
|
2504
2505
|
};
|
|
2505
2506
|
const transformers = {
|
|
2506
2507
|
Comment,
|
|
@@ -2715,5 +2716,5 @@ function compileTemplateForSSR(src, filename, options, mode = shared.DEFAULT_SSR
|
|
|
2715
2716
|
|
|
2716
2717
|
exports.compileComponentForSSR = compileComponentForSSR;
|
|
2717
2718
|
exports.compileTemplateForSSR = compileTemplateForSSR;
|
|
2718
|
-
/** version: 9.0.4-alpha.
|
|
2719
|
-
//# sourceMappingURL=index.cjs.map
|
|
2719
|
+
/** version: 9.0.4-alpha.2 */
|
|
2720
|
+
//# sourceMappingURL=index.cjs.js.map
|
package/dist/index.js
CHANGED
|
@@ -12,7 +12,7 @@ import { parse as parse$1 } from 'node:path';
|
|
|
12
12
|
import { generateScopeTokens, bindExpression, toPropertyName, kebabcaseToCamelcase, parse as parse$2 } from '@lwc/template-compiler';
|
|
13
13
|
import { builders as builders$1 } from 'estree-toolkit/dist/builders';
|
|
14
14
|
import { isValidES3Identifier } from '@babel/types';
|
|
15
|
-
import { inspect } from '
|
|
15
|
+
import { inspect } from 'util';
|
|
16
16
|
|
|
17
17
|
/*
|
|
18
18
|
* Copyright (c) 2024, salesforce.com, inc.
|
|
@@ -833,11 +833,12 @@ function addGenerateMarkupFunction(program, state, tagName, filename) {
|
|
|
833
833
|
// At the time of generation, the invoker does not have reference to its tag name to pass as an argument.
|
|
834
834
|
const defaultTagName = builders.literal(tagName);
|
|
835
835
|
const classIdentifier = builders.identifier(state.lwcClassName);
|
|
836
|
+
let exposeTemplateBlock = null;
|
|
836
837
|
const defaultTmplPath = `./${parse$1(filename).name}.html`;
|
|
837
838
|
const tmplVar = builders.identifier('__lwcTmpl');
|
|
838
839
|
program.body.unshift(bImportDeclaration({ default: tmplVar.name }, defaultTmplPath));
|
|
839
840
|
program.body.unshift(bImportDeclaration({ SYMBOL__DEFAULT_TEMPLATE: '__SYMBOL__DEFAULT_TEMPLATE' }));
|
|
840
|
-
|
|
841
|
+
exposeTemplateBlock = bExposeTemplate(tmplVar, classIdentifier);
|
|
841
842
|
// If no wire adapters are detected on the component, we don't bother injecting the wire-related code.
|
|
842
843
|
let connectWireAdapterCode = [];
|
|
843
844
|
if (state.wireAdapters.length) {
|
|
@@ -991,17 +992,17 @@ const visitors = {
|
|
|
991
992
|
removeDecoratorImport(path);
|
|
992
993
|
},
|
|
993
994
|
ImportExpression(path, state) {
|
|
994
|
-
const {
|
|
995
|
-
if (!
|
|
996
|
-
// if no `
|
|
995
|
+
const { experimentalDynamicComponent, importManager } = state;
|
|
996
|
+
if (!experimentalDynamicComponent) {
|
|
997
|
+
// if no `experimentalDynamicComponent` config, then leave dynamic `import()`s as-is
|
|
997
998
|
return;
|
|
998
999
|
}
|
|
999
|
-
if (
|
|
1000
|
+
if (experimentalDynamicComponent.strictSpecifier) {
|
|
1000
1001
|
if (!is.literal(path.node?.source) || typeof path.node.source.value !== 'string') {
|
|
1001
1002
|
throw generateError(path.node, LWCClassErrors.INVALID_DYNAMIC_IMPORT_SOURCE_STRICT, is.literal(path.node?.source) ? String(path.node.source.value) : 'undefined');
|
|
1002
1003
|
}
|
|
1003
1004
|
}
|
|
1004
|
-
const loader =
|
|
1005
|
+
const loader = experimentalDynamicComponent.loader;
|
|
1005
1006
|
if (!loader) {
|
|
1006
1007
|
// if no `loader` defined, then leave dynamic `import()`s as-is
|
|
1007
1008
|
return;
|
|
@@ -1209,7 +1210,7 @@ function compileJS(src, filename, tagName, options, compilationMode) {
|
|
|
1209
1210
|
publicProperties: new Map(),
|
|
1210
1211
|
privateProperties: new Set(),
|
|
1211
1212
|
wireAdapters: [],
|
|
1212
|
-
|
|
1213
|
+
experimentalDynamicComponent: options.experimentalDynamicComponent,
|
|
1213
1214
|
importManager: new ImportManager(),
|
|
1214
1215
|
trustedLwcIdentifiers: new WeakSet(),
|
|
1215
1216
|
};
|
|
@@ -2710,5 +2711,5 @@ function compileTemplateForSSR(src, filename, options, mode = DEFAULT_SSR_MODE)
|
|
|
2710
2711
|
}
|
|
2711
2712
|
|
|
2712
2713
|
export { compileComponentForSSR, compileTemplateForSSR };
|
|
2713
|
-
/** version: 9.0.4-alpha.
|
|
2714
|
+
/** version: 9.0.4-alpha.2 */
|
|
2714
2715
|
//# sourceMappingURL=index.js.map
|
package/dist/shared.d.ts
CHANGED
|
@@ -2,5 +2,7 @@ import type { LwcBabelPluginOptions } from '@lwc/babel-plugin-component';
|
|
|
2
2
|
import type { Config as TemplateCompilerConfig } from '@lwc/template-compiler';
|
|
3
3
|
export type Expression = string;
|
|
4
4
|
export type TemplateTransformOptions = Pick<TemplateCompilerConfig, 'name' | 'namespace'>;
|
|
5
|
-
export type ComponentTransformOptions = Partial<Pick<LwcBabelPluginOptions, 'name' | 'namespace'
|
|
5
|
+
export type ComponentTransformOptions = Partial<Pick<LwcBabelPluginOptions, 'name' | 'namespace'>> & {
|
|
6
|
+
experimentalDynamicComponent?: LwcBabelPluginOptions['dynamicImports'];
|
|
7
|
+
};
|
|
6
8
|
//# sourceMappingURL=shared.d.ts.map
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"You can safely modify dependencies, devDependencies, keywords, etc., but other props will be overwritten."
|
|
5
5
|
],
|
|
6
6
|
"name": "@lwc/ssr-compiler",
|
|
7
|
-
"version": "9.0.4-alpha.
|
|
7
|
+
"version": "9.0.4-alpha.2",
|
|
8
8
|
"description": "Compile component for use during server-side rendering",
|
|
9
9
|
"keywords": [
|
|
10
10
|
"compiler",
|
|
@@ -21,22 +21,17 @@
|
|
|
21
21
|
"url": "https://github.com/salesforce/lwc/issues"
|
|
22
22
|
},
|
|
23
23
|
"license": "MIT",
|
|
24
|
-
"type": "module",
|
|
25
24
|
"publishConfig": {
|
|
26
25
|
"access": "public"
|
|
27
26
|
},
|
|
28
|
-
"engines": {
|
|
29
|
-
"node": ">=16.6.0"
|
|
30
|
-
},
|
|
31
27
|
"volta": {
|
|
32
28
|
"extends": "../../../package.json"
|
|
33
29
|
},
|
|
34
|
-
"main": "dist/index.js",
|
|
30
|
+
"main": "dist/index.cjs.js",
|
|
35
31
|
"module": "dist/index.js",
|
|
36
32
|
"types": "dist/index.d.ts",
|
|
37
33
|
"files": [
|
|
38
34
|
"dist/**/*.js",
|
|
39
|
-
"dist/**/*.cjs",
|
|
40
35
|
"dist/**/*.d.ts"
|
|
41
36
|
],
|
|
42
37
|
"scripts": {
|
|
@@ -54,17 +49,17 @@
|
|
|
54
49
|
},
|
|
55
50
|
"dependencies": {
|
|
56
51
|
"@babel/types": "7.29.0",
|
|
57
|
-
"@lwc/errors": "9.0.4-alpha.
|
|
58
|
-
"@lwc/shared": "9.0.4-alpha.
|
|
59
|
-
"@lwc/template-compiler": "9.0.4-alpha.
|
|
52
|
+
"@lwc/errors": "9.0.4-alpha.2",
|
|
53
|
+
"@lwc/shared": "9.0.4-alpha.2",
|
|
54
|
+
"@lwc/template-compiler": "9.0.4-alpha.2",
|
|
60
55
|
"acorn": "8.16.0",
|
|
61
56
|
"astring": "^1.9.0",
|
|
62
57
|
"estree-toolkit": "^1.7.13",
|
|
63
58
|
"immer": "^11.1.4",
|
|
64
|
-
"meriyah": "^
|
|
59
|
+
"meriyah": "^5.0.0"
|
|
65
60
|
},
|
|
66
61
|
"devDependencies": {
|
|
67
|
-
"@lwc/babel-plugin-component": "9.0.4-alpha.
|
|
62
|
+
"@lwc/babel-plugin-component": "9.0.4-alpha.2",
|
|
68
63
|
"@types/estree": "^1.0.8"
|
|
69
64
|
}
|
|
70
65
|
}
|