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

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.
@@ -64,10 +64,6 @@ var DEFAULT_MODULE_PROVIDERS = [
64
64
  "@lwrjs/lwc-module-provider",
65
65
  "@lwrjs/npm-module-provider"
66
66
  ];
67
- var DEFAULT_BUNDLE_PROVIDERS = [
68
- "@lwrjs/module-bundler/amd-bundle-provider",
69
- "@lwrjs/module-bundler/esm-bundle-provider"
70
- ];
71
67
  var DEFAULT_RESOURCE_PROVIDERS = ["@lwrjs/loader"];
72
68
  var DEFAULT_VIEW_PROVIDERS = [
73
69
  "@lwrjs/nunjucks-view-provider",
@@ -95,8 +91,7 @@ var DEFAULT_BUNDLE_EXCLUSIONS = [
95
91
  "@lwc/synthetic-shadow",
96
92
  "lwr/navigation",
97
93
  "lwr/esmLoader",
98
- "lwr/profiler",
99
- "lwc_ssr_placeholder"
94
+ "lwr/profiler"
100
95
  ];
101
96
  var DEFAULT_LWR_CONFIG = {
102
97
  port: PORT,
@@ -117,7 +112,6 @@ var DEFAULT_LWR_CONFIG = {
117
112
  globalData: {},
118
113
  hooks: [],
119
114
  moduleProviders: DEFAULT_MODULE_PROVIDERS,
120
- bundleProviders: DEFAULT_BUNDLE_PROVIDERS,
121
115
  resourceProviders: DEFAULT_RESOURCE_PROVIDERS,
122
116
  viewProviders: DEFAULT_VIEW_PROVIDERS,
123
117
  viewTransformers: DEFAULT_VIEW_TRANSFORM_PLUGINS,
@@ -25,8 +25,6 @@ var __toModule = (module2) => {
25
25
  __markAsModule(exports);
26
26
  __export(exports, {
27
27
  loadConfig: () => loadConfig,
28
- loadRoutes: () => loadRoutes,
29
- loadServices: () => loadServices,
30
28
  resolveGlobalConfig: () => resolveGlobalConfig
31
29
  });
32
30
  var import_fs = __toModule(require("fs"));
@@ -87,7 +85,6 @@ function normalizeConfig(config) {
87
85
  lwc: (0, import_lwc.normalizeLwcConfig)(config.lwc),
88
86
  hooks: (0, import_services.normalizeServices)(config.hooks),
89
87
  moduleProviders: (0, import_services.normalizeServices)(config.moduleProviders),
90
- bundleProviders: (0, import_services.normalizeServices)(config.bundleProviders),
91
88
  assetProviders: (0, import_services.normalizeServices)(config.assetProviders),
92
89
  assetTransformers: (0, import_services.normalizeServices)(config.assetTransformers),
93
90
  resourceProviders: (0, import_services.normalizeServices)(config.resourceProviders),
@@ -117,7 +114,6 @@ function normalizeConfigPaths(config) {
117
114
  },
118
115
  hooks: (0, import_services.normalizeServicePaths)(config.hooks, rootDir),
119
116
  moduleProviders: (0, import_services.normalizeServicePaths)(config.moduleProviders, rootDir),
120
- bundleProviders: (0, import_services.normalizeServicePaths)(config.bundleProviders, rootDir),
121
117
  assetProviders: (0, import_services.normalizeServicePaths)(config.assetProviders, rootDir),
122
118
  assetTransformers: (0, import_services.normalizeServicePaths)(config.assetTransformers, rootDir),
123
119
  resourceProviders: (0, import_services.normalizeServicePaths)(config.resourceProviders, rootDir),
@@ -127,15 +123,6 @@ function normalizeConfigPaths(config) {
127
123
  errorRoutes: (0, import_routes.normalizeRoutePaths)(config.errorRoutes, resourcePaths)
128
124
  };
129
125
  }
130
- async function applyConfigHooks(globalConfig, runtimeEnvironment, globalData) {
131
- const hooks = await (0, import_services.loadServiceEntries)(globalConfig.hooks, globalConfig.rootDir, globalConfig.cacheDir);
132
- for (const [hook, hookConfig = {}] of hooks) {
133
- await new hook(hookConfig).initConfigs(globalConfig, globalData, runtimeEnvironment);
134
- }
135
- globalConfig.routes = (0, import_routes.normalizeRoutes)(globalConfig.routes);
136
- globalConfig.errorRoutes = (0, import_routes.normalizeRoutes)(globalConfig.errorRoutes);
137
- (0, import_app_config.validateLwrAppConfig)(JSON.stringify(globalConfig), "post");
138
- }
139
126
  function resolveGlobalConfig(configArg, options) {
140
127
  const skipDirNormalization = options?.skipDirNormalization;
141
128
  const skipCacheDirCreation = options?.skipDirNormalization;
@@ -149,40 +136,16 @@ function resolveGlobalConfig(configArg, options) {
149
136
  }
150
137
  return normalizeConfigPaths(normalizedConfig);
151
138
  }
152
- async function loadConfig(config, options) {
153
- const globalConfig = await resolveGlobalConfig(config, options);
154
- const runtimeEnvironment = (0, import_runtime_config.getRuntimeEnvironment)(globalConfig);
155
- const globalData = await (0, import_global_data.getGlobalData)(globalConfig.globalDataDir, globalConfig.globalData);
156
- await applyConfigHooks(globalConfig, runtimeEnvironment, globalData);
139
+ function loadConfig(config, options) {
140
+ const appConfig = resolveGlobalConfig(config, options);
141
+ const runtimeEnvironment = (0, import_runtime_config.getRuntimeEnvironment)(appConfig);
142
+ const globalData = (0, import_global_data.getGlobalData)(appConfig.globalDataDir, appConfig.globalData);
143
+ if (!appConfig.hooks.length) {
144
+ (0, import_app_config.validateLwrAppConfig)(appConfig, "post");
145
+ }
157
146
  return {
158
- appConfig: globalConfig,
147
+ appConfig,
159
148
  runtimeEnvironment,
160
149
  globalData
161
150
  };
162
151
  }
163
- async function loadServices(config) {
164
- const moduleProviders = await (0, import_services.loadServiceEntries)(config.moduleProviders, config.rootDir, config.cacheDir);
165
- const bundleProviders = await (0, import_services.loadServiceEntries)(config.bundleProviders, config.rootDir, config.cacheDir);
166
- const assetProviders = await (0, import_services.loadServiceEntries)(config.assetProviders, config.rootDir, config.cacheDir);
167
- const assetTransformers = await (0, import_services.loadServiceEntries)(config.assetTransformers, config.rootDir, config.cacheDir);
168
- const resourceProviders = await (0, import_services.loadServiceEntries)(config.resourceProviders, config.rootDir, config.cacheDir);
169
- const viewProviders = await (0, import_services.loadServiceEntries)(config.viewProviders, config.rootDir, config.cacheDir);
170
- const viewTransformers = await (0, import_services.loadServiceEntries)(config.viewTransformers, config.rootDir, config.cacheDir);
171
- return {
172
- moduleProviders,
173
- bundleProviders,
174
- assetProviders,
175
- assetTransformers,
176
- resourceProviders,
177
- viewProviders,
178
- viewTransformers
179
- };
180
- }
181
- async function loadRoutes(config) {
182
- const routes = await (0, import_routes.loadRouteHandlers)(config.routes, config.rootDir, config.cacheDir);
183
- const errorRoutes = await (0, import_routes.loadRouteHandlers)(config.errorRoutes, config.rootDir, config.cacheDir);
184
- return {
185
- routes,
186
- errorRoutes
187
- };
188
- }
@@ -21,26 +21,38 @@ var __toModule = (module2) => {
21
21
  return __exportStar(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? {get: () => module2.default, enumerable: true} : {value: module2, enumerable: true})), module2);
22
22
  };
23
23
 
24
- // packages/@lwrjs/config/src/utils/module-loader.ts
24
+ // packages/@lwrjs/config/src/hooks.ts
25
25
  __markAsModule(exports);
26
26
  __export(exports, {
27
- loadModule: () => loadModule
27
+ executeConfigHooks: () => executeConfigHooks,
28
+ executeStartHooks: () => executeStartHooks
28
29
  });
29
- var import_shared_utils = __toModule(require("@lwrjs/shared-utils"));
30
- var import_typescript = __toModule(require("@lwrjs/shared-utils/typescript"));
31
- async function loadModule(filepath, rootDir, cacheDir) {
32
- let resolvedFilePath = (0, import_shared_utils.normalizeDirectory)(filepath, rootDir);
33
- const resolvedCacheDir = (0, import_shared_utils.normalizeDirectory)(cacheDir, rootDir);
34
- try {
35
- if (resolvedFilePath.endsWith(".ts")) {
36
- const fullPath = (0, import_shared_utils.resolveFileExtension)(resolvedFilePath);
37
- resolvedFilePath = await (0, import_typescript.transpileTs)(fullPath, {rootDir, cacheDir: resolvedCacheDir});
30
+ var import_routes = __toModule(require("./utils/routes.cjs"));
31
+ var import_app_config = __toModule(require("./validation/app-config.cjs"));
32
+ async function executeConfigHooks(hooks, globalConfig, runtimeEnvironment, globalData) {
33
+ if (!hooks.length) {
34
+ return;
35
+ }
36
+ for (const hook of hooks) {
37
+ if (!hook.initConfigs) {
38
+ continue;
39
+ }
40
+ await hook.initConfigs(globalConfig, globalData, runtimeEnvironment);
41
+ }
42
+ globalConfig.routes = (0, import_routes.normalizeRoutes)(globalConfig.routes);
43
+ globalConfig.errorRoutes = (0, import_routes.normalizeRoutes)(globalConfig.errorRoutes);
44
+ (0, import_app_config.validateLwrAppConfig)(globalConfig, "post");
45
+ }
46
+ function executeStartHooks(hooks, globalConfig) {
47
+ if (!hooks.length) {
48
+ return;
49
+ }
50
+ for (const hook of hooks) {
51
+ if (!hook.onStart) {
52
+ continue;
38
53
  }
39
- const moduleEntry = await Promise.resolve().then(() => __toModule(require(resolvedFilePath)));
40
- const output = moduleEntry.default || moduleEntry;
41
- return output;
42
- } catch (err) {
43
- console.log(err);
44
- throw new Error(`Unable to load configurable module: ${filepath}`);
54
+ hook.onStart(globalConfig.routes);
45
55
  }
56
+ globalConfig.routes = (0, import_routes.normalizeRoutes)(globalConfig.routes);
57
+ (0, import_app_config.validateLwrAppConfig)(globalConfig, "post");
46
58
  }
@@ -25,12 +25,13 @@ var __toModule = (module2) => {
25
25
  __markAsModule(exports);
26
26
  __export(exports, {
27
27
  LWR_VERSION: () => import_package.version,
28
+ executeConfigHooks: () => import_hooks.executeConfigHooks,
29
+ executeStartHooks: () => import_hooks.executeStartHooks,
28
30
  getRuntimeEnvironment: () => import_runtime_config.getRuntimeEnvironment,
29
31
  loadConfig: () => import_global_config.loadConfig,
30
- loadRoutes: () => import_global_config.loadRoutes,
31
- loadServices: () => import_global_config.loadServices,
32
32
  normalizeConfig: () => import_global_config.resolveGlobalConfig
33
33
  });
34
+ var import_package = __toModule(require("@lwrjs/config/package"));
34
35
  var import_global_config = __toModule(require("./global-config.cjs"));
35
36
  var import_runtime_config = __toModule(require("./runtime-config.cjs"));
36
- var import_package = __toModule(require("@lwrjs/config/package"));
37
+ var import_hooks = __toModule(require("./hooks.cjs"));
@@ -0,0 +1,115 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getProtoOf = Object.getPrototypeOf;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
7
+ var __markAsModule = (target) => __defProp(target, "__esModule", {value: true});
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, {get: all[name], enumerable: true});
11
+ };
12
+ var __exportStar = (target, module2, desc) => {
13
+ if (module2 && typeof module2 === "object" || typeof module2 === "function") {
14
+ for (let key of __getOwnPropNames(module2))
15
+ if (!__hasOwnProp.call(target, key) && key !== "default")
16
+ __defProp(target, key, {get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable});
17
+ }
18
+ return target;
19
+ };
20
+ var __toModule = (module2) => {
21
+ return __exportStar(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? {get: () => module2.default, enumerable: true} : {value: module2, enumerable: true})), module2);
22
+ };
23
+
24
+ // packages/@lwrjs/config/src/modules.ts
25
+ __markAsModule(exports);
26
+ __export(exports, {
27
+ loadHooks: () => loadHooks,
28
+ loadRoutes: () => loadRoutes,
29
+ loadServices: () => loadServices
30
+ });
31
+ var import_path = __toModule(require("path"));
32
+ var import_shared_utils = __toModule(require("@lwrjs/shared-utils"));
33
+ var import_typescript = __toModule(require("@lwrjs/shared-utils/typescript"));
34
+ var BUNDLE_PROVIDERS = [
35
+ ["@lwrjs/module-bundler/amd-bundle-provider", void 0],
36
+ ["@lwrjs/module-bundler/esm-bundle-provider", void 0]
37
+ ];
38
+ async function importModule(filepath, rootDir, cacheDir) {
39
+ let resolvedFilePath = (0, import_shared_utils.normalizeDirectory)(filepath, rootDir);
40
+ const resolvedCacheDir = (0, import_shared_utils.normalizeDirectory)(cacheDir, rootDir);
41
+ try {
42
+ if (resolvedFilePath.endsWith(".ts")) {
43
+ const fullPath = (0, import_shared_utils.resolveFileExtension)(resolvedFilePath);
44
+ resolvedFilePath = await (0, import_typescript.transpileTs)(fullPath, {rootDir, cacheDir: resolvedCacheDir});
45
+ }
46
+ const moduleEntry = await Promise.resolve().then(() => __toModule(require(resolvedFilePath)));
47
+ const output = moduleEntry.default || moduleEntry;
48
+ return output;
49
+ } catch (err) {
50
+ console.log(err);
51
+ throw new Error(`Unable to load configurable module: ${filepath}`);
52
+ }
53
+ }
54
+ async function loadServiceEntries(entries, rootDir, cacheDir) {
55
+ return Promise.all(entries.map(async ([entry, config]) => {
56
+ const ctor = await importModule(entry, rootDir, import_path.default.join(cacheDir, "services"));
57
+ return [ctor, config];
58
+ }));
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
+ async function loadHooks(config) {
81
+ if (!config.hooks) {
82
+ return [];
83
+ }
84
+ const hookCtors = await loadServiceEntries(config.hooks, config.rootDir, config.cacheDir);
85
+ const hooks = hookCtors.map(([hookCtor, hookConfig = {}]) => {
86
+ return new hookCtor(hookConfig);
87
+ });
88
+ return hooks;
89
+ }
90
+ async function loadServices(config) {
91
+ const moduleProviders = await loadServiceEntries(config.moduleProviders, config.rootDir, config.cacheDir);
92
+ const bundleProviders = await loadServiceEntries(BUNDLE_PROVIDERS, config.rootDir, config.cacheDir);
93
+ const assetProviders = await loadServiceEntries(config.assetProviders, config.rootDir, config.cacheDir);
94
+ const assetTransformers = await loadServiceEntries(config.assetTransformers, config.rootDir, config.cacheDir);
95
+ const resourceProviders = await loadServiceEntries(config.resourceProviders, config.rootDir, config.cacheDir);
96
+ const viewProviders = await loadServiceEntries(config.viewProviders, config.rootDir, config.cacheDir);
97
+ const viewTransformers = await loadServiceEntries(config.viewTransformers, config.rootDir, config.cacheDir);
98
+ return {
99
+ moduleProviders,
100
+ bundleProviders,
101
+ assetProviders,
102
+ assetTransformers,
103
+ resourceProviders,
104
+ viewProviders,
105
+ viewTransformers
106
+ };
107
+ }
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
+ };
115
+ }
@@ -24,13 +24,11 @@ var __toModule = (module2) => {
24
24
  // packages/@lwrjs/config/src/utils/routes.ts
25
25
  __markAsModule(exports);
26
26
  __export(exports, {
27
- loadRouteHandlers: () => loadRouteHandlers,
28
27
  normalizeRoutePaths: () => normalizeRoutePaths,
29
28
  normalizeRoutes: () => normalizeRoutes
30
29
  });
31
30
  var import_path = __toModule(require("path"));
32
31
  var import_shared_utils = __toModule(require("@lwrjs/shared-utils"));
33
- var import_module_loader = __toModule(require("./module-loader.cjs"));
34
32
  function normalizeRoutes(routes = []) {
35
33
  return routes.map((route) => ({
36
34
  ...route,
@@ -50,23 +48,3 @@ function normalizeRoutePaths(routes = [], resourcePaths) {
50
48
  return route;
51
49
  });
52
50
  }
53
- async function loadRouteHandlers(routes, rootDir, cacheDir) {
54
- const cache = {};
55
- return Promise.all(routes.map(async (route) => {
56
- if (!route.routeHandler) {
57
- return route;
58
- }
59
- if (cache[route.routeHandler]) {
60
- return {
61
- ...route,
62
- routeHandler: cache[route.routeHandler]
63
- };
64
- }
65
- const routeHandler = await (0, import_module_loader.loadModule)(route.routeHandler, rootDir, import_path.default.join(cacheDir, "routeHandlers"));
66
- cache[route.routeHandler] = routeHandler;
67
- return {
68
- ...route,
69
- routeHandler
70
- };
71
- }));
72
- }
@@ -24,14 +24,12 @@ var __toModule = (module2) => {
24
24
  // packages/@lwrjs/config/src/utils/services.ts
25
25
  __markAsModule(exports);
26
26
  __export(exports, {
27
- loadServiceEntries: () => loadServiceEntries,
28
27
  normalizeServicePaths: () => normalizeServicePaths,
29
28
  normalizeServices: () => normalizeServices
30
29
  });
31
30
  var import_path = __toModule(require("path"));
32
31
  var import_shared_utils = __toModule(require("@lwrjs/shared-utils"));
33
32
  var import_defaults = __toModule(require("../defaults.cjs"));
34
- var import_module_loader = __toModule(require("./module-loader.cjs"));
35
33
  function normalizeServices(services = []) {
36
34
  return services.map((service) => Array.isArray(service) ? service : [service, void 0]);
37
35
  }
@@ -45,9 +43,3 @@ function normalizeServicePaths(services, rootDir) {
45
43
  return [serviceName, serviceConfig];
46
44
  });
47
45
  }
48
- async function loadServiceEntries(entries, rootDir, cacheDir) {
49
- return Promise.all(entries.map(async ([entry, config]) => {
50
- const ctor = await (0, import_module_loader.loadModule)(entry, rootDir, import_path.default.join(cacheDir, "services"));
51
- return [ctor, config];
52
- }));
53
- }
@@ -47,7 +47,6 @@ var ROOT_ATTRIBUTE_KEYS = createKeys("root", [
47
47
  "assetProviders",
48
48
  "assetTransformers",
49
49
  "bundleConfig",
50
- "bundleProviders",
51
50
  "cacheDir",
52
51
  "contentDir",
53
52
  "environment",
@@ -164,7 +164,6 @@ function validateRoot(node, validationContext, preMerge) {
164
164
  validationContext.assertNotEmptyString((0, import_jsonc_parser.findNodeAtLocation)(node, ["globalDataDir"]), "globalDataDir");
165
165
  validationContext.assertArrayOfServices((0, import_jsonc_parser.findNodeAtLocation)(node, ["hooks"]), "hooks");
166
166
  validationContext.assertArrayOfServices((0, import_jsonc_parser.findNodeAtLocation)(node, ["moduleProviders"]), "moduleProviders");
167
- validationContext.assertArrayOfServices((0, import_jsonc_parser.findNodeAtLocation)(node, ["bundleProviders"]), "bundleProviders");
168
167
  validationContext.assertArrayOfServices((0, import_jsonc_parser.findNodeAtLocation)(node, ["viewProviders"]), "viewProviders");
169
168
  validationContext.assertArrayOfServices((0, import_jsonc_parser.findNodeAtLocation)(node, ["resourceProviders"]), "resourceProviders");
170
169
  validationContext.assertArrayOfServices((0, import_jsonc_parser.findNodeAtLocation)(node, ["assetProviders"]), "assetProviders");
@@ -28,10 +28,6 @@ const DEFAULT_MODULE_PROVIDERS = [
28
28
  '@lwrjs/lwc-module-provider',
29
29
  '@lwrjs/npm-module-provider',
30
30
  ];
31
- const DEFAULT_BUNDLE_PROVIDERS = [
32
- '@lwrjs/module-bundler/amd-bundle-provider',
33
- '@lwrjs/module-bundler/esm-bundle-provider',
34
- ];
35
31
  const DEFAULT_RESOURCE_PROVIDERS = ['@lwrjs/loader'];
36
32
  const DEFAULT_VIEW_PROVIDERS = [
37
33
  '@lwrjs/nunjucks-view-provider',
@@ -60,7 +56,6 @@ export const DEFAULT_BUNDLE_EXCLUSIONS = [
60
56
  'lwr/navigation',
61
57
  'lwr/esmLoader',
62
58
  'lwr/profiler',
63
- 'lwc_ssr_placeholder',
64
59
  ];
65
60
  export const DEFAULT_LWR_CONFIG = {
66
61
  port: PORT,
@@ -81,7 +76,6 @@ export const DEFAULT_LWR_CONFIG = {
81
76
  globalData: {},
82
77
  hooks: [],
83
78
  moduleProviders: DEFAULT_MODULE_PROVIDERS,
84
- bundleProviders: DEFAULT_BUNDLE_PROVIDERS,
85
79
  resourceProviders: DEFAULT_RESOURCE_PROVIDERS,
86
80
  viewProviders: DEFAULT_VIEW_PROVIDERS,
87
81
  viewTransformers: DEFAULT_VIEW_TRANSFORM_PLUGINS,
@@ -1,4 +1,4 @@
1
- import type { GlobalData, LwrGlobalConfig, NormalizedLwrGlobalConfig, RuntimeEnvironment, NormalizedLwrRoute, NormalizedLwrErrorRoute, Services, Route } from '@lwrjs/types';
1
+ import type { GlobalData, LwrGlobalConfig, NormalizedLwrGlobalConfig, RuntimeEnvironment } from '@lwrjs/types';
2
2
  export interface ResolveConfigOptions {
3
3
  skipDirNormalization?: boolean;
4
4
  skipCacheDirCreation?: boolean;
@@ -8,10 +8,6 @@ export interface Configurations {
8
8
  runtimeEnvironment: RuntimeEnvironment;
9
9
  globalData: GlobalData;
10
10
  }
11
- export interface Routes {
12
- routes: Route<NormalizedLwrRoute>[];
13
- errorRoutes: Route<NormalizedLwrErrorRoute>[];
14
- }
15
11
  /**
16
12
  * Load, merge, and normalize all of the config sources.
17
13
  *
@@ -35,19 +31,5 @@ export declare function resolveGlobalConfig(configArg?: LwrGlobalConfig, options
35
31
  * @param {LwrGlobalConfig} config - programmatic global config
36
32
  * @returns {Configurations} all of the fully resolved configurations
37
33
  */
38
- export declare function loadConfig(config?: LwrGlobalConfig, options?: ResolveConfigOptions): Promise<Configurations>;
39
- /**
40
- * Load service modules from the filepaths configured in the global config
41
- *
42
- * @param config - global config
43
- * @returns {Services} all of the imported service constructors
44
- */
45
- export declare function loadServices(config: NormalizedLwrGlobalConfig): Promise<Services>;
46
- /**
47
- * Load all route handlers from the filepaths configured in the global config
48
- *
49
- * @param config - global config
50
- * @returns {Routes} all routes with resolved route handlers
51
- */
52
- export declare function loadRoutes(config: NormalizedLwrGlobalConfig): Promise<Routes>;
34
+ export declare function loadConfig(config?: LwrGlobalConfig, options?: ResolveConfigOptions): Configurations;
53
35
  //# sourceMappingURL=global-config.d.ts.map
@@ -5,8 +5,8 @@ import { readFile, normalizeDirectory, getFeatureFlags, logger, ASSETS_CACHE_DIR
5
5
  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';
6
6
  import { validateLwrAppConfig } from './validation/app-config.js';
7
7
  import { normalizeAssetPaths, normalizeAssets } from './utils/assets.js';
8
- import { loadServiceEntries, normalizeServicePaths, normalizeServices } from './utils/services.js';
9
- import { loadRouteHandlers, normalizeRoutePaths, normalizeRoutes } from './utils/routes.js';
8
+ import { normalizeServicePaths, normalizeServices } from './utils/services.js';
9
+ import { 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';
@@ -113,7 +113,6 @@ function normalizeConfig(config) {
113
113
  // normalize all services
114
114
  hooks: normalizeServices(config.hooks),
115
115
  moduleProviders: normalizeServices(config.moduleProviders),
116
- bundleProviders: normalizeServices(config.bundleProviders),
117
116
  assetProviders: normalizeServices(config.assetProviders),
118
117
  assetTransformers: normalizeServices(config.assetTransformers),
119
118
  resourceProviders: normalizeServices(config.resourceProviders),
@@ -155,7 +154,6 @@ function normalizeConfigPaths(config) {
155
154
  // normalize all service paths
156
155
  hooks: normalizeServicePaths(config.hooks, rootDir),
157
156
  moduleProviders: normalizeServicePaths(config.moduleProviders, rootDir),
158
- bundleProviders: normalizeServicePaths(config.bundleProviders, rootDir),
159
157
  assetProviders: normalizeServicePaths(config.assetProviders, rootDir),
160
158
  assetTransformers: normalizeServicePaths(config.assetTransformers, rootDir),
161
159
  resourceProviders: normalizeServicePaths(config.resourceProviders, rootDir),
@@ -166,16 +164,6 @@ function normalizeConfigPaths(config) {
166
164
  errorRoutes: normalizeRoutePaths(config.errorRoutes, resourcePaths),
167
165
  };
168
166
  }
169
- async function applyConfigHooks(globalConfig, runtimeEnvironment, globalData) {
170
- const hooks = await loadServiceEntries(globalConfig.hooks, globalConfig.rootDir, globalConfig.cacheDir);
171
- for (const [hook, hookConfig = {}] of hooks) {
172
- // eslint-disable-next-line no-await-in-loop
173
- await new hook(hookConfig).initConfigs(globalConfig, globalData, runtimeEnvironment);
174
- }
175
- globalConfig.routes = normalizeRoutes(globalConfig.routes);
176
- globalConfig.errorRoutes = normalizeRoutes(globalConfig.errorRoutes);
177
- validateLwrAppConfig(JSON.stringify(globalConfig), 'post');
178
- }
179
167
  /**
180
168
  * Load, merge, and normalize all of the config sources.
181
169
  *
@@ -213,53 +201,19 @@ export function resolveGlobalConfig(configArg, options) {
213
201
  * @param {LwrGlobalConfig} config - programmatic global config
214
202
  * @returns {Configurations} all of the fully resolved configurations
215
203
  */
216
- export async function loadConfig(config, options) {
217
- const globalConfig = await resolveGlobalConfig(config, options);
218
- const runtimeEnvironment = getRuntimeEnvironment(globalConfig);
219
- const globalData = await getGlobalData(globalConfig.globalDataDir, globalConfig.globalData);
220
- await applyConfigHooks(globalConfig, runtimeEnvironment, globalData);
221
- return {
222
- appConfig: globalConfig,
223
- runtimeEnvironment: runtimeEnvironment,
224
- globalData: globalData,
225
- };
226
- }
227
- /**
228
- * Load service modules from the filepaths configured in the global config
229
- *
230
- * @param config - global config
231
- * @returns {Services} all of the imported service constructors
232
- */
233
- export async function loadServices(config) {
234
- const moduleProviders = await loadServiceEntries(config.moduleProviders, config.rootDir, config.cacheDir);
235
- const bundleProviders = await loadServiceEntries(config.bundleProviders, config.rootDir, config.cacheDir);
236
- const assetProviders = await loadServiceEntries(config.assetProviders, config.rootDir, config.cacheDir);
237
- const assetTransformers = await loadServiceEntries(config.assetTransformers, config.rootDir, config.cacheDir);
238
- const resourceProviders = await loadServiceEntries(config.resourceProviders, config.rootDir, config.cacheDir);
239
- const viewProviders = await loadServiceEntries(config.viewProviders, config.rootDir, config.cacheDir);
240
- const viewTransformers = await loadServiceEntries(config.viewTransformers, config.rootDir, config.cacheDir);
241
- return {
242
- moduleProviders,
243
- bundleProviders,
244
- assetProviders,
245
- assetTransformers,
246
- resourceProviders,
247
- viewProviders,
248
- viewTransformers,
249
- };
250
- }
251
- /**
252
- * Load all route handlers from the filepaths configured in the global config
253
- *
254
- * @param config - global config
255
- * @returns {Routes} all routes with resolved route handlers
256
- */
257
- export async function loadRoutes(config) {
258
- const routes = await loadRouteHandlers(config.routes, config.rootDir, config.cacheDir);
259
- const errorRoutes = await loadRouteHandlers(config.errorRoutes, config.rootDir, config.cacheDir);
204
+ export function loadConfig(config, options) {
205
+ const appConfig = resolveGlobalConfig(config, options);
206
+ const runtimeEnvironment = getRuntimeEnvironment(appConfig);
207
+ const globalData = getGlobalData(appConfig.globalDataDir, appConfig.globalData);
208
+ // ensure post config hook validation is ran even if config hooks don't exist
209
+ if (!appConfig.hooks.length) {
210
+ // route length validation happens in the `post` phase of validation
211
+ validateLwrAppConfig(appConfig, 'post');
212
+ }
260
213
  return {
261
- routes,
262
- errorRoutes,
214
+ appConfig,
215
+ runtimeEnvironment,
216
+ globalData,
263
217
  };
264
218
  }
265
219
  //# sourceMappingURL=global-config.js.map
@@ -0,0 +1,32 @@
1
+ import type { GlobalData, HooksPlugin, NormalizedLwrGlobalConfig, RuntimeEnvironment } from '@lwrjs/types';
2
+ /**
3
+ * Run `initConfigs` hooks
4
+ *
5
+ * @remarks
6
+ * Route normalization and validation will be executed after all config hooks have been executed.
7
+ *
8
+ * @privateRemarks
9
+ * Changes to configurations are made by reference.
10
+ *
11
+ * @param hooks - hooks plugins
12
+ * @param globalConfig - global configuration
13
+ * @param runtimeEnvironment - runtime environment resolved from programmatic config and config file
14
+ * @param globalData - resolved global data
15
+ */
16
+ export declare function executeConfigHooks(hooks: HooksPlugin[], globalConfig: NormalizedLwrGlobalConfig, runtimeEnvironment: RuntimeEnvironment, globalData: GlobalData): Promise<void>;
17
+ /**
18
+ * Run `onStart` hooks
19
+ *
20
+ * @remarks
21
+ * Route normalization and validation will be executed after all config hooks have been executed.
22
+ *
23
+ * @privateRemarks
24
+ * Changes to configurations are made by reference.
25
+ *
26
+ * These hooks can only modify the `routes` property in the global config.
27
+ *
28
+ * @param hooks - hooks plugins
29
+ * @param globalConfig - global configuration
30
+ */
31
+ export declare function executeStartHooks(hooks: HooksPlugin[], globalConfig: NormalizedLwrGlobalConfig): void;
32
+ //# sourceMappingURL=hooks.d.ts.map
@@ -0,0 +1,59 @@
1
+ import { normalizeRoutes } from './utils/routes.js';
2
+ import { validateLwrAppConfig } from './validation/app-config.js';
3
+ /**
4
+ * Run `initConfigs` hooks
5
+ *
6
+ * @remarks
7
+ * Route normalization and validation will be executed after all config hooks have been executed.
8
+ *
9
+ * @privateRemarks
10
+ * Changes to configurations are made by reference.
11
+ *
12
+ * @param hooks - hooks plugins
13
+ * @param globalConfig - global configuration
14
+ * @param runtimeEnvironment - runtime environment resolved from programmatic config and config file
15
+ * @param globalData - resolved global data
16
+ */
17
+ export async function executeConfigHooks(hooks, globalConfig, runtimeEnvironment, globalData) {
18
+ if (!hooks.length) {
19
+ return;
20
+ }
21
+ for (const hook of hooks) {
22
+ if (!hook.initConfigs) {
23
+ continue;
24
+ }
25
+ // eslint-disable-next-line no-await-in-loop
26
+ await hook.initConfigs(globalConfig, globalData, runtimeEnvironment);
27
+ }
28
+ globalConfig.routes = normalizeRoutes(globalConfig.routes);
29
+ globalConfig.errorRoutes = normalizeRoutes(globalConfig.errorRoutes);
30
+ validateLwrAppConfig(globalConfig, 'post');
31
+ }
32
+ /**
33
+ * Run `onStart` hooks
34
+ *
35
+ * @remarks
36
+ * Route normalization and validation will be executed after all config hooks have been executed.
37
+ *
38
+ * @privateRemarks
39
+ * Changes to configurations are made by reference.
40
+ *
41
+ * These hooks can only modify the `routes` property in the global config.
42
+ *
43
+ * @param hooks - hooks plugins
44
+ * @param globalConfig - global configuration
45
+ */
46
+ export function executeStartHooks(hooks, globalConfig) {
47
+ if (!hooks.length) {
48
+ return;
49
+ }
50
+ for (const hook of hooks) {
51
+ if (!hook.onStart) {
52
+ continue;
53
+ }
54
+ hook.onStart(globalConfig.routes);
55
+ }
56
+ globalConfig.routes = normalizeRoutes(globalConfig.routes);
57
+ validateLwrAppConfig(globalConfig, 'post');
58
+ }
59
+ //# sourceMappingURL=hooks.js.map
@@ -1,5 +1,5 @@
1
- import { resolveGlobalConfig as normalizeConfig, loadConfig, loadRoutes, loadServices } from './global-config.js';
2
- import { getRuntimeEnvironment } from './runtime-config.js';
3
1
  export { version as LWR_VERSION } from '@lwrjs/config/package';
4
- export { normalizeConfig, loadConfig, loadRoutes, loadServices, getRuntimeEnvironment };
2
+ export { loadConfig, resolveGlobalConfig as normalizeConfig } from './global-config.js';
3
+ export { getRuntimeEnvironment } from './runtime-config.js';
4
+ export { executeConfigHooks, executeStartHooks } from './hooks.js';
5
5
  //# sourceMappingURL=index.d.ts.map
package/build/es/index.js CHANGED
@@ -1,6 +1,5 @@
1
- import { resolveGlobalConfig as normalizeConfig, loadConfig, loadRoutes, loadServices, } from './global-config.js';
2
- import { getRuntimeEnvironment } from './runtime-config.js';
3
1
  export { version as LWR_VERSION } from '@lwrjs/config/package';
4
- // Only export the functions we utilize internally
5
- export { normalizeConfig, loadConfig, loadRoutes, loadServices, getRuntimeEnvironment };
2
+ export { loadConfig, resolveGlobalConfig as normalizeConfig } from './global-config.js';
3
+ export { getRuntimeEnvironment } from './runtime-config.js';
4
+ export { executeConfigHooks, executeStartHooks } from './hooks.js';
6
5
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,36 @@
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
+ }
6
+ /**
7
+ * Import and instantiate hooks defined in the global config
8
+ *
9
+ * @remarks
10
+ * The optional dependency `esbuild` MUST be installed to load hook modules.
11
+ *
12
+ * @param config - global config
13
+ * @returns {HooksPlugin[]} all instantiated hooks
14
+ */
15
+ export declare function loadHooks(config: NormalizedLwrGlobalConfig): Promise<HooksPlugin[]>;
16
+ /**
17
+ * Load service modules from the filepaths configured in the global config
18
+ *
19
+ * @remarks
20
+ * The optional dependency `esbuild` MUST be installed to load service modules.
21
+ *
22
+ * @param config - global config
23
+ * @returns {Services} all of the imported service constructors
24
+ */
25
+ export declare function loadServices(config: NormalizedLwrGlobalConfig): Promise<Services>;
26
+ /**
27
+ * Load all route handlers from the filepaths configured in the global config
28
+ *
29
+ * @remarks
30
+ * The optional dependency `esbuild` MUST be installed to load route handler modules.
31
+ *
32
+ * @param config - global config
33
+ * @returns {Routes} all routes with resolved route handlers
34
+ */
35
+ export declare function loadRoutes(config: NormalizedLwrGlobalConfig): Promise<Routes>;
36
+ //# sourceMappingURL=modules.d.ts.map
@@ -0,0 +1,116 @@
1
+ import path from 'path';
2
+ import { normalizeDirectory, resolveFileExtension } from '@lwrjs/shared-utils';
3
+ import { transpileTs } from '@lwrjs/shared-utils/typescript';
4
+ // Bundle Providers are not configurable
5
+ const BUNDLE_PROVIDERS = [
6
+ ['@lwrjs/module-bundler/amd-bundle-provider', undefined],
7
+ ['@lwrjs/module-bundler/esm-bundle-provider', undefined],
8
+ ];
9
+ async function importModule(filepath, rootDir, cacheDir) {
10
+ // ensure paths are fully resolved before loading source
11
+ let resolvedFilePath = normalizeDirectory(filepath, rootDir);
12
+ const resolvedCacheDir = normalizeDirectory(cacheDir, rootDir);
13
+ try {
14
+ if (resolvedFilePath.endsWith('.ts')) {
15
+ const fullPath = resolveFileExtension(resolvedFilePath);
16
+ resolvedFilePath = await transpileTs(fullPath, { rootDir, cacheDir: resolvedCacheDir });
17
+ }
18
+ const moduleEntry = await import(resolvedFilePath);
19
+ const output = moduleEntry.default || moduleEntry;
20
+ return output;
21
+ }
22
+ catch (err) {
23
+ console.log(err);
24
+ throw new Error(`Unable to load configurable module: ${filepath}`);
25
+ }
26
+ }
27
+ async function loadServiceEntries(entries, rootDir, cacheDir) {
28
+ return Promise.all(entries.map(async ([entry, config]) => {
29
+ const ctor = await importModule(entry, rootDir, path.join(cacheDir, 'services'));
30
+ return [ctor, config];
31
+ }));
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
+ /**
54
+ * Import and instantiate hooks defined in the global config
55
+ *
56
+ * @remarks
57
+ * The optional dependency `esbuild` MUST be installed to load hook modules.
58
+ *
59
+ * @param config - global config
60
+ * @returns {HooksPlugin[]} all instantiated hooks
61
+ */
62
+ export async function loadHooks(config) {
63
+ if (!config.hooks) {
64
+ return [];
65
+ }
66
+ const hookCtors = await loadServiceEntries(config.hooks, config.rootDir, config.cacheDir);
67
+ const hooks = hookCtors.map(([hookCtor, hookConfig = {}]) => {
68
+ return new hookCtor(hookConfig);
69
+ });
70
+ return hooks;
71
+ }
72
+ /**
73
+ * Load service modules from the filepaths configured in the global config
74
+ *
75
+ * @remarks
76
+ * The optional dependency `esbuild` MUST be installed to load service modules.
77
+ *
78
+ * @param config - global config
79
+ * @returns {Services} all of the imported service constructors
80
+ */
81
+ export async function loadServices(config) {
82
+ const moduleProviders = await loadServiceEntries(config.moduleProviders, config.rootDir, config.cacheDir);
83
+ const bundleProviders = await loadServiceEntries(BUNDLE_PROVIDERS, config.rootDir, config.cacheDir);
84
+ const assetProviders = await loadServiceEntries(config.assetProviders, config.rootDir, config.cacheDir);
85
+ const assetTransformers = await loadServiceEntries(config.assetTransformers, config.rootDir, config.cacheDir);
86
+ const resourceProviders = await loadServiceEntries(config.resourceProviders, config.rootDir, config.cacheDir);
87
+ const viewProviders = await loadServiceEntries(config.viewProviders, config.rootDir, config.cacheDir);
88
+ const viewTransformers = await loadServiceEntries(config.viewTransformers, config.rootDir, config.cacheDir);
89
+ return {
90
+ moduleProviders,
91
+ bundleProviders,
92
+ assetProviders,
93
+ assetTransformers,
94
+ resourceProviders,
95
+ viewProviders,
96
+ viewTransformers,
97
+ };
98
+ }
99
+ /**
100
+ * Load all route handlers from the filepaths configured in the global config
101
+ *
102
+ * @remarks
103
+ * The optional dependency `esbuild` MUST be installed to load route handler modules.
104
+ *
105
+ * @param config - global config
106
+ * @returns {Routes} all routes with resolved route handlers
107
+ */
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
+ };
115
+ }
116
+ //# sourceMappingURL=modules.js.map
@@ -1,8 +1,7 @@
1
- import type { LwrErrorRoute, LwrRoute, NormalizedLwrErrorRoute, NormalizedLwrRoute, ResourcePaths, Route } from '@lwrjs/types';
1
+ import type { LwrErrorRoute, LwrRoute, NormalizedLwrErrorRoute, NormalizedLwrRoute, ResourcePaths } from '@lwrjs/types';
2
2
  declare type ViewOrErrorRoute = LwrRoute | LwrErrorRoute;
3
3
  declare type NormalizedRoute<T extends ViewOrErrorRoute> = T extends LwrRoute ? NormalizedLwrRoute : NormalizedLwrErrorRoute;
4
4
  export declare function normalizeRoutes<T extends ViewOrErrorRoute>(routes?: T[]): NormalizedRoute<T>[];
5
5
  export declare function normalizeRoutePaths<T extends ViewOrErrorRoute>(routes: T[] | undefined, resourcePaths: ResourcePaths): NormalizedRoute<T>[];
6
- export declare function loadRouteHandlers<T extends ViewOrErrorRoute>(routes: T[], rootDir: string, cacheDir: string): Promise<Route<T>[]>;
7
6
  export {};
8
7
  //# sourceMappingURL=routes.d.ts.map
@@ -1,6 +1,5 @@
1
1
  import path from 'path';
2
2
  import { DEFAULT_LWR_BOOTSTRAP_CONFIG, normalizeDirectory, normalizeResourcePath } from '@lwrjs/shared-utils';
3
- import { loadModule } from './module-loader.js';
4
3
  export function normalizeRoutes(routes = []) {
5
4
  return routes.map((route) => ({
6
5
  ...route,
@@ -23,24 +22,4 @@ export function normalizeRoutePaths(routes = [], resourcePaths) {
23
22
  return route;
24
23
  });
25
24
  }
26
- export async function loadRouteHandlers(routes, rootDir, cacheDir) {
27
- const cache = {};
28
- return Promise.all(routes.map(async (route) => {
29
- if (!route.routeHandler) {
30
- return route;
31
- }
32
- if (cache[route.routeHandler]) {
33
- return {
34
- ...route,
35
- routeHandler: cache[route.routeHandler],
36
- };
37
- }
38
- const routeHandler = await loadModule(route.routeHandler, rootDir, path.join(cacheDir, 'routeHandlers'));
39
- cache[route.routeHandler] = routeHandler;
40
- return {
41
- ...route,
42
- routeHandler,
43
- };
44
- }));
45
- }
46
25
  //# sourceMappingURL=routes.js.map
@@ -1,5 +1,4 @@
1
- import type { LwrService, ServiceConfig, ServiceEntry, ResolvedServiceEntry } from '@lwrjs/types';
1
+ import type { ServiceConfig, ServiceEntry } from '@lwrjs/types';
2
2
  export declare function normalizeServices(services?: ServiceConfig[]): ServiceEntry[];
3
3
  export declare function normalizeServicePaths(services: ServiceConfig[], rootDir: string): ServiceEntry[];
4
- export declare function loadServiceEntries<T extends LwrService>(entries: ServiceEntry[], rootDir: string, cacheDir: string): Promise<ResolvedServiceEntry<T>[]>;
5
4
  //# sourceMappingURL=services.d.ts.map
@@ -1,7 +1,6 @@
1
1
  import path from 'path';
2
2
  import { normalizeDirectory } from '@lwrjs/shared-utils';
3
3
  import { DEFAULT_SERVICE_PACKAGE_NAME } from '../defaults.js';
4
- import { loadModule } from './module-loader.js';
5
4
  export function normalizeServices(services = []) {
6
5
  return services.map((service) => (Array.isArray(service) ? service : [service, undefined]));
7
6
  }
@@ -17,10 +16,4 @@ export function normalizeServicePaths(services, rootDir) {
17
16
  return [serviceName, serviceConfig];
18
17
  });
19
18
  }
20
- export async function loadServiceEntries(entries, rootDir, cacheDir) {
21
- return Promise.all(entries.map(async ([entry, config]) => {
22
- const ctor = await loadModule(entry, rootDir, path.join(cacheDir, 'services'));
23
- return [ctor, config];
24
- }));
25
- }
26
19
  //# sourceMappingURL=services.js.map
@@ -15,7 +15,7 @@ interface ConfigMap {
15
15
  bootstrap: NormalizedLwrAppBootstrapConfig;
16
16
  locker: RequiredLwrLockerConfig;
17
17
  }
18
- export declare const ROOT_ATTRIBUTE_KEYS: ["amdLoader", "apiVersion", "assets", "assetProviders", "assetTransformers", "bundleConfig", "bundleProviders", "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"];
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
19
  export declare const ASSET_DIR_ATTRIBUTE_KEYS: ["alias", "dir", "urlPath"];
20
20
  export declare const ASSET_FILE_ATTRIBUTE_KEYS: ["alias", "file", "urlPath"];
21
21
  export declare const LOCKER_ATTRIBUTE_KEYS: ["enabled", "trustedComponents", "clientOnly"];
@@ -13,7 +13,6 @@ export const ROOT_ATTRIBUTE_KEYS = createKeys('root', [
13
13
  'assetProviders',
14
14
  'assetTransformers',
15
15
  'bundleConfig',
16
- 'bundleProviders',
17
16
  'cacheDir',
18
17
  'contentDir',
19
18
  'environment',
@@ -178,7 +178,6 @@ function validateLocker(node, validationContext) {
178
178
  * - rootDir, cacheDir, contentDir, layoutsDir, globalDataDir: strings
179
179
  * - hooks: array of strings
180
180
  * - moduleProviders: array of services
181
- * - bundleProviders: array of services
182
181
  * - viewProviders: array of services
183
182
  * - resourceProviders: array of services
184
183
  * - assetProviders: array of services
@@ -214,7 +213,6 @@ function validateRoot(node, validationContext, preMerge) {
214
213
  validationContext.assertNotEmptyString(findNode(node, ['globalDataDir']), 'globalDataDir');
215
214
  validationContext.assertArrayOfServices(findNode(node, ['hooks']), 'hooks');
216
215
  validationContext.assertArrayOfServices(findNode(node, ['moduleProviders']), 'moduleProviders');
217
- validationContext.assertArrayOfServices(findNode(node, ['bundleProviders']), 'bundleProviders');
218
216
  validationContext.assertArrayOfServices(findNode(node, ['viewProviders']), 'viewProviders');
219
217
  validationContext.assertArrayOfServices(findNode(node, ['resourceProviders']), 'resourceProviders');
220
218
  validationContext.assertArrayOfServices(findNode(node, ['assetProviders']), 'assetProviders');
package/package.json CHANGED
@@ -4,15 +4,15 @@
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
- "version": "0.9.0-alpha.15",
7
+ "version": "0.9.0-alpha.17",
8
8
  "homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
9
9
  "repository": {
10
10
  "type": "git",
11
- "url": "https://github.com/salesforce/lwr.git",
11
+ "url": "https://github.com/salesforce-experience-platform-emu/lwr.git",
12
12
  "directory": "packages/@lwrjs/config"
13
13
  },
14
14
  "bugs": {
15
- "url": "https://github.com/salesforce/lwr/issues"
15
+ "url": "https://github.com/salesforce-experience-platform-emu/lwr/issues"
16
16
  },
17
17
  "type": "module",
18
18
  "types": "build/es/index.d.ts",
@@ -23,6 +23,10 @@
23
23
  "import": "./build/es/index.js",
24
24
  "require": "./build/cjs/index.cjs"
25
25
  },
26
+ "./modules": {
27
+ "import": "./build/es/modules.js",
28
+ "require": "./build/cjs/modules.cjs"
29
+ },
26
30
  "./package": "./package.cjs"
27
31
  },
28
32
  "files": [
@@ -32,17 +36,16 @@
32
36
  "package.cjs"
33
37
  ],
34
38
  "dependencies": {
35
- "@lwrjs/diagnostics": "0.9.0-alpha.15",
36
- "@lwrjs/shared-utils": "0.9.0-alpha.15",
37
- "esbuild": "^0.9.7",
39
+ "@lwrjs/diagnostics": "0.9.0-alpha.17",
40
+ "@lwrjs/shared-utils": "0.9.0-alpha.17",
38
41
  "fs-extra": "^10.1.0",
39
42
  "jsonc-parser": "^3.0.0"
40
43
  },
41
44
  "devDependencies": {
42
- "@lwrjs/types": "0.9.0-alpha.15"
45
+ "@lwrjs/types": "0.9.0-alpha.17"
43
46
  },
44
47
  "engines": {
45
48
  "node": ">=14.15.4 <19"
46
49
  },
47
- "gitHead": "f32f103d2d5e516daccce1be69f68acd7b4b86fb"
50
+ "gitHead": "447417ff091802927b25cfc1bcb01da02264f41b"
48
51
  }
@@ -1,2 +0,0 @@
1
- export declare function loadModule<T>(filepath: string, rootDir: string, cacheDir: string): Promise<T>;
2
- //# sourceMappingURL=module-loader.d.ts.map
@@ -1,21 +0,0 @@
1
- import { normalizeDirectory, resolveFileExtension } from '@lwrjs/shared-utils';
2
- import { transpileTs } from '@lwrjs/shared-utils/typescript';
3
- export async function loadModule(filepath, rootDir, cacheDir) {
4
- // ensure paths are fully resolved before loading source
5
- let resolvedFilePath = normalizeDirectory(filepath, rootDir);
6
- const resolvedCacheDir = normalizeDirectory(cacheDir, rootDir);
7
- try {
8
- if (resolvedFilePath.endsWith('.ts')) {
9
- const fullPath = resolveFileExtension(resolvedFilePath);
10
- resolvedFilePath = await transpileTs(fullPath, { rootDir, cacheDir: resolvedCacheDir });
11
- }
12
- const moduleEntry = await import(resolvedFilePath);
13
- const output = moduleEntry.default || moduleEntry;
14
- return output;
15
- }
16
- catch (err) {
17
- console.log(err);
18
- throw new Error(`Unable to load configurable module: ${filepath}`);
19
- }
20
- }
21
- //# sourceMappingURL=module-loader.js.map