@lwrjs/config 0.12.0-alpha.1 → 0.12.0-alpha.11
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 +14 -7
- package/build/cjs/global-config.cjs +14 -24
- package/build/cjs/hooks.cjs +12 -7
- package/build/cjs/index.cjs +4 -5
- package/build/cjs/utils/routes.cjs +9 -10
- package/build/cjs/validation/app-config-context.cjs +12 -23
- package/build/cjs/validation/app-config.cjs +2 -1
- package/build/es/defaults.d.ts +0 -2
- package/build/es/defaults.js +15 -6
- package/build/es/global-config.d.ts +0 -7
- package/build/es/global-config.js +8 -31
- package/build/es/hooks.d.ts +2 -1
- package/build/es/hooks.js +12 -7
- package/build/es/index.d.ts +2 -2
- package/build/es/index.js +2 -2
- package/build/es/utils/routes.js +14 -10
- package/build/es/validation/app-config-context.d.ts +3 -3
- package/build/es/validation/app-config-context.js +12 -23
- package/build/es/validation/app-config.js +2 -2
- package/package.cjs +21 -6
- package/package.json +8 -7
- package/types/package.d.ts +13 -0
package/build/cjs/defaults.cjs
CHANGED
|
@@ -36,8 +36,6 @@ __export(exports, {
|
|
|
36
36
|
DEFAULT_ROOT_DIR: () => DEFAULT_ROOT_DIR,
|
|
37
37
|
DEFAULT_SERVICE_PACKAGE_NAME: () => DEFAULT_SERVICE_PACKAGE_NAME,
|
|
38
38
|
LWR_VERSION: () => LWR_VERSION,
|
|
39
|
-
SSR_MODULE_PROVIDER: () => SSR_MODULE_PROVIDER,
|
|
40
|
-
SSR_VIEW_TRANSFORM_PLUGIN: () => SSR_VIEW_TRANSFORM_PLUGIN,
|
|
41
39
|
getDefaultBundleConfig: () => getDefaultBundleConfig
|
|
42
40
|
});
|
|
43
41
|
var import_shared_utils = __toModule(require("@lwrjs/shared-utils"));
|
|
@@ -47,7 +45,7 @@ var PORT = process.env.PORT ? parseInt(process.env.PORT, 10) : 3e3;
|
|
|
47
45
|
var MODE = process.env.MODE || "prod";
|
|
48
46
|
var DEFAULT_BASE_PATH = "";
|
|
49
47
|
var DEFAULT_API_VERSION = "1";
|
|
50
|
-
var LWR_VERSION = import_package.
|
|
48
|
+
var LWR_VERSION = import_package.lwrVersion;
|
|
51
49
|
var DEFAULT_SERVER_TYPE = "express";
|
|
52
50
|
var DEFAULT_LWR_CONFIG_JSON = "$rootDir/lwr.config.json";
|
|
53
51
|
var DEFAULT_GENERATOR_CONFIG = {
|
|
@@ -67,9 +65,9 @@ var DEFAULT_MODULE_PROVIDERS = [
|
|
|
67
65
|
"@lwrjs/app-service/moduleProvider",
|
|
68
66
|
"@lwrjs/router/module-provider",
|
|
69
67
|
"@lwrjs/lwc-module-provider",
|
|
68
|
+
"@lwrjs/lwc-ssr/moduleProvider",
|
|
70
69
|
"@lwrjs/npm-module-provider"
|
|
71
70
|
];
|
|
72
|
-
var SSR_MODULE_PROVIDER = "@lwrjs/lwc-ssr/moduleProvider";
|
|
73
71
|
var DEFAULT_RESOURCE_PROVIDERS = ["@lwrjs/loader"];
|
|
74
72
|
var DEFAULT_VIEW_PROVIDERS = [
|
|
75
73
|
"@lwrjs/nunjucks-view-provider",
|
|
@@ -81,9 +79,12 @@ var DEFAULT_BUNDLE_PROVIDERS = [
|
|
|
81
79
|
"@lwrjs/module-bundler/amd-bundle-provider",
|
|
82
80
|
"@lwrjs/module-bundler/esm-bundle-provider"
|
|
83
81
|
];
|
|
84
|
-
var DEFAULT_VIEW_TRANSFORM_PLUGINS = ["@lwrjs/base-view-transformer"];
|
|
85
|
-
var SSR_VIEW_TRANSFORM_PLUGIN = "@lwrjs/lwc-ssr/viewTransformer";
|
|
86
82
|
var DEFAULT_ASSET_PROVIDERS = ["@lwrjs/fs-asset-provider"];
|
|
83
|
+
var DEFAULT_VIEW_TRANSFORM_PLUGINS = [
|
|
84
|
+
"@lwrjs/base-view-transformer",
|
|
85
|
+
"@lwrjs/lwc-ssr/viewTransformer",
|
|
86
|
+
"@lwrjs/lwc-ssr/dataViewTransformer"
|
|
87
|
+
];
|
|
87
88
|
var DEFAULT_ASSET_TRANSFORM_PLUGINS = ["@lwrjs/asset-transformer"];
|
|
88
89
|
var DEFAULT_URI_TRANSFORM_PLUGINS = [];
|
|
89
90
|
var DEFAULT_AMD_LOADER = "lwr/loader";
|
|
@@ -150,7 +151,13 @@ var DEFAULT_LWR_CONFIG = {
|
|
|
150
151
|
viewTransformers: DEFAULT_VIEW_TRANSFORM_PLUGINS,
|
|
151
152
|
environment: {},
|
|
152
153
|
lwc: {modules: []},
|
|
153
|
-
routes: [
|
|
154
|
+
routes: [
|
|
155
|
+
{
|
|
156
|
+
id: "lwrInfo",
|
|
157
|
+
path: "/lwr-info",
|
|
158
|
+
routeHandler: `@lwrjs/core/info/route-handler`
|
|
159
|
+
}
|
|
160
|
+
],
|
|
154
161
|
errorRoutes: [],
|
|
155
162
|
routeHandlers: {},
|
|
156
163
|
bundleConfig: getDefaultBundleConfig(MODE),
|
|
@@ -24,7 +24,6 @@ var __toModule = (module2) => {
|
|
|
24
24
|
// packages/@lwrjs/config/src/global-config.ts
|
|
25
25
|
__markAsModule(exports);
|
|
26
26
|
__export(exports, {
|
|
27
|
-
applySsrConfig: () => applySsrConfig,
|
|
28
27
|
applyStaticProviderConfig: () => applyStaticProviderConfig,
|
|
29
28
|
getLwrConfigFromFile: () => getLwrConfigFromFile,
|
|
30
29
|
loadConfig: () => loadConfig,
|
|
@@ -36,7 +35,6 @@ var import_jsonc_parser = __toModule(require("jsonc-parser"));
|
|
|
36
35
|
var import_diagnostics = __toModule(require("@lwrjs/diagnostics"));
|
|
37
36
|
var import_shared_utils = __toModule(require("@lwrjs/shared-utils"));
|
|
38
37
|
var import_defaults = __toModule(require("./defaults.cjs"));
|
|
39
|
-
var import_defaults2 = __toModule(require("./defaults.cjs"));
|
|
40
38
|
var import_app_config = __toModule(require("./validation/app-config.cjs"));
|
|
41
39
|
var import_assets = __toModule(require("./utils/assets.cjs"));
|
|
42
40
|
var import_services = __toModule(require("./utils/services.cjs"));
|
|
@@ -46,7 +44,7 @@ var import_lwc = __toModule(require("./utils/lwc.cjs"));
|
|
|
46
44
|
var import_runtime_config = __toModule(require("./runtime-config.cjs"));
|
|
47
45
|
var import_global_data = __toModule(require("./utils/global-data.cjs"));
|
|
48
46
|
var import_instrumentation = __toModule(require("@lwrjs/instrumentation"));
|
|
49
|
-
function getLwrConfigFromFile(rootDir, lwrConfigPath =
|
|
47
|
+
function getLwrConfigFromFile(rootDir, lwrConfigPath = import_defaults.DEFAULT_LWR_CONFIG_JSON) {
|
|
50
48
|
const resolvedLwrConfigPath = import_path.default.resolve((0, import_shared_utils.normalizeDirectory)(lwrConfigPath, rootDir));
|
|
51
49
|
if (!import_fs.default.existsSync(resolvedLwrConfigPath)) {
|
|
52
50
|
import_diagnostics.logger.warn({label: `config`, message: `LWR Config not found on "${resolvedLwrConfigPath}"`});
|
|
@@ -67,10 +65,13 @@ function mergeConfig(configArg) {
|
|
|
67
65
|
configArg = (0, import_merge.trimLwrConfig)(configArg);
|
|
68
66
|
(0, import_app_config.validateLwrAppConfig)(configArg, "pre");
|
|
69
67
|
}
|
|
70
|
-
const rootDir = import_path.default.resolve(configArg?.rootDir ||
|
|
68
|
+
const rootDir = import_path.default.resolve(configArg?.rootDir || import_defaults.DEFAULT_ROOT_DIR);
|
|
71
69
|
const configFile = !configArg?.ignoreLwrConfigFile ? getLwrConfigFromFile(rootDir, configArg?.lwrConfigFile) : void 0;
|
|
70
|
+
if (configFile) {
|
|
71
|
+
configFile.routes = (configFile?.routes ?? []).concat(import_defaults.DEFAULT_LWR_CONFIG.routes);
|
|
72
|
+
}
|
|
72
73
|
return {
|
|
73
|
-
...
|
|
74
|
+
...import_defaults.DEFAULT_LWR_CONFIG,
|
|
74
75
|
...configFile,
|
|
75
76
|
...configArg,
|
|
76
77
|
lwc: (0, import_merge.mergeLwcConfig)(configFile, configArg),
|
|
@@ -81,12 +82,12 @@ function mergeConfig(configArg) {
|
|
|
81
82
|
};
|
|
82
83
|
}
|
|
83
84
|
function normalizeConfig(config) {
|
|
84
|
-
const amdLoader = (0, import_shared_utils.getFeatureFlags)().LEGACY_LOADER ?
|
|
85
|
+
const amdLoader = (0, import_shared_utils.getFeatureFlags)().LEGACY_LOADER ? import_defaults.DEFAULT_AMD_LOADER_LEGACY : import_defaults.DEFAULT_AMD_LOADER;
|
|
85
86
|
return {
|
|
86
87
|
...config,
|
|
87
88
|
amdLoader,
|
|
88
|
-
esmLoader:
|
|
89
|
-
lwrVersion:
|
|
89
|
+
esmLoader: import_defaults.DEFAULT_ESM_LOADER,
|
|
90
|
+
lwrVersion: import_defaults.LWR_VERSION,
|
|
90
91
|
assets: (0, import_assets.normalizeAssets)(config.assets),
|
|
91
92
|
lwc: (0, import_lwc.normalizeLwcConfig)(config.lwc),
|
|
92
93
|
hooks: (0, import_services.normalizeServices)(config.hooks),
|
|
@@ -104,7 +105,7 @@ function normalizeConfig(config) {
|
|
|
104
105
|
};
|
|
105
106
|
}
|
|
106
107
|
function normalizeConfigPaths(config) {
|
|
107
|
-
const rootDir = config.rootDir ||
|
|
108
|
+
const rootDir = config.rootDir || import_defaults.DEFAULT_ROOT_DIR;
|
|
108
109
|
const resourcePaths = {
|
|
109
110
|
rootDir,
|
|
110
111
|
assets: (0, import_assets.normalizeAssetPaths)(config.assets, rootDir),
|
|
@@ -134,26 +135,16 @@ function normalizeConfigPaths(config) {
|
|
|
134
135
|
routeHandlers: (0, import_routes.normalizeRouteHandlerPaths)(config.routeHandlers, resourcePaths)
|
|
135
136
|
};
|
|
136
137
|
}
|
|
137
|
-
function applySsrConfig(config) {
|
|
138
|
-
const hasSSR = config.routes.some((r) => r.bootstrap.ssr);
|
|
139
|
-
if (!hasSSR) {
|
|
140
|
-
return config;
|
|
141
|
-
}
|
|
142
|
-
const hasSsrModuleProvider = config.moduleProviders.some(([m]) => m === import_defaults.SSR_MODULE_PROVIDER);
|
|
143
|
-
const hasSsrViewTransformer = config.viewTransformers.some(([v]) => v === import_defaults.SSR_VIEW_TRANSFORM_PLUGIN);
|
|
144
|
-
return {
|
|
145
|
-
...config,
|
|
146
|
-
moduleProviders: hasSsrModuleProvider ? config.moduleProviders : [[import_defaults.SSR_MODULE_PROVIDER, void 0], ...config.moduleProviders],
|
|
147
|
-
viewTransformers: hasSsrViewTransformer ? config.viewTransformers : [...config.viewTransformers, [import_defaults.SSR_VIEW_TRANSFORM_PLUGIN, void 0]]
|
|
148
|
-
};
|
|
149
|
-
}
|
|
150
138
|
function applyStaticProviderConfig(config) {
|
|
151
139
|
return {
|
|
152
140
|
...config,
|
|
153
141
|
assetProviders: [["@lwrjs/static/asset-provider", void 0]],
|
|
154
142
|
assetTransformers: [],
|
|
155
143
|
resourceProviders: [["@lwrjs/static/resource-provider", {}]],
|
|
156
|
-
moduleProviders: [
|
|
144
|
+
moduleProviders: [
|
|
145
|
+
["@lwrjs/static/module-provider", void 0],
|
|
146
|
+
["@lwrjs/lwc-ssr/moduleProvider", void 0]
|
|
147
|
+
],
|
|
157
148
|
bundleProviders: [
|
|
158
149
|
["@lwrjs/static/bundle-provider", void 0],
|
|
159
150
|
["@lwrjs/module-bundler/amd-runtime-bundle-provider", void 0]
|
|
@@ -168,7 +159,6 @@ function resolveGlobalConfig(configArg, options) {
|
|
|
168
159
|
if (options?.useStaticProviders) {
|
|
169
160
|
normalizedConfig = applyStaticProviderConfig(normalizedConfig);
|
|
170
161
|
}
|
|
171
|
-
normalizedConfig = applySsrConfig(normalizedConfig);
|
|
172
162
|
if (!options?.skipCacheDirCreation) {
|
|
173
163
|
createCacheFolder(normalizedConfig.cacheDir, normalizedConfig.rootDir);
|
|
174
164
|
}
|
package/build/cjs/hooks.cjs
CHANGED
|
@@ -25,12 +25,12 @@ var __toModule = (module2) => {
|
|
|
25
25
|
__markAsModule(exports);
|
|
26
26
|
__export(exports, {
|
|
27
27
|
executeConfigHooks: () => executeConfigHooks,
|
|
28
|
+
executeContextHooks: () => executeContextHooks,
|
|
28
29
|
executeInstrumentationHooks: () => executeInstrumentationHooks,
|
|
29
30
|
executeStartHooks: () => executeStartHooks
|
|
30
31
|
});
|
|
31
32
|
var import_routes = __toModule(require("./utils/routes.cjs"));
|
|
32
33
|
var import_app_config = __toModule(require("./validation/app-config.cjs"));
|
|
33
|
-
var import_global_config = __toModule(require("./global-config.cjs"));
|
|
34
34
|
var import_instrumentation = __toModule(require("@lwrjs/instrumentation"));
|
|
35
35
|
async function executeConfigHooks(hooks, globalConfig, runtimeEnvironment, globalData, skipValidate = false) {
|
|
36
36
|
const span = (0, import_instrumentation.getTracer)().startSpan({name: import_instrumentation.ConfigSpan.ExecuteConfigHooks});
|
|
@@ -46,9 +46,6 @@ async function executeConfigHooks(hooks, globalConfig, runtimeEnvironment, globa
|
|
|
46
46
|
}
|
|
47
47
|
globalConfig.routes = (0, import_routes.normalizeRoutes)(globalConfig.routes, globalConfig.routeHandlers);
|
|
48
48
|
globalConfig.errorRoutes = (0, import_routes.normalizeRoutes)(globalConfig.errorRoutes, globalConfig.routeHandlers);
|
|
49
|
-
const ssrConfig = (0, import_global_config.applySsrConfig)(globalConfig);
|
|
50
|
-
globalConfig.moduleProviders = ssrConfig.moduleProviders;
|
|
51
|
-
globalConfig.viewTransformers = ssrConfig.viewTransformers;
|
|
52
49
|
if (!skipValidate) {
|
|
53
50
|
(0, import_app_config.validateLwrAppConfig)(globalConfig, "post");
|
|
54
51
|
}
|
|
@@ -78,9 +75,6 @@ function executeStartHooks(hooks, globalConfig, runtimeEnvironment, skipValidate
|
|
|
78
75
|
}
|
|
79
76
|
globalConfig.routes = (0, import_routes.normalizeRoutes)(globalConfig.routes, globalConfig.routeHandlers);
|
|
80
77
|
globalConfig.errorRoutes = (0, import_routes.normalizeRoutes)(globalConfig.errorRoutes, globalConfig.routeHandlers);
|
|
81
|
-
const ssrConfig = (0, import_global_config.applySsrConfig)(globalConfig);
|
|
82
|
-
globalConfig.moduleProviders = ssrConfig.moduleProviders;
|
|
83
|
-
globalConfig.viewTransformers = ssrConfig.viewTransformers;
|
|
84
78
|
if (!skipValidate) {
|
|
85
79
|
(0, import_app_config.validateLwrAppConfig)(globalConfig, "post");
|
|
86
80
|
}
|
|
@@ -99,3 +93,14 @@ function executeInstrumentationHooks(hooks) {
|
|
|
99
93
|
span.end();
|
|
100
94
|
return retVal;
|
|
101
95
|
}
|
|
96
|
+
async function executeContextHooks(hooks, serverContext) {
|
|
97
|
+
if (!hooks.length) {
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
for (const hook of hooks) {
|
|
101
|
+
if (!hook.setupServerContext) {
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
await hook.setupServerContext(serverContext, hooks);
|
|
105
|
+
}
|
|
106
|
+
}
|
package/build/cjs/index.cjs
CHANGED
|
@@ -25,10 +25,9 @@ var __toModule = (module2) => {
|
|
|
25
25
|
__markAsModule(exports);
|
|
26
26
|
__export(exports, {
|
|
27
27
|
LWC_VERSION: () => import_package.lwcVersion,
|
|
28
|
-
LWR_VERSION: () => import_package.
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
executeStartHooks: () => import_hooks.executeStartHooks,
|
|
28
|
+
LWR_VERSION: () => import_package.lwrVersion,
|
|
29
|
+
NODE_VERSION: () => import_package.nodeVersion,
|
|
30
|
+
PWA_KIT_RUNTIME_VERSION: () => import_package.pwaKitRuntimeVersion,
|
|
32
31
|
getLwrConfigFromFile: () => import_global_config.getLwrConfigFromFile,
|
|
33
32
|
getRuntimeEnvironment: () => import_runtime_config.getRuntimeEnvironment,
|
|
34
33
|
loadConfig: () => import_global_config.loadConfig,
|
|
@@ -38,5 +37,5 @@ __export(exports, {
|
|
|
38
37
|
var import_package = __toModule(require("@lwrjs/config/package"));
|
|
39
38
|
var import_global_config = __toModule(require("./global-config.cjs"));
|
|
40
39
|
var import_runtime_config = __toModule(require("./runtime-config.cjs"));
|
|
41
|
-
|
|
40
|
+
__exportStar(exports, __toModule(require("./hooks.cjs")));
|
|
42
41
|
var import_app_config = __toModule(require("./validation/app-config.cjs"));
|
|
@@ -36,6 +36,13 @@ function normalizeRoutes(routes, routeHandlers) {
|
|
|
36
36
|
return routes.map((route) => {
|
|
37
37
|
const rawServices = route?.bootstrap?.services || [];
|
|
38
38
|
const services = rawServices.map((s) => typeof s === "string" ? {name: s, ssr: false} : s);
|
|
39
|
+
const preloadData = route.bootstrap?.preloadData === void 0 ? route.bootstrap?.ssr === true ? true : false : route.bootstrap?.preloadData;
|
|
40
|
+
const bootstrap = {
|
|
41
|
+
...import_shared_utils.DEFAULT_LWR_BOOTSTRAP_CONFIG,
|
|
42
|
+
...route.bootstrap,
|
|
43
|
+
preloadData,
|
|
44
|
+
services
|
|
45
|
+
};
|
|
39
46
|
if (route.routeHandler) {
|
|
40
47
|
const handler = typeof route.routeHandler === "string" ? route.routeHandler : route.routeHandler[0];
|
|
41
48
|
if (!(handler in routeHandlers)) {
|
|
@@ -44,20 +51,12 @@ function normalizeRoutes(routes, routeHandlers) {
|
|
|
44
51
|
return {
|
|
45
52
|
...route,
|
|
46
53
|
routeHandler: typeof route.routeHandler === "string" ? [route.routeHandler, void 0] : route.routeHandler,
|
|
47
|
-
bootstrap
|
|
48
|
-
...import_shared_utils.DEFAULT_LWR_BOOTSTRAP_CONFIG,
|
|
49
|
-
...route.bootstrap,
|
|
50
|
-
services
|
|
51
|
-
}
|
|
54
|
+
bootstrap
|
|
52
55
|
};
|
|
53
56
|
}
|
|
54
57
|
return {
|
|
55
58
|
...route,
|
|
56
|
-
bootstrap
|
|
57
|
-
...import_shared_utils.DEFAULT_LWR_BOOTSTRAP_CONFIG,
|
|
58
|
-
...route.bootstrap,
|
|
59
|
-
services
|
|
60
|
-
}
|
|
59
|
+
bootstrap
|
|
61
60
|
};
|
|
62
61
|
});
|
|
63
62
|
}
|
|
@@ -83,7 +83,7 @@ var ROOT_ATTRIBUTE_KEYS = createKeys("root", [
|
|
|
83
83
|
]);
|
|
84
84
|
var ASSET_DIR_ATTRIBUTE_KEYS = createKeys("assetDir", ["alias", "dir", "urlPath", "root"]);
|
|
85
85
|
var ASSET_FILE_ATTRIBUTE_KEYS = createKeys("assetFile", ["alias", "file", "urlPath"]);
|
|
86
|
-
var LOCKER_ATTRIBUTE_KEYS = createKeys("locker", ["enabled", "trustedComponents"
|
|
86
|
+
var LOCKER_ATTRIBUTE_KEYS = createKeys("locker", ["enabled", "trustedComponents"]);
|
|
87
87
|
var I18N_ATTRIBUTE_KEYS = createKeys("i18n", ["defaultLocale", "locales", "uriPattern"]);
|
|
88
88
|
var STATIC_SITE_GENERATOR_ATTRIBUTE_KEYS = createKeys("staticSiteGenerator", [
|
|
89
89
|
"outputDir",
|
|
@@ -124,6 +124,7 @@ var BOOTSTRAP_ATTRIBUTE_KEYS = createKeys("bootstrap", [
|
|
|
124
124
|
"services",
|
|
125
125
|
"configAsSrc",
|
|
126
126
|
"ssr",
|
|
127
|
+
"preloadData",
|
|
127
128
|
"mixedMode",
|
|
128
129
|
"module",
|
|
129
130
|
"preloadModules"
|
|
@@ -437,28 +438,6 @@ var ValidationContext = class {
|
|
|
437
438
|
});
|
|
438
439
|
}
|
|
439
440
|
}
|
|
440
|
-
assertClientLockerSSR(routesNode, lockerNode) {
|
|
441
|
-
if (routesNode && lockerNode) {
|
|
442
|
-
const enabled = (0, import_jsonc_parser.findNodeAtLocation)(lockerNode, ["enabled"]);
|
|
443
|
-
const clientOnly = (0, import_jsonc_parser.findNodeAtLocation)(lockerNode, ["clientOnly"]);
|
|
444
|
-
const compileTimeLocker = enabled && enabled.value === true && (!clientOnly || clientOnly.value === false);
|
|
445
|
-
if (compileTimeLocker && routesNode.children) {
|
|
446
|
-
const hasSSR = routesNode.children.some((n) => {
|
|
447
|
-
const bootstrap = (0, import_jsonc_parser.findNodeAtLocation)(n, ["bootstrap"]);
|
|
448
|
-
if (bootstrap) {
|
|
449
|
-
const ssr = (0, import_jsonc_parser.findNodeAtLocation)(bootstrap, ["ssr"]);
|
|
450
|
-
return ssr?.value === true;
|
|
451
|
-
}
|
|
452
|
-
});
|
|
453
|
-
if (hasSSR) {
|
|
454
|
-
this.diagnostics.push({
|
|
455
|
-
description: import_diagnostics.descriptions.CONFIG_PARSER.COMPILE_LOCKER_SSR(),
|
|
456
|
-
location: this.getLocationFromNode(lockerNode)
|
|
457
|
-
});
|
|
458
|
-
}
|
|
459
|
-
}
|
|
460
|
-
}
|
|
461
|
-
}
|
|
462
441
|
assertRequiredKeys(node, property, requiredPropertyKeys) {
|
|
463
442
|
const missingProps = requiredPropertyKeys.filter((p) => (0, import_jsonc_parser.findNodeAtLocation)(node, [p]) === void 0);
|
|
464
443
|
if (missingProps.length > 0) {
|
|
@@ -524,4 +503,14 @@ var ValidationContext = class {
|
|
|
524
503
|
}
|
|
525
504
|
}
|
|
526
505
|
}
|
|
506
|
+
assertSsrPreloadData(node, propPrefix) {
|
|
507
|
+
const ssr = (0, import_jsonc_parser.findNodeAtLocation)(node, ["ssr"])?.value;
|
|
508
|
+
const preloadData = (0, import_jsonc_parser.findNodeAtLocation)(node, ["preloadData"])?.value;
|
|
509
|
+
if (ssr === true && preloadData === false) {
|
|
510
|
+
this.diagnostics.push({
|
|
511
|
+
description: import_diagnostics.descriptions.CONFIG_PARSER.SSR_WITHOUT_PRELOAD(propPrefix),
|
|
512
|
+
location: this.getLocationFromNode(node)
|
|
513
|
+
});
|
|
514
|
+
}
|
|
515
|
+
}
|
|
527
516
|
};
|
|
@@ -47,10 +47,12 @@ function validateBootstrap(node, validationContext, propPrefix) {
|
|
|
47
47
|
validationContext.assertArrayOfSpecifiers((0, import_jsonc_parser.findNodeAtLocation)(node, ["preloadModules"]), `${propPrefix}.preloadModules`);
|
|
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
|
+
validationContext.assertIsBoolean((0, import_jsonc_parser.findNodeAtLocation)(node, ["preloadData"]), `${propPrefix}.preloadData`);
|
|
50
51
|
validationContext.assertIsBoolean((0, import_jsonc_parser.findNodeAtLocation)(node, ["mixedMode"]), `${propPrefix}.mixedMode`);
|
|
51
52
|
validationContext.assertIsBoolean((0, import_jsonc_parser.findNodeAtLocation)(node, ["configAsSrc"]), `${propPrefix}.configAsSrc`);
|
|
52
53
|
validationContext.assertIsSpecifier((0, import_jsonc_parser.findNodeAtLocation)(node, ["module"]), `${propPrefix}.module`);
|
|
53
54
|
validationContext.assertIsBoolean((0, import_jsonc_parser.findNodeAtLocation)(node, ["syntheticShadow"]), `${propPrefix}.syntheticShadow`);
|
|
55
|
+
validationContext.assertSsrPreloadData(node, propPrefix);
|
|
54
56
|
const workers = (0, import_jsonc_parser.findNodeAtLocation)(node, ["workers"]);
|
|
55
57
|
if (workers && workers.children) {
|
|
56
58
|
workers.children.forEach((w, index) => {
|
|
@@ -242,7 +244,6 @@ function validateRoot(node, validationContext, preMerge) {
|
|
|
242
244
|
validateLocker(lockerNode, validationContext);
|
|
243
245
|
validateI18NConfig((0, import_jsonc_parser.findNodeAtLocation)(node, ["i18n"]), validationContext, preMerge);
|
|
244
246
|
validateBundleConfig(bundleConfigNode, validationContext);
|
|
245
|
-
validationContext.assertClientLockerSSR(routes, lockerNode);
|
|
246
247
|
validationContext.assertNotEmptyString((0, import_jsonc_parser.findNodeAtLocation)(node, ["apiVersion"]), "apiVersion");
|
|
247
248
|
validationContext.assertNotEmptyString((0, import_jsonc_parser.findNodeAtLocation)(node, ["lwrVersion"]), "lwrVersion");
|
|
248
249
|
validationContext.assertIsSpecifier((0, import_jsonc_parser.findNodeAtLocation)(node, ["amdLoader"]), "amdLoader");
|
package/build/es/defaults.d.ts
CHANGED
|
@@ -3,8 +3,6 @@ export declare const LWR_VERSION: string;
|
|
|
3
3
|
export declare const DEFAULT_LWR_CONFIG_JSON = "$rootDir/lwr.config.json";
|
|
4
4
|
export declare const DEFAULT_GENERATOR_CONFIG: StaticSiteGenerator;
|
|
5
5
|
export declare const DEFAULT_ROOT_DIR: string;
|
|
6
|
-
export declare const SSR_MODULE_PROVIDER = "@lwrjs/lwc-ssr/moduleProvider";
|
|
7
|
-
export declare const SSR_VIEW_TRANSFORM_PLUGIN = "@lwrjs/lwc-ssr/viewTransformer";
|
|
8
6
|
export declare const DEFAULT_AMD_LOADER = "lwr/loader";
|
|
9
7
|
export declare const DEFAULT_AMD_LOADER_LEGACY = "lwr/loaderLegacy";
|
|
10
8
|
export declare const DEFAULT_ESM_LOADER = "lwr/esmLoader";
|
package/build/es/defaults.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { DEFAULT_LWR_LOCKER_CONFIG, getFeatureFlags } from '@lwrjs/shared-utils';
|
|
2
|
-
import {
|
|
2
|
+
import { lwrVersion } from '@lwrjs/config/package';
|
|
3
3
|
import { DEFAULT_I18N_CONFIG, getServerModeConfig } from './runtime-config.js';
|
|
4
4
|
const PORT = process.env.PORT ? parseInt(process.env.PORT, 10) : 3000;
|
|
5
5
|
const MODE = process.env.MODE || 'prod';
|
|
6
6
|
const DEFAULT_BASE_PATH = '';
|
|
7
7
|
const DEFAULT_API_VERSION = '1';
|
|
8
|
-
export const LWR_VERSION =
|
|
8
|
+
export const LWR_VERSION = lwrVersion;
|
|
9
9
|
const DEFAULT_SERVER_TYPE = 'express';
|
|
10
10
|
export const DEFAULT_LWR_CONFIG_JSON = '$rootDir/lwr.config.json';
|
|
11
11
|
export const DEFAULT_GENERATOR_CONFIG = {
|
|
@@ -27,9 +27,9 @@ const DEFAULT_MODULE_PROVIDERS = [
|
|
|
27
27
|
'@lwrjs/app-service/moduleProvider',
|
|
28
28
|
'@lwrjs/router/module-provider',
|
|
29
29
|
'@lwrjs/lwc-module-provider',
|
|
30
|
+
'@lwrjs/lwc-ssr/moduleProvider',
|
|
30
31
|
'@lwrjs/npm-module-provider',
|
|
31
32
|
];
|
|
32
|
-
export const SSR_MODULE_PROVIDER = '@lwrjs/lwc-ssr/moduleProvider';
|
|
33
33
|
const DEFAULT_RESOURCE_PROVIDERS = ['@lwrjs/loader'];
|
|
34
34
|
const DEFAULT_VIEW_PROVIDERS = [
|
|
35
35
|
'@lwrjs/nunjucks-view-provider',
|
|
@@ -41,9 +41,12 @@ const DEFAULT_BUNDLE_PROVIDERS = [
|
|
|
41
41
|
'@lwrjs/module-bundler/amd-bundle-provider',
|
|
42
42
|
'@lwrjs/module-bundler/esm-bundle-provider',
|
|
43
43
|
];
|
|
44
|
-
const DEFAULT_VIEW_TRANSFORM_PLUGINS = ['@lwrjs/base-view-transformer'];
|
|
45
|
-
export const SSR_VIEW_TRANSFORM_PLUGIN = '@lwrjs/lwc-ssr/viewTransformer';
|
|
46
44
|
const DEFAULT_ASSET_PROVIDERS = ['@lwrjs/fs-asset-provider'];
|
|
45
|
+
const DEFAULT_VIEW_TRANSFORM_PLUGINS = [
|
|
46
|
+
'@lwrjs/base-view-transformer',
|
|
47
|
+
'@lwrjs/lwc-ssr/viewTransformer',
|
|
48
|
+
'@lwrjs/lwc-ssr/dataViewTransformer',
|
|
49
|
+
];
|
|
47
50
|
const DEFAULT_ASSET_TRANSFORM_PLUGINS = ['@lwrjs/asset-transformer'];
|
|
48
51
|
const DEFAULT_URI_TRANSFORM_PLUGINS = [];
|
|
49
52
|
export const DEFAULT_AMD_LOADER = 'lwr/loader';
|
|
@@ -114,7 +117,13 @@ export const DEFAULT_LWR_CONFIG = {
|
|
|
114
117
|
viewTransformers: DEFAULT_VIEW_TRANSFORM_PLUGINS,
|
|
115
118
|
environment: {},
|
|
116
119
|
lwc: { modules: [] },
|
|
117
|
-
routes: [
|
|
120
|
+
routes: [
|
|
121
|
+
{
|
|
122
|
+
id: 'lwrInfo',
|
|
123
|
+
path: '/lwr-info',
|
|
124
|
+
routeHandler: `@lwrjs/core/info/route-handler`,
|
|
125
|
+
},
|
|
126
|
+
],
|
|
118
127
|
errorRoutes: [],
|
|
119
128
|
routeHandlers: {},
|
|
120
129
|
bundleConfig: getDefaultBundleConfig(MODE),
|
|
@@ -24,13 +24,6 @@ export interface Configurations {
|
|
|
24
24
|
* @returns {LwrGlobalConfig | undefined} the validated config file contents if it exists
|
|
25
25
|
*/
|
|
26
26
|
export declare function getLwrConfigFromFile(rootDir: string, lwrConfigPath?: string): LwrGlobalConfig | undefined;
|
|
27
|
-
/**
|
|
28
|
-
* Add the SSR module provider and view transformer, if any route has `ssr` turned on.
|
|
29
|
-
*
|
|
30
|
-
* @param {NormalizedLwrGlobalConfig} config - a normalized global config to check / mutate
|
|
31
|
-
* @returns {NormalizedLwrGlobalConfig} an SSR-enabled normalized global config, if needed
|
|
32
|
-
*/
|
|
33
|
-
export declare function applySsrConfig(config: NormalizedLwrGlobalConfig): NormalizedLwrGlobalConfig;
|
|
34
27
|
/**
|
|
35
28
|
* Apply Static Providers for MRT runtime (used exclusively by buildServer)
|
|
36
29
|
*
|
|
@@ -3,7 +3,6 @@ import path from 'path';
|
|
|
3
3
|
import { parse } from 'jsonc-parser';
|
|
4
4
|
import { logger } from '@lwrjs/diagnostics';
|
|
5
5
|
import { readFile, normalizeDirectory, getFeatureFlags, ASSETS_CACHE_DIR } from '@lwrjs/shared-utils';
|
|
6
|
-
import { SSR_MODULE_PROVIDER, SSR_VIEW_TRANSFORM_PLUGIN } from './defaults.js';
|
|
7
6
|
import { DEFAULT_AMD_LOADER, DEFAULT_AMD_LOADER_LEGACY, DEFAULT_ESM_LOADER, DEFAULT_LWR_CONFIG, DEFAULT_LWR_CONFIG_JSON, DEFAULT_ROOT_DIR, LWR_VERSION, } from './defaults.js';
|
|
8
7
|
import { validateLwrAppConfig } from './validation/app-config.js';
|
|
9
8
|
import { normalizeAssetPaths, normalizeAssets } from './utils/assets.js';
|
|
@@ -78,6 +77,10 @@ function mergeConfig(configArg) {
|
|
|
78
77
|
const configFile = !configArg?.ignoreLwrConfigFile
|
|
79
78
|
? getLwrConfigFromFile(rootDir, configArg?.lwrConfigFile)
|
|
80
79
|
: undefined;
|
|
80
|
+
// merge default routes with the config file routes
|
|
81
|
+
if (configFile) {
|
|
82
|
+
configFile.routes = (configFile?.routes ?? []).concat(DEFAULT_LWR_CONFIG.routes);
|
|
83
|
+
}
|
|
81
84
|
// merge the various configs in order of priority
|
|
82
85
|
return {
|
|
83
86
|
...DEFAULT_LWR_CONFIG,
|
|
@@ -172,33 +175,6 @@ function normalizeConfigPaths(config) {
|
|
|
172
175
|
routeHandlers: normalizeRouteHandlerPaths(config.routeHandlers, resourcePaths),
|
|
173
176
|
};
|
|
174
177
|
}
|
|
175
|
-
/**
|
|
176
|
-
* Add the SSR module provider and view transformer, if any route has `ssr` turned on.
|
|
177
|
-
*
|
|
178
|
-
* @param {NormalizedLwrGlobalConfig} config - a normalized global config to check / mutate
|
|
179
|
-
* @returns {NormalizedLwrGlobalConfig} an SSR-enabled normalized global config, if needed
|
|
180
|
-
*/
|
|
181
|
-
export function applySsrConfig(config) {
|
|
182
|
-
// check if any route has SSR turned on
|
|
183
|
-
const hasSSR = config.routes.some((r) => r.bootstrap.ssr);
|
|
184
|
-
if (!hasSSR) {
|
|
185
|
-
return config;
|
|
186
|
-
}
|
|
187
|
-
// add the SSR configuration, if it's not already there
|
|
188
|
-
// note: this is a noop when called from an onStart hook of an LWR@MRT app,
|
|
189
|
-
// since the app has already been built / rolled up
|
|
190
|
-
const hasSsrModuleProvider = config.moduleProviders.some(([m]) => m === SSR_MODULE_PROVIDER);
|
|
191
|
-
const hasSsrViewTransformer = config.viewTransformers.some(([v]) => v === SSR_VIEW_TRANSFORM_PLUGIN);
|
|
192
|
-
return {
|
|
193
|
-
...config,
|
|
194
|
-
moduleProviders: hasSsrModuleProvider
|
|
195
|
-
? config.moduleProviders
|
|
196
|
-
: [[SSR_MODULE_PROVIDER, undefined], ...config.moduleProviders],
|
|
197
|
-
viewTransformers: hasSsrViewTransformer
|
|
198
|
-
? config.viewTransformers
|
|
199
|
-
: [...config.viewTransformers, [SSR_VIEW_TRANSFORM_PLUGIN, undefined]],
|
|
200
|
-
};
|
|
201
|
-
}
|
|
202
178
|
/**
|
|
203
179
|
* Apply Static Providers for MRT runtime (used exclusively by buildServer)
|
|
204
180
|
*
|
|
@@ -211,7 +187,10 @@ export function applyStaticProviderConfig(config) {
|
|
|
211
187
|
assetProviders: [['@lwrjs/static/asset-provider', undefined]],
|
|
212
188
|
assetTransformers: [],
|
|
213
189
|
resourceProviders: [['@lwrjs/static/resource-provider', {}]],
|
|
214
|
-
moduleProviders: [
|
|
190
|
+
moduleProviders: [
|
|
191
|
+
['@lwrjs/static/module-provider', undefined],
|
|
192
|
+
['@lwrjs/lwc-ssr/moduleProvider', undefined],
|
|
193
|
+
],
|
|
215
194
|
bundleProviders: [
|
|
216
195
|
['@lwrjs/static/bundle-provider', undefined],
|
|
217
196
|
['@lwrjs/module-bundler/amd-runtime-bundle-provider', undefined],
|
|
@@ -242,8 +221,6 @@ export function resolveGlobalConfig(configArg, options) {
|
|
|
242
221
|
if (options?.useStaticProviders) {
|
|
243
222
|
normalizedConfig = applyStaticProviderConfig(normalizedConfig);
|
|
244
223
|
}
|
|
245
|
-
// Add SSR config if applicable
|
|
246
|
-
normalizedConfig = applySsrConfig(normalizedConfig);
|
|
247
224
|
// skip cache dir creation when the option is set
|
|
248
225
|
if (!options?.skipCacheDirCreation) {
|
|
249
226
|
createCacheFolder(normalizedConfig.cacheDir, normalizedConfig.rootDir);
|
package/build/es/hooks.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { GlobalData, HooksPlugin, NormalizedLwrGlobalConfig, RuntimeEnvironment } from '@lwrjs/types';
|
|
1
|
+
import type { GlobalData, HooksPlugin, NormalizedLwrGlobalConfig, RuntimeEnvironment, ServerContext } from '@lwrjs/types';
|
|
2
2
|
/**
|
|
3
3
|
* Run `initConfigs` hooks
|
|
4
4
|
*
|
|
@@ -30,4 +30,5 @@ export declare function executeConfigHooks(hooks: HooksPlugin[], globalConfig: N
|
|
|
30
30
|
*/
|
|
31
31
|
export declare function executeStartHooks(hooks: HooksPlugin[], globalConfig: NormalizedLwrGlobalConfig, runtimeEnvironment: RuntimeEnvironment, skipValidate?: boolean): void;
|
|
32
32
|
export declare function executeInstrumentationHooks(hooks: HooksPlugin[]): boolean;
|
|
33
|
+
export declare function executeContextHooks(hooks: HooksPlugin[], serverContext: ServerContext): Promise<void>;
|
|
33
34
|
//# sourceMappingURL=hooks.d.ts.map
|
package/build/es/hooks.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { normalizeRoutes } from './utils/routes.js';
|
|
2
2
|
import { validateLwrAppConfig } from './validation/app-config.js';
|
|
3
|
-
import { applySsrConfig } from './global-config.js';
|
|
4
3
|
import { getTracer, ConfigSpan } from '@lwrjs/instrumentation';
|
|
5
4
|
/**
|
|
6
5
|
* Run `initConfigs` hooks
|
|
@@ -31,9 +30,6 @@ export async function executeConfigHooks(hooks, globalConfig, runtimeEnvironment
|
|
|
31
30
|
}
|
|
32
31
|
globalConfig.routes = normalizeRoutes(globalConfig.routes, globalConfig.routeHandlers);
|
|
33
32
|
globalConfig.errorRoutes = normalizeRoutes(globalConfig.errorRoutes, globalConfig.routeHandlers);
|
|
34
|
-
const ssrConfig = applySsrConfig(globalConfig);
|
|
35
|
-
globalConfig.moduleProviders = ssrConfig.moduleProviders;
|
|
36
|
-
globalConfig.viewTransformers = ssrConfig.viewTransformers;
|
|
37
33
|
if (!skipValidate) {
|
|
38
34
|
validateLwrAppConfig(globalConfig, 'post');
|
|
39
35
|
}
|
|
@@ -78,9 +74,6 @@ export function executeStartHooks(hooks, globalConfig, runtimeEnvironment, skipV
|
|
|
78
74
|
}
|
|
79
75
|
globalConfig.routes = normalizeRoutes(globalConfig.routes, globalConfig.routeHandlers);
|
|
80
76
|
globalConfig.errorRoutes = normalizeRoutes(globalConfig.errorRoutes, globalConfig.routeHandlers);
|
|
81
|
-
const ssrConfig = applySsrConfig(globalConfig);
|
|
82
|
-
globalConfig.moduleProviders = ssrConfig.moduleProviders;
|
|
83
|
-
globalConfig.viewTransformers = ssrConfig.viewTransformers;
|
|
84
77
|
if (!skipValidate) {
|
|
85
78
|
validateLwrAppConfig(globalConfig, 'post');
|
|
86
79
|
}
|
|
@@ -99,4 +92,16 @@ export function executeInstrumentationHooks(hooks) {
|
|
|
99
92
|
span.end();
|
|
100
93
|
return retVal;
|
|
101
94
|
}
|
|
95
|
+
export async function executeContextHooks(hooks, serverContext) {
|
|
96
|
+
if (!hooks.length) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
for (const hook of hooks) {
|
|
100
|
+
if (!hook.setupServerContext) {
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
// eslint-disable-next-line no-await-in-loop
|
|
104
|
+
await hook.setupServerContext(serverContext, hooks);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
102
107
|
//# sourceMappingURL=hooks.js.map
|
package/build/es/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { lwrVersion as LWR_VERSION, lwcVersion as LWC_VERSION, nodeVersion as NODE_VERSION, pwaKitRuntimeVersion as PWA_KIT_RUNTIME_VERSION, } from '@lwrjs/config/package';
|
|
2
2
|
export { loadConfig, resolveGlobalConfig as normalizeConfig, getLwrConfigFromFile } from './global-config.js';
|
|
3
3
|
export { getRuntimeEnvironment } from './runtime-config.js';
|
|
4
|
-
export
|
|
4
|
+
export * from './hooks.js';
|
|
5
5
|
export { validateLwrAppConfig } from './validation/app-config.js';
|
|
6
6
|
//# sourceMappingURL=index.d.ts.map
|
package/build/es/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { lwrVersion as LWR_VERSION, lwcVersion as LWC_VERSION, nodeVersion as NODE_VERSION, pwaKitRuntimeVersion as PWA_KIT_RUNTIME_VERSION, } from '@lwrjs/config/package';
|
|
2
2
|
export { loadConfig, resolveGlobalConfig as normalizeConfig, getLwrConfigFromFile } from './global-config.js';
|
|
3
3
|
export { getRuntimeEnvironment } from './runtime-config.js';
|
|
4
|
-
export
|
|
4
|
+
export * from './hooks.js';
|
|
5
5
|
export { validateLwrAppConfig } from './validation/app-config.js';
|
|
6
6
|
//# sourceMappingURL=index.js.map
|
package/build/es/utils/routes.js
CHANGED
|
@@ -6,6 +6,18 @@ export function normalizeRoutes(routes, routeHandlers) {
|
|
|
6
6
|
// normalize the bootstrap services
|
|
7
7
|
const rawServices = route?.bootstrap?.services || [];
|
|
8
8
|
const services = rawServices.map((s) => (typeof s === 'string' ? { name: s, ssr: false } : s));
|
|
9
|
+
// default preloadData to true if ssr is true
|
|
10
|
+
const preloadData = route.bootstrap?.preloadData === undefined
|
|
11
|
+
? route.bootstrap?.ssr === true
|
|
12
|
+
? true
|
|
13
|
+
: false
|
|
14
|
+
: route.bootstrap?.preloadData;
|
|
15
|
+
const bootstrap = {
|
|
16
|
+
...DEFAULT_LWR_BOOTSTRAP_CONFIG,
|
|
17
|
+
...route.bootstrap,
|
|
18
|
+
preloadData,
|
|
19
|
+
services,
|
|
20
|
+
};
|
|
9
21
|
// when a route handler is set, ensure it is set in the route handler config
|
|
10
22
|
if (route.routeHandler) {
|
|
11
23
|
const handler = typeof route.routeHandler === 'string' ? route.routeHandler : route.routeHandler[0];
|
|
@@ -17,20 +29,12 @@ export function normalizeRoutes(routes, routeHandlers) {
|
|
|
17
29
|
routeHandler: typeof route.routeHandler === 'string'
|
|
18
30
|
? [route.routeHandler, undefined]
|
|
19
31
|
: route.routeHandler,
|
|
20
|
-
bootstrap
|
|
21
|
-
...DEFAULT_LWR_BOOTSTRAP_CONFIG,
|
|
22
|
-
...route.bootstrap,
|
|
23
|
-
services,
|
|
24
|
-
},
|
|
32
|
+
bootstrap,
|
|
25
33
|
};
|
|
26
34
|
}
|
|
27
35
|
return {
|
|
28
36
|
...route,
|
|
29
|
-
bootstrap
|
|
30
|
-
...DEFAULT_LWR_BOOTSTRAP_CONFIG,
|
|
31
|
-
...route.bootstrap,
|
|
32
|
-
services,
|
|
33
|
-
},
|
|
37
|
+
bootstrap,
|
|
34
38
|
};
|
|
35
39
|
});
|
|
36
40
|
}
|
|
@@ -28,12 +28,12 @@ interface ConfigMap {
|
|
|
28
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"];
|
|
29
29
|
export declare const ASSET_DIR_ATTRIBUTE_KEYS: ["alias", "dir", "urlPath", "root"];
|
|
30
30
|
export declare const ASSET_FILE_ATTRIBUTE_KEYS: ["alias", "file", "urlPath"];
|
|
31
|
-
export declare const LOCKER_ATTRIBUTE_KEYS: ["enabled", "trustedComponents"
|
|
31
|
+
export declare const LOCKER_ATTRIBUTE_KEYS: ["enabled", "trustedComponents"];
|
|
32
32
|
export declare const I18N_ATTRIBUTE_KEYS: ["defaultLocale", "locales", "uriPattern"];
|
|
33
33
|
export declare const STATIC_SITE_GENERATOR_ATTRIBUTE_KEYS: ["outputDir", "skipBaseDocumentGeneration", "skipCleanOutputDir", "_additionalModules", "_additionalRoutePaths"];
|
|
34
34
|
export declare const ROUTE_ATTRIBUTE_KEYS: ["bootstrap", "subRoutes", "contentTemplate", "id", "cache", "layoutTemplate", "method", "path", "rootComponent", "routeHandler", "properties"];
|
|
35
35
|
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", "mixedMode", "module", "preloadModules"];
|
|
36
|
+
export declare const BOOTSTRAP_ATTRIBUTE_KEYS: ["autoBoot", "syntheticShadow", "workers", "services", "configAsSrc", "ssr", "preloadData", "mixedMode", "module", "preloadModules"];
|
|
37
37
|
export declare const BASE_PATH_REGEX: RegExp;
|
|
38
38
|
export declare class ValidationContext {
|
|
39
39
|
diagnostics: Diagnostic[];
|
|
@@ -63,12 +63,12 @@ export declare class ValidationContext {
|
|
|
63
63
|
assertIsStringOrObject(node: Node | undefined, property: string, index?: number): void;
|
|
64
64
|
assertIsService(node: Node | undefined, property: string, index?: number): void;
|
|
65
65
|
assertUniqueIds(nodes: Node[], property: string): void;
|
|
66
|
-
assertClientLockerSSR(routesNode: Node | undefined, lockerNode: Node | undefined): void;
|
|
67
66
|
assertRequiredKeys(node: Node, property: string, requiredPropertyKeys: string[]): void;
|
|
68
67
|
assertValidKeys<T extends keyof ConfigMap>(node: Node, property: T, validPropertyKeys: (keyof ConfigMap[T])[]): void;
|
|
69
68
|
assertNoBundleConfigDupes(node: Node, dupes: string[]): void;
|
|
70
69
|
assertDefaultInLocales(node: Node, defaultLocale: string, localesIds: string[]): void;
|
|
71
70
|
assertFallbackIds(nodes: Node[]): void;
|
|
71
|
+
assertSsrPreloadData(node: Node, propPrefix: string): void;
|
|
72
72
|
}
|
|
73
73
|
export {};
|
|
74
74
|
//# sourceMappingURL=app-config-context.d.ts.map
|
|
@@ -47,7 +47,7 @@ export const ROOT_ATTRIBUTE_KEYS = createKeys('root', [
|
|
|
47
47
|
]);
|
|
48
48
|
export const ASSET_DIR_ATTRIBUTE_KEYS = createKeys('assetDir', ['alias', 'dir', 'urlPath', 'root']);
|
|
49
49
|
export const ASSET_FILE_ATTRIBUTE_KEYS = createKeys('assetFile', ['alias', 'file', 'urlPath']);
|
|
50
|
-
export const LOCKER_ATTRIBUTE_KEYS = createKeys('locker', ['enabled', 'trustedComponents'
|
|
50
|
+
export const LOCKER_ATTRIBUTE_KEYS = createKeys('locker', ['enabled', 'trustedComponents']);
|
|
51
51
|
export const I18N_ATTRIBUTE_KEYS = createKeys('i18n', ['defaultLocale', 'locales', 'uriPattern']);
|
|
52
52
|
export const STATIC_SITE_GENERATOR_ATTRIBUTE_KEYS = createKeys('staticSiteGenerator', [
|
|
53
53
|
'outputDir',
|
|
@@ -88,6 +88,7 @@ export const BOOTSTRAP_ATTRIBUTE_KEYS = createKeys('bootstrap', [
|
|
|
88
88
|
'services',
|
|
89
89
|
'configAsSrc',
|
|
90
90
|
'ssr',
|
|
91
|
+
'preloadData',
|
|
91
92
|
'mixedMode',
|
|
92
93
|
'module',
|
|
93
94
|
'preloadModules',
|
|
@@ -420,28 +421,6 @@ export class ValidationContext {
|
|
|
420
421
|
});
|
|
421
422
|
}
|
|
422
423
|
}
|
|
423
|
-
assertClientLockerSSR(routesNode, lockerNode) {
|
|
424
|
-
if (routesNode && lockerNode) {
|
|
425
|
-
const enabled = findNodeAtLocation(lockerNode, ['enabled']);
|
|
426
|
-
const clientOnly = findNodeAtLocation(lockerNode, ['clientOnly']);
|
|
427
|
-
const compileTimeLocker = enabled && enabled.value === true && (!clientOnly || clientOnly.value === false);
|
|
428
|
-
if (compileTimeLocker && routesNode.children) {
|
|
429
|
-
const hasSSR = routesNode.children.some((n) => {
|
|
430
|
-
const bootstrap = findNodeAtLocation(n, ['bootstrap']);
|
|
431
|
-
if (bootstrap) {
|
|
432
|
-
const ssr = findNodeAtLocation(bootstrap, ['ssr']);
|
|
433
|
-
return ssr?.value === true;
|
|
434
|
-
}
|
|
435
|
-
});
|
|
436
|
-
if (hasSSR) {
|
|
437
|
-
this.diagnostics.push({
|
|
438
|
-
description: descriptions.CONFIG_PARSER.COMPILE_LOCKER_SSR(),
|
|
439
|
-
location: this.getLocationFromNode(lockerNode),
|
|
440
|
-
});
|
|
441
|
-
}
|
|
442
|
-
}
|
|
443
|
-
}
|
|
444
|
-
}
|
|
445
424
|
assertRequiredKeys(node, property, requiredPropertyKeys) {
|
|
446
425
|
// All of the given properties must exist on the node
|
|
447
426
|
const missingProps = requiredPropertyKeys.filter((p) => findNodeAtLocation(node, [p]) === undefined);
|
|
@@ -511,5 +490,15 @@ export class ValidationContext {
|
|
|
511
490
|
}
|
|
512
491
|
}
|
|
513
492
|
}
|
|
493
|
+
assertSsrPreloadData(node, propPrefix) {
|
|
494
|
+
const ssr = findNodeAtLocation(node, ['ssr'])?.value;
|
|
495
|
+
const preloadData = findNodeAtLocation(node, ['preloadData'])?.value;
|
|
496
|
+
if (ssr === true && preloadData === false) {
|
|
497
|
+
this.diagnostics.push({
|
|
498
|
+
description: descriptions.CONFIG_PARSER.SSR_WITHOUT_PRELOAD(propPrefix),
|
|
499
|
+
location: this.getLocationFromNode(node),
|
|
500
|
+
});
|
|
501
|
+
}
|
|
502
|
+
}
|
|
514
503
|
}
|
|
515
504
|
//# sourceMappingURL=app-config-context.js.map
|
|
@@ -28,10 +28,12 @@ function validateBootstrap(node, validationContext, propPrefix) {
|
|
|
28
28
|
validationContext.assertArrayOfSpecifiers(findNode(node, ['preloadModules']), `${propPrefix}.preloadModules`);
|
|
29
29
|
validationContext.assertIsBoolean(findNode(node, ['autoBoot']), `${propPrefix}.autoBoot`);
|
|
30
30
|
validationContext.assertIsBoolean(findNode(node, ['ssr']), `${propPrefix}.ssr`);
|
|
31
|
+
validationContext.assertIsBoolean(findNode(node, ['preloadData']), `${propPrefix}.preloadData`);
|
|
31
32
|
validationContext.assertIsBoolean(findNode(node, ['mixedMode']), `${propPrefix}.mixedMode`);
|
|
32
33
|
validationContext.assertIsBoolean(findNode(node, ['configAsSrc']), `${propPrefix}.configAsSrc`);
|
|
33
34
|
validationContext.assertIsSpecifier(findNode(node, ['module']), `${propPrefix}.module`);
|
|
34
35
|
validationContext.assertIsBoolean(findNode(node, ['syntheticShadow']), `${propPrefix}.syntheticShadow`);
|
|
36
|
+
validationContext.assertSsrPreloadData(node, propPrefix);
|
|
35
37
|
// Each value in the worker map msut be a specifier
|
|
36
38
|
const workers = findNode(node, ['workers']);
|
|
37
39
|
if (workers && workers.children) {
|
|
@@ -271,7 +273,6 @@ function validateLocker(node, validationContext) {
|
|
|
271
273
|
* - errorRoutes...
|
|
272
274
|
* - assets...
|
|
273
275
|
* - locker...
|
|
274
|
-
* - SSR is only used with clientOnly locker (or locker is disabled)
|
|
275
276
|
* - route and errorRoute ids must be unique
|
|
276
277
|
* - apiVersion: string
|
|
277
278
|
* - lwrVersion: string
|
|
@@ -308,7 +309,6 @@ function validateRoot(node, validationContext, preMerge) {
|
|
|
308
309
|
validateLocker(lockerNode, validationContext);
|
|
309
310
|
validateI18NConfig(findNode(node, ['i18n']), validationContext, preMerge);
|
|
310
311
|
validateBundleConfig(bundleConfigNode, validationContext);
|
|
311
|
-
validationContext.assertClientLockerSSR(routes, lockerNode);
|
|
312
312
|
validationContext.assertNotEmptyString(findNode(node, ['apiVersion']), 'apiVersion');
|
|
313
313
|
validationContext.assertNotEmptyString(findNode(node, ['lwrVersion']), 'lwrVersion');
|
|
314
314
|
validationContext.assertIsSpecifier(findNode(node, ['amdLoader']), 'amdLoader');
|
package/package.cjs
CHANGED
|
@@ -4,17 +4,17 @@ const resolve = require('resolve');
|
|
|
4
4
|
const rootPath = path.join(__dirname, './');
|
|
5
5
|
|
|
6
6
|
// Get the LWR Version
|
|
7
|
-
let
|
|
7
|
+
let lwrVersion;
|
|
8
8
|
if (globalThis.LWR_VERSION) {
|
|
9
|
-
|
|
9
|
+
lwrVersion = globalThis.LWR_VERSION;
|
|
10
10
|
} else {
|
|
11
|
-
|
|
11
|
+
lwrVersion = JSON.parse(fs.readFileSync(path.join(rootPath, 'package.json'), 'utf-8')).version;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
// Get the LWC Version
|
|
15
15
|
let lwcVersion;
|
|
16
16
|
if (globalThis.LWC_VERSION) {
|
|
17
|
-
|
|
17
|
+
lwcVersion = globalThis.LWC_VERSION;
|
|
18
18
|
} else {
|
|
19
19
|
try {
|
|
20
20
|
const packageJsonPath = resolve.sync(`lwc/package.json`);
|
|
@@ -26,8 +26,23 @@ if (globalThis.LWC_VERSION) {
|
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
+
// Get the PWA Kit Dev Runtime Version
|
|
30
|
+
let pwaKitRuntimeVersion;
|
|
31
|
+
try {
|
|
32
|
+
const packageJsonPath = resolve.sync(`@salesforce/pwa-kit-runtime/package.json`);
|
|
33
|
+
const { version: packageVersion } = JSON.parse(fs.readFileSync(packageJsonPath), 'utf-8');
|
|
34
|
+
pwaKitRuntimeVersion = packageVersion;
|
|
35
|
+
} catch(err) {
|
|
36
|
+
console.log(`[config] peer dependency pwa-kit-runtime was not provided`);
|
|
37
|
+
pwaKitRuntimeVersion = 'not-provided';
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const nodeVersion = process.version
|
|
41
|
+
|
|
29
42
|
module.exports = {
|
|
30
43
|
rootPath,
|
|
31
|
-
|
|
32
|
-
lwcVersion
|
|
44
|
+
lwrVersion,
|
|
45
|
+
lwcVersion,
|
|
46
|
+
nodeVersion,
|
|
47
|
+
pwaKitRuntimeVersion
|
|
33
48
|
};
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
|
-
"version": "0.12.0-alpha.
|
|
7
|
+
"version": "0.12.0-alpha.11",
|
|
8
8
|
"homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
"build/**/*.js",
|
|
34
34
|
"build/**/*.cjs",
|
|
35
35
|
"build/**/*.d.ts",
|
|
36
|
+
"types/**/*.d.ts",
|
|
36
37
|
"package.cjs"
|
|
37
38
|
],
|
|
38
39
|
"scripts": {
|
|
@@ -41,14 +42,14 @@
|
|
|
41
42
|
"test": "jest"
|
|
42
43
|
},
|
|
43
44
|
"dependencies": {
|
|
44
|
-
"@lwrjs/diagnostics": "0.12.0-alpha.
|
|
45
|
-
"@lwrjs/instrumentation": "0.12.0-alpha.
|
|
46
|
-
"@lwrjs/shared-utils": "0.12.0-alpha.
|
|
45
|
+
"@lwrjs/diagnostics": "0.12.0-alpha.11",
|
|
46
|
+
"@lwrjs/instrumentation": "0.12.0-alpha.11",
|
|
47
|
+
"@lwrjs/shared-utils": "0.12.0-alpha.11",
|
|
47
48
|
"fs-extra": "^11.1.1",
|
|
48
49
|
"jsonc-parser": "^3.0.0"
|
|
49
50
|
},
|
|
50
51
|
"devDependencies": {
|
|
51
|
-
"@lwrjs/types": "0.12.0-alpha.
|
|
52
|
+
"@lwrjs/types": "0.12.0-alpha.11",
|
|
52
53
|
"jest": "^26.6.3",
|
|
53
54
|
"ts-jest": "^26.5.6"
|
|
54
55
|
},
|
|
@@ -64,10 +65,10 @@
|
|
|
64
65
|
}
|
|
65
66
|
},
|
|
66
67
|
"engines": {
|
|
67
|
-
"node": ">=
|
|
68
|
+
"node": ">=18.0.0"
|
|
68
69
|
},
|
|
69
70
|
"volta": {
|
|
70
71
|
"extends": "../../../package.json"
|
|
71
72
|
},
|
|
72
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "781951a5ef92ce735cbffce7c7a2a32c60bd3c16"
|
|
73
74
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
declare module '@lwrjs/config/package' {
|
|
2
|
+
export const version: string;
|
|
3
|
+
export const lwcVersion: string;
|
|
4
|
+
export const rootPath: string;
|
|
5
|
+
export const lwrVersion: string;
|
|
6
|
+
export const nodeVersion: string;
|
|
7
|
+
export const pwaKitRuntimeVersion: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
declare module '@lwrjs/instrumentation/package' {
|
|
11
|
+
export const version: string;
|
|
12
|
+
export const rootPath: string;
|
|
13
|
+
}
|