@lwrjs/config 0.8.0-alpha.3
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/LICENSE +10 -0
- package/build/cjs/env-config.cjs +339 -0
- package/build/cjs/index.cjs +32 -0
- package/build/cjs/validation/app-config-context.cjs +406 -0
- package/build/cjs/validation/app-config.cjs +192 -0
- package/build/cjs/validation/helpers.cjs +34 -0
- package/build/es/env-config.d.ts +14 -0
- package/build/es/env-config.js +352 -0
- package/build/es/index.d.ts +4 -0
- package/build/es/index.js +5 -0
- package/build/es/validation/app-config-context.d.ts +55 -0
- package/build/es/validation/app-config-context.js +391 -0
- package/build/es/validation/app-config.d.ts +10 -0
- package/build/es/validation/app-config.js +245 -0
- package/build/es/validation/helpers.d.ts +8 -0
- package/build/es/validation/helpers.js +23 -0
- package/package.cjs +9 -0
- package/package.json +48 -0
- package/runtime-configs/compat.json +13 -0
- package/runtime-configs/dev.json +13 -0
- package/runtime-configs/prod-compat.json +13 -0
- package/runtime-configs/prod.json +13 -0
|
@@ -0,0 +1,352 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { createRequire } from 'module';
|
|
4
|
+
import { ASSETS_CACHE_DIR, readFile, normalizeDirectory, normalizeResourcePath, DEFAULT_LWR_BOOTSTRAP_CONFIG, DEFAULT_LWR_LOCKER_CONFIG, DEFAULT_LOCKER_TRUSTED_CMP, normalizeInterchangeableModuleConfig, getFeatureFlags, } from '@lwrjs/shared-utils';
|
|
5
|
+
import { rootPath, version } from '@lwrjs/config/package';
|
|
6
|
+
import { validateLwrAppConfig } from './validation/app-config.js';
|
|
7
|
+
import { LwrConfigValidationError } from '@lwrjs/diagnostics';
|
|
8
|
+
const PORT = process.env.PORT ? parseInt(process.env.PORT, 10) : 3000;
|
|
9
|
+
const MODE = process.env.MODE || 'dev';
|
|
10
|
+
const DEFAULT_BASE_PATH = '';
|
|
11
|
+
const DEFAULT_API_VERSION = '1';
|
|
12
|
+
const LWR_VERSION = version;
|
|
13
|
+
const DEFAULT_SERVER_TYPE = 'express';
|
|
14
|
+
const DEFAULT_LWR_CONFIG_JSON = '$rootDir/lwr.config.json';
|
|
15
|
+
const DEFAULT_GENERATOR_CONFIG = {
|
|
16
|
+
outputDir: '__generated_site__',
|
|
17
|
+
locales: ['en-US'],
|
|
18
|
+
_additionalRoutePaths: [],
|
|
19
|
+
};
|
|
20
|
+
// Directories
|
|
21
|
+
const DEFAULT_ROOT_DIR = process.cwd();
|
|
22
|
+
const DEFAULT_CACHE_FOLDER = '$rootDir/__lwr_cache__';
|
|
23
|
+
const DEFAULT_ASSETS_DIR = '$rootDir/src/assets';
|
|
24
|
+
const DEFAULT_CONTENT_DIR = '$rootDir/src/content';
|
|
25
|
+
const DEFAULT_LAYOUTS_DIR = '$rootDir/src/layouts';
|
|
26
|
+
const DEFAULT_DATA_DIR = '$rootDir/src/data';
|
|
27
|
+
// Providers
|
|
28
|
+
const DEFAULT_MODULE_PROVIDERS = [
|
|
29
|
+
'@lwrjs/app-service/moduleProvider',
|
|
30
|
+
'@lwrjs/lwc-ssr/moduleProvider',
|
|
31
|
+
'@lwrjs/router/module-provider',
|
|
32
|
+
'@lwrjs/lwc-module-provider',
|
|
33
|
+
'@lwrjs/npm-module-provider',
|
|
34
|
+
];
|
|
35
|
+
const DEFAULT_RESOURCE_PROVIDERS = ['@lwrjs/loader'];
|
|
36
|
+
const DEFAULT_VIEW_PROVIDERS = [
|
|
37
|
+
'@lwrjs/nunjucks-view-provider',
|
|
38
|
+
'@lwrjs/html-view-provider',
|
|
39
|
+
'@lwrjs/markdown-view-provider',
|
|
40
|
+
'@lwrjs/base-view-provider',
|
|
41
|
+
];
|
|
42
|
+
const DEFAULT_VIEW_TRANFORM_PLUGINS = ['@lwrjs/base-view-transformer', '@lwrjs/lwc-ssr/viewTransformer'];
|
|
43
|
+
const DEFAULT_ASSET_PROVIDERS = ['@lwrjs/fs-asset-provider'];
|
|
44
|
+
const DEFAULT_ASSET_TRANFORM_PLUGINS = ['@lwrjs/asset-transformer'];
|
|
45
|
+
// Packages/modules
|
|
46
|
+
const DEFAULT_TEMPLATE_ENGINE = '@lwrjs/base-template-engine';
|
|
47
|
+
const DEFAULT_AMD_LOADER = 'lwr/loader';
|
|
48
|
+
const DEFAULT_AMD_LOADER_LEGACY = 'lwr/loaderLegacy';
|
|
49
|
+
const DEFAULT_ESM_LOADER = 'lwr/esmLoader';
|
|
50
|
+
const DEFAULT_SERVICE_PACKAGE_NAME = /lwr-(\w+)-service/;
|
|
51
|
+
const DEFAULT_LWR_MODULES = [
|
|
52
|
+
{ npm: getLWCEngineSpecifier() },
|
|
53
|
+
{ npm: '@lwrjs/client-modules' },
|
|
54
|
+
{ npm: '@lwrjs/loader' },
|
|
55
|
+
{ npm: '@lwrjs/o11y' },
|
|
56
|
+
{ npm: '@lwrjs/router' },
|
|
57
|
+
{ npm: '@lwc/synthetic-shadow' },
|
|
58
|
+
];
|
|
59
|
+
const DEFAULT_BUNDLE_EXCLUSIONS = [
|
|
60
|
+
'lwc',
|
|
61
|
+
'@lwc/synthetic-shadow',
|
|
62
|
+
'lwr/navigation',
|
|
63
|
+
'lwr/esmLoader',
|
|
64
|
+
'lwr/profiler',
|
|
65
|
+
];
|
|
66
|
+
// Default config objects
|
|
67
|
+
const DEFAULT_LWR_CONFIG = {
|
|
68
|
+
port: PORT,
|
|
69
|
+
ignoreLwrConfigFile: false,
|
|
70
|
+
lwrConfigFile: DEFAULT_LWR_CONFIG_JSON,
|
|
71
|
+
basePath: DEFAULT_BASE_PATH,
|
|
72
|
+
rootDir: DEFAULT_ROOT_DIR,
|
|
73
|
+
cacheDir: DEFAULT_CACHE_FOLDER,
|
|
74
|
+
serverMode: MODE,
|
|
75
|
+
apiVersion: DEFAULT_API_VERSION,
|
|
76
|
+
assets: DEFAULT_ASSETS_DIR,
|
|
77
|
+
assetProviders: DEFAULT_ASSET_PROVIDERS,
|
|
78
|
+
assetTransformers: DEFAULT_ASSET_TRANFORM_PLUGINS,
|
|
79
|
+
contentDir: DEFAULT_CONTENT_DIR,
|
|
80
|
+
layoutsDir: DEFAULT_LAYOUTS_DIR,
|
|
81
|
+
staticSiteGenerator: DEFAULT_GENERATOR_CONFIG,
|
|
82
|
+
globalDataDir: DEFAULT_DATA_DIR,
|
|
83
|
+
globalData: {},
|
|
84
|
+
hooks: [],
|
|
85
|
+
moduleProviders: DEFAULT_MODULE_PROVIDERS,
|
|
86
|
+
resourceProviders: DEFAULT_RESOURCE_PROVIDERS,
|
|
87
|
+
viewProviders: DEFAULT_VIEW_PROVIDERS,
|
|
88
|
+
viewTransformers: DEFAULT_VIEW_TRANFORM_PLUGINS,
|
|
89
|
+
templateEngine: DEFAULT_TEMPLATE_ENGINE,
|
|
90
|
+
environment: {},
|
|
91
|
+
lwc: { modules: [] },
|
|
92
|
+
routes: [],
|
|
93
|
+
errorRoutes: [],
|
|
94
|
+
bundleConfig: { exclude: DEFAULT_BUNDLE_EXCLUSIONS },
|
|
95
|
+
serverType: DEFAULT_SERVER_TYPE,
|
|
96
|
+
locker: DEFAULT_LWR_LOCKER_CONFIG,
|
|
97
|
+
};
|
|
98
|
+
function createCacheFolder(cache, rootDir) {
|
|
99
|
+
const cacheDir = normalizeDirectory(cache, rootDir);
|
|
100
|
+
const absPath = path.resolve(cacheDir);
|
|
101
|
+
fs.mkdirSync(path.join(absPath, ASSETS_CACHE_DIR), { recursive: true });
|
|
102
|
+
return absPath;
|
|
103
|
+
}
|
|
104
|
+
function getLwrConfigFromFile(rootDir, customDir = DEFAULT_LWR_CONFIG_JSON) {
|
|
105
|
+
const lwrConfigPath = path.resolve(normalizeDirectory(customDir, rootDir));
|
|
106
|
+
if (fs.existsSync(lwrConfigPath)) {
|
|
107
|
+
const configAsString = readFile(lwrConfigPath);
|
|
108
|
+
try {
|
|
109
|
+
return validateLwrAppConfig(configAsString, 'file');
|
|
110
|
+
}
|
|
111
|
+
catch (e) {
|
|
112
|
+
if (e instanceof LwrConfigValidationError) {
|
|
113
|
+
// TODO: temporary workaround for https://github.com/salesforce/lwr/issues/825
|
|
114
|
+
if (process.env.UNSAFE_IGNORE_CONFIG_VALIDATION === 'true') {
|
|
115
|
+
console.warn('ignoring config validation errors due to UNSAFE_IGNORE_CONFIG_VALIDATION flag...proceed with caution');
|
|
116
|
+
console.dir(e, { depth: null });
|
|
117
|
+
return JSON.parse(configAsString);
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
throw e;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return undefined;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
console.log(`[Warning] LWR Config not found on "${lwrConfigPath}"`);
|
|
128
|
+
return undefined;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
export function explodeMode(mode) {
|
|
132
|
+
const modeConfigFile = path.join(rootPath, `./runtime-configs/${mode}.json`);
|
|
133
|
+
if (!fs.existsSync(modeConfigFile)) {
|
|
134
|
+
throw new Error(`No configuration found for server mode - ${mode}`);
|
|
135
|
+
}
|
|
136
|
+
const modeConfig = JSON.parse(readFile(modeConfigFile));
|
|
137
|
+
return modeConfig;
|
|
138
|
+
}
|
|
139
|
+
function normalizeServices(services, rootDir) {
|
|
140
|
+
return services.map((service) => {
|
|
141
|
+
const [serviceName, serviceConfig = undefined] = Array.isArray(service) ? service : [service];
|
|
142
|
+
let rawServiceName = normalizeDirectory(serviceName, rootDir);
|
|
143
|
+
// We consider it an npm module if it starts with @ or if is of the form lwr-[servicename]-service
|
|
144
|
+
// Otherwise resolve it as a relative path
|
|
145
|
+
if (!rawServiceName.startsWith('@') && !DEFAULT_SERVICE_PACKAGE_NAME.test(rawServiceName)) {
|
|
146
|
+
rawServiceName = path.resolve(rawServiceName);
|
|
147
|
+
}
|
|
148
|
+
return [rawServiceName, serviceConfig];
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
function normalizeModules(modules, rootDir) {
|
|
152
|
+
return modules.map((m) => {
|
|
153
|
+
const dirRecord = m;
|
|
154
|
+
if (dirRecord.dir) {
|
|
155
|
+
dirRecord.dir = path.resolve(normalizeDirectory(dirRecord.dir, rootDir));
|
|
156
|
+
}
|
|
157
|
+
const aliasRecord = m;
|
|
158
|
+
if (aliasRecord.path) {
|
|
159
|
+
aliasRecord.path = path.resolve(normalizeDirectory(aliasRecord.path, rootDir));
|
|
160
|
+
}
|
|
161
|
+
return m;
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
function normalizeRoutes(routes, resourcePaths) {
|
|
165
|
+
return routes.map((route) => {
|
|
166
|
+
const { routeHandler, contentTemplate, layoutTemplate } = route;
|
|
167
|
+
const bootstrap = {
|
|
168
|
+
...DEFAULT_LWR_BOOTSTRAP_CONFIG,
|
|
169
|
+
...route.bootstrap,
|
|
170
|
+
};
|
|
171
|
+
return {
|
|
172
|
+
...route,
|
|
173
|
+
bootstrap,
|
|
174
|
+
// default routes to be idempotent
|
|
175
|
+
routeHandler: routeHandler && path.resolve(normalizeDirectory(routeHandler, resourcePaths.rootDir)),
|
|
176
|
+
contentTemplate: contentTemplate && path.resolve(normalizeResourcePath(contentTemplate, resourcePaths)),
|
|
177
|
+
layoutTemplate: layoutTemplate && path.resolve(normalizeResourcePath(layoutTemplate, resourcePaths)),
|
|
178
|
+
};
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
function normalizeAssetsDir(assets, rootDir) {
|
|
182
|
+
if (typeof assets === 'string') {
|
|
183
|
+
return [
|
|
184
|
+
{
|
|
185
|
+
alias: 'assetsDir',
|
|
186
|
+
dir: normalizeDirectory(assets, rootDir),
|
|
187
|
+
urlPath: '/public/assets',
|
|
188
|
+
},
|
|
189
|
+
];
|
|
190
|
+
}
|
|
191
|
+
else {
|
|
192
|
+
return assets.map((asset) => {
|
|
193
|
+
const assetDir = asset.dir;
|
|
194
|
+
const assetFile = asset.file;
|
|
195
|
+
return {
|
|
196
|
+
...asset,
|
|
197
|
+
dir: assetDir && normalizeDirectory(assetDir, rootDir),
|
|
198
|
+
file: assetFile && normalizeDirectory(assetFile, rootDir),
|
|
199
|
+
};
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
// deep merge LWC configs
|
|
204
|
+
function mergeLWCConfigs(config1, config2) {
|
|
205
|
+
const modules1 = config1?.lwc?.modules || [];
|
|
206
|
+
const modules2 = config2?.lwc?.modules || [];
|
|
207
|
+
const interchangeable1 = config1?.lwc?.interchangeable || [];
|
|
208
|
+
const interchangeable2 = config2?.lwc?.interchangeable || [];
|
|
209
|
+
const mergedInterchangeable = [...interchangeable1, ...interchangeable2];
|
|
210
|
+
const interchangeableModules1 = config1?.lwc?.interchangeableModules || [];
|
|
211
|
+
const interchangeableModules2 = config2?.lwc?.interchangeableModules || [];
|
|
212
|
+
const mergedInterchangeableModules = [...interchangeableModules1, ...interchangeableModules2];
|
|
213
|
+
return {
|
|
214
|
+
modules: [...modules1, ...modules2],
|
|
215
|
+
interchangeable: mergedInterchangeable.length ? mergedInterchangeable : undefined,
|
|
216
|
+
interchangeableModules: mergedInterchangeableModules.length
|
|
217
|
+
? mergedInterchangeableModules
|
|
218
|
+
: undefined,
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
// merge default bundle exclusions with any bundle exclusions specified in config
|
|
222
|
+
function mergeBundleConfig(jsonConfig, config) {
|
|
223
|
+
const defaultExclusions = config?.bundleConfig?.UNSAFE_lwrDefaultExclude ||
|
|
224
|
+
jsonConfig?.bundleConfig?.UNSAFE_lwrDefaultExclude ||
|
|
225
|
+
DEFAULT_BUNDLE_EXCLUSIONS;
|
|
226
|
+
const configExclusions = config?.bundleConfig?.exclude || jsonConfig?.bundleConfig?.exclude || [];
|
|
227
|
+
return {
|
|
228
|
+
...jsonConfig?.bundleConfig,
|
|
229
|
+
...config?.bundleConfig,
|
|
230
|
+
exclude: [...new Set([...defaultExclusions, ...configExclusions])],
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
// merge default locker trusted namespaces/cmps with any trusted namespaces/cmps specified in config
|
|
234
|
+
function mergeLockerConfig(jsonConfig, config) {
|
|
235
|
+
const defaultNamespaces = DEFAULT_LOCKER_TRUSTED_CMP;
|
|
236
|
+
const configNamespaces = config?.locker?.trustedComponents || jsonConfig?.locker?.trustedComponents || [];
|
|
237
|
+
return {
|
|
238
|
+
...DEFAULT_LWR_LOCKER_CONFIG,
|
|
239
|
+
...jsonConfig?.locker,
|
|
240
|
+
...config?.locker,
|
|
241
|
+
trustedComponents: [...new Set([...defaultNamespaces, ...configNamespaces])],
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
// Ensure correct engine since LWC 2+ changed engine packaging, see https://github.com/salesforce/lwr/issues/791
|
|
245
|
+
function getLWCEngineSpecifier() {
|
|
246
|
+
const require = createRequire(path.join(process.cwd(), './env-config.js'));
|
|
247
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
248
|
+
const { version } = require('lwc/package.json');
|
|
249
|
+
if (version && version.startsWith('1')) {
|
|
250
|
+
return '@lwc/engine';
|
|
251
|
+
}
|
|
252
|
+
// default to engine for LWC version 2+
|
|
253
|
+
return '@lwc/engine-dom';
|
|
254
|
+
}
|
|
255
|
+
function normalizeLwcConfig(config) {
|
|
256
|
+
return {
|
|
257
|
+
...config,
|
|
258
|
+
interchangeableModulesMap: config.interchangeableModules
|
|
259
|
+
? normalizeInterchangeableModuleConfig(config.interchangeableModules)
|
|
260
|
+
: undefined,
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
function trimLwrConfig(config) {
|
|
264
|
+
Object.keys(config).forEach((k) => {
|
|
265
|
+
if (config[k] === undefined)
|
|
266
|
+
delete config[k];
|
|
267
|
+
});
|
|
268
|
+
return config;
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* Merge and normalize all LWR configurations.
|
|
272
|
+
*
|
|
273
|
+
* @remarks
|
|
274
|
+
* Configurations are merged in the following order:
|
|
275
|
+
* defaults -> optional config file (lwr.config.json) -> optional config arg
|
|
276
|
+
*
|
|
277
|
+
* @param config - optional config supplied separate from the config file
|
|
278
|
+
* @returns the merged and normalized LWR configuration
|
|
279
|
+
*/
|
|
280
|
+
export function normalizeConfig(config) {
|
|
281
|
+
if (config !== undefined) {
|
|
282
|
+
config = trimLwrConfig(config);
|
|
283
|
+
try {
|
|
284
|
+
validateLwrAppConfig(JSON.stringify(config), 'pre');
|
|
285
|
+
}
|
|
286
|
+
catch (e) {
|
|
287
|
+
// TODO: temporary workaround for https://github.com/salesforce/lwr/issues/825
|
|
288
|
+
if (process.env.UNSAFE_IGNORE_CONFIG_VALIDATION === 'true') {
|
|
289
|
+
console.warn('ignoring config validation errors due to UNSAFE_IGNORE_CONFIG_VALIDATION flag...proceed with caution');
|
|
290
|
+
console.dir(e, { depth: null });
|
|
291
|
+
}
|
|
292
|
+
else {
|
|
293
|
+
throw e;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
// Merge all configurations together, and return
|
|
298
|
+
const rootDir = path.resolve(config?.rootDir || DEFAULT_ROOT_DIR);
|
|
299
|
+
const lwrJsonConfig = config?.ignoreLwrConfigFile === true
|
|
300
|
+
? undefined
|
|
301
|
+
: getLwrConfigFromFile(rootDir, config?.lwrConfigFile);
|
|
302
|
+
const mergedLwrGlobalConfig = {
|
|
303
|
+
...DEFAULT_LWR_CONFIG,
|
|
304
|
+
...lwrJsonConfig,
|
|
305
|
+
...config,
|
|
306
|
+
lwc: normalizeLwcConfig(mergeLWCConfigs(lwrJsonConfig, config)),
|
|
307
|
+
bundleConfig: mergeBundleConfig(lwrJsonConfig, config),
|
|
308
|
+
locker: mergeLockerConfig(lwrJsonConfig, config),
|
|
309
|
+
staticSiteGenerator: {
|
|
310
|
+
...DEFAULT_GENERATOR_CONFIG,
|
|
311
|
+
...lwrJsonConfig?.staticSiteGenerator,
|
|
312
|
+
...config?.staticSiteGenerator,
|
|
313
|
+
},
|
|
314
|
+
rootDir,
|
|
315
|
+
};
|
|
316
|
+
// Normalize entries (eg: parse full file paths, etc)
|
|
317
|
+
const assets = normalizeAssetsDir(mergedLwrGlobalConfig.assets, rootDir);
|
|
318
|
+
const contentDir = normalizeDirectory(mergedLwrGlobalConfig.contentDir, rootDir);
|
|
319
|
+
const layoutsDir = normalizeDirectory(mergedLwrGlobalConfig.layoutsDir, rootDir);
|
|
320
|
+
const amdLoader = getFeatureFlags().LEGACY_LOADER ? DEFAULT_AMD_LOADER_LEGACY : DEFAULT_AMD_LOADER;
|
|
321
|
+
return {
|
|
322
|
+
...mergedLwrGlobalConfig,
|
|
323
|
+
assets,
|
|
324
|
+
contentDir,
|
|
325
|
+
layoutsDir,
|
|
326
|
+
globalDataDir: normalizeDirectory(mergedLwrGlobalConfig.globalDataDir, rootDir),
|
|
327
|
+
hooks: normalizeServices(mergedLwrGlobalConfig.hooks, rootDir),
|
|
328
|
+
cacheDir: createCacheFolder(mergedLwrGlobalConfig.cacheDir, rootDir),
|
|
329
|
+
lwc: {
|
|
330
|
+
modules: normalizeModules([...DEFAULT_LWR_MODULES, ...mergedLwrGlobalConfig.lwc.modules], rootDir),
|
|
331
|
+
interchangeable: mergedLwrGlobalConfig.lwc.interchangeable,
|
|
332
|
+
interchangeableModulesMap: mergedLwrGlobalConfig.lwc.interchangeableModulesMap,
|
|
333
|
+
},
|
|
334
|
+
moduleProviders: normalizeServices(mergedLwrGlobalConfig.moduleProviders, rootDir),
|
|
335
|
+
assetProviders: normalizeServices(mergedLwrGlobalConfig.assetProviders, rootDir),
|
|
336
|
+
assetTransformers: normalizeServices(mergedLwrGlobalConfig.assetTransformers, rootDir),
|
|
337
|
+
resourceProviders: normalizeServices(mergedLwrGlobalConfig.resourceProviders, rootDir),
|
|
338
|
+
viewProviders: normalizeServices(mergedLwrGlobalConfig.viewProviders, rootDir),
|
|
339
|
+
viewTransformers: normalizeServices(mergedLwrGlobalConfig.viewTransformers, rootDir),
|
|
340
|
+
routes: normalizeRoutes(mergedLwrGlobalConfig.routes, { rootDir, assets, contentDir, layoutsDir }),
|
|
341
|
+
errorRoutes: normalizeRoutes(mergedLwrGlobalConfig.errorRoutes, {
|
|
342
|
+
rootDir,
|
|
343
|
+
assets,
|
|
344
|
+
contentDir,
|
|
345
|
+
layoutsDir,
|
|
346
|
+
}),
|
|
347
|
+
amdLoader,
|
|
348
|
+
esmLoader: DEFAULT_ESM_LOADER,
|
|
349
|
+
lwrVersion: LWR_VERSION,
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
//# sourceMappingURL=env-config.js.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { normalizeConfig, explodeMode } from './env-config.js';
|
|
2
|
+
import { validateLwrAppConfig } from './validation/app-config.js';
|
|
3
|
+
// Only export the functions we utilize internally
|
|
4
|
+
export { normalizeConfig, explodeMode, validateLwrAppConfig };
|
|
5
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { AssetDirConfig, AssetFileConfig, LwrErrorRoute, LwrRoute, NormalizedLwrGlobalConfig, NormalizedLwrAppBootstrapConfig, LwrLockerConfig } from '@lwrjs/types';
|
|
2
|
+
import { Node } from 'jsonc-parser';
|
|
3
|
+
import { Diagnostic } from '@lwrjs/diagnostics';
|
|
4
|
+
declare type RequiredAssetDirConfig = Required<AssetDirConfig>;
|
|
5
|
+
declare type RequiredAssetFileConfig = Required<AssetFileConfig>;
|
|
6
|
+
declare type RequiredLwrRoute = Required<LwrRoute>;
|
|
7
|
+
declare type RequiredLwrErrorRoute = Required<LwrErrorRoute>;
|
|
8
|
+
declare type RequiredLwrLockerConfig = Required<LwrLockerConfig>;
|
|
9
|
+
interface ConfigMap {
|
|
10
|
+
root: NormalizedLwrGlobalConfig;
|
|
11
|
+
assetDir: RequiredAssetDirConfig;
|
|
12
|
+
assetFile: RequiredAssetFileConfig;
|
|
13
|
+
routes: RequiredLwrRoute;
|
|
14
|
+
errorRoutes: RequiredLwrErrorRoute;
|
|
15
|
+
bootstrap: NormalizedLwrAppBootstrapConfig;
|
|
16
|
+
locker: RequiredLwrLockerConfig;
|
|
17
|
+
}
|
|
18
|
+
export declare const ROOT_ATTRIBUTE_KEYS: ["amdLoader", "apiVersion", "assets", "assetProviders", "assetTransformers", "bundleConfig", "cacheDir", "contentDir", "environment", "errorRoutes", "esmLoader", "staticSiteGenerator", "globalData", "globalDataDir", "hooks", "ignoreLwrConfigFile", "lwrConfigFile", "layoutsDir", "locker", "lwc", "lwrVersion", "moduleProviders", "port", "basePath", "resourceProviders", "rootDir", "routes", "serverMode", "serverType", "templateEngine", "viewProviders", "viewTransformers"];
|
|
19
|
+
export declare const ASSET_DIR_ATTRIBUTE_KEYS: ["alias", "dir", "urlPath"];
|
|
20
|
+
export declare const ASSET_FILE_ATTRIBUTE_KEYS: ["alias", "file", "urlPath"];
|
|
21
|
+
export declare const LOCKER_ATTRIBUTE_KEYS: ["enabled", "trustedComponents", "clientOnly"];
|
|
22
|
+
export declare const ROUTE_ATTRIBUTE_KEYS: ["bootstrap", "contentTemplate", "id", "cache", "layoutTemplate", "method", "path", "rootComponent", "routeHandler", "properties"];
|
|
23
|
+
export declare const ERROR_ROUTE_ATTRIBUTE_KEYS: ["bootstrap", "contentTemplate", "id", "layoutTemplate", "rootComponent", "routeHandler", "status", "properties", "cache"];
|
|
24
|
+
export declare const BOOTSTRAP_ATTRIBUTE_KEYS: ["autoBoot", "syntheticShadow", "workers", "services", "configAsSrc", "experimentalSSR"];
|
|
25
|
+
export declare const BASE_PATH_REGEX: RegExp;
|
|
26
|
+
export declare class ValidationContext {
|
|
27
|
+
diagnostics: Diagnostic[];
|
|
28
|
+
sourceText: string;
|
|
29
|
+
constructor(sourceText: string);
|
|
30
|
+
private getLocationFromNode;
|
|
31
|
+
assertIsObject<T extends keyof ConfigMap>(node: Node, property: T): void;
|
|
32
|
+
assertIsBoolean(node: Node | undefined, property: string): void;
|
|
33
|
+
assertIsArray(node: Node | undefined, property: string): void;
|
|
34
|
+
assertIsSpecifier(node: Node | undefined, property: string): void;
|
|
35
|
+
assertIsPath(node: Node | undefined, property: string): void;
|
|
36
|
+
assertIsPort(node: Node | undefined, property: string): void;
|
|
37
|
+
assertIsServerType(node: Node | undefined, property: string): void;
|
|
38
|
+
assertIsStaticSiteGenerator(node: Node | undefined, property: string): void;
|
|
39
|
+
assertIsMethod(node: Node | undefined, property: string): void;
|
|
40
|
+
assertIsStatus(node: Node | undefined, property: string): void;
|
|
41
|
+
assertIsEnvironment(node: Node | undefined, property: string): void;
|
|
42
|
+
assertIsBasePath(node: Node | undefined, property: string): void;
|
|
43
|
+
assertNotEmptyString(node: Node | undefined, property: string): void;
|
|
44
|
+
assertNotEmptyArray(node: Node | undefined, property: string): void;
|
|
45
|
+
assertHasOneOrMore(node: Node, property: string, childProps: string[]): void;
|
|
46
|
+
assertHasOnlyOne(node: Node, property: string, childProps: string[]): void;
|
|
47
|
+
assertArrayOfStrings(node: Node | undefined, property: string): void;
|
|
48
|
+
assertArrayOfSpecifiers(node: Node | undefined, property: string): void;
|
|
49
|
+
assertArrayOfServices(node: Node | undefined, property: string): void;
|
|
50
|
+
assertUniqueIds(nodes: Node[], property: string): void;
|
|
51
|
+
assertRequiredKeys(node: Node, property: string, requiredPropertyKeys: string[]): void;
|
|
52
|
+
assertValidKeys<T extends keyof ConfigMap>(node: Node, property: T, validPropertyKeys: (keyof ConfigMap[T])[]): void;
|
|
53
|
+
}
|
|
54
|
+
export {};
|
|
55
|
+
//# sourceMappingURL=app-config-context.d.ts.map
|