@modern-js/runtime 3.11.2 → 3.12.0
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/dist/cjs/cli/ssr/index.js +2 -2
- package/dist/cjs/cli/ssr/mode.js +1 -1
- package/dist/cjs/cli/template.js +1 -1
- package/dist/cjs/core/context/monitors/default.js +2 -2
- package/dist/cjs/core/context/response/index.js +3 -3
- package/dist/cjs/core/context/serverPayload/index.js +1 -1
- package/dist/cjs/core/react/wrapper.js +1 -1
- package/dist/cjs/core/server/stream/createReadableStream.worker.js +1 -1
- package/dist/cjs/core/server/string/loadable.js +2 -2
- package/dist/cjs/router/cli/code/index.js +2 -1
- package/dist/cjs/router/cli/code/nestedRoutes.js +6 -0
- package/dist/cjs/router/cli/code/templates.js +19 -9
- package/dist/cjs/router/cli/code/utils.js +4 -0
- package/dist/cjs/router/cli/config-routes/converter.js +2 -2
- package/dist/cjs/router/cli/constants.js +4 -0
- package/dist/cjs/router/cli/index.js +1 -1
- package/dist/cjs/router/runtime/plugin.node.js +2 -2
- package/dist/esm/cli/ssr/index.mjs +2 -2
- package/dist/esm/cli/ssr/mode.mjs +1 -1
- package/dist/esm/cli/template.mjs +1 -1
- package/dist/esm/core/context/monitors/default.mjs +2 -2
- package/dist/esm/core/context/response/index.mjs +3 -3
- package/dist/esm/core/context/serverPayload/index.mjs +1 -1
- package/dist/esm/core/react/wrapper.mjs +1 -1
- package/dist/esm/core/server/stream/createReadableStream.worker.mjs +1 -1
- package/dist/esm/core/server/string/loadable.mjs +2 -2
- package/dist/esm/router/cli/code/index.mjs +3 -2
- package/dist/esm/router/cli/code/nestedRoutes.mjs +7 -1
- package/dist/esm/router/cli/code/templates.mjs +19 -9
- package/dist/esm/router/cli/code/utils.mjs +3 -2
- package/dist/esm/router/cli/config-routes/converter.mjs +2 -2
- package/dist/esm/router/cli/constants.mjs +2 -1
- package/dist/esm/router/cli/index.mjs +1 -1
- package/dist/esm/router/runtime/plugin.node.mjs +2 -2
- package/dist/esm-node/cli/ssr/index.mjs +2 -2
- package/dist/esm-node/cli/ssr/mode.mjs +1 -1
- package/dist/esm-node/cli/template.mjs +1 -1
- package/dist/esm-node/core/context/monitors/default.mjs +2 -2
- package/dist/esm-node/core/context/response/index.mjs +3 -3
- package/dist/esm-node/core/context/serverPayload/index.mjs +1 -1
- package/dist/esm-node/core/react/wrapper.mjs +1 -1
- package/dist/esm-node/core/server/stream/createReadableStream.worker.mjs +1 -1
- package/dist/esm-node/core/server/string/loadable.mjs +2 -2
- package/dist/esm-node/router/cli/code/index.mjs +3 -2
- package/dist/esm-node/router/cli/code/nestedRoutes.mjs +7 -1
- package/dist/esm-node/router/cli/code/templates.mjs +19 -9
- package/dist/esm-node/router/cli/code/utils.mjs +3 -2
- package/dist/esm-node/router/cli/config-routes/converter.mjs +2 -2
- package/dist/esm-node/router/cli/constants.mjs +2 -1
- package/dist/esm-node/router/cli/index.mjs +1 -1
- package/dist/esm-node/router/runtime/plugin.node.mjs +2 -2
- package/dist/types/cli/template.d.ts +1 -1
- package/dist/types/core/context/response/index.d.ts +3 -3
- package/dist/types/core/context/serverPayload/index.d.ts +1 -1
- package/dist/types/router/cli/code/templates.d.ts +2 -1
- package/dist/types/router/cli/code/utils.d.ts +1 -0
- package/dist/types/router/cli/constants.d.ts +1 -0
- package/package.json +11 -11
|
@@ -4,9 +4,11 @@ import { JS_EXTENSIONS, findExists, formatImportPath, fs, getEntryOptions, isSSG
|
|
|
4
4
|
import { ROUTE_MODULES } from "@modern-js/utils/universal/constants";
|
|
5
5
|
import { APP_INIT_EXPORTED, TEMP_LOADERS_DIR } from "../constants.mjs";
|
|
6
6
|
import { getPathWithoutExt, getServerLoadersFile, parseModule, replaceWithAlias } from "./utils.mjs";
|
|
7
|
-
const routesForServer = ({ routesForServerLoaderMatches })=>{
|
|
7
|
+
const routesForServer = ({ routesForServerLoaderMatches, ssg = false })=>{
|
|
8
8
|
const loaders = [];
|
|
9
9
|
const actions = [];
|
|
10
|
+
const ssgParamsImports = [];
|
|
11
|
+
const ssgParamsEntries = [];
|
|
10
12
|
const loadersMap = {};
|
|
11
13
|
const traverseRouteTree = (route)=>{
|
|
12
14
|
let children;
|
|
@@ -14,6 +16,11 @@ const routesForServer = ({ routesForServerLoaderMatches })=>{
|
|
|
14
16
|
let loader;
|
|
15
17
|
let action;
|
|
16
18
|
if ('nested' === route.type) {
|
|
19
|
+
if (ssg && route.ssgParams && route.id && !route.inValidSSRRoute) {
|
|
20
|
+
const name = `ssgParams_${ssgParamsImports.length}`;
|
|
21
|
+
ssgParamsImports.push(`import { ssgParams as ${name} } from ${JSON.stringify(slash(route.ssgParams))};`);
|
|
22
|
+
ssgParamsEntries.push(`${JSON.stringify(route.id)}: ${name}`);
|
|
23
|
+
}
|
|
17
24
|
if (route.loader || route.data) {
|
|
18
25
|
loaders.push(route.loader);
|
|
19
26
|
const loaderId = loaders.length - 1;
|
|
@@ -39,6 +46,7 @@ const routesForServer = ({ routesForServerLoaderMatches })=>{
|
|
|
39
46
|
action,
|
|
40
47
|
children
|
|
41
48
|
};
|
|
49
|
+
if ('ssgParams' in finalRoute) delete finalRoute.ssgParams;
|
|
42
50
|
return finalRoute;
|
|
43
51
|
};
|
|
44
52
|
let routesCode = `
|
|
@@ -65,10 +73,11 @@ const routesForServer = ({ routesForServerLoaderMatches })=>{
|
|
|
65
73
|
if (route.action) importLoadersCode += `import { loader as ${key}, action as action_${loaderInfo.loaderId} } from "${slash(loaderInfo.filePath)}";\n`;
|
|
66
74
|
else importLoadersCode += `import { loader as ${key} } from "${slash(loaderInfo.filePath)}";\n`;
|
|
67
75
|
} else importLoadersCode += `import ${key} from "${slash(loaderInfo.filePath)}";\n`;
|
|
68
|
-
|
|
76
|
+
const code = `
|
|
69
77
|
${importLoadersCode}
|
|
70
78
|
${routesCode}
|
|
71
79
|
`;
|
|
80
|
+
return ssg ? `${code}\n${ssgParamsImports.join('\n')}\nexport const ssgParams = {${ssgParamsEntries.join(',')}};\n` : code;
|
|
72
81
|
};
|
|
73
82
|
const createMatchReg = (keyword)=>new RegExp(`("${keyword}":\\s)"([^\n]+)"`, 'g');
|
|
74
83
|
async function hasUseClientDirective(componentPath, srcDirectory, internalSrcAlias) {
|
|
@@ -112,7 +121,7 @@ const fileSystemRoutes = async ({ metaName, routes, ssrMode, nestedRoutesEntry,
|
|
|
112
121
|
};
|
|
113
122
|
const createLazyImport = ({ componentPath, routeId, webpackChunkName, eager })=>{
|
|
114
123
|
const importOptions = webpackChunkName ? `/* webpackChunkName: "${routeId}" */ ` : eager ? '/* webpackMode: "eager" */ ' : '';
|
|
115
|
-
return `() => import(${importOptions}'${componentPath}').then(routeModule => handleRouteModule(routeModule, "${routeId}"))`;
|
|
124
|
+
return `() => import(${importOptions}'${formatImportPath(componentPath)}').then(routeModule => handleRouteModule(routeModule, "${routeId}"))`;
|
|
116
125
|
};
|
|
117
126
|
const traverseRouteTree = async (route, isRscClientBundle)=>{
|
|
118
127
|
let children;
|
|
@@ -161,7 +170,7 @@ const fileSystemRoutes = async ({ metaName, routes, ssrMode, nestedRoutesEntry,
|
|
|
161
170
|
componentPath: route._component,
|
|
162
171
|
routeId: route.id
|
|
163
172
|
});
|
|
164
|
-
rootLayoutCode = `import RootLayout from '${route._component}'`;
|
|
173
|
+
rootLayoutCode = `import RootLayout from '${formatImportPath(route._component)}'`;
|
|
165
174
|
component = 'RootLayout';
|
|
166
175
|
} else if (splitRouteChunks) {
|
|
167
176
|
lazyImport = createLazyImport({
|
|
@@ -182,7 +191,7 @@ const fileSystemRoutes = async ({ metaName, routes, ssrMode, nestedRoutesEntry,
|
|
|
182
191
|
component = `lazy(${lazyImport})`;
|
|
183
192
|
}
|
|
184
193
|
} else if (route._component) if (splitRouteChunks) {
|
|
185
|
-
lazyImport = `() => import('${route._component}')`;
|
|
194
|
+
lazyImport = `() => import('${formatImportPath(route._component)}')`;
|
|
186
195
|
component = `loadable(${lazyImport})`;
|
|
187
196
|
} else {
|
|
188
197
|
components.push(route._component);
|
|
@@ -208,6 +217,7 @@ const fileSystemRoutes = async ({ metaName, routes, ssrMode, nestedRoutesEntry,
|
|
|
208
217
|
component
|
|
209
218
|
}
|
|
210
219
|
};
|
|
220
|
+
delete finalRoute.ssgParams;
|
|
211
221
|
if ('nested' === route.type && route._component && (route.loader || route.data)) finalRoute.shouldRevalidate = `createShouldRevalidate("${route.id}")`;
|
|
212
222
|
return finalRoute;
|
|
213
223
|
};
|
|
@@ -231,7 +241,7 @@ const fileSystemRoutes = async ({ metaName, routes, ssrMode, nestedRoutesEntry,
|
|
|
231
241
|
const newRouteStr = regs.reduce((acc, reg)=>acc.replace(reg, '$1$2'), routeStr).replace(/"(RootLayout)"/g, '$1').replace(/\\"/g, '"');
|
|
232
242
|
routeComponentsCode += `${newRouteStr},`;
|
|
233
243
|
} else {
|
|
234
|
-
const component = `loadable(() => import('${route._component}'))`;
|
|
244
|
+
const component = `loadable(() => import('${formatImportPath(route._component)}'))`;
|
|
235
245
|
const finalRoute = {
|
|
236
246
|
...route,
|
|
237
247
|
component
|
|
@@ -246,9 +256,9 @@ const fileSystemRoutes = async ({ metaName, routes, ssrMode, nestedRoutesEntry,
|
|
|
246
256
|
routeComponentsCode += `${newRouteStr},`;
|
|
247
257
|
}
|
|
248
258
|
routeComponentsCode += `\n];`;
|
|
249
|
-
const importLoadingCode = loadings.map((loading, index)=>`import loading_${index} from '${loading}';\n`).join('');
|
|
250
|
-
const importComponentsCode = components.map((component, index)=>`import component_${index} from '${component}';\n`).join('');
|
|
251
|
-
const importErrorComponentsCode = errors.map((error, index)=>`import error_${index} from '${error}';\n`).join('');
|
|
259
|
+
const importLoadingCode = loadings.map((loading, index)=>`import loading_${index} from '${formatImportPath(loading)}';\n`).join('');
|
|
260
|
+
const importComponentsCode = components.map((component, index)=>`import component_${index} from '${formatImportPath(component)}';\n`).join('');
|
|
261
|
+
const importErrorComponentsCode = errors.map((error, index)=>`import error_${index} from '${formatImportPath(error)}';\n`).join('');
|
|
252
262
|
let importLoadersCode = '';
|
|
253
263
|
for (const [key, loaderInfo] of Object.entries(loadersMap))if (loaderInfo.inline) {
|
|
254
264
|
const { route } = loaderInfo;
|
|
@@ -3,7 +3,7 @@ import path from "path";
|
|
|
3
3
|
import { JS_EXTENSIONS, fs as utils_fs, normalizeToPosixPath } from "@modern-js/utils";
|
|
4
4
|
import { transform } from "@swc/core";
|
|
5
5
|
import { parse } from "es-module-lexer";
|
|
6
|
-
import { ACTION_EXPORT_NAME, LOADER_EXPORT_NAME } from "../constants.mjs";
|
|
6
|
+
import { ACTION_EXPORT_NAME, LOADER_EXPORT_NAME, SSG_PARAMS_EXPORT_NAME } from "../constants.mjs";
|
|
7
7
|
const walkDirectory = (dir)=>fs.readdirSync(dir).reduce((previous, filename)=>{
|
|
8
8
|
const filePath = path.join(dir, filename);
|
|
9
9
|
if (fs.statSync(filePath).isDirectory()) return [
|
|
@@ -76,10 +76,11 @@ const hasExport = async (filename, exportName, source)=>{
|
|
|
76
76
|
};
|
|
77
77
|
const hasLoader = (filename, source)=>hasExport(filename, LOADER_EXPORT_NAME, source);
|
|
78
78
|
const hasAction = (filename, source)=>hasExport(filename, ACTION_EXPORT_NAME, source);
|
|
79
|
+
const hasSsgParams = (filename, source)=>hasExport(filename, SSG_PARAMS_EXPORT_NAME, source);
|
|
79
80
|
const getServerLoadersFile = (internalDirectory, entryName)=>path.join(internalDirectory, entryName, 'route-server-loaders.js');
|
|
80
81
|
const getServerCombinedModuleFile = (internalDirectory, entryName)=>path.join(internalDirectory, entryName, 'server-loader-combined.js');
|
|
81
82
|
const getPathWithoutExt = (filename)=>{
|
|
82
83
|
const extname = path.extname(filename);
|
|
83
84
|
return extname ? filename.slice(0, -extname.length) : filename;
|
|
84
85
|
};
|
|
85
|
-
export { getPathWithoutExt, getServerCombinedModuleFile, getServerLoadersFile, hasAction, hasLoader, isPageComponentFile, parseModule, replaceWithAlias, walkDirectory };
|
|
86
|
+
export { getPathWithoutExt, getServerCombinedModuleFile, getServerLoadersFile, hasAction, hasLoader, hasSsgParams, isPageComponentFile, parseModule, replaceWithAlias, walkDirectory };
|
|
@@ -63,14 +63,14 @@ async function discoverRelatedFiles(nestedRoute, componentPath, alias) {
|
|
|
63
63
|
const aliasedPath = alias ? replaceWithAlias(alias.basename, filePath, alias.name) : filePath;
|
|
64
64
|
nestedRoute[key] = normalizeToPosixPath(aliasedPath);
|
|
65
65
|
}
|
|
66
|
-
} catch
|
|
66
|
+
} catch {}
|
|
67
67
|
}));
|
|
68
68
|
}
|
|
69
69
|
function normalizeRoutes(generatedRoutes) {
|
|
70
70
|
return generatedRoutes.map((route)=>normalizeRoute(route));
|
|
71
71
|
}
|
|
72
72
|
function normalizeRoute(route) {
|
|
73
|
-
const { component, ...rest } = route;
|
|
73
|
+
const { component: _component, ...rest } = route;
|
|
74
74
|
const processedRoute = {
|
|
75
75
|
...rest,
|
|
76
76
|
...route.children && route.children.length > 0 ? {
|
|
@@ -2,6 +2,7 @@ const NESTED_ROUTES_DIR = 'routes';
|
|
|
2
2
|
const FILE_SYSTEM_ROUTES_FILE_NAME = 'routes.js';
|
|
3
3
|
const LOADER_EXPORT_NAME = 'loader';
|
|
4
4
|
const ACTION_EXPORT_NAME = 'action';
|
|
5
|
+
const SSG_PARAMS_EXPORT_NAME = 'ssgParams';
|
|
5
6
|
const TEMP_LOADERS_DIR = '__loaders__';
|
|
6
7
|
const FILE_SYSTEM_ROUTES_INDEX = 'index';
|
|
7
8
|
const FILE_SYSTEM_ROUTES_IGNORED_REGEX = /\.(d|test|spec|e2e)\.(js|jsx|ts|tsx)$/;
|
|
@@ -29,4 +30,4 @@ const NESTED_ROUTE = {
|
|
|
29
30
|
ERROR_FILE: 'error',
|
|
30
31
|
LOADER_FILE: 'loader'
|
|
31
32
|
};
|
|
32
|
-
export { ACTION_EXPORT_NAME, APP_CONFIG_NAME, APP_INIT_EXPORTED, FILE_SYSTEM_ROUTES_COMPONENTS_DIR, FILE_SYSTEM_ROUTES_DYNAMIC_REGEXP, FILE_SYSTEM_ROUTES_FILE_NAME, FILE_SYSTEM_ROUTES_IGNORED_REGEX, FILE_SYSTEM_ROUTES_INDEX, LOADER_EXPORT_NAME, NESTED_ROUTE, NESTED_ROUTES_DIR, TEMP_LOADERS_DIR };
|
|
33
|
+
export { ACTION_EXPORT_NAME, APP_CONFIG_NAME, APP_INIT_EXPORTED, FILE_SYSTEM_ROUTES_COMPONENTS_DIR, FILE_SYSTEM_ROUTES_DYNAMIC_REGEXP, FILE_SYSTEM_ROUTES_FILE_NAME, FILE_SYSTEM_ROUTES_IGNORED_REGEX, FILE_SYSTEM_ROUTES_INDEX, LOADER_EXPORT_NAME, NESTED_ROUTE, NESTED_ROUTES_DIR, SSG_PARAMS_EXPORT_NAME, TEMP_LOADERS_DIR };
|
|
@@ -10,7 +10,7 @@ const routerPlugin = ()=>({
|
|
|
10
10
|
setup: (api)=>{
|
|
11
11
|
const nestedRoutes = {};
|
|
12
12
|
const nestedRoutesForServer = {};
|
|
13
|
-
|
|
13
|
+
api.getAppContext();
|
|
14
14
|
api.addCommand(({ program })=>{
|
|
15
15
|
program.command('routes').description('generate routes inspect report').action(async ()=>{
|
|
16
16
|
const { generateRoutesInspectReport } = await import("./code/inspect.mjs");
|
|
@@ -39,7 +39,7 @@ const routerPlugin = (userConfig = {})=>({
|
|
|
39
39
|
if (!finalRouteConfig.routes && !createRoutes) return;
|
|
40
40
|
const enableRsc = getGlobalEnableRsc();
|
|
41
41
|
if (enableRsc) await prepareRSCRoutes(finalRouteConfig.routes);
|
|
42
|
-
const {
|
|
42
|
+
const { mode: ssrMode, nonce, loaderFailureMode = 'errorBoundary', baseUrl } = context.ssrContext;
|
|
43
43
|
const _basename = '/' === baseUrl ? urlJoin(baseUrl, basename) : baseUrl;
|
|
44
44
|
const requestContext = createRequestContext(context.ssrContext?.loaderContext);
|
|
45
45
|
const hooks = api.getHooks();
|
|
@@ -93,7 +93,7 @@ const routerPlugin = (userConfig = {})=>({
|
|
|
93
93
|
if (!finalRouteConfig) return App;
|
|
94
94
|
const getRouteApp = ()=>{
|
|
95
95
|
const enableRsc = getGlobalEnableRsc();
|
|
96
|
-
return (
|
|
96
|
+
return ()=>{
|
|
97
97
|
const context = useContext(InternalRuntimeContext);
|
|
98
98
|
const { routerContext, ssrContext, routes } = context;
|
|
99
99
|
const { nonce, mode, useJsonScript } = ssrContext;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "node:module";
|
|
2
2
|
function resolveSSRMode(params) {
|
|
3
|
-
const { entry, config,
|
|
3
|
+
const { entry, config, nestedRoutesEntry } = params;
|
|
4
4
|
const isSsgEnabled = config.output?.ssg || config.output?.ssgByEntries && (entry ? !!config.output.ssgByEntries[entry] : Object.keys(config.output.ssgByEntries).length > 0);
|
|
5
5
|
if (isSsgEnabled) if (nestedRoutesEntry) return 'stream';
|
|
6
6
|
else return 'string';
|
|
@@ -32,7 +32,7 @@ ${genRenderStatement({
|
|
|
32
32
|
isNestedRouter
|
|
33
33
|
})}`;
|
|
34
34
|
};
|
|
35
|
-
const entryForCSRWithRSC = ({ metaName, entryName,
|
|
35
|
+
const entryForCSRWithRSC = ({ metaName, entryName, mountId = 'root', isNestedRouter })=>`
|
|
36
36
|
import '@${metaName}/runtime/registry/${entryName}';
|
|
37
37
|
import { render } from '@${metaName}/runtime/browser';
|
|
38
38
|
import { createRoot } from '@${metaName}/runtime/react';
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import "node:module";
|
|
2
2
|
const defaultMonitors = {
|
|
3
|
-
counter (
|
|
3
|
+
counter () {},
|
|
4
4
|
info: console.info,
|
|
5
5
|
debug: console.debug,
|
|
6
6
|
trace: console.trace,
|
|
7
7
|
warn: console.warn,
|
|
8
8
|
error: console.error,
|
|
9
|
-
timing (
|
|
9
|
+
timing () {}
|
|
10
10
|
};
|
|
11
11
|
export { defaultMonitors };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import "node:module";
|
|
2
2
|
const getResponseProxy = ()=>null;
|
|
3
|
-
const setHeaders = (
|
|
4
|
-
const setStatus = (
|
|
5
|
-
const redirect = (
|
|
3
|
+
const setHeaders = (_headers)=>{};
|
|
4
|
+
const setStatus = (_status)=>{};
|
|
5
|
+
const redirect = (_url, _init)=>{
|
|
6
6
|
console.warn("You should not use this API in the browser, please use the router's redirect or useNavigate method.");
|
|
7
7
|
};
|
|
8
8
|
export { getResponseProxy, redirect, setHeaders, setStatus };
|
|
@@ -2,7 +2,7 @@ import "node:module";
|
|
|
2
2
|
import { jsx } from "react/jsx-runtime";
|
|
3
3
|
import { InternalRuntimeContext, RuntimeContext } from "../context/index.mjs";
|
|
4
4
|
function wrapRuntimeContextProvider(App, contextValue) {
|
|
5
|
-
const { isBrowser, initialData, routes, context, routeManifest, routerContext, unstable_getBlockNavState, ssrContext, _internalContext, _internalRouterBaseName, ...rest } = contextValue;
|
|
5
|
+
const { isBrowser, initialData, routes, context, routeManifest: _routeManifest, routerContext: _routerContext, unstable_getBlockNavState: _unstable_getBlockNavState, ssrContext: _ssrContext, _internalContext, _internalRouterBaseName, ...rest } = contextValue;
|
|
6
6
|
const runtimeContextValue = {
|
|
7
7
|
isBrowser,
|
|
8
8
|
initialData,
|
|
@@ -122,7 +122,7 @@ const createReadableStreamFromElement = async (request, rootElement, options)=>{
|
|
|
122
122
|
}
|
|
123
123
|
});
|
|
124
124
|
return stream;
|
|
125
|
-
} catch
|
|
125
|
+
} catch {
|
|
126
126
|
const fallbackHtml = `${shellBefore}${shellAfter}`;
|
|
127
127
|
const stream = getReadableStreamFromString(fallbackHtml);
|
|
128
128
|
return stream;
|
|
@@ -44,7 +44,7 @@ class LoadableCollector {
|
|
|
44
44
|
asyncChunks.push(...extractor.getChunkAssets([
|
|
45
45
|
`async-${entryName}`
|
|
46
46
|
]));
|
|
47
|
-
} catch
|
|
47
|
+
} catch {}
|
|
48
48
|
const chunks = [].concat(asyncChunks).concat(extractor.getChunkAssets(extractor.chunks));
|
|
49
49
|
const scriptChunks = generateChunks(chunks, 'js');
|
|
50
50
|
const styleChunks = generateChunks(chunks, 'css');
|
|
@@ -84,7 +84,7 @@ class LoadableCollector {
|
|
|
84
84
|
chunkSet.jsChunk += scripts.filter((script)=>Boolean(script)).join('');
|
|
85
85
|
}
|
|
86
86
|
async emitStyleAssets(chunks) {
|
|
87
|
-
const { template, chunkSet, config
|
|
87
|
+
const { template, chunkSet, config } = this.options;
|
|
88
88
|
const { inlineStyles } = config;
|
|
89
89
|
const atrributes = attributesToString(this.generateAttributes());
|
|
90
90
|
const css = await Promise.all(chunks.filter((chunk)=>!hasStylesheetLink(template, chunk.url) && !this.existsAssets?.includes(chunk.path)).map(async (chunk)=>{
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "node:module";
|
|
2
2
|
import path from "path";
|
|
3
|
-
import { collectRouteComponentFiles, filterRoutesForServer, filterRoutesLoader, fs, getEntryOptions, isUseRsc, isUseSSRBundle, logger, markRoutes } from "@modern-js/utils";
|
|
3
|
+
import { collectRouteComponentFiles, filterRoutesForServer, filterRoutesLoader, fs, getEntryOptions, isSSGEntry, isUseRsc, isUseSSRBundle, logger, markRoutes } from "@modern-js/utils";
|
|
4
4
|
import { cloneDeep } from "@modern-js/utils/lodash";
|
|
5
5
|
import { ENTRY_POINT_RUNTIME_GLOBAL_CONTEXT_FILE_NAME } from "../../../cli/constants.mjs";
|
|
6
6
|
import { resolveSSRMode } from "../../../cli/ssr/mode.mjs";
|
|
@@ -106,7 +106,8 @@ const generateCode = async (appContext, config, entrypoints, api)=>{
|
|
|
106
106
|
const filtedRoutesForServer = filterRoutesForServer(routes);
|
|
107
107
|
const routesForServerLoaderMatches = filterRoutesLoader(routes);
|
|
108
108
|
const code = __rspack_external__templates_mjs_ab577925.routesForServer({
|
|
109
|
-
routesForServerLoaderMatches
|
|
109
|
+
routesForServerLoaderMatches,
|
|
110
|
+
ssg: isSSGEntry(config, entryName, entrypoints)
|
|
110
111
|
});
|
|
111
112
|
await fs.ensureFile(routesServerFile);
|
|
112
113
|
await fs.writeFile(routesServerFile, code);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "node:module";
|
|
2
2
|
import { JS_EXTENSIONS, fs, normalizeToPosixPath } from "@modern-js/utils";
|
|
3
3
|
import { NESTED_ROUTE } from "../constants.mjs";
|
|
4
|
-
import { getPathWithoutExt, hasAction, replaceWithAlias } from "./utils.mjs";
|
|
4
|
+
import { getPathWithoutExt, hasAction, hasSsgParams, replaceWithAlias } from "./utils.mjs";
|
|
5
5
|
import * as __rspack_external_path from "path";
|
|
6
6
|
const conventionNames = Object.values(NESTED_ROUTE);
|
|
7
7
|
const replaceDynamicPath = (routePath)=>routePath.replace(/\[(.*?)\]/g, ':$1');
|
|
@@ -85,12 +85,14 @@ const walk = async (options)=>{
|
|
|
85
85
|
let pageClientData = '';
|
|
86
86
|
let pageData = '';
|
|
87
87
|
let pageAction = '';
|
|
88
|
+
let pageSsgParams = '';
|
|
88
89
|
let splatLoaderFile = '';
|
|
89
90
|
let splatRoute = null;
|
|
90
91
|
let splatConfigFile = '';
|
|
91
92
|
let splatClientData = '';
|
|
92
93
|
let splatData = '';
|
|
93
94
|
let splatAction = '';
|
|
95
|
+
let splatSsgParams = '';
|
|
94
96
|
const items = await fs.readdir(dirname);
|
|
95
97
|
for (const item of items){
|
|
96
98
|
const itemPath = __rspack_external_path.join(dirname, item);
|
|
@@ -126,6 +128,7 @@ const walk = async (options)=>{
|
|
|
126
128
|
if (itemWithoutExt === NESTED_ROUTE.PAGE_DATA_FILE) {
|
|
127
129
|
pageData = itemPathWithAlias;
|
|
128
130
|
if (await hasAction(itemPath)) pageAction = itemPathWithAlias;
|
|
131
|
+
if (await hasSsgParams(itemPath)) pageSsgParams = itemPathWithAlias;
|
|
129
132
|
}
|
|
130
133
|
if (itemWithoutExt === NESTED_ROUTE.PAGE_CONFIG_FILE) pageConfigFile = itemPathWithAlias;
|
|
131
134
|
if (itemWithoutExt === NESTED_ROUTE.PAGE_FILE) {
|
|
@@ -137,6 +140,7 @@ const walk = async (options)=>{
|
|
|
137
140
|
if (pageData) pageRoute.data = pageData;
|
|
138
141
|
if (pageClientData) pageRoute.clientData = pageClientData;
|
|
139
142
|
if (pageAction) pageRoute.action = pageAction;
|
|
143
|
+
if (pageSsgParams) pageRoute.ssgParams = pageSsgParams;
|
|
140
144
|
route.children?.unshift(pageRoute);
|
|
141
145
|
}
|
|
142
146
|
if (itemWithoutExt === NESTED_ROUTE.SPLATE_LOADER_FILE) splatLoaderFile = itemPathWithAlias;
|
|
@@ -147,6 +151,7 @@ const walk = async (options)=>{
|
|
|
147
151
|
if (itemWithoutExt === NESTED_ROUTE.SPLATE_DATA_FILE) {
|
|
148
152
|
splatData = itemPathWithAlias;
|
|
149
153
|
if (await hasAction(itemPath)) splatAction = itemPathWithAlias;
|
|
154
|
+
if (await hasSsgParams(itemPath)) splatSsgParams = itemPathWithAlias;
|
|
150
155
|
}
|
|
151
156
|
if (itemWithoutExt === NESTED_ROUTE.SPLATE_FILE) {
|
|
152
157
|
splatRoute = createRoute({
|
|
@@ -159,6 +164,7 @@ const walk = async (options)=>{
|
|
|
159
164
|
if (splatData) splatRoute.data = splatData;
|
|
160
165
|
if (splatConfigFile) splatRoute.config = splatConfigFile;
|
|
161
166
|
if (splatAction) splatRoute.action = splatAction;
|
|
167
|
+
if (splatSsgParams) splatRoute.ssgParams = splatSsgParams;
|
|
162
168
|
route.children?.push(splatRoute);
|
|
163
169
|
}
|
|
164
170
|
if (itemWithoutExt === NESTED_ROUTE.LOADING_FILE) route.loading = itemPathWithAlias;
|
|
@@ -6,9 +6,11 @@ import { JS_EXTENSIONS, findExists, formatImportPath, fs, getEntryOptions, isSSG
|
|
|
6
6
|
import { ROUTE_MODULES } from "@modern-js/utils/universal/constants";
|
|
7
7
|
import { APP_INIT_EXPORTED, TEMP_LOADERS_DIR } from "../constants.mjs";
|
|
8
8
|
import { getPathWithoutExt, getServerLoadersFile, parseModule, replaceWithAlias } from "./utils.mjs";
|
|
9
|
-
const routesForServer = ({ routesForServerLoaderMatches })=>{
|
|
9
|
+
const routesForServer = ({ routesForServerLoaderMatches, ssg = false })=>{
|
|
10
10
|
const loaders = [];
|
|
11
11
|
const actions = [];
|
|
12
|
+
const ssgParamsImports = [];
|
|
13
|
+
const ssgParamsEntries = [];
|
|
12
14
|
const loadersMap = {};
|
|
13
15
|
const traverseRouteTree = (route)=>{
|
|
14
16
|
let children;
|
|
@@ -16,6 +18,11 @@ const routesForServer = ({ routesForServerLoaderMatches })=>{
|
|
|
16
18
|
let loader;
|
|
17
19
|
let action;
|
|
18
20
|
if ('nested' === route.type) {
|
|
21
|
+
if (ssg && route.ssgParams && route.id && !route.inValidSSRRoute) {
|
|
22
|
+
const name = `ssgParams_${ssgParamsImports.length}`;
|
|
23
|
+
ssgParamsImports.push(`import { ssgParams as ${name} } from ${JSON.stringify(slash(route.ssgParams))};`);
|
|
24
|
+
ssgParamsEntries.push(`${JSON.stringify(route.id)}: ${name}`);
|
|
25
|
+
}
|
|
19
26
|
if (route.loader || route.data) {
|
|
20
27
|
loaders.push(route.loader);
|
|
21
28
|
const loaderId = loaders.length - 1;
|
|
@@ -41,6 +48,7 @@ const routesForServer = ({ routesForServerLoaderMatches })=>{
|
|
|
41
48
|
action,
|
|
42
49
|
children
|
|
43
50
|
};
|
|
51
|
+
if ('ssgParams' in finalRoute) delete finalRoute.ssgParams;
|
|
44
52
|
return finalRoute;
|
|
45
53
|
};
|
|
46
54
|
let routesCode = `
|
|
@@ -67,10 +75,11 @@ const routesForServer = ({ routesForServerLoaderMatches })=>{
|
|
|
67
75
|
if (route.action) importLoadersCode += `import { loader as ${key}, action as action_${loaderInfo.loaderId} } from "${slash(loaderInfo.filePath)}";\n`;
|
|
68
76
|
else importLoadersCode += `import { loader as ${key} } from "${slash(loaderInfo.filePath)}";\n`;
|
|
69
77
|
} else importLoadersCode += `import ${key} from "${slash(loaderInfo.filePath)}";\n`;
|
|
70
|
-
|
|
78
|
+
const code = `
|
|
71
79
|
${importLoadersCode}
|
|
72
80
|
${routesCode}
|
|
73
81
|
`;
|
|
82
|
+
return ssg ? `${code}\n${ssgParamsImports.join('\n')}\nexport const ssgParams = {${ssgParamsEntries.join(',')}};\n` : code;
|
|
74
83
|
};
|
|
75
84
|
const createMatchReg = (keyword)=>new RegExp(`("${keyword}":\\s)"([^\n]+)"`, 'g');
|
|
76
85
|
async function hasUseClientDirective(componentPath, srcDirectory, internalSrcAlias) {
|
|
@@ -114,7 +123,7 @@ const fileSystemRoutes = async ({ metaName, routes, ssrMode, nestedRoutesEntry,
|
|
|
114
123
|
};
|
|
115
124
|
const createLazyImport = ({ componentPath, routeId, webpackChunkName, eager })=>{
|
|
116
125
|
const importOptions = webpackChunkName ? `/* webpackChunkName: "${routeId}" */ ` : eager ? '/* webpackMode: "eager" */ ' : '';
|
|
117
|
-
return `() => import(${importOptions}'${componentPath}').then(routeModule => handleRouteModule(routeModule, "${routeId}"))`;
|
|
126
|
+
return `() => import(${importOptions}'${formatImportPath(componentPath)}').then(routeModule => handleRouteModule(routeModule, "${routeId}"))`;
|
|
118
127
|
};
|
|
119
128
|
const traverseRouteTree = async (route, isRscClientBundle)=>{
|
|
120
129
|
let children;
|
|
@@ -163,7 +172,7 @@ const fileSystemRoutes = async ({ metaName, routes, ssrMode, nestedRoutesEntry,
|
|
|
163
172
|
componentPath: route._component,
|
|
164
173
|
routeId: route.id
|
|
165
174
|
});
|
|
166
|
-
rootLayoutCode = `import RootLayout from '${route._component}'`;
|
|
175
|
+
rootLayoutCode = `import RootLayout from '${formatImportPath(route._component)}'`;
|
|
167
176
|
component = 'RootLayout';
|
|
168
177
|
} else if (splitRouteChunks) {
|
|
169
178
|
lazyImport = createLazyImport({
|
|
@@ -184,7 +193,7 @@ const fileSystemRoutes = async ({ metaName, routes, ssrMode, nestedRoutesEntry,
|
|
|
184
193
|
component = `lazy(${lazyImport})`;
|
|
185
194
|
}
|
|
186
195
|
} else if (route._component) if (splitRouteChunks) {
|
|
187
|
-
lazyImport = `() => import('${route._component}')`;
|
|
196
|
+
lazyImport = `() => import('${formatImportPath(route._component)}')`;
|
|
188
197
|
component = `loadable(${lazyImport})`;
|
|
189
198
|
} else {
|
|
190
199
|
components.push(route._component);
|
|
@@ -210,6 +219,7 @@ const fileSystemRoutes = async ({ metaName, routes, ssrMode, nestedRoutesEntry,
|
|
|
210
219
|
component
|
|
211
220
|
}
|
|
212
221
|
};
|
|
222
|
+
delete finalRoute.ssgParams;
|
|
213
223
|
if ('nested' === route.type && route._component && (route.loader || route.data)) finalRoute.shouldRevalidate = `createShouldRevalidate("${route.id}")`;
|
|
214
224
|
return finalRoute;
|
|
215
225
|
};
|
|
@@ -233,7 +243,7 @@ const fileSystemRoutes = async ({ metaName, routes, ssrMode, nestedRoutesEntry,
|
|
|
233
243
|
const newRouteStr = regs.reduce((acc, reg)=>acc.replace(reg, '$1$2'), routeStr).replace(/"(RootLayout)"/g, '$1').replace(/\\"/g, '"');
|
|
234
244
|
routeComponentsCode += `${newRouteStr},`;
|
|
235
245
|
} else {
|
|
236
|
-
const component = `loadable(() => import('${route._component}'))`;
|
|
246
|
+
const component = `loadable(() => import('${formatImportPath(route._component)}'))`;
|
|
237
247
|
const finalRoute = {
|
|
238
248
|
...route,
|
|
239
249
|
component
|
|
@@ -248,9 +258,9 @@ const fileSystemRoutes = async ({ metaName, routes, ssrMode, nestedRoutesEntry,
|
|
|
248
258
|
routeComponentsCode += `${newRouteStr},`;
|
|
249
259
|
}
|
|
250
260
|
routeComponentsCode += `\n];`;
|
|
251
|
-
const importLoadingCode = loadings.map((loading, index)=>`import loading_${index} from '${loading}';\n`).join('');
|
|
252
|
-
const importComponentsCode = components.map((component, index)=>`import component_${index} from '${component}';\n`).join('');
|
|
253
|
-
const importErrorComponentsCode = errors.map((error, index)=>`import error_${index} from '${error}';\n`).join('');
|
|
261
|
+
const importLoadingCode = loadings.map((loading, index)=>`import loading_${index} from '${formatImportPath(loading)}';\n`).join('');
|
|
262
|
+
const importComponentsCode = components.map((component, index)=>`import component_${index} from '${formatImportPath(component)}';\n`).join('');
|
|
263
|
+
const importErrorComponentsCode = errors.map((error, index)=>`import error_${index} from '${formatImportPath(error)}';\n`).join('');
|
|
254
264
|
let importLoadersCode = '';
|
|
255
265
|
for (const [key, loaderInfo] of Object.entries(loadersMap))if (loaderInfo.inline) {
|
|
256
266
|
const { route } = loaderInfo;
|
|
@@ -4,7 +4,7 @@ import path from "path";
|
|
|
4
4
|
import { JS_EXTENSIONS, fs as utils_fs, normalizeToPosixPath } from "@modern-js/utils";
|
|
5
5
|
import { transform } from "@swc/core";
|
|
6
6
|
import { parse } from "es-module-lexer";
|
|
7
|
-
import { ACTION_EXPORT_NAME, LOADER_EXPORT_NAME } from "../constants.mjs";
|
|
7
|
+
import { ACTION_EXPORT_NAME, LOADER_EXPORT_NAME, SSG_PARAMS_EXPORT_NAME } from "../constants.mjs";
|
|
8
8
|
const walkDirectory = (dir)=>fs.readdirSync(dir).reduce((previous, filename)=>{
|
|
9
9
|
const filePath = path.join(dir, filename);
|
|
10
10
|
if (fs.statSync(filePath).isDirectory()) return [
|
|
@@ -77,10 +77,11 @@ const hasExport = async (filename, exportName, source)=>{
|
|
|
77
77
|
};
|
|
78
78
|
const hasLoader = (filename, source)=>hasExport(filename, LOADER_EXPORT_NAME, source);
|
|
79
79
|
const hasAction = (filename, source)=>hasExport(filename, ACTION_EXPORT_NAME, source);
|
|
80
|
+
const hasSsgParams = (filename, source)=>hasExport(filename, SSG_PARAMS_EXPORT_NAME, source);
|
|
80
81
|
const getServerLoadersFile = (internalDirectory, entryName)=>path.join(internalDirectory, entryName, 'route-server-loaders.js');
|
|
81
82
|
const getServerCombinedModuleFile = (internalDirectory, entryName)=>path.join(internalDirectory, entryName, 'server-loader-combined.js');
|
|
82
83
|
const getPathWithoutExt = (filename)=>{
|
|
83
84
|
const extname = path.extname(filename);
|
|
84
85
|
return extname ? filename.slice(0, -extname.length) : filename;
|
|
85
86
|
};
|
|
86
|
-
export { getPathWithoutExt, getServerCombinedModuleFile, getServerLoadersFile, hasAction, hasLoader, isPageComponentFile, parseModule, replaceWithAlias, walkDirectory };
|
|
87
|
+
export { getPathWithoutExt, getServerCombinedModuleFile, getServerLoadersFile, hasAction, hasLoader, hasSsgParams, isPageComponentFile, parseModule, replaceWithAlias, walkDirectory };
|
|
@@ -64,14 +64,14 @@ async function discoverRelatedFiles(nestedRoute, componentPath, alias) {
|
|
|
64
64
|
const aliasedPath = alias ? replaceWithAlias(alias.basename, filePath, alias.name) : filePath;
|
|
65
65
|
nestedRoute[key] = normalizeToPosixPath(aliasedPath);
|
|
66
66
|
}
|
|
67
|
-
} catch
|
|
67
|
+
} catch {}
|
|
68
68
|
}));
|
|
69
69
|
}
|
|
70
70
|
function normalizeRoutes(generatedRoutes) {
|
|
71
71
|
return generatedRoutes.map((route)=>normalizeRoute(route));
|
|
72
72
|
}
|
|
73
73
|
function normalizeRoute(route) {
|
|
74
|
-
const { component, ...rest } = route;
|
|
74
|
+
const { component: _component, ...rest } = route;
|
|
75
75
|
const processedRoute = {
|
|
76
76
|
...rest,
|
|
77
77
|
...route.children && route.children.length > 0 ? {
|
|
@@ -3,6 +3,7 @@ const NESTED_ROUTES_DIR = 'routes';
|
|
|
3
3
|
const FILE_SYSTEM_ROUTES_FILE_NAME = 'routes.js';
|
|
4
4
|
const LOADER_EXPORT_NAME = 'loader';
|
|
5
5
|
const ACTION_EXPORT_NAME = 'action';
|
|
6
|
+
const SSG_PARAMS_EXPORT_NAME = 'ssgParams';
|
|
6
7
|
const TEMP_LOADERS_DIR = '__loaders__';
|
|
7
8
|
const FILE_SYSTEM_ROUTES_INDEX = 'index';
|
|
8
9
|
const FILE_SYSTEM_ROUTES_IGNORED_REGEX = /\.(d|test|spec|e2e)\.(js|jsx|ts|tsx)$/;
|
|
@@ -30,4 +31,4 @@ const NESTED_ROUTE = {
|
|
|
30
31
|
ERROR_FILE: 'error',
|
|
31
32
|
LOADER_FILE: 'loader'
|
|
32
33
|
};
|
|
33
|
-
export { ACTION_EXPORT_NAME, APP_CONFIG_NAME, APP_INIT_EXPORTED, FILE_SYSTEM_ROUTES_COMPONENTS_DIR, FILE_SYSTEM_ROUTES_DYNAMIC_REGEXP, FILE_SYSTEM_ROUTES_FILE_NAME, FILE_SYSTEM_ROUTES_IGNORED_REGEX, FILE_SYSTEM_ROUTES_INDEX, LOADER_EXPORT_NAME, NESTED_ROUTE, NESTED_ROUTES_DIR, TEMP_LOADERS_DIR };
|
|
34
|
+
export { ACTION_EXPORT_NAME, APP_CONFIG_NAME, APP_INIT_EXPORTED, FILE_SYSTEM_ROUTES_COMPONENTS_DIR, FILE_SYSTEM_ROUTES_DYNAMIC_REGEXP, FILE_SYSTEM_ROUTES_FILE_NAME, FILE_SYSTEM_ROUTES_IGNORED_REGEX, FILE_SYSTEM_ROUTES_INDEX, LOADER_EXPORT_NAME, NESTED_ROUTE, NESTED_ROUTES_DIR, SSG_PARAMS_EXPORT_NAME, TEMP_LOADERS_DIR };
|
|
@@ -14,7 +14,7 @@ const routerPlugin = ()=>({
|
|
|
14
14
|
setup: (api)=>{
|
|
15
15
|
const nestedRoutes = {};
|
|
16
16
|
const nestedRoutesForServer = {};
|
|
17
|
-
|
|
17
|
+
api.getAppContext();
|
|
18
18
|
api.addCommand(({ program })=>{
|
|
19
19
|
program.command('routes').description('generate routes inspect report').action(async ()=>{
|
|
20
20
|
const { generateRoutesInspectReport } = await import("./code/inspect.mjs");
|
|
@@ -40,7 +40,7 @@ const routerPlugin = (userConfig = {})=>({
|
|
|
40
40
|
if (!finalRouteConfig.routes && !createRoutes) return;
|
|
41
41
|
const enableRsc = getGlobalEnableRsc();
|
|
42
42
|
if (enableRsc) await prepareRSCRoutes(finalRouteConfig.routes);
|
|
43
|
-
const {
|
|
43
|
+
const { mode: ssrMode, nonce, loaderFailureMode = 'errorBoundary', baseUrl } = context.ssrContext;
|
|
44
44
|
const _basename = '/' === baseUrl ? urlJoin(baseUrl, basename) : baseUrl;
|
|
45
45
|
const requestContext = createRequestContext(context.ssrContext?.loaderContext);
|
|
46
46
|
const hooks = api.getHooks();
|
|
@@ -94,7 +94,7 @@ const routerPlugin = (userConfig = {})=>({
|
|
|
94
94
|
if (!finalRouteConfig) return App;
|
|
95
95
|
const getRouteApp = ()=>{
|
|
96
96
|
const enableRsc = getGlobalEnableRsc();
|
|
97
|
-
return (
|
|
97
|
+
return ()=>{
|
|
98
98
|
const context = useContext(InternalRuntimeContext);
|
|
99
99
|
const { routerContext, ssrContext, routes } = context;
|
|
100
100
|
const { nonce, mode, useJsonScript } = ssrContext;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { RuntimePluginConfig } from '@modern-js/app-tools';
|
|
2
|
-
export declare const entryForCSRWithRSC: ({ metaName, entryName,
|
|
2
|
+
export declare const entryForCSRWithRSC: ({ metaName, entryName, mountId, isNestedRouter, }: {
|
|
3
3
|
metaName: string;
|
|
4
4
|
entryName: string;
|
|
5
5
|
urlPath?: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export declare const getResponseProxy: () => null;
|
|
2
|
-
export declare const setHeaders: (
|
|
3
|
-
export declare const setStatus: (
|
|
4
|
-
export declare const redirect: (
|
|
2
|
+
export declare const setHeaders: (_headers: Record<string, string>) => void;
|
|
3
|
+
export declare const setStatus: (_status: number) => void;
|
|
4
|
+
export declare const redirect: (_url: string, _init?: number | ResponseInit) => void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { PayloadRoute, ServerPayload } from './index.server.js';
|
|
2
2
|
export type { ServerPayload, PayloadRoute };
|
|
3
3
|
export declare const getServerPayload: () => ServerPayload | undefined;
|
|
4
|
-
export declare const setServerPayload: (
|
|
4
|
+
export declare const setServerPayload: (_payload: ServerPayload) => void;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { AppNormalizedConfig, AppToolsContext } from '@modern-js/app-tools';
|
|
2
2
|
import type { Entrypoint, NestedRouteForCli, PageRoute, RouteLegacy, SSRMode } from '@modern-js/types';
|
|
3
|
-
export declare const routesForServer: ({ routesForServerLoaderMatches, }: {
|
|
3
|
+
export declare const routesForServer: ({ routesForServerLoaderMatches, ssg, }: {
|
|
4
4
|
routesForServerLoaderMatches: (NestedRouteForCli | PageRoute)[];
|
|
5
|
+
ssg?: boolean;
|
|
5
6
|
}) => string;
|
|
6
7
|
export declare const fileSystemRoutes: ({ metaName, routes, ssrMode, nestedRoutesEntry, entryName, internalDirectory, splitRouteChunks, isRscClientBundle, srcDirectory, internalSrcAlias, }: {
|
|
7
8
|
metaName: string;
|
|
@@ -7,6 +7,7 @@ export declare const parseModule: ({ source, filename, }: {
|
|
|
7
7
|
}) => Promise<readonly [imports: readonly import("es-module-lexer").ImportSpecifier[], exports: readonly import("es-module-lexer").ExportSpecifier[], facade: boolean, hasModuleSyntax: boolean]>;
|
|
8
8
|
export declare const hasLoader: (filename: string, source?: string) => Promise<boolean>;
|
|
9
9
|
export declare const hasAction: (filename: string, source?: string) => Promise<boolean>;
|
|
10
|
+
export declare const hasSsgParams: (filename: string, source?: string) => Promise<boolean>;
|
|
10
11
|
export declare const getServerLoadersFile: (internalDirectory: string, entryName: string) => string;
|
|
11
12
|
export declare const getServerCombinedModuleFile: (internalDirectory: string, entryName: string) => string;
|
|
12
13
|
export declare const getPathWithoutExt: (filename: string) => string;
|
|
@@ -2,6 +2,7 @@ export declare const NESTED_ROUTES_DIR = "routes";
|
|
|
2
2
|
export declare const FILE_SYSTEM_ROUTES_FILE_NAME = "routes.js";
|
|
3
3
|
export declare const LOADER_EXPORT_NAME = "loader";
|
|
4
4
|
export declare const ACTION_EXPORT_NAME = "action";
|
|
5
|
+
export declare const SSG_PARAMS_EXPORT_NAME = "ssgParams";
|
|
5
6
|
export declare const TEMP_LOADERS_DIR = "__loaders__";
|
|
6
7
|
export declare const FILE_SYSTEM_ROUTES_INDEX = "index";
|
|
7
8
|
export declare const FILE_SYSTEM_ROUTES_IGNORED_REGEX: RegExp;
|