lwr 0.13.0-alpha.8 → 0.13.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.
- package/README.md +1 -1
- package/build/cjs/cli/commands/audit.cjs +44 -27
- package/build/cjs/cli/commands/mrt-dev.cjs +1 -1
- package/build/cjs/cli/commands/preview.cjs +3 -3
- package/build/cjs/cli/utils.cjs +1 -1
- package/build/es/cli/commands/audit.js +67 -42
- package/build/es/cli/commands/mrt-dev.js +1 -1
- package/build/es/cli/commands/preview.js +4 -3
- package/build/es/cli/utils.js +1 -2
- package/package.json +13 -12
package/README.md
CHANGED
|
@@ -22,7 +22,7 @@ LWR describes any configurable aspects of the application in a well-defined, por
|
|
|
22
22
|
## Installation
|
|
23
23
|
|
|
24
24
|
> **Compatibility Note:**
|
|
25
|
-
> LWR requires [Node.js](https://nodejs.org/en/) version >=
|
|
25
|
+
> LWR requires [Node.js](https://nodejs.org/en/) version >=18.0.0.
|
|
26
26
|
|
|
27
27
|
With NPM:
|
|
28
28
|
|
|
@@ -28,6 +28,7 @@ __export(exports, {
|
|
|
28
28
|
});
|
|
29
29
|
var import_compiler = __toModule(require("@lwc/compiler"));
|
|
30
30
|
var import_module_resolver = __toModule(require("@lwc/module-resolver"));
|
|
31
|
+
var import_es_module_lexer = __toModule(require("es-module-lexer"));
|
|
31
32
|
var import_config = __toModule(require("@lwrjs/config"));
|
|
32
33
|
var import_shared_utils = __toModule(require("@lwrjs/shared-utils"));
|
|
33
34
|
var import_commander = __toModule(require("commander"));
|
|
@@ -40,7 +41,7 @@ var CAPABILITY_SSR_ONLY = "lightning__ServerRenderable";
|
|
|
40
41
|
var CAPABILITY_SSR_HYDRATION = "lightning__ServerRenderableWithHydration";
|
|
41
42
|
var CAPABILITY_UNKNOWN = "Unknown";
|
|
42
43
|
var CAPABILITY_PRIVATE = "Private";
|
|
43
|
-
var PLATFORM_NS = ["lwr", "webruntime"
|
|
44
|
+
var PLATFORM_NS = ["lwr", "webruntime"];
|
|
44
45
|
var LWC_REGEX = /^[\w-]+\/[\w-]+$/;
|
|
45
46
|
var LWC_TRANSFORM_CONFIG = {
|
|
46
47
|
experimentalDynamicComponent: {strictSpecifier: false},
|
|
@@ -81,11 +82,14 @@ async function analyzeComponentCapabilities(specifier, rootDir, modules, depth)
|
|
|
81
82
|
if (CACHE.has(specifier))
|
|
82
83
|
return CACHE.get(specifier);
|
|
83
84
|
const cmpDir = await getComponentDir(specifier, rootDir, modules);
|
|
84
|
-
|
|
85
|
+
if (!cmpDir)
|
|
86
|
+
return void 0;
|
|
87
|
+
const info = {
|
|
85
88
|
specifier,
|
|
86
89
|
ssrCapability: await parseSsrCapability(specifier, cmpDir),
|
|
87
|
-
children:
|
|
88
|
-
}
|
|
90
|
+
children: []
|
|
91
|
+
};
|
|
92
|
+
info.children = await analyzeChildren(info, cmpDir, rootDir, modules, depth);
|
|
89
93
|
info && CACHE.set(specifier, info);
|
|
90
94
|
return info;
|
|
91
95
|
}
|
|
@@ -105,8 +109,12 @@ async function getComponentDir(specifier, rootDir, modules) {
|
|
|
105
109
|
async function parseSsrCapability(specifier, cmpDir) {
|
|
106
110
|
const xml = readFile(import_path.default.join(cmpDir, `${(0, import_shared_utils.explodeSpecifier)(specifier).name}.js-meta.xml`));
|
|
107
111
|
if (!xml) {
|
|
108
|
-
|
|
109
|
-
|
|
112
|
+
const {namespace = ""} = (0, import_shared_utils.explodeSpecifier)(specifier);
|
|
113
|
+
if (!PLATFORM_NS.includes(namespace)) {
|
|
114
|
+
console.log(import_chalk.default.bgYellow("WARN"), import_chalk.default.bgGray(specifier), "does not have a js-meta.xml file");
|
|
115
|
+
return void 0;
|
|
116
|
+
}
|
|
117
|
+
return CAPABILITY_PRIVATE;
|
|
110
118
|
}
|
|
111
119
|
const metadata = await (0, import_xml2js.parseStringPromise)(xml);
|
|
112
120
|
const capabilities = metadata.LightningComponentBundle?.capabilities;
|
|
@@ -118,25 +126,27 @@ async function parseSsrCapability(specifier, cmpDir) {
|
|
|
118
126
|
}
|
|
119
127
|
return void 0;
|
|
120
128
|
}
|
|
121
|
-
async function analyzeChildren(
|
|
129
|
+
async function analyzeChildren(info, cmpDir, rootDir, modules, maxDepth = 1, curDepth = 0) {
|
|
130
|
+
const {isLWC, imports} = await parseJsDeps(info.specifier, cmpDir);
|
|
131
|
+
info.isLWC = isLWC;
|
|
122
132
|
if (curDepth === maxDepth)
|
|
123
133
|
return [];
|
|
124
|
-
const htmlDeps = await parseHtmlDeps(specifier, cmpDir);
|
|
125
|
-
const jsDeps = await parseJsDeps(specifier, cmpDir);
|
|
126
|
-
const deps = [...htmlDeps, ...jsDeps];
|
|
134
|
+
const htmlDeps = await parseHtmlDeps(info.specifier, cmpDir);
|
|
127
135
|
const children = [];
|
|
128
|
-
for (const d of
|
|
136
|
+
for (const d of [...htmlDeps, ...imports]) {
|
|
129
137
|
if (CACHE.has(d)) {
|
|
130
138
|
children.push(CACHE.get(d));
|
|
131
139
|
continue;
|
|
132
140
|
}
|
|
133
141
|
const dir = await getComponentDir(d, rootDir, modules);
|
|
134
|
-
const
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
142
|
+
const child = {specifier: d, children: []};
|
|
143
|
+
if (dir) {
|
|
144
|
+
child.ssrCapability = await parseSsrCapability(d, dir);
|
|
145
|
+
child.children = await analyzeChildren(child, dir, rootDir, modules, maxDepth, curDepth + 1);
|
|
146
|
+
} else {
|
|
147
|
+
const {namespace = ""} = (0, import_shared_utils.explodeSpecifier)(d);
|
|
148
|
+
child.ssrCapability = PLATFORM_NS.includes(namespace) ? CAPABILITY_PRIVATE : CAPABILITY_UNKNOWN;
|
|
149
|
+
}
|
|
140
150
|
CACHE.set(d, child);
|
|
141
151
|
children.push(child);
|
|
142
152
|
}
|
|
@@ -149,18 +159,22 @@ async function parseHtmlDeps(specifier, cmpDir) {
|
|
|
149
159
|
return [];
|
|
150
160
|
const {namespace, name} = (0, import_shared_utils.explodeSpecifier)(specifier);
|
|
151
161
|
const {code} = (0, import_compiler.transformSync)(htmlCode, filename, {...LWC_TRANSFORM_CONFIG, namespace, name});
|
|
152
|
-
|
|
153
|
-
return imports.map((i) => i.moduleSpecifier).filter((d) => LWC_REGEX.test(d));
|
|
162
|
+
return (await getModuleMetadata(code)).imports;
|
|
154
163
|
}
|
|
155
164
|
async function parseJsDeps(specifier, cmpDir) {
|
|
156
165
|
let jsCode = readFile(import_path.default.join(cmpDir, `${(0, import_shared_utils.explodeSpecifier)(specifier).name}.js`));
|
|
157
166
|
if (!jsCode) {
|
|
158
167
|
jsCode = readFile(import_path.default.join(cmpDir, `${(0, import_shared_utils.explodeSpecifier)(specifier).name}.ts`));
|
|
159
168
|
}
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
169
|
+
return await getModuleMetadata(jsCode);
|
|
170
|
+
}
|
|
171
|
+
async function getModuleMetadata(code) {
|
|
172
|
+
if (!code)
|
|
173
|
+
return {imports: []};
|
|
174
|
+
const [imps, exports2] = await (0, import_es_module_lexer.parse)(code);
|
|
175
|
+
const isLWC = exports2.some((e) => e.n === "default" && e.ln);
|
|
176
|
+
const imports = imps.map((i) => i.n || code.substring(i.s, i.e)).filter((d) => LWC_REGEX.test(d));
|
|
177
|
+
return {isLWC, imports};
|
|
164
178
|
}
|
|
165
179
|
function getLwcConfig(rootDir, lwrFile) {
|
|
166
180
|
const absLwrConfigPath = import_path.default.isAbsolute(lwrFile) ? lwrFile : import_path.default.join(rootDir, lwrFile);
|
|
@@ -231,12 +245,14 @@ function print(info, verbose = false) {
|
|
|
231
245
|
}
|
|
232
246
|
function groupCapabilitiesByType(all, info) {
|
|
233
247
|
for (const c of info.children) {
|
|
234
|
-
if (
|
|
248
|
+
if (c.ssrCapability === CAPABILITY_UNKNOWN) {
|
|
249
|
+
all.unknown.add(c.specifier);
|
|
250
|
+
} else if (!c.isLWC) {
|
|
251
|
+
continue;
|
|
252
|
+
} else if (!c.ssrCapability) {
|
|
235
253
|
all.csr.add(c.specifier);
|
|
236
254
|
} else if (c.ssrCapability === CAPABILITY_SSR_HYDRATION) {
|
|
237
255
|
all.hydrate.add(c.specifier);
|
|
238
|
-
} else if (c.ssrCapability === CAPABILITY_UNKNOWN) {
|
|
239
|
-
all.unknown.add(c.specifier);
|
|
240
256
|
}
|
|
241
257
|
groupCapabilitiesByType(all, c);
|
|
242
258
|
}
|
|
@@ -250,7 +266,8 @@ function buildTree(info, rootCap, isRoot = false) {
|
|
|
250
266
|
const cap = i.ssrCapability;
|
|
251
267
|
if (cap === CAPABILITY_PRIVATE)
|
|
252
268
|
continue;
|
|
253
|
-
const
|
|
269
|
+
const pass = !rootCap || rootCap === CAPABILITY_SSR_ONLY && cap === CAPABILITY_SSR_ONLY || rootCap === CAPABILITY_SSR_HYDRATION && cap;
|
|
270
|
+
const status = isRoot ? "" : cap === CAPABILITY_UNKNOWN ? import_chalk.default.bgYellow("WARN") : pass ? import_chalk.default.bgGreen("PASS") : !i.isLWC ? import_chalk.default.bgYellow("WARN (non-component module)") : import_chalk.default.bgRed("FAIL");
|
|
254
271
|
tree[`${status} ${import_chalk.default.bgGray(i.specifier)} ${cap || CSR_ONLY}`] = buildTree(i.children, rootCap);
|
|
255
272
|
}
|
|
256
273
|
return tree;
|
|
@@ -32,6 +32,6 @@ var import_api = __toModule(require("@lwrjs/api"));
|
|
|
32
32
|
function createExperimentalMrtDevCommand() {
|
|
33
33
|
return new import_commander.Command("experimental-mrt-dev").description("[experimental] local development with HMR for an MRT bundle").addOption((0, import_utils.getPortOption)()).addOption((0, import_utils.getSandboxOption)()).addOption((0, import_utils.getSsrTimeoutOption)()).option("-o, --open", `[boolean] open browser on startup`, false).action(async (options, cmd) => {
|
|
34
34
|
const {port, open, logLevel, sandbox, timeout} = cmd.optsWithGlobals();
|
|
35
|
-
await (0, import_api.expDev)({sandbox, logLevel, timeout, port, open});
|
|
35
|
+
await (0, import_api.expDev)({sandbox, logLevel, timeout, port, open, mrtBundleRoot: "app"});
|
|
36
36
|
});
|
|
37
37
|
}
|
|
@@ -30,8 +30,8 @@ var import_commander = __toModule(require("commander"));
|
|
|
30
30
|
var import_utils = __toModule(require("../utils.cjs"));
|
|
31
31
|
var import_api = __toModule(require("@lwrjs/api"));
|
|
32
32
|
function createPreviewCommand() {
|
|
33
|
-
return new import_commander.Command("preview").aliases(["start"]).description("Preview your built server on the specified target environment").addOption((0, import_utils.getPortOption)()).addOption((0, import_utils.getModeOption)()).addOption((0, import_utils.getTargetOption)()).option("-b, --buildDir <string>", "[string] The prebuilt directory for your site").option("-o, --open", `[boolean] open browser on startup`, false).action(async (_options, cmd) => {
|
|
34
|
-
const {rootDir, config, port, target, mode, buildDir, open, logLevel} = cmd.optsWithGlobals();
|
|
35
|
-
await (0, import_api.expPreview)({rootDir, config, port, target, mode, buildDir, open, logLevel});
|
|
33
|
+
return new import_commander.Command("preview").aliases(["start"]).description("Preview your built server on the specified target environment").addOption((0, import_utils.getPortOption)()).addOption((0, import_utils.getModeOption)()).addOption((0, import_utils.getTargetOption)()).addOption((0, import_utils.getSsrTimeoutOption)()).option("-b, --buildDir <string>", "[string] The prebuilt directory for your site").option("-o, --open", `[boolean] open browser on startup`, false).action(async (_options, cmd) => {
|
|
34
|
+
const {rootDir, config, port, target, mode, buildDir, open, logLevel, timeout} = cmd.optsWithGlobals();
|
|
35
|
+
await (0, import_api.expPreview)({rootDir, config, port, target, mode, buildDir, open, logLevel, timeout});
|
|
36
36
|
});
|
|
37
37
|
}
|
package/build/cjs/cli/utils.cjs
CHANGED
|
@@ -36,7 +36,7 @@ function getTargetOption() {
|
|
|
36
36
|
return new import_commander.Option("-t, --target <target>", "[string] configured target for deployment").choices(["default", "mrt", "netlify"]).default("default");
|
|
37
37
|
}
|
|
38
38
|
function getSsrTimeoutOption() {
|
|
39
|
-
return new import_commander.Option("--timeout [number]", `
|
|
39
|
+
return new import_commander.Option("--timeout [number]", `Set an ssr timeout in ms. If not specified, SSR requests will never timeout.`).env("SSR_TIMEOUT").argParser(parseNumArg);
|
|
40
40
|
}
|
|
41
41
|
function getPortOption() {
|
|
42
42
|
return new import_commander.Option("-p, --port <number>", `[number] set port`).env("PORT").argParser(parseNumArg);
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { transformSync } from '@lwc/compiler';
|
|
2
2
|
import { resolveModule } from '@lwc/module-resolver';
|
|
3
|
+
import { parse as parseModule } from 'es-module-lexer';
|
|
3
4
|
import { loadConfig } from '@lwrjs/config';
|
|
4
|
-
import { explodeSpecifier
|
|
5
|
+
import { explodeSpecifier } from '@lwrjs/shared-utils';
|
|
5
6
|
import { Command } from 'commander';
|
|
6
7
|
import chalk from 'chalk';
|
|
7
8
|
import path from 'path';
|
|
@@ -11,8 +12,8 @@ import { parseStringPromise } from 'xml2js';
|
|
|
11
12
|
const CAPABILITY_SSR_ONLY = 'lightning__ServerRenderable'; // SSR-only
|
|
12
13
|
const CAPABILITY_SSR_HYDRATION = 'lightning__ServerRenderableWithHydration'; // SSR with hydration
|
|
13
14
|
const CAPABILITY_UNKNOWN = 'Unknown'; // unresolvable modules
|
|
14
|
-
const CAPABILITY_PRIVATE = 'Private'; // unexposed platform modules (eg: "lwr/routerUtils"
|
|
15
|
-
const PLATFORM_NS = ['lwr', 'webruntime'
|
|
15
|
+
const CAPABILITY_PRIVATE = 'Private'; // unexposed platform modules (eg: "lwr/routerUtils")
|
|
16
|
+
const PLATFORM_NS = ['lwr', 'webruntime'];
|
|
16
17
|
const LWC_REGEX = /^[\w-]+\/[\w-]+$/; // LWC component specifier format
|
|
17
18
|
const LWC_TRANSFORM_CONFIG = {
|
|
18
19
|
// pass to the LWC compiler
|
|
@@ -73,13 +74,14 @@ async function analyzeComponentCapabilities(specifier, rootDir, modules, depth)
|
|
|
73
74
|
if (CACHE.has(specifier))
|
|
74
75
|
return CACHE.get(specifier);
|
|
75
76
|
const cmpDir = await getComponentDir(specifier, rootDir, modules);
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
77
|
+
if (!cmpDir)
|
|
78
|
+
return undefined;
|
|
79
|
+
const info = {
|
|
80
|
+
specifier: specifier,
|
|
81
|
+
ssrCapability: await parseSsrCapability(specifier, cmpDir),
|
|
82
|
+
children: [],
|
|
83
|
+
};
|
|
84
|
+
info.children = await analyzeChildren(info, cmpDir, rootDir, modules, depth);
|
|
83
85
|
info && CACHE.set(specifier, info);
|
|
84
86
|
return info;
|
|
85
87
|
}
|
|
@@ -117,8 +119,13 @@ async function parseSsrCapability(specifier, cmpDir) {
|
|
|
117
119
|
const xml = readFile(path.join(cmpDir, `${explodeSpecifier(specifier).name}.js-meta.xml`));
|
|
118
120
|
if (!xml) {
|
|
119
121
|
// some components may not have a js-meta file
|
|
120
|
-
|
|
121
|
-
|
|
122
|
+
const { namespace = '' } = explodeSpecifier(specifier);
|
|
123
|
+
if (!PLATFORM_NS.includes(namespace)) {
|
|
124
|
+
// do not warn for private modules
|
|
125
|
+
console.log(chalk.bgYellow('WARN'), chalk.bgGray(specifier), 'does not have a js-meta.xml file');
|
|
126
|
+
return undefined;
|
|
127
|
+
}
|
|
128
|
+
return CAPABILITY_PRIVATE;
|
|
122
129
|
}
|
|
123
130
|
const metadata = await parseStringPromise(xml);
|
|
124
131
|
const capabilities = metadata.LightningComponentBundle?.capabilities;
|
|
@@ -145,29 +152,29 @@ async function parseSsrCapability(specifier, cmpDir) {
|
|
|
145
152
|
* @param curDepth The depth currently being analyzed
|
|
146
153
|
* @returns An array of component specifiers and SSR capabilities
|
|
147
154
|
*/
|
|
148
|
-
async function analyzeChildren(
|
|
155
|
+
async function analyzeChildren(info, cmpDir, rootDir, modules, maxDepth = 1, curDepth = 0) {
|
|
156
|
+
const { isLWC, imports } = await parseJsDeps(info.specifier, cmpDir);
|
|
157
|
+
info.isLWC = isLWC; // always get the LWC boolean for the parent
|
|
149
158
|
if (curDepth === maxDepth)
|
|
150
159
|
return [];
|
|
151
|
-
const htmlDeps = await parseHtmlDeps(specifier, cmpDir);
|
|
152
|
-
const jsDeps = await parseJsDeps(specifier, cmpDir);
|
|
153
|
-
const deps = [...htmlDeps, ...jsDeps];
|
|
160
|
+
const htmlDeps = await parseHtmlDeps(info.specifier, cmpDir);
|
|
154
161
|
const children = [];
|
|
155
|
-
for (const d of
|
|
162
|
+
for (const d of [...htmlDeps, ...imports]) {
|
|
156
163
|
if (CACHE.has(d)) {
|
|
157
164
|
children.push(CACHE.get(d));
|
|
158
165
|
continue;
|
|
159
166
|
}
|
|
160
167
|
const dir = await getComponentDir(d, rootDir, modules);
|
|
161
|
-
const {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
168
|
+
const child = { specifier: d, children: [] };
|
|
169
|
+
if (dir) {
|
|
170
|
+
// child exists on the file system
|
|
171
|
+
child.ssrCapability = await parseSsrCapability(d, dir);
|
|
172
|
+
child.children = await analyzeChildren(child, dir, rootDir, modules, maxDepth, curDepth + 1);
|
|
173
|
+
}
|
|
174
|
+
else {
|
|
175
|
+
const { namespace = '' } = explodeSpecifier(d);
|
|
176
|
+
child.ssrCapability = PLATFORM_NS.includes(namespace) ? CAPABILITY_PRIVATE : CAPABILITY_UNKNOWN;
|
|
177
|
+
}
|
|
171
178
|
CACHE.set(d, child);
|
|
172
179
|
children.push(child);
|
|
173
180
|
}
|
|
@@ -186,14 +193,13 @@ async function parseHtmlDeps(specifier, cmpDir) {
|
|
|
186
193
|
return []; // some LWC modules do not have HTML
|
|
187
194
|
const { namespace, name } = explodeSpecifier(specifier);
|
|
188
195
|
const { code } = transformSync(htmlCode, filename, { ...LWC_TRANSFORM_CONFIG, namespace, name });
|
|
189
|
-
|
|
190
|
-
return imports.map((i) => i.moduleSpecifier).filter((d) => LWC_REGEX.test(d));
|
|
196
|
+
return (await getModuleMetadata(code)).imports;
|
|
191
197
|
}
|
|
192
198
|
/**
|
|
193
199
|
* Parse the LWC component dependencies from a component's JS
|
|
194
200
|
* @param specifier Specifier for the given component
|
|
195
201
|
* @param cmpDir Path to the component directory
|
|
196
|
-
* @returns An array of component specifiers
|
|
202
|
+
* @returns An array of component specifiers and a boolean indicating if this is an LWC component
|
|
197
203
|
*/
|
|
198
204
|
async function parseJsDeps(specifier, cmpDir) {
|
|
199
205
|
let jsCode = readFile(path.join(cmpDir, `${explodeSpecifier(specifier).name}.js`));
|
|
@@ -201,10 +207,23 @@ async function parseJsDeps(specifier, cmpDir) {
|
|
|
201
207
|
// try looking for a ts file if a js file not found
|
|
202
208
|
jsCode = readFile(path.join(cmpDir, `${explodeSpecifier(specifier).name}.ts`));
|
|
203
209
|
}
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
210
|
+
return await getModuleMetadata(jsCode);
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Parse a module to get its LWC module imports, and determine if it is an LWC component
|
|
214
|
+
* @param code Code string for an ES module
|
|
215
|
+
* @returns An array of component specifiers and a boolean indicating if this is an LWC component
|
|
216
|
+
*/
|
|
217
|
+
async function getModuleMetadata(code) {
|
|
218
|
+
if (!code)
|
|
219
|
+
return { imports: [] };
|
|
220
|
+
const [imps, exports] = await parseModule(code); // use await, so we do not need to call init()
|
|
221
|
+
// assume it's an LWC component if it has a named default export
|
|
222
|
+
// ideally, we'd check if it extends from LightningElement (either directly or chained)
|
|
223
|
+
const isLWC = exports.some((e) => e.n === 'default' && e.ln);
|
|
224
|
+
// filter out imports which are not LWC specifiers via a regex
|
|
225
|
+
const imports = imps.map((i) => i.n || code.substring(i.s, i.e)).filter((d) => LWC_REGEX.test(d));
|
|
226
|
+
return { isLWC, imports };
|
|
208
227
|
}
|
|
209
228
|
/** FILE SYSTEM HELPERS **/
|
|
210
229
|
/**
|
|
@@ -318,15 +337,18 @@ function print(info, verbose = false) {
|
|
|
318
337
|
*/
|
|
319
338
|
function groupCapabilitiesByType(all, info) {
|
|
320
339
|
for (const c of info.children) {
|
|
321
|
-
if (
|
|
340
|
+
if (c.ssrCapability === CAPABILITY_UNKNOWN) {
|
|
341
|
+
all.unknown.add(c.specifier);
|
|
342
|
+
}
|
|
343
|
+
else if (!c.isLWC) {
|
|
344
|
+
continue; // incompatible LWC util modules are just warnings
|
|
345
|
+
}
|
|
346
|
+
else if (!c.ssrCapability) {
|
|
322
347
|
all.csr.add(c.specifier);
|
|
323
348
|
}
|
|
324
349
|
else if (c.ssrCapability === CAPABILITY_SSR_HYDRATION) {
|
|
325
350
|
all.hydrate.add(c.specifier);
|
|
326
351
|
}
|
|
327
|
-
else if (c.ssrCapability === CAPABILITY_UNKNOWN) {
|
|
328
|
-
all.unknown.add(c.specifier);
|
|
329
|
-
}
|
|
330
352
|
groupCapabilitiesByType(all, c);
|
|
331
353
|
}
|
|
332
354
|
return all;
|
|
@@ -346,15 +368,18 @@ function buildTree(info, rootCap, isRoot = false) {
|
|
|
346
368
|
const cap = i.ssrCapability;
|
|
347
369
|
if (cap === CAPABILITY_PRIVATE)
|
|
348
370
|
continue; // exclude private platform deps
|
|
371
|
+
const pass = !rootCap ||
|
|
372
|
+
(rootCap === CAPABILITY_SSR_ONLY && cap === CAPABILITY_SSR_ONLY) ||
|
|
373
|
+
(rootCap === CAPABILITY_SSR_HYDRATION && cap);
|
|
349
374
|
const status = isRoot
|
|
350
375
|
? ''
|
|
351
376
|
: cap === CAPABILITY_UNKNOWN
|
|
352
377
|
? chalk.bgYellow('WARN')
|
|
353
|
-
:
|
|
354
|
-
(rootCap === CAPABILITY_SSR_ONLY && cap === CAPABILITY_SSR_ONLY) ||
|
|
355
|
-
(rootCap === CAPABILITY_SSR_HYDRATION && cap)
|
|
378
|
+
: pass
|
|
356
379
|
? chalk.bgGreen('PASS')
|
|
357
|
-
:
|
|
380
|
+
: !i.isLWC
|
|
381
|
+
? chalk.bgYellow('WARN (non-component module)')
|
|
382
|
+
: chalk.bgRed('FAIL');
|
|
358
383
|
tree[`${status} ${chalk.bgGray(i.specifier)} ${cap || CSR_ONLY}`] = buildTree(i.children, rootCap);
|
|
359
384
|
}
|
|
360
385
|
return tree;
|
|
@@ -10,7 +10,7 @@ export function createExperimentalMrtDevCommand() {
|
|
|
10
10
|
.option('-o, --open', `[boolean] open browser on startup`, false)
|
|
11
11
|
.action(async (options, cmd) => {
|
|
12
12
|
const { port, open, logLevel, sandbox, timeout } = cmd.optsWithGlobals();
|
|
13
|
-
await expDev({ sandbox, logLevel, timeout, port, open });
|
|
13
|
+
await expDev({ sandbox, logLevel, timeout, port, open, mrtBundleRoot: 'app' });
|
|
14
14
|
});
|
|
15
15
|
}
|
|
16
16
|
//# sourceMappingURL=mrt-dev.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
|
-
import { getModeOption, getPortOption, getTargetOption } from '../utils.js';
|
|
2
|
+
import { getModeOption, getPortOption, getSsrTimeoutOption, getTargetOption } from '../utils.js';
|
|
3
3
|
import { expPreview } from '@lwrjs/api';
|
|
4
4
|
export function createPreviewCommand() {
|
|
5
5
|
return new Command('preview')
|
|
@@ -8,11 +8,12 @@ export function createPreviewCommand() {
|
|
|
8
8
|
.addOption(getPortOption())
|
|
9
9
|
.addOption(getModeOption())
|
|
10
10
|
.addOption(getTargetOption())
|
|
11
|
+
.addOption(getSsrTimeoutOption())
|
|
11
12
|
.option('-b, --buildDir <string>', '[string] The prebuilt directory for your site')
|
|
12
13
|
.option('-o, --open', `[boolean] open browser on startup`, false)
|
|
13
14
|
.action(async (_options, cmd) => {
|
|
14
|
-
const { rootDir, config, port, target, mode, buildDir, open, logLevel } = cmd.optsWithGlobals();
|
|
15
|
-
await expPreview({ rootDir, config, port, target, mode, buildDir, open, logLevel });
|
|
15
|
+
const { rootDir, config, port, target, mode, buildDir, open, logLevel, timeout } = cmd.optsWithGlobals();
|
|
16
|
+
await expPreview({ rootDir, config, port, target, mode, buildDir, open, logLevel, timeout });
|
|
16
17
|
});
|
|
17
18
|
}
|
|
18
19
|
//# sourceMappingURL=preview.js.map
|
package/build/es/cli/utils.js
CHANGED
|
@@ -5,9 +5,8 @@ export function getTargetOption() {
|
|
|
5
5
|
.default('default');
|
|
6
6
|
}
|
|
7
7
|
export function getSsrTimeoutOption() {
|
|
8
|
-
return new Option('--timeout [number]', `
|
|
8
|
+
return new Option('--timeout [number]', `Set an ssr timeout in ms. If not specified, SSR requests will never timeout.`)
|
|
9
9
|
.env('SSR_TIMEOUT')
|
|
10
|
-
.default('30000')
|
|
11
10
|
.argParser(parseNumArg);
|
|
12
11
|
}
|
|
13
12
|
export function getPortOption() {
|
package/package.json
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
},
|
|
19
19
|
"type": "module",
|
|
20
20
|
"types": "build/es/index.d.ts",
|
|
21
|
-
"version": "0.13.0
|
|
21
|
+
"version": "0.13.0",
|
|
22
22
|
"module": "build/es/index.js",
|
|
23
23
|
"main": "build/cjs/index.cjs",
|
|
24
24
|
"files": [
|
|
@@ -41,23 +41,24 @@
|
|
|
41
41
|
}
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@lwrjs/api": "0.13.0
|
|
45
|
-
"@lwrjs/config": "0.13.0
|
|
46
|
-
"@lwrjs/core": "0.13.0
|
|
47
|
-
"@lwrjs/dev-proxy-server": "0.13.0
|
|
48
|
-
"@lwrjs/diagnostics": "0.13.0
|
|
49
|
-
"@lwrjs/shared-utils": "0.13.0
|
|
50
|
-
"@lwrjs/static": "0.13.0
|
|
51
|
-
"@lwrjs/tools": "0.13.0
|
|
44
|
+
"@lwrjs/api": "0.13.0",
|
|
45
|
+
"@lwrjs/config": "0.13.0",
|
|
46
|
+
"@lwrjs/core": "0.13.0",
|
|
47
|
+
"@lwrjs/dev-proxy-server": "0.13.0",
|
|
48
|
+
"@lwrjs/diagnostics": "0.13.0",
|
|
49
|
+
"@lwrjs/shared-utils": "0.13.0",
|
|
50
|
+
"@lwrjs/static": "0.13.0",
|
|
51
|
+
"@lwrjs/tools": "0.13.0",
|
|
52
52
|
"chalk": "^5.3.0",
|
|
53
53
|
"commander": "^10.0.0",
|
|
54
|
+
"es-module-lexer": "^1.5.4",
|
|
54
55
|
"fs-extra": "^11.2.0",
|
|
55
56
|
"object-treeify": "^4.0.1",
|
|
56
57
|
"xml2js": "^0.6.2"
|
|
57
58
|
},
|
|
58
59
|
"devDependencies": {
|
|
59
|
-
"@commander-js/extra-typings": "^12.0
|
|
60
|
-
"@lwrjs/types": "0.13.0
|
|
60
|
+
"@commander-js/extra-typings": "^12.1.0",
|
|
61
|
+
"@lwrjs/types": "0.13.0",
|
|
61
62
|
"@types/mock-fs": "^4.13.4",
|
|
62
63
|
"@types/xml2js": "^0.4.14",
|
|
63
64
|
"jest": "^26.6.3",
|
|
@@ -70,5 +71,5 @@
|
|
|
70
71
|
"engines": {
|
|
71
72
|
"node": ">=18.0.0"
|
|
72
73
|
},
|
|
73
|
-
"gitHead": "
|
|
74
|
+
"gitHead": "21dc6b8ffd2e633f36b46daf9e1563992c5143b9"
|
|
74
75
|
}
|