@lwrjs/config 0.9.0-alpha.17 → 0.9.0-alpha.18

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.
@@ -119,6 +119,7 @@ var DEFAULT_LWR_CONFIG = {
119
119
  lwc: {modules: []},
120
120
  routes: [],
121
121
  errorRoutes: [],
122
+ routeHandlers: {},
122
123
  bundleConfig: {exclude: DEFAULT_BUNDLE_EXCLUSIONS},
123
124
  serverType: DEFAULT_SERVER_TYPE,
124
125
  locker: import_shared_utils.DEFAULT_LWR_LOCKER_CONFIG
@@ -90,8 +90,8 @@ function normalizeConfig(config) {
90
90
  resourceProviders: (0, import_services.normalizeServices)(config.resourceProviders),
91
91
  viewProviders: (0, import_services.normalizeServices)(config.viewProviders),
92
92
  viewTransformers: (0, import_services.normalizeServices)(config.viewTransformers),
93
- routes: (0, import_routes.normalizeRoutes)(config.routes),
94
- errorRoutes: (0, import_routes.normalizeRoutes)(config.errorRoutes)
93
+ routes: (0, import_routes.normalizeRoutes)(config.routes, config.routeHandlers),
94
+ errorRoutes: (0, import_routes.normalizeRoutes)(config.errorRoutes, config.routeHandlers)
95
95
  };
96
96
  }
97
97
  function normalizeConfigPaths(config) {
@@ -120,7 +120,8 @@ function normalizeConfigPaths(config) {
120
120
  viewProviders: (0, import_services.normalizeServicePaths)(config.viewProviders, rootDir),
121
121
  viewTransformers: (0, import_services.normalizeServicePaths)(config.viewTransformers, rootDir),
122
122
  routes: (0, import_routes.normalizeRoutePaths)(config.routes, resourcePaths),
123
- errorRoutes: (0, import_routes.normalizeRoutePaths)(config.errorRoutes, resourcePaths)
123
+ errorRoutes: (0, import_routes.normalizeRoutePaths)(config.errorRoutes, resourcePaths),
124
+ routeHandlers: (0, import_routes.normalizeRouteHandlerPaths)(config.routeHandlers, resourcePaths)
124
125
  };
125
126
  }
126
127
  function resolveGlobalConfig(configArg, options) {
@@ -39,8 +39,8 @@ async function executeConfigHooks(hooks, globalConfig, runtimeEnvironment, globa
39
39
  }
40
40
  await hook.initConfigs(globalConfig, globalData, runtimeEnvironment);
41
41
  }
42
- globalConfig.routes = (0, import_routes.normalizeRoutes)(globalConfig.routes);
43
- globalConfig.errorRoutes = (0, import_routes.normalizeRoutes)(globalConfig.errorRoutes);
42
+ globalConfig.routes = (0, import_routes.normalizeRoutes)(globalConfig.routes, globalConfig.routeHandlers);
43
+ globalConfig.errorRoutes = (0, import_routes.normalizeRoutes)(globalConfig.errorRoutes, globalConfig.routeHandlers);
44
44
  (0, import_app_config.validateLwrAppConfig)(globalConfig, "post");
45
45
  }
46
46
  function executeStartHooks(hooks, globalConfig) {
@@ -53,6 +53,6 @@ function executeStartHooks(hooks, globalConfig) {
53
53
  }
54
54
  hook.onStart(globalConfig.routes);
55
55
  }
56
- globalConfig.routes = (0, import_routes.normalizeRoutes)(globalConfig.routes);
56
+ globalConfig.routes = (0, import_routes.normalizeRoutes)(globalConfig.routes, globalConfig.routeHandlers);
57
57
  (0, import_app_config.validateLwrAppConfig)(globalConfig, "post");
58
58
  }
