@lwrjs/config 0.11.0-alpha.1 → 0.11.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/cjs/modules.cjs
CHANGED
|
@@ -86,9 +86,9 @@ async function loadServices(config) {
|
|
|
86
86
|
async function loadRouteHandlers(config) {
|
|
87
87
|
const routeHandlers = {};
|
|
88
88
|
await Promise.all(Object.keys(config.routeHandlers).map(async (id) => {
|
|
89
|
-
const
|
|
89
|
+
const handlerPath = config.routeHandlers[id] || id;
|
|
90
90
|
const handler = await importModule(handlerPath, config.rootDir, import_path.default.join(config.cacheDir, "routeHandlers"));
|
|
91
|
-
routeHandlers[id] =
|
|
91
|
+
routeHandlers[id] = handler;
|
|
92
92
|
}));
|
|
93
93
|
return routeHandlers;
|
|
94
94
|
}
|
|
@@ -35,13 +35,13 @@ var import_shared_utils = __toModule(require("@lwrjs/shared-utils"));
|
|
|
35
35
|
function normalizeRoutes(routes, routeHandlers) {
|
|
36
36
|
return routes.map((route) => {
|
|
37
37
|
if (route.routeHandler) {
|
|
38
|
-
const
|
|
39
|
-
if (!routeHandlers
|
|
40
|
-
routeHandlers[handler] =
|
|
38
|
+
const handler = typeof route.routeHandler === "string" ? route.routeHandler : route.routeHandler[0];
|
|
39
|
+
if (!(handler in routeHandlers)) {
|
|
40
|
+
routeHandlers[handler] = null;
|
|
41
41
|
}
|
|
42
42
|
return {
|
|
43
43
|
...route,
|
|
44
|
-
routeHandler: [
|
|
44
|
+
routeHandler: typeof route.routeHandler === "string" ? [route.routeHandler, void 0] : route.routeHandler,
|
|
45
45
|
bootstrap: {
|
|
46
46
|
...import_shared_utils.DEFAULT_LWR_BOOTSTRAP_CONFIG,
|
|
47
47
|
...route.bootstrap
|
|
@@ -75,16 +75,16 @@ function normalizeRoutePaths(routes = [], resourcePaths) {
|
|
|
75
75
|
function normalizeRouteHandlers(routeHandlers) {
|
|
76
76
|
for (const [id, config] of Object.entries(routeHandlers)) {
|
|
77
77
|
if (typeof config === "string") {
|
|
78
|
-
routeHandlers[id] =
|
|
78
|
+
routeHandlers[id] = config;
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
81
|
return routeHandlers;
|
|
82
82
|
}
|
|
83
83
|
function normalizeRouteHandlerPaths(routeHandlers, resourcePaths) {
|
|
84
|
-
for (const [id,
|
|
85
|
-
const normalizedPath = import_path.default.resolve((0, import_shared_utils.normalizeDirectory)(handler, resourcePaths.rootDir));
|
|
84
|
+
for (const [id, handler] of Object.entries(routeHandlers)) {
|
|
85
|
+
const normalizedPath = import_path.default.resolve((0, import_shared_utils.normalizeDirectory)(handler || id, resourcePaths.rootDir));
|
|
86
86
|
if (import_fs.default.existsSync(normalizedPath)) {
|
|
87
|
-
routeHandlers[id] =
|
|
87
|
+
routeHandlers[id] = normalizedPath;
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
90
|
return routeHandlers;
|
package/build/es/modules.js
CHANGED
|
@@ -85,9 +85,9 @@ export async function loadServices(config) {
|
|
|
85
85
|
export async function loadRouteHandlers(config) {
|
|
86
86
|
const routeHandlers = {};
|
|
87
87
|
await Promise.all(Object.keys(config.routeHandlers).map(async (id) => {
|
|
88
|
-
const
|
|
88
|
+
const handlerPath = config.routeHandlers[id] || id;
|
|
89
89
|
const handler = await importModule(handlerPath, config.rootDir, path.join(config.cacheDir, 'routeHandlers'));
|
|
90
|
-
routeHandlers[id] =
|
|
90
|
+
routeHandlers[id] = handler;
|
|
91
91
|
}));
|
|
92
92
|
return routeHandlers;
|
|
93
93
|
}
|
package/build/es/utils/routes.js
CHANGED
|
@@ -5,13 +5,15 @@ export function normalizeRoutes(routes, routeHandlers) {
|
|
|
5
5
|
return routes.map((route) => {
|
|
6
6
|
// when a route handler is set, ensure it is set in the route handler config
|
|
7
7
|
if (route.routeHandler) {
|
|
8
|
-
const
|
|
9
|
-
if (!routeHandlers
|
|
10
|
-
routeHandlers[handler] =
|
|
8
|
+
const handler = typeof route.routeHandler === 'string' ? route.routeHandler : route.routeHandler[0];
|
|
9
|
+
if (!(handler in routeHandlers)) {
|
|
10
|
+
routeHandlers[handler] = null;
|
|
11
11
|
}
|
|
12
12
|
return {
|
|
13
13
|
...route,
|
|
14
|
-
routeHandler:
|
|
14
|
+
routeHandler: typeof route.routeHandler === 'string'
|
|
15
|
+
? [route.routeHandler, undefined]
|
|
16
|
+
: route.routeHandler,
|
|
15
17
|
bootstrap: {
|
|
16
18
|
...DEFAULT_LWR_BOOTSTRAP_CONFIG,
|
|
17
19
|
...route.bootstrap,
|
|
@@ -46,17 +48,17 @@ export function normalizeRoutePaths(routes = [], resourcePaths) {
|
|
|
46
48
|
export function normalizeRouteHandlers(routeHandlers) {
|
|
47
49
|
for (const [id, config] of Object.entries(routeHandlers)) {
|
|
48
50
|
if (typeof config === 'string') {
|
|
49
|
-
routeHandlers[id] =
|
|
51
|
+
routeHandlers[id] = config;
|
|
50
52
|
}
|
|
51
53
|
}
|
|
52
54
|
return routeHandlers;
|
|
53
55
|
}
|
|
54
56
|
export function normalizeRouteHandlerPaths(routeHandlers, resourcePaths) {
|
|
55
|
-
for (const [id,
|
|
56
|
-
const normalizedPath = path.resolve(normalizeDirectory(handler, resourcePaths.rootDir));
|
|
57
|
+
for (const [id, handler] of Object.entries(routeHandlers)) {
|
|
58
|
+
const normalizedPath = path.resolve(normalizeDirectory(handler || id, resourcePaths.rootDir));
|
|
57
59
|
// use the normalized path if it exists; otherwise the handler is module specifier
|
|
58
60
|
if (fs.existsSync(normalizedPath)) {
|
|
59
|
-
routeHandlers[id] =
|
|
61
|
+
routeHandlers[id] = normalizedPath;
|
|
60
62
|
}
|
|
61
63
|
}
|
|
62
64
|
return routeHandlers;
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
|
-
"version": "0.11.0-alpha.
|
|
7
|
+
"version": "0.11.0-alpha.2",
|
|
8
8
|
"homepage": "https://developer.salesforce.com/docs/platform/lwr/overview",
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
@@ -41,14 +41,14 @@
|
|
|
41
41
|
"test": "jest"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@lwrjs/diagnostics": "0.11.0-alpha.
|
|
45
|
-
"@lwrjs/instrumentation": "0.11.0-alpha.
|
|
46
|
-
"@lwrjs/shared-utils": "0.11.0-alpha.
|
|
44
|
+
"@lwrjs/diagnostics": "0.11.0-alpha.2",
|
|
45
|
+
"@lwrjs/instrumentation": "0.11.0-alpha.2",
|
|
46
|
+
"@lwrjs/shared-utils": "0.11.0-alpha.2",
|
|
47
47
|
"fs-extra": "^11.1.1",
|
|
48
48
|
"jsonc-parser": "^3.0.0"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
|
-
"@lwrjs/types": "0.11.0-alpha.
|
|
51
|
+
"@lwrjs/types": "0.11.0-alpha.2",
|
|
52
52
|
"jest": "^26.6.3",
|
|
53
53
|
"ts-jest": "^26.5.6"
|
|
54
54
|
},
|
|
@@ -61,5 +61,5 @@
|
|
|
61
61
|
"volta": {
|
|
62
62
|
"extends": "../../../package.json"
|
|
63
63
|
},
|
|
64
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "ce7d80468d289a0d24682735513166f163f29f61"
|
|
65
65
|
}
|