@lwrjs/config 0.15.0-alpha.9 → 0.15.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/build/cjs/defaults.cjs +15 -2
- package/build/cjs/global-config.cjs +2 -0
- package/build/cjs/hooks.cjs +10 -1
- package/build/cjs/index.cjs +2 -0
- package/build/cjs/runtime-config.cjs +2 -1
- package/build/cjs/validation/app-config-context.cjs +65 -6
- package/build/cjs/validation/app-config.cjs +8 -0
- package/build/es/defaults.d.ts +14 -0
- package/build/es/defaults.js +24 -1
- package/build/es/global-config.js +5 -0
- package/build/es/hooks.d.ts +2 -1
- package/build/es/hooks.js +15 -2
- package/build/es/index.d.ts +1 -1
- package/build/es/index.js +1 -1
- package/build/es/runtime-config.js +1 -0
- package/build/es/validation/app-config-context.d.ts +12 -6
- package/build/es/validation/app-config-context.js +66 -5
- package/build/es/validation/app-config.js +10 -0
- package/package.json +8 -8
package/build/cjs/defaults.cjs
CHANGED
|
@@ -37,11 +37,15 @@ __export(exports, {
|
|
|
37
37
|
DEFAULT_ROOT_DIR: () => DEFAULT_ROOT_DIR,
|
|
38
38
|
DEFAULT_SERVICE_PACKAGE_NAME: () => DEFAULT_SERVICE_PACKAGE_NAME,
|
|
39
39
|
LWR_INFO_ROUTE: () => LWR_INFO_ROUTE,
|
|
40
|
+
MIN_LWC_VERSION: () => MIN_LWC_VERSION,
|
|
41
|
+
MIN_LWR_VERSION: () => MIN_LWR_VERSION,
|
|
40
42
|
getDefaultBundleConfig: () => getDefaultBundleConfig
|
|
41
43
|
});
|
|
42
44
|
var import_shared_utils = __toModule(require("@lwrjs/shared-utils"));
|
|
43
45
|
var import_runtime_config = __toModule(require("./runtime-config.cjs"));
|
|
44
46
|
var import_package = __toModule(require("@lwrjs/config/package"));
|
|
47
|
+
var MIN_LWR_VERSION = "0.12.0";
|
|
48
|
+
var MIN_LWC_VERSION = "6.1.0";
|
|
45
49
|
var PORT = process.env.PORT ? parseInt(process.env.PORT, 10) : 3e3;
|
|
46
50
|
var MODE = process.env.MODE || "prod";
|
|
47
51
|
var DEFAULT_BASE_PATH = "";
|
|
@@ -156,6 +160,7 @@ var DEFAULT_LWR_CONFIG = {
|
|
|
156
160
|
viewTransformers: DEFAULT_VIEW_TRANSFORM_PLUGINS,
|
|
157
161
|
environment: {},
|
|
158
162
|
lwc: {modules: []},
|
|
163
|
+
caseSensitiveRoutes: false,
|
|
159
164
|
routes: [
|
|
160
165
|
LWR_INFO_ROUTE
|
|
161
166
|
],
|
|
@@ -165,7 +170,10 @@ var DEFAULT_LWR_CONFIG = {
|
|
|
165
170
|
serverType: DEFAULT_SERVER_TYPE,
|
|
166
171
|
locker: import_shared_utils.DEFAULT_LWR_LOCKER_CONFIG,
|
|
167
172
|
uriTransformers: DEFAULT_URI_TRANSFORM_PLUGINS,
|
|
168
|
-
i18n: import_runtime_config.DEFAULT_I18N_CONFIG
|
|
173
|
+
i18n: import_runtime_config.DEFAULT_I18N_CONFIG,
|
|
174
|
+
coreProxy: null,
|
|
175
|
+
unsafeEnableViewLinkCaching: false,
|
|
176
|
+
_isSsrCompilerEnabled: false
|
|
169
177
|
};
|
|
170
178
|
var DEFAULT_LWR_BOOTSTRAP_CONFIG = {
|
|
171
179
|
autoBoot: true,
|
|
@@ -175,9 +183,14 @@ var DEFAULT_LWR_BOOTSTRAP_CONFIG = {
|
|
|
175
183
|
configAsSrc: false,
|
|
176
184
|
ssr: false,
|
|
177
185
|
preloadData: false,
|
|
186
|
+
proxyForSSR: false,
|
|
187
|
+
includeCookiesForSSR: false,
|
|
178
188
|
mixedMode: false,
|
|
179
189
|
module: void 0,
|
|
180
190
|
preloadModules: [],
|
|
181
191
|
lwrVersion: import_package.lwrVersion,
|
|
182
|
-
lwcVersion: import_package.lwcVersion
|
|
192
|
+
lwcVersion: import_package.lwcVersion,
|
|
193
|
+
preloadResources: {
|
|
194
|
+
patterns: []
|
|
195
|
+
}
|
|
183
196
|
};
|
|
@@ -170,6 +170,8 @@ function resolveGlobalConfig(configArg, options) {
|
|
|
170
170
|
const span = (0, import_instrumentation.getTracer)().startSpan({name: import_instrumentation.ConfigSpan.ResolveConfig});
|
|
171
171
|
const mergedConfig = mergeConfig(configArg);
|
|
172
172
|
let normalizedConfig = normalizeConfig(mergedConfig);
|
|
173
|
+
if (normalizedConfig._isSsrCompilerEnabled)
|
|
174
|
+
process.env.SSR_COMPILER_ENABLED = "true";
|
|
173
175
|
if (options?.useStaticProviders) {
|
|
174
176
|
normalizedConfig = applyStaticProviderConfig(normalizedConfig);
|
|
175
177
|
}
|
package/build/cjs/hooks.cjs
CHANGED
|
@@ -30,6 +30,7 @@ __export(exports, {
|
|
|
30
30
|
executeStartHooks: () => executeStartHooks
|
|
31
31
|
});
|
|
32
32
|
var import_routes = __toModule(require("./utils/routes.cjs"));
|
|
33
|
+
var import_assets = __toModule(require("./utils/assets.cjs"));
|
|
33
34
|
var import_app_config = __toModule(require("./validation/app-config.cjs"));
|
|
34
35
|
var import_instrumentation = __toModule(require("@lwrjs/instrumentation"));
|
|
35
36
|
var import_defaults = __toModule(require("./defaults.cjs"));
|
|
@@ -89,14 +90,20 @@ function executeStartHooks(hooks, globalConfig, runtimeEnvironment, skipValidate
|
|
|
89
90
|
continue;
|
|
90
91
|
}
|
|
91
92
|
const onStartConfig = {
|
|
93
|
+
_isSsrCompilerEnabled: globalConfig._isSsrCompilerEnabled,
|
|
92
94
|
basePath: globalConfig.basePath,
|
|
95
|
+
coreProxy: globalConfig.coreProxy,
|
|
93
96
|
i18n: globalConfig.i18n,
|
|
94
97
|
routes: globalConfig.routes,
|
|
98
|
+
assets: globalConfig.assets,
|
|
95
99
|
errorRoutes: globalConfig.errorRoutes
|
|
96
100
|
};
|
|
97
101
|
hook.onStart(onStartConfig);
|
|
98
102
|
runtimeEnvironment.basePath = globalConfig.basePath = onStartConfig.basePath || "";
|
|
99
|
-
globalConfig.i18n = onStartConfig.i18n;
|
|
103
|
+
runtimeEnvironment.i18n = globalConfig.i18n = onStartConfig.i18n;
|
|
104
|
+
globalConfig.assets = (0, import_assets.normalizeAssetPaths)((0, import_assets.normalizeAssets)(onStartConfig.assets), globalConfig.rootDir);
|
|
105
|
+
globalConfig._isSsrCompilerEnabled = onStartConfig._isSsrCompilerEnabled;
|
|
106
|
+
globalConfig.coreProxy = onStartConfig.coreProxy;
|
|
100
107
|
globalConfig.routes = onStartConfig.routes || [];
|
|
101
108
|
globalConfig.errorRoutes = onStartConfig.errorRoutes || [];
|
|
102
109
|
}
|
|
@@ -117,6 +124,8 @@ function executeStartHooks(hooks, globalConfig, runtimeEnvironment, skipValidate
|
|
|
117
124
|
}
|
|
118
125
|
globalConfig.routes = (0, import_routes.normalizeRoutes)(filteredRoutes, globalConfig.routeHandlers);
|
|
119
126
|
globalConfig.errorRoutes = (0, import_routes.normalizeRoutes)(globalConfig.errorRoutes, globalConfig.routeHandlers);
|
|
127
|
+
if (globalConfig._isSsrCompilerEnabled)
|
|
128
|
+
process.env.SSR_COMPILER_ENABLED = "true";
|
|
120
129
|
if (!skipValidate) {
|
|
121
130
|
(0, import_app_config.validateLwrAppConfig)(globalConfig, "post");
|
|
122
131
|
}
|
package/build/cjs/index.cjs
CHANGED
|
@@ -28,6 +28,8 @@ __export(exports, {
|
|
|
28
28
|
DEFAULT_LWR_BOOTSTRAP_CONFIG: () => import_defaults.DEFAULT_LWR_BOOTSTRAP_CONFIG,
|
|
29
29
|
LWC_VERSION: () => import_package.lwcVersion,
|
|
30
30
|
LWR_VERSION: () => import_package.lwrVersion,
|
|
31
|
+
MIN_LWC_VERSION: () => import_defaults.MIN_LWC_VERSION,
|
|
32
|
+
MIN_LWR_VERSION: () => import_defaults.MIN_LWR_VERSION,
|
|
31
33
|
NODE_VERSION: () => import_package.nodeVersion,
|
|
32
34
|
PWA_KIT_RUNTIME_VERSION: () => import_package.pwaKitRuntimeVersion,
|
|
33
35
|
getLwrConfigFromFile: () => import_global_config.getLwrConfigFromFile,
|
|
@@ -28,6 +28,7 @@ __export(exports, {
|
|
|
28
28
|
ASSET_FILE_ATTRIBUTE_KEYS: () => ASSET_FILE_ATTRIBUTE_KEYS,
|
|
29
29
|
BASE_PATH_REGEX: () => BASE_PATH_REGEX,
|
|
30
30
|
BOOTSTRAP_ATTRIBUTE_KEYS: () => BOOTSTRAP_ATTRIBUTE_KEYS,
|
|
31
|
+
CORE_PROXY_ATTRIBUTE_KEYS: () => CORE_PROXY_ATTRIBUTE_KEYS,
|
|
31
32
|
ERROR_ROUTE_ATTRIBUTE_KEYS: () => ERROR_ROUTE_ATTRIBUTE_KEYS,
|
|
32
33
|
I18N_ATTRIBUTE_KEYS: () => I18N_ATTRIBUTE_KEYS,
|
|
33
34
|
LOCKER_ATTRIBUTE_KEYS: () => LOCKER_ATTRIBUTE_KEYS,
|
|
@@ -52,7 +53,9 @@ var ROOT_ATTRIBUTE_KEYS = createKeys("root", [
|
|
|
52
53
|
"bundleConfig",
|
|
53
54
|
"bundleProviders",
|
|
54
55
|
"cacheDir",
|
|
56
|
+
"caseSensitiveRoutes",
|
|
55
57
|
"contentDir",
|
|
58
|
+
"coreProxy",
|
|
56
59
|
"environment",
|
|
57
60
|
"errorRoutes",
|
|
58
61
|
"esmLoader",
|
|
@@ -62,6 +65,7 @@ var ROOT_ATTRIBUTE_KEYS = createKeys("root", [
|
|
|
62
65
|
"hooks",
|
|
63
66
|
"i18n",
|
|
64
67
|
"ignoreLwrConfigFile",
|
|
68
|
+
"_isSsrCompilerEnabled",
|
|
65
69
|
"lwrConfigFile",
|
|
66
70
|
"layoutsDir",
|
|
67
71
|
"locker",
|
|
@@ -79,12 +83,14 @@ var ROOT_ATTRIBUTE_KEYS = createKeys("root", [
|
|
|
79
83
|
"serverType",
|
|
80
84
|
"uriTransformers",
|
|
81
85
|
"viewProviders",
|
|
82
|
-
"viewTransformers"
|
|
86
|
+
"viewTransformers",
|
|
87
|
+
"unsafeEnableViewLinkCaching"
|
|
83
88
|
]);
|
|
84
89
|
var ASSET_DIR_ATTRIBUTE_KEYS = createKeys("assetDir", ["alias", "dir", "urlPath", "root"]);
|
|
85
90
|
var ASSET_FILE_ATTRIBUTE_KEYS = createKeys("assetFile", ["alias", "file", "urlPath"]);
|
|
86
91
|
var LOCKER_ATTRIBUTE_KEYS = createKeys("locker", ["enabled", "trustedComponents"]);
|
|
87
|
-
var I18N_ATTRIBUTE_KEYS = createKeys("i18n", ["defaultLocale", "locales", "uriPattern"]);
|
|
92
|
+
var I18N_ATTRIBUTE_KEYS = createKeys("i18n", ["defaultLocale", "locales", "uriPattern", "defaultRedirectParams"]);
|
|
93
|
+
var CORE_PROXY_ATTRIBUTE_KEYS = createKeys("coreProxy", ["origin", "host", "servername"]);
|
|
88
94
|
var STATIC_SITE_GENERATOR_ATTRIBUTE_KEYS = createKeys("staticSiteGenerator", [
|
|
89
95
|
"outputDir",
|
|
90
96
|
"skipBaseDocumentGeneration",
|
|
@@ -125,11 +131,14 @@ var BOOTSTRAP_ATTRIBUTE_KEYS = createKeys("bootstrap", [
|
|
|
125
131
|
"configAsSrc",
|
|
126
132
|
"ssr",
|
|
127
133
|
"preloadData",
|
|
134
|
+
"proxyForSSR",
|
|
135
|
+
"includeCookiesForSSR",
|
|
128
136
|
"mixedMode",
|
|
129
137
|
"module",
|
|
130
138
|
"preloadModules",
|
|
131
139
|
"lwrVersion",
|
|
132
|
-
"lwcVersion"
|
|
140
|
+
"lwcVersion",
|
|
141
|
+
"preloadResources"
|
|
133
142
|
]);
|
|
134
143
|
function isNotEmptyString(node) {
|
|
135
144
|
return node.type === "string" && node.value.length > 0;
|
|
@@ -144,7 +153,7 @@ var ValidationContext = class {
|
|
|
144
153
|
return (0, import_helpers.calculatePositionFromSource)(this.sourceText, node);
|
|
145
154
|
}
|
|
146
155
|
assertIsObject(node, property) {
|
|
147
|
-
if (node
|
|
156
|
+
if (node?.type !== "object" && node) {
|
|
148
157
|
this.diagnostics.push({
|
|
149
158
|
description: import_diagnostics.descriptions.CONFIG_PARSER.INCORRECT_NODE_TYPE(property, "object", node.type),
|
|
150
159
|
location: this.getLocationFromNode(node)
|
|
@@ -175,6 +184,36 @@ var ValidationContext = class {
|
|
|
175
184
|
});
|
|
176
185
|
}
|
|
177
186
|
}
|
|
187
|
+
assertIsFilePattern(node, property) {
|
|
188
|
+
if (node) {
|
|
189
|
+
const children = node.children || [];
|
|
190
|
+
for (const [index, child] of children.entries()) {
|
|
191
|
+
let matcher = (0, import_jsonc_parser.findNodeAtLocation)(child, ["match"])?.children?.map((val) => val.value) || (0, import_jsonc_parser.findNodeAtLocation)(child, ["match"])?.value;
|
|
192
|
+
if (!Array.isArray(matcher)) {
|
|
193
|
+
matcher = [matcher];
|
|
194
|
+
}
|
|
195
|
+
let misMatch = null;
|
|
196
|
+
for (let i = 0; i < matcher.length; i++) {
|
|
197
|
+
try {
|
|
198
|
+
if (matcher[i] === "")
|
|
199
|
+
throw new Error("Empty string is not a valid regex");
|
|
200
|
+
new RegExp(matcher[i]);
|
|
201
|
+
} catch (e) {
|
|
202
|
+
misMatch = matcher[i];
|
|
203
|
+
this.diagnostics.push({
|
|
204
|
+
description: import_diagnostics.descriptions.CONFIG_PARSER.INVALID_FILE_PATTERN(`${property}[${index}].match`, misMatch),
|
|
205
|
+
location: this.getLocationFromNode(node)
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
if (misMatch)
|
|
209
|
+
break;
|
|
210
|
+
}
|
|
211
|
+
if (misMatch !== null) {
|
|
212
|
+
break;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
}
|
|
178
217
|
assertIsPath(node, property) {
|
|
179
218
|
if (node && (node.type !== "string" || node.value[0] !== "/")) {
|
|
180
219
|
this.diagnostics.push({
|
|
@@ -183,6 +222,14 @@ var ValidationContext = class {
|
|
|
183
222
|
});
|
|
184
223
|
}
|
|
185
224
|
}
|
|
225
|
+
assertIsOrigin(node, property) {
|
|
226
|
+
if (node && (node.type !== "string" || !/^https?:\/\//i.test(node.value))) {
|
|
227
|
+
this.diagnostics.push({
|
|
228
|
+
description: import_diagnostics.descriptions.CONFIG_PARSER.INVALID_ORIGIN(property, node.value),
|
|
229
|
+
location: this.getLocationFromNode(node)
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
}
|
|
186
233
|
assertIsPort(node, property) {
|
|
187
234
|
if (node && (node.type !== "number" || node.value < 0 || node.value > 65353)) {
|
|
188
235
|
this.diagnostics.push({
|
|
@@ -248,7 +295,7 @@ var ValidationContext = class {
|
|
|
248
295
|
});
|
|
249
296
|
}
|
|
250
297
|
}
|
|
251
|
-
assertIsBasePath(node, property) {
|
|
298
|
+
assertIsBasePath(node, property, allowSlash = false) {
|
|
252
299
|
if (!node) {
|
|
253
300
|
return;
|
|
254
301
|
}
|
|
@@ -257,7 +304,7 @@ var ValidationContext = class {
|
|
|
257
304
|
description: import_diagnostics.descriptions.CONFIG_PARSER.INCORRECT_NODE_TYPE(property, "string", node.type),
|
|
258
305
|
location: this.getLocationFromNode(node)
|
|
259
306
|
});
|
|
260
|
-
} else if (node.value === "") {
|
|
307
|
+
} else if (node.value === "" || allowSlash && node.value === "/") {
|
|
261
308
|
return;
|
|
262
309
|
} else if (node.value.match(BASE_PATH_REGEX) === null) {
|
|
263
310
|
this.diagnostics.push({
|
|
@@ -515,4 +562,16 @@ var ValidationContext = class {
|
|
|
515
562
|
});
|
|
516
563
|
}
|
|
517
564
|
}
|
|
565
|
+
assertIsCoreProxy(node, validationContext) {
|
|
566
|
+
if (node && node.type !== "null") {
|
|
567
|
+
validationContext.assertIsObject(node, "coreProxy");
|
|
568
|
+
validationContext.assertValidKeys(node, "coreProxy", CORE_PROXY_ATTRIBUTE_KEYS);
|
|
569
|
+
validationContext.assertRequiredKeys(node, "coreProxy", ["origin"]);
|
|
570
|
+
validationContext.assertNotEmptyString((0, import_jsonc_parser.findNodeAtLocation)(node, ["origin"]), "coreProxy.origin");
|
|
571
|
+
const host = (0, import_jsonc_parser.findNodeAtLocation)(node, ["host"]);
|
|
572
|
+
host && validationContext.assertNotEmptyString(host, "coreProxy.host");
|
|
573
|
+
const servername = (0, import_jsonc_parser.findNodeAtLocation)(node, ["servername"]);
|
|
574
|
+
servername && validationContext.assertNotEmptyString(servername, "coreProxy.servername");
|
|
575
|
+
}
|
|
576
|
+
}
|
|
518
577
|
};
|
|
@@ -48,6 +48,8 @@ function validateBootstrap(node, validationContext, propPrefix) {
|
|
|
48
48
|
validationContext.assertIsBoolean((0, import_jsonc_parser.findNodeAtLocation)(node, ["autoBoot"]), `${propPrefix}.autoBoot`);
|
|
49
49
|
validationContext.assertIsBoolean((0, import_jsonc_parser.findNodeAtLocation)(node, ["ssr"]), `${propPrefix}.ssr`);
|
|
50
50
|
validationContext.assertIsBoolean((0, import_jsonc_parser.findNodeAtLocation)(node, ["preloadData"]), `${propPrefix}.preloadData`);
|
|
51
|
+
validationContext.assertIsBoolean((0, import_jsonc_parser.findNodeAtLocation)(node, ["proxyForSSR"]), `${propPrefix}.proxyForSSR`);
|
|
52
|
+
validationContext.assertIsBoolean((0, import_jsonc_parser.findNodeAtLocation)(node, ["includeCookiesForSSR"]), `${propPrefix}.includeCookiesForSSR`);
|
|
51
53
|
validationContext.assertIsBoolean((0, import_jsonc_parser.findNodeAtLocation)(node, ["mixedMode"]), `${propPrefix}.mixedMode`);
|
|
52
54
|
validationContext.assertIsBoolean((0, import_jsonc_parser.findNodeAtLocation)(node, ["configAsSrc"]), `${propPrefix}.configAsSrc`);
|
|
53
55
|
validationContext.assertIsSpecifier((0, import_jsonc_parser.findNodeAtLocation)(node, ["module"]), `${propPrefix}.module`);
|
|
@@ -55,6 +57,7 @@ function validateBootstrap(node, validationContext, propPrefix) {
|
|
|
55
57
|
validationContext.assertNotEmptyString((0, import_jsonc_parser.findNodeAtLocation)(node, ["lwrVersion"]), `${propPrefix}.lwrVersion`);
|
|
56
58
|
validationContext.assertNotEmptyString((0, import_jsonc_parser.findNodeAtLocation)(node, ["lwcVersion"]), `${propPrefix}.lwcVersion`);
|
|
57
59
|
validationContext.assertSsrPreloadData(node, propPrefix);
|
|
60
|
+
validationContext.assertIsFilePattern((0, import_jsonc_parser.findNodeAtLocation)(node, ["preloadResources", "patterns"]), `${propPrefix}.preloadResources.patterns`);
|
|
58
61
|
const workers = (0, import_jsonc_parser.findNodeAtLocation)(node, ["workers"]);
|
|
59
62
|
if (workers && workers.children) {
|
|
60
63
|
workers.children.forEach((w, index) => {
|
|
@@ -114,6 +117,8 @@ function validateI18NConfig(node, validationContext, preMerge) {
|
|
|
114
117
|
validationContext.assertNotEmptyString(defaultLocale, "i18n.defaultLocale");
|
|
115
118
|
const localeIds = locales?.children?.map((n) => (0, import_jsonc_parser.findNodeAtLocation)(n, ["id"])?.value) || [];
|
|
116
119
|
validationContext.assertDefaultInLocales(node, defaultLocale?.value, localeIds);
|
|
120
|
+
const defaultRedirectParams = (0, import_jsonc_parser.findNodeAtLocation)(node, ["defaultRedirectParams"]);
|
|
121
|
+
validationContext.assertIsObject(defaultRedirectParams, "i18n.defaultRedirectParams");
|
|
117
122
|
}
|
|
118
123
|
}
|
|
119
124
|
function validateStaticSiteGeneratorConfig(node, validationContext) {
|
|
@@ -239,6 +244,7 @@ function validateRoot(node, validationContext, preMerge) {
|
|
|
239
244
|
validationContext.assertUniqueIds([...routes?.children || [], ...errorRoutes?.children || []], "routes");
|
|
240
245
|
const lockerNode = (0, import_jsonc_parser.findNodeAtLocation)(node, ["locker"]);
|
|
241
246
|
const bundleConfigNode = (0, import_jsonc_parser.findNodeAtLocation)(node, ["bundleConfig"]);
|
|
247
|
+
validationContext.assertIsBoolean((0, import_jsonc_parser.findNodeAtLocation)(node, ["caseSensitiveRoutes"]), "caseSensitiveRoutes");
|
|
242
248
|
validateRoutes(routes, validationContext, preMerge);
|
|
243
249
|
validateErrorRoutes(errorRoutes, validationContext);
|
|
244
250
|
validateRouteHandlers((0, import_jsonc_parser.findNodeAtLocation)(node, ["routeHandlers"]), validationContext);
|
|
@@ -268,6 +274,8 @@ function validateRoot(node, validationContext, preMerge) {
|
|
|
268
274
|
validationContext.assertNotEmptyArray((0, import_jsonc_parser.findNodeAtLocation)(node, ["lwc", "modules"]), "lwc.modules");
|
|
269
275
|
validationContext.assertIsEnvironment((0, import_jsonc_parser.findNodeAtLocation)(node, ["environment"]), "environment");
|
|
270
276
|
validationContext.assertIsBasePath((0, import_jsonc_parser.findNodeAtLocation)(node, ["basePath"]), "basePath");
|
|
277
|
+
validationContext.assertIsCoreProxy((0, import_jsonc_parser.findNodeAtLocation)(node, ["coreProxy"]), validationContext);
|
|
278
|
+
validationContext.assertIsBoolean((0, import_jsonc_parser.findNodeAtLocation)(node, ["_isSsrCompilerEnabled"]), "_isSsrCompilerEnabled");
|
|
271
279
|
}
|
|
272
280
|
function validateLwrAppConfig(config, phase) {
|
|
273
281
|
const span = (0, import_instrumentation.getTracer)().startSpan({name: import_instrumentation.ConfigSpan.ValidateConfig});
|
package/build/es/defaults.d.ts
CHANGED
|
@@ -1,4 +1,18 @@
|
|
|
1
1
|
import type { BundleConfig, LwrGlobalConfig, LwrRoute, NormalizedLwrAppBootstrapConfig, StaticSiteGenerator } from '@lwrjs/types';
|
|
2
|
+
/**
|
|
3
|
+
* MIN_LWR_VERSION
|
|
4
|
+
* Minimum LWR version required for the routes to function properly.
|
|
5
|
+
* Anytime we believe we are checking in a breaking change, the required version should be updated
|
|
6
|
+
* manually for all routes to continue functioning properly.
|
|
7
|
+
*/
|
|
8
|
+
export declare const MIN_LWR_VERSION = "0.12.0";
|
|
9
|
+
/**
|
|
10
|
+
* MIN_LWC_VERSION
|
|
11
|
+
* Minimum LWC version required for the routes to function properly.
|
|
12
|
+
* Anytime we believe we are checking in a breaking change, the required version should be updated
|
|
13
|
+
* manually for all routes to continue functioning properly.
|
|
14
|
+
*/
|
|
15
|
+
export declare const MIN_LWC_VERSION = "6.1.0";
|
|
2
16
|
export declare const DEFAULT_LWR_CONFIG_JSON = "$rootDir/lwr.config.json";
|
|
3
17
|
export declare const DEFAULT_GENERATOR_CONFIG: StaticSiteGenerator;
|
|
4
18
|
export declare const DEFAULT_ROOT_DIR: string;
|
package/build/es/defaults.js
CHANGED
|
@@ -1,6 +1,20 @@
|
|
|
1
1
|
import { DEFAULT_LWR_LOCKER_CONFIG, getFeatureFlags } from '@lwrjs/shared-utils';
|
|
2
2
|
import { DEFAULT_I18N_CONFIG, getServerModeConfig } from './runtime-config.js';
|
|
3
3
|
import { lwrVersion as LWR_VERSION, lwcVersion as LWC_VERSION } from '@lwrjs/config/package';
|
|
4
|
+
/**
|
|
5
|
+
* MIN_LWR_VERSION
|
|
6
|
+
* Minimum LWR version required for the routes to function properly.
|
|
7
|
+
* Anytime we believe we are checking in a breaking change, the required version should be updated
|
|
8
|
+
* manually for all routes to continue functioning properly.
|
|
9
|
+
*/
|
|
10
|
+
export const MIN_LWR_VERSION = '0.12.0';
|
|
11
|
+
/**
|
|
12
|
+
* MIN_LWC_VERSION
|
|
13
|
+
* Minimum LWC version required for the routes to function properly.
|
|
14
|
+
* Anytime we believe we are checking in a breaking change, the required version should be updated
|
|
15
|
+
* manually for all routes to continue functioning properly.
|
|
16
|
+
*/
|
|
17
|
+
export const MIN_LWC_VERSION = '6.1.0';
|
|
4
18
|
const PORT = process.env.PORT ? parseInt(process.env.PORT, 10) : 3000;
|
|
5
19
|
const MODE = process.env.MODE || 'prod';
|
|
6
20
|
const DEFAULT_BASE_PATH = '';
|
|
@@ -121,6 +135,7 @@ export const DEFAULT_LWR_CONFIG = {
|
|
|
121
135
|
viewTransformers: DEFAULT_VIEW_TRANSFORM_PLUGINS,
|
|
122
136
|
environment: {},
|
|
123
137
|
lwc: { modules: [] },
|
|
138
|
+
caseSensitiveRoutes: false,
|
|
124
139
|
routes: [
|
|
125
140
|
LWR_INFO_ROUTE,
|
|
126
141
|
],
|
|
@@ -131,6 +146,9 @@ export const DEFAULT_LWR_CONFIG = {
|
|
|
131
146
|
locker: DEFAULT_LWR_LOCKER_CONFIG,
|
|
132
147
|
uriTransformers: DEFAULT_URI_TRANSFORM_PLUGINS,
|
|
133
148
|
i18n: DEFAULT_I18N_CONFIG,
|
|
149
|
+
coreProxy: null,
|
|
150
|
+
unsafeEnableViewLinkCaching: false,
|
|
151
|
+
_isSsrCompilerEnabled: false,
|
|
134
152
|
};
|
|
135
153
|
export const DEFAULT_LWR_BOOTSTRAP_CONFIG = {
|
|
136
154
|
autoBoot: true,
|
|
@@ -140,10 +158,15 @@ export const DEFAULT_LWR_BOOTSTRAP_CONFIG = {
|
|
|
140
158
|
configAsSrc: false,
|
|
141
159
|
ssr: false,
|
|
142
160
|
preloadData: false,
|
|
161
|
+
proxyForSSR: false,
|
|
162
|
+
includeCookiesForSSR: false,
|
|
143
163
|
mixedMode: false,
|
|
144
164
|
module: undefined,
|
|
145
165
|
preloadModules: [],
|
|
146
166
|
lwrVersion: LWR_VERSION,
|
|
147
|
-
lwcVersion: LWC_VERSION
|
|
167
|
+
lwcVersion: LWC_VERSION,
|
|
168
|
+
preloadResources: {
|
|
169
|
+
patterns: []
|
|
170
|
+
},
|
|
148
171
|
};
|
|
149
172
|
//# sourceMappingURL=defaults.js.map
|
|
@@ -233,6 +233,11 @@ export function resolveGlobalConfig(configArg, options) {
|
|
|
233
233
|
const span = getTracer().startSpan({ name: ConfigSpan.ResolveConfig });
|
|
234
234
|
const mergedConfig = mergeConfig(configArg);
|
|
235
235
|
let normalizedConfig = normalizeConfig(mergedConfig);
|
|
236
|
+
// TEMP: Add a feature flag to hold the app config value
|
|
237
|
+
// This is a temporary flag attached to a Core gate. Using an env var avoids the
|
|
238
|
+
// proliferation of function arguments to pass this flag around to dozens of places
|
|
239
|
+
if (normalizedConfig._isSsrCompilerEnabled)
|
|
240
|
+
process.env.SSR_COMPILER_ENABLED = 'true';
|
|
236
241
|
// Add static providers if applicable
|
|
237
242
|
if (options?.useStaticProviders) {
|
|
238
243
|
normalizedConfig = applyStaticProviderConfig(normalizedConfig);
|
package/build/es/hooks.d.ts
CHANGED
|
@@ -9,7 +9,8 @@ export declare function executeConfigHooks(hooks: HooksPlugin[], globalConfig: N
|
|
|
9
9
|
* @privateRemarks
|
|
10
10
|
* Changes to configurations are made by reference.
|
|
11
11
|
*
|
|
12
|
-
* These hooks can
|
|
12
|
+
* These hooks can modify the following global config properties:
|
|
13
|
+
* routes, errorRoutes, assets, i18n, basePath, coreProxy, _isSsrCompilerEnabled
|
|
13
14
|
*
|
|
14
15
|
* @param hooks - hooks plugins
|
|
15
16
|
* @param globalConfig - global configuration
|
package/build/es/hooks.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { normalizeRoutes } from './utils/routes.js';
|
|
2
|
+
import { normalizeAssets, normalizeAssetPaths } from './utils/assets.js';
|
|
2
3
|
import { validateLwrAppConfig } from './validation/app-config.js';
|
|
3
4
|
import { getTracer, ConfigSpan } from '@lwrjs/instrumentation';
|
|
4
5
|
import { LWR_INFO_ROUTE } from './defaults.js';
|
|
@@ -74,7 +75,8 @@ export async function executeConfigHooks(hooks, globalConfig, runtimeEnvironment
|
|
|
74
75
|
* @privateRemarks
|
|
75
76
|
* Changes to configurations are made by reference.
|
|
76
77
|
*
|
|
77
|
-
* These hooks can
|
|
78
|
+
* These hooks can modify the following global config properties:
|
|
79
|
+
* routes, errorRoutes, assets, i18n, basePath, coreProxy, _isSsrCompilerEnabled
|
|
78
80
|
*
|
|
79
81
|
* @param hooks - hooks plugins
|
|
80
82
|
* @param globalConfig - global configuration
|
|
@@ -90,15 +92,21 @@ export function executeStartHooks(hooks, globalConfig, runtimeEnvironment, skipV
|
|
|
90
92
|
continue;
|
|
91
93
|
}
|
|
92
94
|
const onStartConfig = {
|
|
95
|
+
_isSsrCompilerEnabled: globalConfig._isSsrCompilerEnabled,
|
|
93
96
|
basePath: globalConfig.basePath,
|
|
97
|
+
coreProxy: globalConfig.coreProxy,
|
|
94
98
|
i18n: globalConfig.i18n,
|
|
95
99
|
routes: globalConfig.routes,
|
|
100
|
+
assets: globalConfig.assets,
|
|
96
101
|
errorRoutes: globalConfig.errorRoutes,
|
|
97
102
|
};
|
|
98
103
|
hook.onStart(onStartConfig);
|
|
99
104
|
// copy updated values back to the globalConfig
|
|
100
105
|
runtimeEnvironment.basePath = globalConfig.basePath = onStartConfig.basePath || '';
|
|
101
|
-
globalConfig.i18n = onStartConfig.i18n;
|
|
106
|
+
runtimeEnvironment.i18n = globalConfig.i18n = onStartConfig.i18n;
|
|
107
|
+
globalConfig.assets = normalizeAssetPaths(normalizeAssets(onStartConfig.assets), globalConfig.rootDir);
|
|
108
|
+
globalConfig._isSsrCompilerEnabled = onStartConfig._isSsrCompilerEnabled;
|
|
109
|
+
globalConfig.coreProxy = onStartConfig.coreProxy;
|
|
102
110
|
globalConfig.routes = (onStartConfig.routes || []);
|
|
103
111
|
globalConfig.errorRoutes = (onStartConfig.errorRoutes || []);
|
|
104
112
|
}
|
|
@@ -121,6 +129,11 @@ export function executeStartHooks(hooks, globalConfig, runtimeEnvironment, skipV
|
|
|
121
129
|
}
|
|
122
130
|
globalConfig.routes = normalizeRoutes(filteredRoutes, globalConfig.routeHandlers);
|
|
123
131
|
globalConfig.errorRoutes = normalizeRoutes(globalConfig.errorRoutes, globalConfig.routeHandlers);
|
|
132
|
+
// TEMP: Add a feature flag to hold the app config value
|
|
133
|
+
// This is a temporary flag attached to a Core gate. Using an env var avoids the
|
|
134
|
+
// proliferation of function arguments to pass this flag around to dozens of places
|
|
135
|
+
if (globalConfig._isSsrCompilerEnabled)
|
|
136
|
+
process.env.SSR_COMPILER_ENABLED = 'true';
|
|
124
137
|
if (!skipValidate) {
|
|
125
138
|
validateLwrAppConfig(globalConfig, 'post');
|
|
126
139
|
}
|
package/build/es/index.d.ts
CHANGED
|
@@ -2,6 +2,6 @@ export { lwrVersion as LWR_VERSION, lwcVersion as LWC_VERSION, nodeVersion as NO
|
|
|
2
2
|
export { loadConfig, resolveGlobalConfig as normalizeConfig, getLwrConfigFromFile } from './global-config.js';
|
|
3
3
|
export { getRuntimeEnvironment, DEFAULT_I18N_CONFIG } from './runtime-config.js';
|
|
4
4
|
export * from './hooks.js';
|
|
5
|
-
export { DEFAULT_LWR_BOOTSTRAP_CONFIG } from './defaults.js';
|
|
5
|
+
export { DEFAULT_LWR_BOOTSTRAP_CONFIG, MIN_LWR_VERSION, MIN_LWC_VERSION } from './defaults.js';
|
|
6
6
|
export { validateLwrAppConfig } from './validation/app-config.js';
|
|
7
7
|
//# sourceMappingURL=index.d.ts.map
|
package/build/es/index.js
CHANGED
|
@@ -2,6 +2,6 @@ export { lwrVersion as LWR_VERSION, lwcVersion as LWC_VERSION, nodeVersion as NO
|
|
|
2
2
|
export { loadConfig, resolveGlobalConfig as normalizeConfig, getLwrConfigFromFile } from './global-config.js';
|
|
3
3
|
export { getRuntimeEnvironment, DEFAULT_I18N_CONFIG } from './runtime-config.js';
|
|
4
4
|
export * from './hooks.js';
|
|
5
|
-
export { DEFAULT_LWR_BOOTSTRAP_CONFIG } from './defaults.js';
|
|
5
|
+
export { DEFAULT_LWR_BOOTSTRAP_CONFIG, MIN_LWR_VERSION, MIN_LWC_VERSION } from './defaults.js';
|
|
6
6
|
export { validateLwrAppConfig } from './validation/app-config.js';
|
|
7
7
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AssetDirConfig, AssetFileConfig, LwrErrorRoute, LwrRoute, NormalizedLwrGlobalConfig, NormalizedLwrAppBootstrapConfig, LwrLockerConfig, RouteHandlersConfig, BundleConfig, I18NConfig, Locale, StaticSiteGenerator } from '@lwrjs/types';
|
|
1
|
+
import type { AssetDirConfig, AssetFileConfig, DirectToCoreProxy, LwrErrorRoute, LwrRoute, NormalizedLwrGlobalConfig, NormalizedLwrAppBootstrapConfig, LwrLockerConfig, RouteHandlersConfig, BundleConfig, I18NConfig, Locale, StaticSiteGenerator } from '@lwrjs/types';
|
|
2
2
|
import { Node } from 'jsonc-parser';
|
|
3
3
|
import { Diagnostic } from '@lwrjs/diagnostics';
|
|
4
4
|
type RequiredAssetDirConfig = Required<AssetDirConfig>;
|
|
@@ -9,6 +9,7 @@ type RequiredLwrLockerConfig = Required<LwrLockerConfig>;
|
|
|
9
9
|
type RequiredI18NConfig = Required<I18NConfig>;
|
|
10
10
|
type RequiredLocalesConfig = Required<Locale>;
|
|
11
11
|
type RequiredSSGConfig = Required<StaticSiteGenerator>;
|
|
12
|
+
type RequiredDirectToCoreProxy = Required<DirectToCoreProxy>;
|
|
12
13
|
interface ConfigMap {
|
|
13
14
|
root: NormalizedLwrGlobalConfig;
|
|
14
15
|
assetDir: RequiredAssetDirConfig;
|
|
@@ -24,34 +25,38 @@ interface ConfigMap {
|
|
|
24
25
|
i18n: RequiredI18NConfig;
|
|
25
26
|
'i18n.locales': RequiredLocalesConfig;
|
|
26
27
|
staticSiteGenerator: RequiredSSGConfig;
|
|
28
|
+
coreProxy: RequiredDirectToCoreProxy;
|
|
27
29
|
}
|
|
28
|
-
export declare const ROOT_ATTRIBUTE_KEYS: ["amdLoader", "apiVersion", "assets", "assetProviders", "assetTransformers", "bundleConfig", "bundleProviders", "cacheDir", "contentDir", "environment", "errorRoutes", "esmLoader", "staticSiteGenerator", "globalData", "globalDataDir", "hooks", "i18n", "ignoreLwrConfigFile", "lwrConfigFile", "layoutsDir", "locker", "lwc", "lwrVersion", "moduleProviders", "port", "basePath", "resourceProviders", "rootDir", "routeHandlers", "routes", "serverMode", "minify", "serverType", "uriTransformers", "viewProviders", "viewTransformers"];
|
|
30
|
+
export declare const ROOT_ATTRIBUTE_KEYS: ["amdLoader", "apiVersion", "assets", "assetProviders", "assetTransformers", "bundleConfig", "bundleProviders", "cacheDir", "caseSensitiveRoutes", "contentDir", "coreProxy", "environment", "errorRoutes", "esmLoader", "staticSiteGenerator", "globalData", "globalDataDir", "hooks", "i18n", "ignoreLwrConfigFile", "_isSsrCompilerEnabled", "lwrConfigFile", "layoutsDir", "locker", "lwc", "lwrVersion", "moduleProviders", "port", "basePath", "resourceProviders", "rootDir", "routeHandlers", "routes", "serverMode", "minify", "serverType", "uriTransformers", "viewProviders", "viewTransformers", "unsafeEnableViewLinkCaching"];
|
|
29
31
|
export declare const ASSET_DIR_ATTRIBUTE_KEYS: ["alias", "dir", "urlPath", "root"];
|
|
30
32
|
export declare const ASSET_FILE_ATTRIBUTE_KEYS: ["alias", "file", "urlPath"];
|
|
31
33
|
export declare const LOCKER_ATTRIBUTE_KEYS: ["enabled", "trustedComponents"];
|
|
32
|
-
export declare const I18N_ATTRIBUTE_KEYS: ["defaultLocale", "locales", "uriPattern"];
|
|
34
|
+
export declare const I18N_ATTRIBUTE_KEYS: ["defaultLocale", "locales", "uriPattern", "defaultRedirectParams"];
|
|
35
|
+
export declare const CORE_PROXY_ATTRIBUTE_KEYS: ["origin", "host", "servername"];
|
|
33
36
|
export declare const STATIC_SITE_GENERATOR_ATTRIBUTE_KEYS: ["outputDir", "skipBaseDocumentGeneration", "skipCleanOutputDir", "_additionalModules", "_additionalRoutePaths"];
|
|
34
37
|
export declare const ROUTE_ATTRIBUTE_KEYS: ["bootstrap", "subRoutes", "contentTemplate", "id", "cache", "layoutTemplate", "method", "path", "rootComponent", "routeHandler", "properties"];
|
|
35
38
|
export declare const ERROR_ROUTE_ATTRIBUTE_KEYS: ["bootstrap", "subRoutes", "contentTemplate", "id", "layoutTemplate", "rootComponent", "routeHandler", "status", "properties", "cache"];
|
|
36
|
-
export declare const BOOTSTRAP_ATTRIBUTE_KEYS: ["autoBoot", "syntheticShadow", "workers", "services", "configAsSrc", "ssr", "preloadData", "mixedMode", "module", "preloadModules", "lwrVersion", "lwcVersion"];
|
|
39
|
+
export declare const BOOTSTRAP_ATTRIBUTE_KEYS: ["autoBoot", "syntheticShadow", "workers", "services", "configAsSrc", "ssr", "preloadData", "proxyForSSR", "includeCookiesForSSR", "mixedMode", "module", "preloadModules", "lwrVersion", "lwcVersion", "preloadResources"];
|
|
37
40
|
export declare const BASE_PATH_REGEX: RegExp;
|
|
38
41
|
export declare class ValidationContext {
|
|
39
42
|
diagnostics: Diagnostic[];
|
|
40
43
|
sourceText: string;
|
|
41
44
|
constructor(sourceText: string);
|
|
42
45
|
private getLocationFromNode;
|
|
43
|
-
assertIsObject
|
|
46
|
+
assertIsObject(node: Node | undefined, property: string): void;
|
|
44
47
|
assertIsBoolean(node: Node | undefined, property: string): void;
|
|
45
48
|
assertIsArray(node: Node | undefined, property: string): void;
|
|
46
49
|
assertIsSpecifier(node: Node | undefined, property: string): void;
|
|
50
|
+
assertIsFilePattern(node: Node | undefined, property: string): void;
|
|
47
51
|
assertIsPath(node: Node | undefined, property: string): void;
|
|
52
|
+
assertIsOrigin(node: Node | undefined, property: string): void;
|
|
48
53
|
assertIsPort(node: Node | undefined, property: string): void;
|
|
49
54
|
assertIsServerType(node: Node | undefined, property: string): void;
|
|
50
55
|
assertIsStaticSiteGenerator(node: Node | undefined, property: string): void;
|
|
51
56
|
assertIsMethod(node: Node | undefined, property: string): void;
|
|
52
57
|
assertIsStatus(node: Node | undefined, property: string): void;
|
|
53
58
|
assertIsEnvironment(node: Node | undefined, property: string): void;
|
|
54
|
-
assertIsBasePath(node: Node | undefined, property: string): void;
|
|
59
|
+
assertIsBasePath(node: Node | undefined, property: string, allowSlash?: boolean): void;
|
|
55
60
|
assertNotEmptyString(node: Node | undefined, property: string): void;
|
|
56
61
|
assertNotEmptyArray(node: Node | undefined, property: string): void;
|
|
57
62
|
assertHasOneOrMore(node: Node, property: string, childProps: string[]): void;
|
|
@@ -69,6 +74,7 @@ export declare class ValidationContext {
|
|
|
69
74
|
assertDefaultInLocales(node: Node, defaultLocale: string, localesIds: string[]): void;
|
|
70
75
|
assertFallbackIds(nodes: Node[]): void;
|
|
71
76
|
assertSsrPreloadData(node: Node, propPrefix: string): void;
|
|
77
|
+
assertIsCoreProxy(node: Node | undefined, validationContext: ValidationContext): void;
|
|
72
78
|
}
|
|
73
79
|
export {};
|
|
74
80
|
//# sourceMappingURL=app-config-context.d.ts.map
|
|
@@ -16,7 +16,9 @@ export const ROOT_ATTRIBUTE_KEYS = createKeys('root', [
|
|
|
16
16
|
'bundleConfig',
|
|
17
17
|
'bundleProviders',
|
|
18
18
|
'cacheDir',
|
|
19
|
+
'caseSensitiveRoutes',
|
|
19
20
|
'contentDir',
|
|
21
|
+
'coreProxy',
|
|
20
22
|
'environment',
|
|
21
23
|
'errorRoutes',
|
|
22
24
|
'esmLoader',
|
|
@@ -26,6 +28,7 @@ export const ROOT_ATTRIBUTE_KEYS = createKeys('root', [
|
|
|
26
28
|
'hooks',
|
|
27
29
|
'i18n',
|
|
28
30
|
'ignoreLwrConfigFile',
|
|
31
|
+
'_isSsrCompilerEnabled',
|
|
29
32
|
'lwrConfigFile',
|
|
30
33
|
'layoutsDir',
|
|
31
34
|
'locker',
|
|
@@ -44,11 +47,13 @@ export const ROOT_ATTRIBUTE_KEYS = createKeys('root', [
|
|
|
44
47
|
'uriTransformers',
|
|
45
48
|
'viewProviders',
|
|
46
49
|
'viewTransformers',
|
|
50
|
+
'unsafeEnableViewLinkCaching',
|
|
47
51
|
]);
|
|
48
52
|
export const ASSET_DIR_ATTRIBUTE_KEYS = createKeys('assetDir', ['alias', 'dir', 'urlPath', 'root']);
|
|
49
53
|
export const ASSET_FILE_ATTRIBUTE_KEYS = createKeys('assetFile', ['alias', 'file', 'urlPath']);
|
|
50
54
|
export const LOCKER_ATTRIBUTE_KEYS = createKeys('locker', ['enabled', 'trustedComponents']);
|
|
51
|
-
export const I18N_ATTRIBUTE_KEYS = createKeys('i18n', ['defaultLocale', 'locales', 'uriPattern']);
|
|
55
|
+
export const I18N_ATTRIBUTE_KEYS = createKeys('i18n', ['defaultLocale', 'locales', 'uriPattern', 'defaultRedirectParams']);
|
|
56
|
+
export const CORE_PROXY_ATTRIBUTE_KEYS = createKeys('coreProxy', ['origin', 'host', 'servername']);
|
|
52
57
|
export const STATIC_SITE_GENERATOR_ATTRIBUTE_KEYS = createKeys('staticSiteGenerator', [
|
|
53
58
|
'outputDir',
|
|
54
59
|
'skipBaseDocumentGeneration',
|
|
@@ -89,11 +94,14 @@ export const BOOTSTRAP_ATTRIBUTE_KEYS = createKeys('bootstrap', [
|
|
|
89
94
|
'configAsSrc',
|
|
90
95
|
'ssr',
|
|
91
96
|
'preloadData',
|
|
97
|
+
'proxyForSSR',
|
|
98
|
+
'includeCookiesForSSR',
|
|
92
99
|
'mixedMode',
|
|
93
100
|
'module',
|
|
94
101
|
'preloadModules',
|
|
95
102
|
'lwrVersion',
|
|
96
|
-
'lwcVersion'
|
|
103
|
+
'lwcVersion',
|
|
104
|
+
'preloadResources'
|
|
97
105
|
]);
|
|
98
106
|
function isNotEmptyString(node) {
|
|
99
107
|
return node.type === 'string' && node.value.length > 0;
|
|
@@ -108,7 +116,7 @@ export class ValidationContext {
|
|
|
108
116
|
return calculatePositionFromSource(this.sourceText, node);
|
|
109
117
|
}
|
|
110
118
|
assertIsObject(node, property) {
|
|
111
|
-
if (node
|
|
119
|
+
if (node?.type !== 'object' && node) {
|
|
112
120
|
this.diagnostics.push({
|
|
113
121
|
description: descriptions.CONFIG_PARSER.INCORRECT_NODE_TYPE(property, 'object', node.type),
|
|
114
122
|
location: this.getLocationFromNode(node),
|
|
@@ -139,6 +147,39 @@ export class ValidationContext {
|
|
|
139
147
|
});
|
|
140
148
|
}
|
|
141
149
|
}
|
|
150
|
+
assertIsFilePattern(node, property) {
|
|
151
|
+
if (node) {
|
|
152
|
+
const children = node.children || [];
|
|
153
|
+
for (const [index, child] of children.entries()) {
|
|
154
|
+
let matcher = findNodeAtLocation(child, ['match'])?.children?.map(val => val.value) || findNodeAtLocation(child, ['match'])?.value;
|
|
155
|
+
if (!Array.isArray(matcher)) {
|
|
156
|
+
matcher = [matcher];
|
|
157
|
+
}
|
|
158
|
+
let misMatch = null;
|
|
159
|
+
for (let i = 0; i < matcher.length; i++) {
|
|
160
|
+
try {
|
|
161
|
+
if (matcher[i] === '')
|
|
162
|
+
throw new Error('Empty string is not a valid regex');
|
|
163
|
+
// match is a regex set as string, the below line would throw an error if the backslashes are not escaped
|
|
164
|
+
// eg: Regex /^.*\.css(?:\?.*)?$/ should be "^.*\\.css(?:\\?.*)?$"
|
|
165
|
+
new RegExp(matcher[i]);
|
|
166
|
+
}
|
|
167
|
+
catch (e) {
|
|
168
|
+
misMatch = matcher[i];
|
|
169
|
+
this.diagnostics.push({
|
|
170
|
+
description: descriptions.CONFIG_PARSER.INVALID_FILE_PATTERN(`${property}[${index}].match`, misMatch),
|
|
171
|
+
location: this.getLocationFromNode(node)
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
if (misMatch)
|
|
175
|
+
break;
|
|
176
|
+
}
|
|
177
|
+
if (misMatch !== null) {
|
|
178
|
+
break;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
142
183
|
assertIsPath(node, property) {
|
|
143
184
|
if (node && (node.type !== 'string' || node.value[0] !== '/')) {
|
|
144
185
|
this.diagnostics.push({
|
|
@@ -147,6 +188,14 @@ export class ValidationContext {
|
|
|
147
188
|
});
|
|
148
189
|
}
|
|
149
190
|
}
|
|
191
|
+
assertIsOrigin(node, property) {
|
|
192
|
+
if (node && (node.type !== 'string' || !/^https?:\/\//i.test(node.value))) {
|
|
193
|
+
this.diagnostics.push({
|
|
194
|
+
description: descriptions.CONFIG_PARSER.INVALID_ORIGIN(property, node.value),
|
|
195
|
+
location: this.getLocationFromNode(node),
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
}
|
|
150
199
|
assertIsPort(node, property) {
|
|
151
200
|
if (node && (node.type !== 'number' || node.value < 0 || node.value > 65353)) {
|
|
152
201
|
this.diagnostics.push({
|
|
@@ -212,7 +261,7 @@ export class ValidationContext {
|
|
|
212
261
|
});
|
|
213
262
|
}
|
|
214
263
|
}
|
|
215
|
-
assertIsBasePath(node, property) {
|
|
264
|
+
assertIsBasePath(node, property, allowSlash = false) {
|
|
216
265
|
if (!node) {
|
|
217
266
|
return;
|
|
218
267
|
}
|
|
@@ -222,7 +271,7 @@ export class ValidationContext {
|
|
|
222
271
|
location: this.getLocationFromNode(node),
|
|
223
272
|
});
|
|
224
273
|
}
|
|
225
|
-
else if (node.value === '') {
|
|
274
|
+
else if (node.value === '' || allowSlash && node.value === '/') {
|
|
226
275
|
return;
|
|
227
276
|
}
|
|
228
277
|
else if (node.value.match(BASE_PATH_REGEX) === null) {
|
|
@@ -502,5 +551,17 @@ export class ValidationContext {
|
|
|
502
551
|
});
|
|
503
552
|
}
|
|
504
553
|
}
|
|
554
|
+
assertIsCoreProxy(node, validationContext) {
|
|
555
|
+
if (node && node.type !== 'null') {
|
|
556
|
+
validationContext.assertIsObject(node, 'coreProxy');
|
|
557
|
+
validationContext.assertValidKeys(node, 'coreProxy', CORE_PROXY_ATTRIBUTE_KEYS);
|
|
558
|
+
validationContext.assertRequiredKeys(node, 'coreProxy', ['origin']);
|
|
559
|
+
validationContext.assertNotEmptyString(findNodeAtLocation(node, ['origin']), 'coreProxy.origin');
|
|
560
|
+
const host = findNodeAtLocation(node, ['host']);
|
|
561
|
+
host && validationContext.assertNotEmptyString(host, 'coreProxy.host');
|
|
562
|
+
const servername = findNodeAtLocation(node, ['servername']);
|
|
563
|
+
servername && validationContext.assertNotEmptyString(servername, 'coreProxy.servername');
|
|
564
|
+
}
|
|
565
|
+
}
|
|
505
566
|
}
|
|
506
567
|
//# sourceMappingURL=app-config-context.js.map
|
|
@@ -17,10 +17,12 @@ export const SOURCE_BY_PHASE = {
|
|
|
17
17
|
* - syntheticShadow: optional boolean
|
|
18
18
|
* - workers: optional map of string:specifier pairs
|
|
19
19
|
* - ssr: optional boolean
|
|
20
|
+
* - proxyForSSR: optional boolean
|
|
20
21
|
* - configAsSrc: optional boolean to include the client bootstrap config as src via in-lined
|
|
21
22
|
* - module: optional string specifier
|
|
22
23
|
* - lwrVersion: optional string version
|
|
23
24
|
* - lwcVersion: optional string version
|
|
25
|
+
* - preloadResources: optional object
|
|
24
26
|
*/
|
|
25
27
|
function validateBootstrap(node, validationContext, propPrefix) {
|
|
26
28
|
if (node) {
|
|
@@ -31,6 +33,8 @@ function validateBootstrap(node, validationContext, propPrefix) {
|
|
|
31
33
|
validationContext.assertIsBoolean(findNode(node, ['autoBoot']), `${propPrefix}.autoBoot`);
|
|
32
34
|
validationContext.assertIsBoolean(findNode(node, ['ssr']), `${propPrefix}.ssr`);
|
|
33
35
|
validationContext.assertIsBoolean(findNode(node, ['preloadData']), `${propPrefix}.preloadData`);
|
|
36
|
+
validationContext.assertIsBoolean(findNode(node, ['proxyForSSR']), `${propPrefix}.proxyForSSR`);
|
|
37
|
+
validationContext.assertIsBoolean(findNode(node, ['includeCookiesForSSR']), `${propPrefix}.includeCookiesForSSR`);
|
|
34
38
|
validationContext.assertIsBoolean(findNode(node, ['mixedMode']), `${propPrefix}.mixedMode`);
|
|
35
39
|
validationContext.assertIsBoolean(findNode(node, ['configAsSrc']), `${propPrefix}.configAsSrc`);
|
|
36
40
|
validationContext.assertIsSpecifier(findNode(node, ['module']), `${propPrefix}.module`);
|
|
@@ -38,6 +42,7 @@ function validateBootstrap(node, validationContext, propPrefix) {
|
|
|
38
42
|
validationContext.assertNotEmptyString(findNode(node, ['lwrVersion']), `${propPrefix}.lwrVersion`);
|
|
39
43
|
validationContext.assertNotEmptyString(findNode(node, ['lwcVersion']), `${propPrefix}.lwcVersion`);
|
|
40
44
|
validationContext.assertSsrPreloadData(node, propPrefix);
|
|
45
|
+
validationContext.assertIsFilePattern(findNode(node, ['preloadResources', 'patterns']), `${propPrefix}.preloadResources.patterns`);
|
|
41
46
|
// Each value in the worker map msut be a specifier
|
|
42
47
|
const workers = findNode(node, ['workers']);
|
|
43
48
|
if (workers && workers.children) {
|
|
@@ -126,6 +131,8 @@ function validateI18NConfig(node, validationContext, preMerge) {
|
|
|
126
131
|
validationContext.assertNotEmptyString(defaultLocale, 'i18n.defaultLocale');
|
|
127
132
|
const localeIds = locales?.children?.map((n) => findNode(n, ['id'])?.value) || [];
|
|
128
133
|
validationContext.assertDefaultInLocales(node, defaultLocale?.value, localeIds);
|
|
134
|
+
const defaultRedirectParams = findNode(node, ['defaultRedirectParams']);
|
|
135
|
+
validationContext.assertIsObject(defaultRedirectParams, 'i18n.defaultRedirectParams');
|
|
129
136
|
}
|
|
130
137
|
}
|
|
131
138
|
function validateStaticSiteGeneratorConfig(node, validationContext) {
|
|
@@ -306,6 +313,7 @@ function validateRoot(node, validationContext, preMerge) {
|
|
|
306
313
|
validationContext.assertUniqueIds([...(routes?.children || []), ...(errorRoutes?.children || [])], 'routes');
|
|
307
314
|
const lockerNode = findNode(node, ['locker']);
|
|
308
315
|
const bundleConfigNode = findNode(node, ['bundleConfig']);
|
|
316
|
+
validationContext.assertIsBoolean(findNode(node, ['caseSensitiveRoutes']), 'caseSensitiveRoutes');
|
|
309
317
|
validateRoutes(routes, validationContext, preMerge);
|
|
310
318
|
validateErrorRoutes(errorRoutes, validationContext);
|
|
311
319
|
validateRouteHandlers(findNode(node, ['routeHandlers']), validationContext);
|
|
@@ -335,6 +343,8 @@ function validateRoot(node, validationContext, preMerge) {
|
|
|
335
343
|
validationContext.assertNotEmptyArray(findNode(node, ['lwc', 'modules']), 'lwc.modules');
|
|
336
344
|
validationContext.assertIsEnvironment(findNode(node, ['environment']), 'environment');
|
|
337
345
|
validationContext.assertIsBasePath(findNode(node, ['basePath']), 'basePath');
|
|
346
|
+
validationContext.assertIsCoreProxy(findNode(node, ['coreProxy']), validationContext);
|
|
347
|
+
validationContext.assertIsBoolean(findNode(node, ['_isSsrCompilerEnabled']), '_isSsrCompilerEnabled');
|
|
338
348
|
}
|
|
339
349
|
export function validateLwrAppConfig(config, phase) {
|
|
340
350
|
const span = getTracer().startSpan({ name: ConfigSpan.ValidateConfig });
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
|
-
"version": "0.15.0
|
|
7
|
+
"version": "0.15.0",
|
|
8
8
|
"homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
@@ -42,22 +42,22 @@
|
|
|
42
42
|
"test": "jest"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@lwrjs/diagnostics": "0.15.0
|
|
46
|
-
"@lwrjs/instrumentation": "0.15.0
|
|
47
|
-
"@lwrjs/shared-utils": "0.15.0
|
|
45
|
+
"@lwrjs/diagnostics": "0.15.0",
|
|
46
|
+
"@lwrjs/instrumentation": "0.15.0",
|
|
47
|
+
"@lwrjs/shared-utils": "0.15.0",
|
|
48
48
|
"fs-extra": "^11.2.0",
|
|
49
49
|
"jsonc-parser": "^3.3.1"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@lwrjs/types": "0.15.0
|
|
52
|
+
"@lwrjs/types": "0.15.0",
|
|
53
53
|
"jest": "^26.6.3",
|
|
54
|
-
"memfs": "^4.
|
|
54
|
+
"memfs": "^4.13.0",
|
|
55
55
|
"ts-jest": "^26.5.6"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
|
58
58
|
"@lwc/engine-dom": ">= 2.x",
|
|
59
59
|
"@lwc/synthetic-shadow": ">= 2.x",
|
|
60
|
-
"@lwrjs/esbuild": "0.
|
|
60
|
+
"@lwrjs/esbuild": "0.15.x || >= 0.15.0-alpha",
|
|
61
61
|
"lwc": ">= 2.x"
|
|
62
62
|
},
|
|
63
63
|
"peerDependenciesMeta": {
|
|
@@ -71,5 +71,5 @@
|
|
|
71
71
|
"volta": {
|
|
72
72
|
"extends": "../../../package.json"
|
|
73
73
|
},
|
|
74
|
-
"gitHead": "
|
|
74
|
+
"gitHead": "ee374df435d5342f63e4da126a09461e761837f3"
|
|
75
75
|
}
|