@modern-js/app-tools 2.53.1-alpha.4 → 2.54.1-alpha.0
Sign up to get free protection for your applications and to get access to all the features.
- package/bin/modern.js +0 -2
- package/dist/cjs/builder/shared/builderPlugins/adapterHtml.js +2 -1
- package/dist/cjs/builder/shared/builderPlugins/adapterSSR.js +2 -2
- package/dist/cjs/commands/build.js +2 -0
- package/dist/cjs/commands/deploy.js +2 -2
- package/dist/cjs/commands/dev.js +19 -5
- package/dist/cjs/commands/index.js +113 -7
- package/dist/cjs/commands/serve.js +19 -5
- package/dist/cjs/hooks.js +5 -0
- package/dist/cjs/index.js +14 -83
- package/dist/cjs/plugins/analyze/constants.js +56 -0
- package/dist/cjs/{analyze → plugins/analyze}/generateCode.js +11 -84
- package/dist/cjs/{analyze → plugins/analyze}/getBundleEntry.js +11 -20
- package/dist/cjs/{analyze → plugins/analyze}/getFileSystemEntry.js +33 -47
- package/dist/cjs/{analyze → plugins/analyze}/getServerRoutes.js +1 -1
- package/dist/cjs/{analyze → plugins/analyze}/index.js +9 -24
- package/dist/cjs/plugins/analyze/templates.js +101 -0
- package/dist/cjs/{analyze → plugins/analyze}/utils.js +12 -55
- package/dist/cjs/plugins/deploy/platforms/netlify.js +2 -2
- package/dist/cjs/plugins/deploy/platforms/node.js +2 -2
- package/dist/cjs/plugins/deploy/platforms/vercel.js +2 -2
- package/dist/cjs/{initialize → plugins/initialize}/index.js +1 -1
- package/dist/cjs/plugins/serverBuild.js +10 -4
- package/dist/cjs/utils/createServer.js +1 -1
- package/dist/cjs/utils/{getServerInternalPlugins.js → loadPlugins.js} +18 -11
- package/dist/esm/builder/shared/builderPlugins/adapterHtml.js +4 -1
- package/dist/esm/builder/shared/builderPlugins/adapterSSR.js +2 -2
- package/dist/esm/commands/build.js +16 -9
- package/dist/esm/commands/deploy.js +2 -2
- package/dist/esm/commands/dev.js +13 -9
- package/dist/esm/commands/index.js +411 -3
- package/dist/esm/commands/serve.js +12 -8
- package/dist/esm/hooks.js +5 -0
- package/dist/esm/index.js +12 -394
- package/dist/esm/plugins/analyze/constants.js +24 -0
- package/dist/esm/{analyze → plugins/analyze}/generateCode.js +27 -169
- package/dist/esm/plugins/analyze/getBundleEntry.js +101 -0
- package/dist/esm/plugins/analyze/getFileSystemEntry.js +195 -0
- package/dist/esm/{analyze → plugins/analyze}/getServerRoutes.js +1 -1
- package/dist/esm/{analyze → plugins/analyze}/index.js +42 -70
- package/dist/esm/plugins/analyze/templates.js +22 -0
- package/dist/esm/{analyze → plugins/analyze}/utils.js +13 -135
- package/dist/esm/plugins/deploy/platforms/netlify.js +5 -3
- package/dist/esm/plugins/deploy/platforms/node.js +5 -3
- package/dist/esm/plugins/deploy/platforms/vercel.js +5 -3
- package/dist/esm/{initialize → plugins/initialize}/index.js +1 -1
- package/dist/esm/plugins/serverBuild.js +13 -6
- package/dist/esm/utils/createServer.js +2 -2
- package/dist/esm/utils/loadPlugins.js +64 -0
- package/dist/esm-node/builder/shared/builderPlugins/adapterHtml.js +2 -1
- package/dist/esm-node/builder/shared/builderPlugins/adapterSSR.js +2 -2
- package/dist/esm-node/commands/build.js +2 -0
- package/dist/esm-node/commands/deploy.js +2 -2
- package/dist/esm-node/commands/dev.js +11 -7
- package/dist/esm-node/commands/index.js +92 -3
- package/dist/esm-node/commands/serve.js +10 -6
- package/dist/esm-node/hooks.js +5 -0
- package/dist/esm-node/index.js +12 -79
- package/dist/esm-node/plugins/analyze/constants.js +24 -0
- package/dist/esm-node/{analyze → plugins/analyze}/generateCode.js +14 -87
- package/dist/esm-node/{analyze → plugins/analyze}/getBundleEntry.js +11 -20
- package/dist/esm-node/plugins/analyze/getFileSystemEntry.js +75 -0
- package/dist/esm-node/{analyze → plugins/analyze}/getServerRoutes.js +1 -1
- package/dist/esm-node/{analyze → plugins/analyze}/index.js +10 -25
- package/dist/esm-node/plugins/analyze/templates.js +75 -0
- package/dist/esm-node/{analyze → plugins/analyze}/utils.js +13 -52
- package/dist/esm-node/plugins/deploy/platforms/netlify.js +3 -3
- package/dist/esm-node/plugins/deploy/platforms/node.js +3 -3
- package/dist/esm-node/plugins/deploy/platforms/vercel.js +3 -3
- package/dist/esm-node/{initialize → plugins/initialize}/index.js +1 -1
- package/dist/esm-node/plugins/serverBuild.js +11 -5
- package/dist/esm-node/utils/createServer.js +2 -2
- package/dist/esm-node/utils/loadPlugins.js +21 -0
- package/dist/types/builder/builder-webpack/createCopyPattern.d.ts +2 -2
- package/dist/types/commands/index.d.ts +10 -3
- package/dist/types/config/initialize/inits.d.ts +1 -1
- package/dist/types/exports/server.d.ts +4 -0
- package/dist/types/index.d.ts +2 -5
- package/dist/types/plugins/analyze/constants.d.ts +9 -0
- package/dist/types/{analyze → plugins/analyze}/generateCode.d.ts +1 -1
- package/dist/types/plugins/analyze/getBundleEntry.d.ts +4 -0
- package/dist/types/plugins/analyze/getFileSystemEntry.d.ts +5 -0
- package/dist/types/{analyze → plugins/analyze}/getHtmlTemplate.d.ts +1 -1
- package/dist/types/{analyze → plugins/analyze}/getServerRoutes.d.ts +1 -1
- package/dist/types/{analyze → plugins/analyze}/index.d.ts +1 -1
- package/dist/types/plugins/analyze/templates.d.ts +19 -0
- package/dist/types/{analyze → plugins/analyze}/utils.d.ts +4 -6
- package/dist/types/{initialize → plugins/initialize}/index.d.ts +1 -1
- package/dist/types/types/hooks.d.ts +11 -1
- package/dist/types/utils/loadPlugins.d.ts +5 -0
- package/package.json +22 -22
- package/dist/cjs/analyze/constants.js +0 -122
- package/dist/cjs/analyze/getClientRoutes/getRoutes.js +0 -197
- package/dist/cjs/analyze/getClientRoutes/getRoutesLegacy.js +0 -195
- package/dist/cjs/analyze/getClientRoutes/index.js +0 -31
- package/dist/cjs/analyze/getClientRoutes/utils.js +0 -59
- package/dist/cjs/analyze/makeLegalIdentifier.js +0 -37
- package/dist/cjs/analyze/nestedRoutes.js +0 -295
- package/dist/cjs/analyze/templates.js +0 -444
- package/dist/esm/analyze/constants.js +0 -76
- package/dist/esm/analyze/getBundleEntry.js +0 -75
- package/dist/esm/analyze/getClientRoutes/getRoutes.js +0 -185
- package/dist/esm/analyze/getClientRoutes/getRoutesLegacy.js +0 -183
- package/dist/esm/analyze/getClientRoutes/index.js +0 -6
- package/dist/esm/analyze/getClientRoutes/utils.js +0 -28
- package/dist/esm/analyze/getFileSystemEntry.js +0 -113
- package/dist/esm/analyze/makeLegalIdentifier.js +0 -15
- package/dist/esm/analyze/nestedRoutes.js +0 -398
- package/dist/esm/analyze/templates.js +0 -435
- package/dist/esm/utils/getServerInternalPlugins.js +0 -40
- package/dist/esm-node/analyze/constants.js +0 -76
- package/dist/esm-node/analyze/getClientRoutes/getRoutes.js +0 -163
- package/dist/esm-node/analyze/getClientRoutes/getRoutesLegacy.js +0 -161
- package/dist/esm-node/analyze/getClientRoutes/index.js +0 -6
- package/dist/esm-node/analyze/getClientRoutes/utils.js +0 -22
- package/dist/esm-node/analyze/getFileSystemEntry.js +0 -89
- package/dist/esm-node/analyze/makeLegalIdentifier.js +0 -13
- package/dist/esm-node/analyze/nestedRoutes.js +0 -259
- package/dist/esm-node/analyze/templates.js +0 -405
- package/dist/esm-node/utils/getServerInternalPlugins.js +0 -15
- package/dist/types/analyze/constants.d.ts +0 -42
- package/dist/types/analyze/getBundleEntry.d.ts +0 -3
- package/dist/types/analyze/getClientRoutes/getRoutes.d.ts +0 -8
- package/dist/types/analyze/getClientRoutes/getRoutesLegacy.d.ts +0 -9
- package/dist/types/analyze/getClientRoutes/index.d.ts +0 -2
- package/dist/types/analyze/getClientRoutes/utils.d.ts +0 -5
- package/dist/types/analyze/getFileSystemEntry.d.ts +0 -4
- package/dist/types/analyze/makeLegalIdentifier.d.ts +0 -1
- package/dist/types/analyze/nestedRoutes.d.ts +0 -7
- package/dist/types/analyze/templates.d.ts +0 -30
- package/dist/types/utils/getServerInternalPlugins.d.ts +0 -2
- /package/dist/cjs/{analyze → plugins/analyze}/getHtmlTemplate.js +0 -0
- /package/dist/cjs/{analyze → plugins/analyze}/isDefaultExportFunction.js +0 -0
- /package/dist/esm/{analyze → plugins/analyze}/getHtmlTemplate.js +0 -0
- /package/dist/esm/{analyze → plugins/analyze}/isDefaultExportFunction.js +0 -0
- /package/dist/esm-node/{analyze → plugins/analyze}/getHtmlTemplate.js +0 -0
- /package/dist/esm-node/{analyze → plugins/analyze}/isDefaultExportFunction.js +0 -0
- /package/dist/types/{analyze → plugins/analyze}/isDefaultExportFunction.d.ts +0 -0
@@ -1,398 +0,0 @@
|
|
1
|
-
import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
|
2
|
-
import { _ as _object_spread } from "@swc/helpers/_/_object_spread";
|
3
|
-
import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props";
|
4
|
-
import { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
|
5
|
-
import * as path from "path";
|
6
|
-
import { fs, normalizeToPosixPath } from "@modern-js/utils";
|
7
|
-
import { getPathWithoutExt } from "../utils/routes";
|
8
|
-
import { JS_EXTENSIONS, NESTED_ROUTE } from "./constants";
|
9
|
-
import { hasAction, replaceWithAlias } from "./utils";
|
10
|
-
var conventionNames = Object.values(NESTED_ROUTE);
|
11
|
-
var replaceDynamicPath = function(routePath) {
|
12
|
-
return routePath.replace(/\[(.*?)\]/g, ":$1");
|
13
|
-
};
|
14
|
-
var getRouteId = function(componentPath, routesDir, entryName, isMainEntry) {
|
15
|
-
var relativePath = normalizeToPosixPath(path.relative(routesDir, componentPath));
|
16
|
-
var pathWithoutExt = getPathWithoutExt(relativePath);
|
17
|
-
var id = "";
|
18
|
-
if (isMainEntry) {
|
19
|
-
id = pathWithoutExt;
|
20
|
-
} else {
|
21
|
-
id = "".concat(entryName, "_").concat(pathWithoutExt);
|
22
|
-
}
|
23
|
-
return id.replace(/\[(.*?)\]/g, "($1)");
|
24
|
-
};
|
25
|
-
var createIndexRoute = function(routeInfo, rootDir, filename, entryName, isMainEntry) {
|
26
|
-
return createRoute(_object_spread_props(_object_spread({}, routeInfo), {
|
27
|
-
index: true,
|
28
|
-
children: void 0
|
29
|
-
}), rootDir, filename, entryName, isMainEntry);
|
30
|
-
};
|
31
|
-
var createRoute = function(routeInfo, rootDir, filename, entryName, isMainEntry) {
|
32
|
-
var id = getRouteId(filename, rootDir, entryName, isMainEntry);
|
33
|
-
return _object_spread_props(_object_spread({}, routeInfo), {
|
34
|
-
id,
|
35
|
-
type: "nested"
|
36
|
-
});
|
37
|
-
};
|
38
|
-
var optimizeRoute = function(routeTree) {
|
39
|
-
if (!routeTree.children || routeTree.children.length === 0) {
|
40
|
-
return [
|
41
|
-
routeTree
|
42
|
-
];
|
43
|
-
}
|
44
|
-
var children = routeTree.children;
|
45
|
-
if (!routeTree._component && !routeTree.error && !routeTree.loading && !routeTree.config && !routeTree.clientData) {
|
46
|
-
var newRoutes = children.map(function(child) {
|
47
|
-
var routePath = "".concat(routeTree.path ? routeTree.path : "").concat(child.path ? "/".concat(child.path) : "");
|
48
|
-
var newRoute = _object_spread_props(_object_spread({}, child), {
|
49
|
-
path: routePath.replace(/\/\//g, "/")
|
50
|
-
});
|
51
|
-
if (routePath.length > 0) {
|
52
|
-
delete newRoute.index;
|
53
|
-
} else {
|
54
|
-
delete newRoute.path;
|
55
|
-
}
|
56
|
-
return newRoute;
|
57
|
-
});
|
58
|
-
return Array.from(new Set(newRoutes)).flatMap(optimizeRoute);
|
59
|
-
} else {
|
60
|
-
var optimizedChildren = routeTree.children.flatMap(optimizeRoute);
|
61
|
-
return [
|
62
|
-
_object_spread_props(_object_spread({}, routeTree), {
|
63
|
-
children: optimizedChildren
|
64
|
-
})
|
65
|
-
];
|
66
|
-
}
|
67
|
-
};
|
68
|
-
var walk = function() {
|
69
|
-
var _ref = _async_to_generator(function(dirname, rootDir, alias, entryName, isMainEntry, oldVersion) {
|
70
|
-
var _finalRoute_children, isDirectory, relativeDir, pathSegments, lastSegment, isRoot, isPathlessLayout, isWithoutLayoutPath, routePath, route, pageLoaderFile, pageRoute, pageConfigFile, pageClientData, pageData, pageAction, splatLoaderFile, splatRoute, splatConfigFile, splatClientData, splatData, splatAction, items, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, item, itemPath, itemPathWithAlias, extname, itemWithoutExt, isDirectory1, childRoute, _route_children, _route_children1, _route_children2, err, finalRoute, childRoutes, childRoute1, _$path, optimizedRoutes;
|
71
|
-
return _ts_generator(this, function(_state) {
|
72
|
-
switch (_state.label) {
|
73
|
-
case 0:
|
74
|
-
return [
|
75
|
-
4,
|
76
|
-
fs.pathExists(dirname)
|
77
|
-
];
|
78
|
-
case 1:
|
79
|
-
if (!_state.sent()) {
|
80
|
-
return [
|
81
|
-
2,
|
82
|
-
null
|
83
|
-
];
|
84
|
-
}
|
85
|
-
return [
|
86
|
-
4,
|
87
|
-
fs.stat(dirname)
|
88
|
-
];
|
89
|
-
case 2:
|
90
|
-
isDirectory = _state.sent().isDirectory();
|
91
|
-
if (!isDirectory) {
|
92
|
-
return [
|
93
|
-
2,
|
94
|
-
null
|
95
|
-
];
|
96
|
-
}
|
97
|
-
relativeDir = path.relative(rootDir, dirname);
|
98
|
-
pathSegments = relativeDir.split(path.sep);
|
99
|
-
lastSegment = pathSegments[pathSegments.length - 1];
|
100
|
-
isRoot = lastSegment === "";
|
101
|
-
isPathlessLayout = lastSegment.startsWith("__");
|
102
|
-
isWithoutLayoutPath = lastSegment.includes(".");
|
103
|
-
routePath = isRoot || isPathlessLayout ? "/" : "".concat(lastSegment);
|
104
|
-
if (isWithoutLayoutPath) {
|
105
|
-
routePath = lastSegment.split(".").join("/");
|
106
|
-
}
|
107
|
-
routePath = replaceDynamicPath(routePath);
|
108
|
-
route = {
|
109
|
-
path: routePath === null || routePath === void 0 ? void 0 : routePath.replace(/\$$/, "?"),
|
110
|
-
children: [],
|
111
|
-
isRoot
|
112
|
-
};
|
113
|
-
pageLoaderFile = "";
|
114
|
-
pageRoute = null;
|
115
|
-
pageConfigFile = "";
|
116
|
-
pageClientData = "";
|
117
|
-
pageData = "";
|
118
|
-
pageAction = "";
|
119
|
-
splatLoaderFile = "";
|
120
|
-
splatRoute = null;
|
121
|
-
splatConfigFile = "";
|
122
|
-
splatClientData = "";
|
123
|
-
splatData = "";
|
124
|
-
splatAction = "";
|
125
|
-
return [
|
126
|
-
4,
|
127
|
-
fs.readdir(dirname)
|
128
|
-
];
|
129
|
-
case 3:
|
130
|
-
items = _state.sent();
|
131
|
-
_iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
132
|
-
_state.label = 4;
|
133
|
-
case 4:
|
134
|
-
_state.trys.push([
|
135
|
-
4,
|
136
|
-
17,
|
137
|
-
18,
|
138
|
-
19
|
139
|
-
]);
|
140
|
-
_iterator = items[Symbol.iterator]();
|
141
|
-
_state.label = 5;
|
142
|
-
case 5:
|
143
|
-
if (!!(_iteratorNormalCompletion = (_step = _iterator.next()).done))
|
144
|
-
return [
|
145
|
-
3,
|
146
|
-
16
|
147
|
-
];
|
148
|
-
item = _step.value;
|
149
|
-
itemPath = path.join(dirname, item);
|
150
|
-
itemPathWithAlias = getPathWithoutExt(replaceWithAlias(alias.basename, itemPath, alias.name));
|
151
|
-
extname = path.extname(item);
|
152
|
-
itemWithoutExt = item.slice(0, -extname.length);
|
153
|
-
return [
|
154
|
-
4,
|
155
|
-
fs.stat(itemPath)
|
156
|
-
];
|
157
|
-
case 6:
|
158
|
-
isDirectory1 = _state.sent().isDirectory();
|
159
|
-
if (!isDirectory1)
|
160
|
-
return [
|
161
|
-
3,
|
162
|
-
8
|
163
|
-
];
|
164
|
-
return [
|
165
|
-
4,
|
166
|
-
walk(itemPath, rootDir, alias, entryName, isMainEntry, oldVersion)
|
167
|
-
];
|
168
|
-
case 7:
|
169
|
-
childRoute = _state.sent();
|
170
|
-
if (childRoute && !Array.isArray(childRoute)) {
|
171
|
-
;
|
172
|
-
(_route_children = route.children) === null || _route_children === void 0 ? void 0 : _route_children.push(childRoute);
|
173
|
-
}
|
174
|
-
_state.label = 8;
|
175
|
-
case 8:
|
176
|
-
if (extname && (!JS_EXTENSIONS.includes(extname) || !conventionNames.includes(itemWithoutExt))) {
|
177
|
-
return [
|
178
|
-
3,
|
179
|
-
15
|
180
|
-
];
|
181
|
-
}
|
182
|
-
if (itemWithoutExt === NESTED_ROUTE.LAYOUT_LOADER_FILE) {
|
183
|
-
if (!route.loader) {
|
184
|
-
route.loader = itemPathWithAlias;
|
185
|
-
}
|
186
|
-
}
|
187
|
-
if (itemWithoutExt === NESTED_ROUTE.LAYOUT_CLIENT_LOADER) {
|
188
|
-
route.clientData = itemPathWithAlias;
|
189
|
-
}
|
190
|
-
if (!(itemWithoutExt === NESTED_ROUTE.LAYOUT_DATA_FILE))
|
191
|
-
return [
|
192
|
-
3,
|
193
|
-
10
|
194
|
-
];
|
195
|
-
route.data = itemPathWithAlias;
|
196
|
-
return [
|
197
|
-
4,
|
198
|
-
hasAction(itemPath)
|
199
|
-
];
|
200
|
-
case 9:
|
201
|
-
if (_state.sent()) {
|
202
|
-
route.action = itemPathWithAlias;
|
203
|
-
}
|
204
|
-
_state.label = 10;
|
205
|
-
case 10:
|
206
|
-
if (itemWithoutExt === NESTED_ROUTE.LAYOUT_CONFIG_FILE) {
|
207
|
-
if (!route.config) {
|
208
|
-
route.config = itemPathWithAlias;
|
209
|
-
}
|
210
|
-
}
|
211
|
-
if (itemWithoutExt === NESTED_ROUTE.LAYOUT_FILE) {
|
212
|
-
route._component = itemPathWithAlias;
|
213
|
-
}
|
214
|
-
if (itemWithoutExt === NESTED_ROUTE.PAGE_LOADER_FILE) {
|
215
|
-
pageLoaderFile = itemPathWithAlias;
|
216
|
-
}
|
217
|
-
if (itemWithoutExt === NESTED_ROUTE.PAGE_CLIENT_LOADER) {
|
218
|
-
pageClientData = itemPathWithAlias;
|
219
|
-
}
|
220
|
-
if (!(itemWithoutExt === NESTED_ROUTE.PAGE_DATA_FILE))
|
221
|
-
return [
|
222
|
-
3,
|
223
|
-
12
|
224
|
-
];
|
225
|
-
pageData = itemPathWithAlias;
|
226
|
-
return [
|
227
|
-
4,
|
228
|
-
hasAction(itemPath)
|
229
|
-
];
|
230
|
-
case 11:
|
231
|
-
if (_state.sent()) {
|
232
|
-
pageAction = itemPathWithAlias;
|
233
|
-
}
|
234
|
-
_state.label = 12;
|
235
|
-
case 12:
|
236
|
-
if (itemWithoutExt === NESTED_ROUTE.PAGE_CONFIG_FILE) {
|
237
|
-
pageConfigFile = itemPathWithAlias;
|
238
|
-
}
|
239
|
-
if (itemWithoutExt === NESTED_ROUTE.PAGE_FILE) {
|
240
|
-
;
|
241
|
-
pageRoute = createIndexRoute({
|
242
|
-
_component: itemPathWithAlias
|
243
|
-
}, rootDir, itemPath, entryName, isMainEntry);
|
244
|
-
if (pageLoaderFile) {
|
245
|
-
pageRoute.loader = pageLoaderFile;
|
246
|
-
}
|
247
|
-
if (pageConfigFile) {
|
248
|
-
pageRoute.config = pageConfigFile;
|
249
|
-
}
|
250
|
-
if (pageData) {
|
251
|
-
pageRoute.data = pageData;
|
252
|
-
}
|
253
|
-
if (pageClientData) {
|
254
|
-
pageRoute.clientData = pageClientData;
|
255
|
-
}
|
256
|
-
if (pageAction) {
|
257
|
-
pageRoute.action = pageAction;
|
258
|
-
}
|
259
|
-
(_route_children1 = route.children) === null || _route_children1 === void 0 ? void 0 : _route_children1.push(pageRoute);
|
260
|
-
}
|
261
|
-
if (itemWithoutExt === NESTED_ROUTE.SPLATE_LOADER_FILE) {
|
262
|
-
splatLoaderFile = itemPathWithAlias;
|
263
|
-
}
|
264
|
-
if (itemWithoutExt === NESTED_ROUTE.SPLATE_CLIENT_DATA) {
|
265
|
-
splatClientData = itemPathWithAlias;
|
266
|
-
}
|
267
|
-
if (itemWithoutExt === NESTED_ROUTE.SPLATE_CONFIG_FILE) {
|
268
|
-
if (!route.config) {
|
269
|
-
splatConfigFile = replaceWithAlias(alias.basename, itemPath, alias.name);
|
270
|
-
}
|
271
|
-
}
|
272
|
-
if (!(itemWithoutExt === NESTED_ROUTE.SPLATE_DATA_FILE))
|
273
|
-
return [
|
274
|
-
3,
|
275
|
-
14
|
276
|
-
];
|
277
|
-
splatData = itemPathWithAlias;
|
278
|
-
return [
|
279
|
-
4,
|
280
|
-
hasAction(itemPath)
|
281
|
-
];
|
282
|
-
case 13:
|
283
|
-
if (_state.sent()) {
|
284
|
-
splatAction = itemPathWithAlias;
|
285
|
-
}
|
286
|
-
_state.label = 14;
|
287
|
-
case 14:
|
288
|
-
if (itemWithoutExt === NESTED_ROUTE.SPLATE_FILE) {
|
289
|
-
;
|
290
|
-
splatRoute = createRoute({
|
291
|
-
_component: itemPathWithAlias,
|
292
|
-
path: "*"
|
293
|
-
}, rootDir, itemPath, entryName, isMainEntry);
|
294
|
-
if (splatLoaderFile) {
|
295
|
-
splatRoute.loader = splatLoaderFile;
|
296
|
-
}
|
297
|
-
if (splatClientData) {
|
298
|
-
splatRoute.clientData = splatClientData;
|
299
|
-
}
|
300
|
-
if (splatData) {
|
301
|
-
splatRoute.data = splatData;
|
302
|
-
}
|
303
|
-
if (splatConfigFile) {
|
304
|
-
splatRoute.config = splatConfigFile;
|
305
|
-
}
|
306
|
-
if (splatAction) {
|
307
|
-
splatRoute.action = splatAction;
|
308
|
-
}
|
309
|
-
(_route_children2 = route.children) === null || _route_children2 === void 0 ? void 0 : _route_children2.push(splatRoute);
|
310
|
-
}
|
311
|
-
if (itemWithoutExt === NESTED_ROUTE.LOADING_FILE) {
|
312
|
-
route.loading = itemPathWithAlias;
|
313
|
-
}
|
314
|
-
if (itemWithoutExt === NESTED_ROUTE.ERROR_FILE) {
|
315
|
-
route.error = itemPathWithAlias;
|
316
|
-
}
|
317
|
-
_state.label = 15;
|
318
|
-
case 15:
|
319
|
-
_iteratorNormalCompletion = true;
|
320
|
-
return [
|
321
|
-
3,
|
322
|
-
5
|
323
|
-
];
|
324
|
-
case 16:
|
325
|
-
return [
|
326
|
-
3,
|
327
|
-
19
|
328
|
-
];
|
329
|
-
case 17:
|
330
|
-
err = _state.sent();
|
331
|
-
_didIteratorError = true;
|
332
|
-
_iteratorError = err;
|
333
|
-
return [
|
334
|
-
3,
|
335
|
-
19
|
336
|
-
];
|
337
|
-
case 18:
|
338
|
-
try {
|
339
|
-
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
340
|
-
_iterator.return();
|
341
|
-
}
|
342
|
-
} finally {
|
343
|
-
if (_didIteratorError) {
|
344
|
-
throw _iteratorError;
|
345
|
-
}
|
346
|
-
}
|
347
|
-
return [
|
348
|
-
7
|
349
|
-
];
|
350
|
-
case 19:
|
351
|
-
finalRoute = createRoute(route, rootDir, path.join(dirname, "".concat(NESTED_ROUTE.LAYOUT_FILE, ".ts")), entryName, isMainEntry);
|
352
|
-
if (isPathlessLayout) {
|
353
|
-
delete finalRoute.path;
|
354
|
-
}
|
355
|
-
childRoutes = finalRoute.children = (_finalRoute_children = finalRoute.children) === null || _finalRoute_children === void 0 ? void 0 : _finalRoute_children.filter(function(childRoute2) {
|
356
|
-
return childRoute2;
|
357
|
-
});
|
358
|
-
if (childRoutes && childRoutes.length === 0 && !finalRoute.index && !finalRoute._component) {
|
359
|
-
return [
|
360
|
-
2,
|
361
|
-
null
|
362
|
-
];
|
363
|
-
}
|
364
|
-
if (childRoutes && childRoutes.length === 1 && !finalRoute._component) {
|
365
|
-
childRoute1 = childRoutes[0];
|
366
|
-
if (childRoute1.path === "*") {
|
367
|
-
_$path = "".concat(finalRoute.path || "", "/").concat(childRoute1.path || "");
|
368
|
-
finalRoute = _object_spread_props(_object_spread({}, childRoute1), {
|
369
|
-
path: _$path
|
370
|
-
});
|
371
|
-
}
|
372
|
-
}
|
373
|
-
if (isRoot && !finalRoute._component) {
|
374
|
-
throw new Error("The root layout component is required, make sure the routes/layout.tsx file exists.");
|
375
|
-
}
|
376
|
-
if (isRoot && !oldVersion) {
|
377
|
-
optimizedRoutes = optimizeRoute(finalRoute);
|
378
|
-
return [
|
379
|
-
2,
|
380
|
-
optimizedRoutes
|
381
|
-
];
|
382
|
-
}
|
383
|
-
return [
|
384
|
-
2,
|
385
|
-
finalRoute
|
386
|
-
];
|
387
|
-
}
|
388
|
-
});
|
389
|
-
});
|
390
|
-
return function walk2(dirname, rootDir, alias, entryName, isMainEntry, oldVersion) {
|
391
|
-
return _ref.apply(this, arguments);
|
392
|
-
};
|
393
|
-
}();
|
394
|
-
export {
|
395
|
-
getRouteId,
|
396
|
-
optimizeRoute,
|
397
|
-
walk
|
398
|
-
};
|