@@ -25,7 +25,7 @@ var __toModule = (module2) => {
25
25
  __markAsModule(exports);
26
26
  __export(exports, {
27
27
  loadHooks: () => loadHooks,
28
- loadRoutes: () => loadRoutes,
28
+ loadRouteHandlers: () => loadRouteHandlers,
29
29
  loadServices: () => loadServices
30
30
  });
31
31
  var import_path = __toModule(require("path"));
@@ -57,26 +57,6 @@ async function loadServiceEntries(entries, rootDir, cacheDir) {
57
57
  return [ctor, config];
58
58
  }));
59
59
  }
60
- async function loadRouteHandlers(routes, rootDir, cacheDir) {
61
- const cache = {};
62
- return Promise.all(routes.map(async (route) => {
63
- if (!route.routeHandler) {
64
- return route;
65
- }
66
- if (cache[route.routeHandler]) {
67
- return {
68
- ...route,
69
- routeHandler: cache[route.routeHandler]
70
- };
71
- }
72
- const routeHandler = await importModule(route.routeHandler, rootDir, import_path.default.join(cacheDir, "routeHandlers"));
73
- cache[route.routeHandler] = routeHandler;
74
- return {
75
- ...route,
76
- routeHandler
77
- };
78
- }));
79
- }
80
60
  async function loadHooks(config) {
81
61
  if (!config.hooks) {
82
62
  return [];
@@ -105,11 +85,12 @@ async function loadServices(config) {
105
85
  viewTransformers
106
86
  };
107
87
  }
108
- async function loadRoutes(config) {
109
- const routes = await loadRouteHandlers(config.routes, config.rootDir, config.cacheDir);
110
- const errorRoutes = await loadRouteHandlers(config.errorRoutes, config.rootDir, config.cacheDir);
111
- return {
112
- routes,
113
- errorRoutes
114
- };
88
+ async function loadRouteHandlers(config) {
89
+ const routeHandlers = {};
90
+ await Promise.all(Object.keys(config.routeHandlers).map(async (id) => {
91
+ const handlerPath = config.routeHandlers[id];
92
+ const handler = await importModule(handlerPath, config.rootDir, import_path.default.join(config.cacheDir, "routeHandlers"));
93
+ routeHandlers[id] = handler;
94
+ }));
95
+ return routeHandlers;
115
96
  }
@@ -24,27 +24,45 @@ var __toModule = (module2) => {
24
24
  // packages/@lwrjs/config/src/utils/routes.ts
25
25
  __markAsModule(exports);
26
26
  __export(exports, {
27
+ normalizeRouteHandlerPaths: () => normalizeRouteHandlerPaths,
27
28
  normalizeRoutePaths: () => normalizeRoutePaths,
28
29
  normalizeRoutes: () => normalizeRoutes
29
30
  });
30
31
  var import_path = __toModule(require("path"));
31
32
  var import_shared_utils = __toModule(require("@lwrjs/shared-utils"));
32
- function normalizeRoutes(routes = []) {
33
- return routes.map((route) => ({
34
- ...route,
35
- bootstrap: {
36
- ...import_shared_utils.DEFAULT_LWR_BOOTSTRAP_CONFIG,
37
- ...route.bootstrap
33
+ function normalizeRoutes(routes, routeHandlers) {
34
+ return routes.map((route) => {
35
+ if (route.routeHandler && !routeHandlers[route.routeHandler]) {
36
+ const handlerPath = route.routeHandler;
37
+ routeHandlers[handlerPath] = handlerPath;
38
38
  }
39
- }));
39
+ return {
40
+ ...route,
41
+ bootstrap: {
42
+ ...import_shared_utils.DEFAULT_LWR_BOOTSTRAP_CONFIG,
43
+ ...route.bootstrap
44
+ }
45
+ };
46
+ });
40
47
  }
41
48
  function normalizeRoutePaths(routes = [], resourcePaths) {
42
49
  return routes.map((route) => {
43
- const {routeHandler, contentTemplate, layoutTemplate, subRoutes} = route;
44
- route.routeHandler = routeHandler && import_path.default.resolve((0, import_shared_utils.normalizeDirectory)(routeHandler, resourcePaths.rootDir));
45
- route.contentTemplate = contentTemplate && import_path.default.resolve((0, import_shared_utils.normalizeResourcePath)(contentTemplate, resourcePaths));
46
- route.layoutTemplate = layoutTemplate && import_path.default.resolve((0, import_shared_utils.normalizeResourcePath)(layoutTemplate, resourcePaths));
47
- route.subRoutes = subRoutes && import_path.default.resolve((0, import_shared_utils.normalizeResourcePath)(subRoutes, resourcePaths));
50
+ const {contentTemplate, layoutTemplate, subRoutes} = route;
51
+ if (contentTemplate) {
52
+ route.contentTemplate = import_path.default.resolve((0, import_shared_utils.normalizeResourcePath)(contentTemplate, resourcePaths));
53
+ }
54
+ if (layoutTemplate) {
55
+ route.layoutTemplate = import_path.default.resolve((0, import_shared_utils.normalizeResourcePath)(layoutTemplate, resourcePaths));
56
+ }
57
+ if (subRoutes) {
58
+ route.subRoutes = import_path.default.resolve((0, import_shared_utils.normalizeResourcePath)(subRoutes, resourcePaths));
59
+ }
48
60
  return route;
49
61
  });
50
62
  }
63
+ function normalizeRouteHandlerPaths(routeHandlers, resourcePaths) {
64
+ for (const [id, handlerPath] of Object.entries(routeHandlers)) {
65
+ routeHandlers[id] = import_path.default.resolve((0, import_shared_utils.normalizeDirectory)(handlerPath, resourcePaths.rootDir));
66
+ }
67
+ return routeHandlers;
68
+ }
@@ -67,6 +67,7 @@ var ROOT_ATTRIBUTE_KEYS = createKeys("root", [
67
67
  "basePath",
68
68
  "resourceProviders",
69
69
  "rootDir",
70
+ "routeHandlers",
70
71
  "routes",
71
72
  "serverMode",
72
73
  "serverType",
@@ -101,6 +101,11 @@ function validateErrorRoutes(node, validationContext) {
101
101
  }
102
102
  }
103
103
  }
104
+ function validateRouteHandlers(node, validationContext) {
105
+ if (node) {
106
+ validationContext.assertIsObject(node, "routeHandlers");
107
+ }
108
+ }
104
109
  function validateAssets(node, validationContext, preMerge) {
105
110
  if (node) {
106
111
  if (preMerge && node.type === "string") {
@@ -147,6 +152,7 @@ function validateRoot(node, validationContext, preMerge) {
147
152
  validationContext.assertUniqueIds([...routes?.children || [], ...errorRoutes?.children || []], "routes");
148
153
  validateRoutes(routes, validationContext, preMerge);
149
154
  validateErrorRoutes(errorRoutes, validationContext);
155
+ validateRouteHandlers((0, import_jsonc_parser.findNodeAtLocation)(node, ["routeHandlers"]), validationContext);
150
156
  validateAssets((0, import_jsonc_parser.findNodeAtLocation)(node, ["assets"]), validationContext, preMerge);
151
157
  validateLocker((0, import_jsonc_parser.findNodeAtLocation)(node, ["locker"]), validationContext);
152
158
  validationContext.assertNotEmptyString((0, import_jsonc_parser.findNodeAtLocation)(node, ["apiVersion"]), "apiVersion");
@@ -83,6 +83,7 @@ export const DEFAULT_LWR_CONFIG = {
83
83
  lwc: { modules: [] },
84
84
  routes: [],
85
85
  errorRoutes: [],
86
+ routeHandlers: {},
86
87
  bundleConfig: { exclude: DEFAULT_BUNDLE_EXCLUSIONS },
87
88
  serverType: DEFAULT_SERVER_TYPE,
88
89
  locker: DEFAULT_LWR_LOCKER_CONFIG,
@@ -6,7 +6,7 @@ import { DEFAULT_AMD_LOADER, DEFAULT_AMD_LOADER_LEGACY, DEFAULT_ESM_LOADER, DEFA
6
6
  import { validateLwrAppConfig } from './validation/app-config.js';
7
7
  import { normalizeAssetPaths, normalizeAssets } from './utils/assets.js';
8
8
  import { normalizeServicePaths, normalizeServices } from './utils/services.js';
9
- import { normalizeRoutePaths, normalizeRoutes } from './utils/routes.js';
9
+ import { normalizeRouteHandlerPaths, normalizeRoutePaths, normalizeRoutes } from './utils/routes.js';
10
10
  import { mergeBundleConfig, mergeLockerConfig, mergeLwcConfig, mergeStaticGenerationConfig, trimLwrConfig, } from './utils/merge.js';
11
11
  import { normalizeLwcConfig, normalizeModulePaths } from './utils/lwc.js';
12
12
  import { getRuntimeEnvironment } from './runtime-config.js';
@@ -118,9 +118,9 @@ function normalizeConfig(config) {
118
118
  resourceProviders: normalizeServices(config.resourceProviders),
119
119
  viewProviders: normalizeServices(config.viewProviders),
120
120
  viewTransformers: normalizeServices(config.viewTransformers),
121
- // normalize all routes
122
- routes: normalizeRoutes(config.routes),
123
- errorRoutes: normalizeRoutes(config.errorRoutes),
121
+ // normalize routes and capture all route handlers
122
+ routes: normalizeRoutes(config.routes, config.routeHandlers),
123
+ errorRoutes: normalizeRoutes(config.errorRoutes, config.routeHandlers),
124
124
  };
125
125
  }
126
126
  /**
@@ -162,6 +162,7 @@ function normalizeConfigPaths(config) {
162
162
  // normalize all route paths
163
163
  routes: normalizeRoutePaths(config.routes, resourcePaths),
164
164
  errorRoutes: normalizeRoutePaths(config.errorRoutes, resourcePaths),
165
+ routeHandlers: normalizeRouteHandlerPaths(config.routeHandlers, resourcePaths),
165
166
  };
166
167
  }
167
168
  /**
package/build/es/hooks.js CHANGED
@@ -25,8 +25,8 @@ export async function executeConfigHooks(hooks, globalConfig, runtimeEnvironment
25
25
  // eslint-disable-next-line no-await-in-loop
26
26
  await hook.initConfigs(globalConfig, globalData, runtimeEnvironment);
27
27
  }
28
- globalConfig.routes = normalizeRoutes(globalConfig.routes);
29
- globalConfig.errorRoutes = normalizeRoutes(globalConfig.errorRoutes);
28
+ globalConfig.routes = normalizeRoutes(globalConfig.routes, globalConfig.routeHandlers);
29
+ globalConfig.errorRoutes = normalizeRoutes(globalConfig.errorRoutes, globalConfig.routeHandlers);
30
30
  validateLwrAppConfig(globalConfig, 'post');
31
31
  }
32
32
  /**
@@ -53,7 +53,7 @@ export function executeStartHooks(hooks, globalConfig) {
53
53
  }
54
54
  hook.onStart(globalConfig.routes);
55
55
  }
56
- globalConfig.routes = normalizeRoutes(globalConfig.routes);
56
+ globalConfig.routes = normalizeRoutes(globalConfig.routes, globalConfig.routeHandlers);
57
57
  validateLwrAppConfig(globalConfig, 'post');
58
58
  }
59
59
  //# sourceMappingURL=hooks.js.map
@@ -1,8 +1,4 @@
1
- import type { HooksPlugin, NormalizedLwrErrorRoute, NormalizedLwrGlobalConfig, NormalizedLwrRoute, Route, Services } from '@lwrjs/types';
2
- export interface Routes {
3
- routes: Route<NormalizedLwrRoute>[];
4
- errorRoutes: Route<NormalizedLwrErrorRoute>[];
5
- }
1
+ import type { HooksPlugin, NormalizedLwrGlobalConfig, RouteHandlers, Services } from '@lwrjs/types';
6
2
  /**
7
3
  * Import and instantiate hooks defined in the global config
8
4
  *
@@ -30,7 +26,7 @@ export declare function loadServices(config: NormalizedLwrGlobalConfig): Promise
30
26
  * The optional dependency `esbuild` MUST be installed to load route handler modules.
31
27
  *
32
28
  * @param config - global config
33
- * @returns {Routes} all routes with resolved route handlers
29
+ * @returns {Routes} resolved route handlers mapped by id
34
30
  */
35
- export declare function loadRoutes(config: NormalizedLwrGlobalConfig): Promise<Routes>;
31
+ export declare function loadRouteHandlers(config: NormalizedLwrGlobalConfig): Promise<RouteHandlers>;
36
32
  //# sourceMappingURL=modules.d.ts.map
@@ -30,26 +30,6 @@ async function loadServiceEntries(entries, rootDir, cacheDir) {
30
30
  return [ctor, config];
31
31
  }));
32
32
  }
33
- async function loadRouteHandlers(routes, rootDir, cacheDir) {
34
- const cache = {};
35
- return Promise.all(routes.map(async (route) => {
36
- if (!route.routeHandler) {
37
- return route;
38
- }
39
- if (cache[route.routeHandler]) {
40
- return {
41
- ...route,
42
- routeHandler: cache[route.routeHandler],
43
- };
44
- }
45
- const routeHandler = await importModule(route.routeHandler, rootDir, path.join(cacheDir, 'routeHandlers'));
46
- cache[route.routeHandler] = routeHandler;
47
- return {
48
- ...route,
49
- routeHandler,
50
- };
51
- }));
52
- }
53
33
  /**
54
34
  * Import and instantiate hooks defined in the global config
55
35
  *
@@ -103,14 +83,15 @@ export async function loadServices(config) {
103
83
  * The optional dependency `esbuild` MUST be installed to load route handler modules.
104
84
  *
105
85
  * @param config - global config
106
- * @returns {Routes} all routes with resolved route handlers
86
+ * @returns {Routes} resolved route handlers mapped by id
107
87
  */
108
- export async function loadRoutes(config) {
109
- const routes = await loadRouteHandlers(config.routes, config.rootDir, config.cacheDir);
110
- const errorRoutes = await loadRouteHandlers(config.errorRoutes, config.rootDir, config.cacheDir);
111
- return {
112
- routes,
113
- errorRoutes,
114
- };
88
+ export async function loadRouteHandlers(config) {
89
+ const routeHandlers = {};
90
+ await Promise.all(Object.keys(config.routeHandlers).map(async (id) => {
91
+ const handlerPath = config.routeHandlers[id];
92
+ const handler = await importModule(handlerPath, config.rootDir, path.join(config.cacheDir, 'routeHandlers'));
93
+ routeHandlers[id] = handler;
94
+ }));
95
+ return routeHandlers;
115
96
  }
116
97
  //# sourceMappingURL=modules.js.map
@@ -1,7 +1,8 @@
1
- import type { LwrErrorRoute, LwrRoute, NormalizedLwrErrorRoute, NormalizedLwrRoute, ResourcePaths } from '@lwrjs/types';
1
+ import type { LwrErrorRoute, LwrRoute, NormalizedLwrErrorRoute, NormalizedLwrRoute, ResourcePaths, RouteHandlersConfig } from '@lwrjs/types';
2
2
  declare type ViewOrErrorRoute = LwrRoute | LwrErrorRoute;
3
3
  declare type NormalizedRoute<T extends ViewOrErrorRoute> = T extends LwrRoute ? NormalizedLwrRoute : NormalizedLwrErrorRoute;
4
- export declare function normalizeRoutes<T extends ViewOrErrorRoute>(routes?: T[]): NormalizedRoute<T>[];
4
+ export declare function normalizeRoutes<T extends ViewOrErrorRoute>(routes: T[], routeHandlers: RouteHandlersConfig): NormalizedRoute<T>[];
5
5
  export declare function normalizeRoutePaths<T extends ViewOrErrorRoute>(routes: T[] | undefined, resourcePaths: ResourcePaths): NormalizedRoute<T>[];
6
+ export declare function normalizeRouteHandlerPaths(routeHandlers: RouteHandlersConfig, resourcePaths: ResourcePaths): RouteHandlersConfig;
6
7
  export {};
7
8
  //# sourceMappingURL=routes.d.ts.map
@@ -1,25 +1,42 @@
1
1
  import path from 'path';
2
2
  import { DEFAULT_LWR_BOOTSTRAP_CONFIG, normalizeDirectory, normalizeResourcePath } from '@lwrjs/shared-utils';
3
- export function normalizeRoutes(routes = []) {
4
- return routes.map((route) => ({
5
- ...route,
6
- bootstrap: {
7
- ...DEFAULT_LWR_BOOTSTRAP_CONFIG,
8
- ...route.bootstrap,
9
- },
10
- }));
3
+ export function normalizeRoutes(routes, routeHandlers) {
4
+ return routes.map((route) => {
5
+ // when a route handler is set, ensure it is set in the route handler config
6
+ if (route.routeHandler && !routeHandlers[route.routeHandler]) {
7
+ const handlerPath = route.routeHandler;
8
+ // the non-normalized path to the handler will be the id used when invoking the route handler
9
+ routeHandlers[handlerPath] = handlerPath;
10
+ }
11
+ return {
12
+ ...route,
13
+ bootstrap: {
14
+ ...DEFAULT_LWR_BOOTSTRAP_CONFIG,
15
+ ...route.bootstrap,
16
+ },
17
+ };
18
+ });
11
19
  }
12
20
  export function normalizeRoutePaths(routes = [], resourcePaths) {
13
21
  return routes.map((route) => {
14
- const { routeHandler, contentTemplate, layoutTemplate, subRoutes } = route;
15
- route.routeHandler =
16
- routeHandler && path.resolve(normalizeDirectory(routeHandler, resourcePaths.rootDir));
17
- route.contentTemplate =
18
- contentTemplate && path.resolve(normalizeResourcePath(contentTemplate, resourcePaths));
19
- route.layoutTemplate =
20
- layoutTemplate && path.resolve(normalizeResourcePath(layoutTemplate, resourcePaths));
21
- route.subRoutes = subRoutes && path.resolve(normalizeResourcePath(subRoutes, resourcePaths));
22
+ // route handler paths are NOT normalized here to maintain the id lookup for route handler invocation
23
+ const { contentTemplate, layoutTemplate, subRoutes } = route;
24
+ if (contentTemplate) {
25
+ route.contentTemplate = path.resolve(normalizeResourcePath(contentTemplate, resourcePaths));
26
+ }
27
+ if (layoutTemplate) {
28
+ route.layoutTemplate = path.resolve(normalizeResourcePath(layoutTemplate, resourcePaths));
29
+ }
30
+ if (subRoutes) {
31
+ route.subRoutes = path.resolve(normalizeResourcePath(subRoutes, resourcePaths));
32
+ }
22
33
  return route;
23
34
  });
24
35
  }
36
+ export function normalizeRouteHandlerPaths(routeHandlers, resourcePaths) {
37
+ for (const [id, handlerPath] of Object.entries(routeHandlers)) {
38
+ routeHandlers[id] = path.resolve(normalizeDirectory(handlerPath, resourcePaths.rootDir));
39
+ }
40
+ return routeHandlers;
41
+ }
25
42
  //# sourceMappingURL=routes.js.map
@@ -1,4 +1,4 @@
1
- import { AssetDirConfig, AssetFileConfig, LwrErrorRoute, LwrRoute, NormalizedLwrGlobalConfig, NormalizedLwrAppBootstrapConfig, LwrLockerConfig } from '@lwrjs/types';
1
+ import { AssetDirConfig, AssetFileConfig, LwrErrorRoute, LwrRoute, NormalizedLwrGlobalConfig, NormalizedLwrAppBootstrapConfig, LwrLockerConfig, RouteHandlersConfig } from '@lwrjs/types';
2
2
  import { Node } from 'jsonc-parser';
3
3
  import { Diagnostic } from '@lwrjs/diagnostics';
4
4
  declare type RequiredAssetDirConfig = Required<AssetDirConfig>;
@@ -12,10 +12,11 @@ interface ConfigMap {
12
12
  assetFile: RequiredAssetFileConfig;
13
13
  routes: RequiredLwrRoute;
14
14
  errorRoutes: RequiredLwrErrorRoute;
15
+ routeHandlers: RouteHandlersConfig;
15
16
  bootstrap: NormalizedLwrAppBootstrapConfig;
16
17
  locker: RequiredLwrLockerConfig;
17
18
  }
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", "viewProviders", "viewTransformers"];
19
+ 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", "routeHandlers", "routes", "serverMode", "serverType", "viewProviders", "viewTransformers"];
19
20
  export declare const ASSET_DIR_ATTRIBUTE_KEYS: ["alias", "dir", "urlPath"];
20
21
  export declare const ASSET_FILE_ATTRIBUTE_KEYS: ["alias", "file", "urlPath"];
21
22
  export declare const LOCKER_ATTRIBUTE_KEYS: ["enabled", "trustedComponents", "clientOnly"];
@@ -33,6 +33,7 @@ export const ROOT_ATTRIBUTE_KEYS = createKeys('root', [
33
33
  'basePath',
34
34
  'resourceProviders',
35
35
  'rootDir',
36
+ 'routeHandlers',
36
37
  'routes',
37
38
  'serverMode',
38
39
  'serverType',
@@ -106,6 +106,11 @@ function validateErrorRoutes(node, validationContext) {
106
106
  }
107
107
  }
108
108
  }
109
+ function validateRouteHandlers(node, validationContext) {
110
+ if (node) {
111
+ validationContext.assertIsObject(node, 'routeHandlers');
112
+ }
113
+ }
109
114
  /**
110
115
  * Check string config.asset OR
111
116
  * Check array config.assets[]:
@@ -196,6 +201,7 @@ function validateRoot(node, validationContext, preMerge) {
196
201
  validationContext.assertUniqueIds([...(routes?.children || []), ...(errorRoutes?.children || [])], 'routes');
197
202
  validateRoutes(routes, validationContext, preMerge);
198
203
  validateErrorRoutes(errorRoutes, validationContext);
204
+ validateRouteHandlers(findNode(node, ['routeHandlers']), validationContext);
199
205
  validateAssets(findNode(node, ['assets']), validationContext, preMerge);
200
206
  validateLocker(findNode(node, ['locker']), validationContext);
201
207
  validationContext.assertNotEmptyString(findNode(node, ['apiVersion']), 'apiVersion');
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
- "version": "0.9.0-alpha.17",
7
+ "version": "0.9.0-alpha.18",
8
8
  "homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
9
9
  "repository": {
10
10
  "type": "git",
@@ -36,16 +36,16 @@
36
36
  "package.cjs"
37
37
  ],
38
38
  "dependencies": {
39
- "@lwrjs/diagnostics": "0.9.0-alpha.17",
40
- "@lwrjs/shared-utils": "0.9.0-alpha.17",
39
+ "@lwrjs/diagnostics": "0.9.0-alpha.18",
40
+ "@lwrjs/shared-utils": "0.9.0-alpha.18",
41
41
  "fs-extra": "^10.1.0",
42
42
  "jsonc-parser": "^3.0.0"
43
43
  },
44
44
  "devDependencies": {
45
- "@lwrjs/types": "0.9.0-alpha.17"
45
+ "@lwrjs/types": "0.9.0-alpha.18"
46
46
  },
47
47
  "engines": {
48
48
  "node": ">=14.15.4 <19"
49
49
  },
50
- "gitHead": "447417ff091802927b25cfc1bcb01da02264f41b"
50
+ "gitHead": "0d612ec0c74c679ce422f7bbae9fae14134f7d9f"
51
51
  }