@modern-js/app-tools 2.53.1-alpha.3 → 2.54.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/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/dependencies/index.js +16 -25
- package/dist/cjs/plugins/deploy/dependencies/utils.js +1 -2
- package/dist/cjs/plugins/deploy/platforms/netlify.js +5 -9
- package/dist/cjs/plugins/deploy/platforms/node.js +5 -13
- package/dist/cjs/plugins/deploy/platforms/vercel.js +5 -9
- 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/dependencies/index.js +69 -94
- package/dist/esm/plugins/deploy/dependencies/utils.js +3 -4
- package/dist/esm/plugins/deploy/platforms/netlify.js +8 -10
- package/dist/esm/plugins/deploy/platforms/node.js +8 -14
- package/dist/esm/plugins/deploy/platforms/vercel.js +8 -10
- 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/dependencies/index.js +18 -27
- package/dist/esm-node/plugins/deploy/dependencies/utils.js +1 -2
- package/dist/esm-node/plugins/deploy/platforms/netlify.js +6 -10
- package/dist/esm-node/plugins/deploy/platforms/node.js +6 -14
- package/dist/esm-node/plugins/deploy/platforms/vercel.js +6 -10
- 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/plugins/deploy/dependencies/index.d.ts +1 -9
- package/dist/types/plugins/deploy/dependencies/utils.d.ts +1 -7
- 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 -30
- 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/cjs/plugins/deploy/exports.js +0 -28
- 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/plugins/deploy/exports.js +0 -4
- 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/plugins/deploy/exports.js +0 -4
- package/dist/esm-node/utils/getServerInternalPlugins.js +0 -15
- package/dist/js/modern/analyze/constants.js +0 -15
- package/dist/js/modern/analyze/generateCode.js +0 -179
- package/dist/js/modern/analyze/getBundleEntry.js +0 -75
- package/dist/js/modern/analyze/getClientRoutes.js +0 -219
- package/dist/js/modern/analyze/getFileSystemEntry.js +0 -74
- package/dist/js/modern/analyze/getHtmlTemplate.js +0 -82
- package/dist/js/modern/analyze/getServerRoutes.js +0 -192
- package/dist/js/modern/analyze/index.js +0 -148
- package/dist/js/modern/analyze/isDefaultExportFunction.js +0 -32
- package/dist/js/modern/analyze/makeLegalIdentifier.js +0 -16
- package/dist/js/modern/analyze/templates.js +0 -88
- package/dist/js/modern/analyze/utils.js +0 -92
- package/dist/js/modern/commands/build.js +0 -154
- package/dist/js/modern/commands/deploy.js +0 -5
- package/dist/js/modern/commands/dev.js +0 -95
- package/dist/js/modern/commands/index.js +0 -3
- package/dist/js/modern/commands/inspect.js +0 -69
- package/dist/js/modern/commands/start.js +0 -31
- package/dist/js/modern/exports/server.js +0 -1
- package/dist/js/modern/hooks.js +0 -21
- package/dist/js/modern/index.js +0 -109
- package/dist/js/modern/locale/en.js +0 -35
- package/dist/js/modern/locale/index.js +0 -9
- package/dist/js/modern/locale/zh.js +0 -35
- package/dist/js/modern/utils/config.js +0 -78
- package/dist/js/modern/utils/createCompiler.js +0 -61
- package/dist/js/modern/utils/createServer.js +0 -18
- package/dist/js/modern/utils/getSpecifiedEntries.js +0 -36
- package/dist/js/modern/utils/language.js +0 -5
- package/dist/js/modern/utils/printInstructions.js +0 -11
- package/dist/js/modern/utils/routes.js +0 -15
- package/dist/js/modern/utils/types.js +0 -0
- package/dist/js/node/analyze/constants.js +0 -36
- package/dist/js/node/analyze/generateCode.js +0 -208
- package/dist/js/node/analyze/getBundleEntry.js +0 -89
- package/dist/js/node/analyze/getClientRoutes.js +0 -241
- package/dist/js/node/analyze/getFileSystemEntry.js +0 -90
- package/dist/js/node/analyze/getHtmlTemplate.js +0 -106
- package/dist/js/node/analyze/getServerRoutes.js +0 -208
- package/dist/js/node/analyze/index.js +0 -178
- package/dist/js/node/analyze/isDefaultExportFunction.js +0 -50
- package/dist/js/node/analyze/makeLegalIdentifier.js +0 -24
- package/dist/js/node/analyze/templates.js +0 -106
- package/dist/js/node/analyze/utils.js +0 -113
- package/dist/js/node/commands/build.js +0 -174
- package/dist/js/node/commands/deploy.js +0 -14
- package/dist/js/node/commands/dev.js +0 -120
- package/dist/js/node/commands/index.js +0 -44
- package/dist/js/node/commands/inspect.js +0 -98
- package/dist/js/node/commands/start.js +0 -47
- package/dist/js/node/exports/server.js +0 -13
- package/dist/js/node/hooks.js +0 -39
- package/dist/js/node/index.js +0 -141
- package/dist/js/node/locale/en.js +0 -42
- package/dist/js/node/locale/index.js +0 -20
- package/dist/js/node/locale/zh.js +0 -42
- package/dist/js/node/utils/config.js +0 -103
- package/dist/js/node/utils/createCompiler.js +0 -81
- package/dist/js/node/utils/createServer.js +0 -35
- package/dist/js/node/utils/getSpecifiedEntries.js +0 -46
- package/dist/js/node/utils/language.js +0 -13
- package/dist/js/node/utils/printInstructions.js +0 -22
- package/dist/js/node/utils/routes.js +0 -25
- package/dist/js/node/utils/types.js +0 -0
- 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/plugins/deploy/exports.d.ts +0 -1
- 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
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Entrypoint } from '@modern-js/types';
|
|
2
|
+
import type { RuntimePlugin } from '../../types';
|
|
3
|
+
export declare const index: ({ mountId, imports, renderFunction, exportStatement, }: {
|
|
4
|
+
mountId: string;
|
|
5
|
+
imports: string;
|
|
6
|
+
exportStatement: string;
|
|
7
|
+
renderFunction: string;
|
|
8
|
+
}) => string;
|
|
9
|
+
export declare const renderFunction: ({ plugins, customBootstrap, fileSystemRoutes, customRuntimeConfig, }: {
|
|
10
|
+
plugins: RuntimePlugin[];
|
|
11
|
+
customBootstrap?: string | false | undefined;
|
|
12
|
+
customRuntimeConfig?: string | false | undefined;
|
|
13
|
+
fileSystemRoutes: Entrypoint['fileSystemRoutes'];
|
|
14
|
+
}) => string;
|
|
15
|
+
export declare const html: (partials: {
|
|
16
|
+
top: string[];
|
|
17
|
+
head: string[];
|
|
18
|
+
body: string[];
|
|
19
|
+
}) => string;
|
|
@@ -1,22 +1,20 @@
|
|
|
1
1
|
import type { Entrypoint } from '@modern-js/types';
|
|
2
|
-
import type { ImportStatement } from '
|
|
2
|
+
import type { ImportStatement } from '../../types';
|
|
3
3
|
export declare const walkDirectory: (dir: string) => string[];
|
|
4
|
-
export declare const getDefaultImports: ({ entrypoint, srcDirectory, appDirectory, internalSrcAlias, internalDirAlias, }: {
|
|
4
|
+
export declare const getDefaultImports: ({ entrypoint, srcDirectory, appDirectory, internalSrcAlias, internalDirAlias, runtimeConfigFile, customRuntimeConfig, }: {
|
|
5
5
|
entrypoint: Entrypoint;
|
|
6
6
|
srcDirectory: string;
|
|
7
7
|
appDirectory: string;
|
|
8
8
|
internalSrcAlias: string;
|
|
9
9
|
internalDirAlias: string;
|
|
10
|
+
runtimeConfigFile: string | false;
|
|
11
|
+
customRuntimeConfig: string | false;
|
|
10
12
|
}) => ImportStatement[];
|
|
11
|
-
export declare const isPageComponentFile: (filePath: string) => boolean;
|
|
12
13
|
export declare const replaceWithAlias: (base: string, filePath: string, alias: string) => string;
|
|
13
14
|
export declare const parseModule: ({ source, filename, }: {
|
|
14
15
|
source: string;
|
|
15
16
|
filename: string;
|
|
16
17
|
}) => Promise<readonly [imports: readonly import("es-module-lexer").ImportSpecifier[], exports: readonly import("es-module-lexer").ExportSpecifier[], facade: boolean]>;
|
|
17
|
-
export declare const hasLoader: (filename: string, source?: string) => Promise<boolean>;
|
|
18
|
-
export declare const hasAction: (filename: string, source?: string) => Promise<boolean>;
|
|
19
|
-
export declare const getServerLoadersFile: (internalDirectory: string, entryName: string) => string;
|
|
20
18
|
export declare const getServerCombinedModueFile: (internalDirectory: string, entryName: string) => string;
|
|
21
19
|
export declare const checkIsBuildCommands: () => boolean;
|
|
22
20
|
export declare const isSubDirOrEqual: (parent: string, child: string) => boolean;
|
|
@@ -1,9 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const handleDependencies: ({ appDir, serverRootDir, includeEntries, entryFilter, modifyPackageJson, copyWholePackage, }: {
|
|
3
|
-
appDir: string;
|
|
4
|
-
serverRootDir: string;
|
|
5
|
-
includeEntries: string[];
|
|
6
|
-
entryFilter?: ((filePath: string) => boolean) | undefined;
|
|
7
|
-
modifyPackageJson?: ((pkgJson: PackageJson) => PackageJson) | undefined;
|
|
8
|
-
copyWholePackage?: ((pkgName: string) => boolean) | undefined;
|
|
9
|
-
}) => Promise<void>;
|
|
1
|
+
export declare const handleDependencies: (appDir: string, serverRootDir: string, include: string[], entryFilter?: ((filePath: string) => boolean) | undefined) => Promise<void>;
|
|
@@ -17,13 +17,7 @@ export type TracedFile = {
|
|
|
17
17
|
pkgName: string;
|
|
18
18
|
pkgVersion?: string;
|
|
19
19
|
};
|
|
20
|
-
|
|
21
|
-
pkg: TracedPackage;
|
|
22
|
-
version: string;
|
|
23
|
-
projectDir: string;
|
|
24
|
-
_pkgPath?: string;
|
|
25
|
-
}
|
|
26
|
-
export declare const writePackage: (options: WritePackageOptions) => Promise<void>;
|
|
20
|
+
export declare const writePackage: (pkg: TracedPackage, version: string, projectDir: string, _pkgPath?: string) => Promise<void>;
|
|
27
21
|
export declare const linkPackage: (from: string, to: string, projectRootDir: string) => Promise<void>;
|
|
28
22
|
interface ReadDirOptions {
|
|
29
23
|
filter?: (filePath: string) => boolean;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AsyncWaterfall, AsyncWorkflow, ParallelWorkflow } from '@modern-js/plugin';
|
|
2
|
-
import type { Entrypoint, HtmlPartials, NestedRouteForCli, PageRoute, RouteLegacy, ServerRoute } from '@modern-js/types';
|
|
2
|
+
import type { Entrypoint, HtmlPartials, NestedRouteForCli, PageRoute, RouteLegacy, ServerPlugin, ServerRoute } from '@modern-js/types';
|
|
3
3
|
import type { RegisterBuildPlatformResult, DevToolData } from '@modern-js/core';
|
|
4
4
|
import type { Stats, MultiStats } from '@rsbuild/shared';
|
|
5
5
|
import type { Rspack, webpack } from '@modern-js/uni-builder';
|
|
@@ -47,6 +47,13 @@ export type AppToolsHooks<B extends Bundler = 'webpack'> = {
|
|
|
47
47
|
modifyServerRoutes: AsyncWaterfall<{
|
|
48
48
|
routes: ServerRoute[];
|
|
49
49
|
}>;
|
|
50
|
+
modifyEntrypoints: AsyncWaterfall<{
|
|
51
|
+
entrypoints: Entrypoint[];
|
|
52
|
+
}>;
|
|
53
|
+
checkEntryPoint: AsyncWaterfall<{
|
|
54
|
+
path: string;
|
|
55
|
+
entry: false | string;
|
|
56
|
+
}>;
|
|
50
57
|
htmlPartials: AsyncWaterfall<{
|
|
51
58
|
entrypoint: Entrypoint;
|
|
52
59
|
partials: HtmlPartials;
|
|
@@ -59,6 +66,9 @@ export type AppToolsHooks<B extends Bundler = 'webpack'> = {
|
|
|
59
66
|
collectServerPlugins: AsyncWaterfall<{
|
|
60
67
|
plugins: Array<Record<string, string>>;
|
|
61
68
|
}>;
|
|
69
|
+
_internalServerPlugins: AsyncWaterfall<{
|
|
70
|
+
plugins: ServerPlugin[];
|
|
71
|
+
}>;
|
|
62
72
|
beforeDev: AsyncWorkflow<void, unknown>;
|
|
63
73
|
afterDev: AsyncWorkflow<{
|
|
64
74
|
isFirstCompile: boolean;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ServerPlugin as ServerPluginInstance } from '@modern-js/server-core';
|
|
2
|
+
import { ServerPlugin } from '@modern-js/types';
|
|
3
|
+
import { AppTools, PluginAPI } from '../types';
|
|
4
|
+
export declare function getServerPlugins(api: PluginAPI<AppTools<'shared'>>): Promise<ServerPlugin[]>;
|
|
5
|
+
export declare function loadServerPlugins(api: PluginAPI<AppTools<'shared'>>, appDirectory: string): Promise<ServerPluginInstance[]>;
|
package/package.json
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"modern",
|
|
16
16
|
"modern.js"
|
|
17
17
|
],
|
|
18
|
-
"version": "2.
|
|
18
|
+
"version": "2.54.0",
|
|
19
19
|
"jsnext:source": "./src/index.ts",
|
|
20
20
|
"types": "./dist/types/index.d.ts",
|
|
21
21
|
"main": "./dist/cjs/index.js",
|
|
@@ -43,11 +43,6 @@
|
|
|
43
43
|
"types": "./dist/types/exports/server.d.ts",
|
|
44
44
|
"jsnext:source": "./src/exports/server.ts",
|
|
45
45
|
"default": "./dist/cjs/exports/server.js"
|
|
46
|
-
},
|
|
47
|
-
"./deploy": {
|
|
48
|
-
"types": "./dist/types/plugins/deploy/exports.d.ts",
|
|
49
|
-
"jsnext:source": "./src/plugins/deploy/exports.ts",
|
|
50
|
-
"default": "./dist/cjs/plugins/deploy/exports.js"
|
|
51
46
|
}
|
|
52
47
|
},
|
|
53
48
|
"engines": {
|
|
@@ -63,9 +58,6 @@
|
|
|
63
58
|
],
|
|
64
59
|
"server": [
|
|
65
60
|
"./dist/types/exports/server.d.ts"
|
|
66
|
-
],
|
|
67
|
-
"deploy": [
|
|
68
|
-
"./dist/types/plugins/deploy/exports.d.ts"
|
|
69
61
|
]
|
|
70
62
|
}
|
|
71
63
|
},
|
|
@@ -77,9 +69,9 @@
|
|
|
77
69
|
"@babel/parser": "^7.22.15",
|
|
78
70
|
"@babel/traverse": "^7.23.2",
|
|
79
71
|
"@babel/types": "^7.23.0",
|
|
80
|
-
"@rsbuild/plugin-node-polyfill": "0.7.
|
|
81
|
-
"@rsbuild/shared": "0.7.
|
|
82
|
-
"@rsbuild/core": "0.7.
|
|
72
|
+
"@rsbuild/plugin-node-polyfill": "0.7.9",
|
|
73
|
+
"@rsbuild/shared": "0.7.9",
|
|
74
|
+
"@rsbuild/core": "0.7.9",
|
|
83
75
|
"@swc/helpers": "0.5.3",
|
|
84
76
|
"@vercel/nft": "^0.26.4",
|
|
85
77
|
"es-module-lexer": "^1.1.0",
|
|
@@ -88,23 +80,23 @@
|
|
|
88
80
|
"mlly": "^1.6.1",
|
|
89
81
|
"pkg-types": "^1.1.0",
|
|
90
82
|
"std-env": "^3.7.0",
|
|
91
|
-
"@modern-js/
|
|
92
|
-
"@modern-js/
|
|
93
|
-
"@modern-js/plugin": "2.
|
|
94
|
-
"@modern-js/
|
|
95
|
-
"@modern-js/
|
|
96
|
-
"@modern-js/plugin-
|
|
97
|
-
"@modern-js/
|
|
98
|
-
"@modern-js/plugin-
|
|
99
|
-
"@modern-js/server
|
|
100
|
-
"@modern-js/server": "2.
|
|
101
|
-
"@modern-js/
|
|
102
|
-
"@modern-js/
|
|
103
|
-
"@modern-js/
|
|
104
|
-
"@modern-js/
|
|
83
|
+
"@modern-js/core": "2.54.0",
|
|
84
|
+
"@modern-js/node-bundle-require": "2.54.0",
|
|
85
|
+
"@modern-js/plugin-lint": "2.54.0",
|
|
86
|
+
"@modern-js/plugin-i18n": "2.54.0",
|
|
87
|
+
"@modern-js/plugin": "2.54.0",
|
|
88
|
+
"@modern-js/plugin-data-loader": "2.54.0",
|
|
89
|
+
"@modern-js/prod-server": "2.54.0",
|
|
90
|
+
"@modern-js/rsbuild-plugin-esbuild": "2.54.0",
|
|
91
|
+
"@modern-js/server": "2.54.0",
|
|
92
|
+
"@modern-js/server-core": "2.54.0",
|
|
93
|
+
"@modern-js/server-utils": "2.54.0",
|
|
94
|
+
"@modern-js/types": "2.54.0",
|
|
95
|
+
"@modern-js/uni-builder": "2.54.0",
|
|
96
|
+
"@modern-js/utils": "2.54.0"
|
|
105
97
|
},
|
|
106
98
|
"devDependencies": {
|
|
107
|
-
"@rsbuild/plugin-swc": "0.7.
|
|
99
|
+
"@rsbuild/plugin-swc": "0.7.9",
|
|
108
100
|
"@types/babel__traverse": "7.18.5",
|
|
109
101
|
"@types/jest": "^29",
|
|
110
102
|
"@types/node": "^14",
|
|
@@ -112,9 +104,9 @@
|
|
|
112
104
|
"ts-node": "^10.9.1",
|
|
113
105
|
"tsconfig-paths": "^4.2.0",
|
|
114
106
|
"typescript": "^5",
|
|
115
|
-
"webpack": "^5.
|
|
116
|
-
"@scripts/build": "2.
|
|
117
|
-
"@scripts/jest-config": "2.
|
|
107
|
+
"webpack": "^5.92.0",
|
|
108
|
+
"@scripts/build": "2.54.0",
|
|
109
|
+
"@scripts/jest-config": "2.54.0"
|
|
118
110
|
},
|
|
119
111
|
"sideEffects": false,
|
|
120
112
|
"publishConfig": {
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var constants_exports = {};
|
|
20
|
-
__export(constants_exports, {
|
|
21
|
-
ACTION_EXPORT_NAME: () => ACTION_EXPORT_NAME,
|
|
22
|
-
APP_CONFIG_NAME: () => APP_CONFIG_NAME,
|
|
23
|
-
APP_FILE_NAME: () => APP_FILE_NAME,
|
|
24
|
-
APP_INIT_EXPORTED: () => APP_INIT_EXPORTED,
|
|
25
|
-
APP_INIT_IMPORTED: () => APP_INIT_IMPORTED,
|
|
26
|
-
ENTRY_BOOTSTRAP_FILE_NAME: () => ENTRY_BOOTSTRAP_FILE_NAME,
|
|
27
|
-
ENTRY_POINT_FILE_NAME: () => ENTRY_POINT_FILE_NAME,
|
|
28
|
-
FILE_SYSTEM_ROUTES_COMPONENTS_DIR: () => FILE_SYSTEM_ROUTES_COMPONENTS_DIR,
|
|
29
|
-
FILE_SYSTEM_ROUTES_DYNAMIC_REGEXP: () => FILE_SYSTEM_ROUTES_DYNAMIC_REGEXP,
|
|
30
|
-
FILE_SYSTEM_ROUTES_FILE_NAME: () => FILE_SYSTEM_ROUTES_FILE_NAME,
|
|
31
|
-
FILE_SYSTEM_ROUTES_GLOBAL_LAYOUT: () => FILE_SYSTEM_ROUTES_GLOBAL_LAYOUT,
|
|
32
|
-
FILE_SYSTEM_ROUTES_IGNORED_REGEX: () => FILE_SYSTEM_ROUTES_IGNORED_REGEX,
|
|
33
|
-
FILE_SYSTEM_ROUTES_INDEX: () => FILE_SYSTEM_ROUTES_INDEX,
|
|
34
|
-
FILE_SYSTEM_ROUTES_LAYOUT: () => FILE_SYSTEM_ROUTES_LAYOUT,
|
|
35
|
-
HTML_PARTIALS_EXTENSIONS: () => HTML_PARTIALS_EXTENSIONS,
|
|
36
|
-
HTML_PARTIALS_FOLDER: () => HTML_PARTIALS_FOLDER,
|
|
37
|
-
INDEX_FILE_NAME: () => INDEX_FILE_NAME,
|
|
38
|
-
JS_EXTENSIONS: () => JS_EXTENSIONS,
|
|
39
|
-
LOADER_EXPORT_NAME: () => LOADER_EXPORT_NAME,
|
|
40
|
-
NESTED_ROUTE: () => NESTED_ROUTE,
|
|
41
|
-
NESTED_ROUTES_DIR: () => NESTED_ROUTES_DIR,
|
|
42
|
-
PAGES_DIR_NAME: () => PAGES_DIR_NAME,
|
|
43
|
-
TEMP_LOADERS_DIR: () => TEMP_LOADERS_DIR
|
|
44
|
-
});
|
|
45
|
-
module.exports = __toCommonJS(constants_exports);
|
|
46
|
-
const JS_EXTENSIONS = [
|
|
47
|
-
".js",
|
|
48
|
-
".ts",
|
|
49
|
-
".jsx",
|
|
50
|
-
".tsx"
|
|
51
|
-
];
|
|
52
|
-
const INDEX_FILE_NAME = "index";
|
|
53
|
-
const APP_FILE_NAME = "App";
|
|
54
|
-
const PAGES_DIR_NAME = "pages";
|
|
55
|
-
const NESTED_ROUTES_DIR = "routes";
|
|
56
|
-
const FILE_SYSTEM_ROUTES_FILE_NAME = "routes.js";
|
|
57
|
-
const LOADER_EXPORT_NAME = "loader";
|
|
58
|
-
const ACTION_EXPORT_NAME = "action";
|
|
59
|
-
const TEMP_LOADERS_DIR = "__loaders__";
|
|
60
|
-
const ENTRY_POINT_FILE_NAME = "index.jsx";
|
|
61
|
-
const ENTRY_BOOTSTRAP_FILE_NAME = "bootstrap.jsx";
|
|
62
|
-
const FILE_SYSTEM_ROUTES_DYNAMIC_REGEXP = /^\[(\S+)\]([*+?]?)$/;
|
|
63
|
-
const FILE_SYSTEM_ROUTES_LAYOUT = "_layout";
|
|
64
|
-
const FILE_SYSTEM_ROUTES_GLOBAL_LAYOUT = "_app";
|
|
65
|
-
const FILE_SYSTEM_ROUTES_INDEX = "index";
|
|
66
|
-
const FILE_SYSTEM_ROUTES_IGNORED_REGEX = /\.(d|test|spec|e2e)\.(js|jsx|ts|tsx)$/;
|
|
67
|
-
const HTML_PARTIALS_FOLDER = "html";
|
|
68
|
-
const HTML_PARTIALS_EXTENSIONS = [
|
|
69
|
-
".htm",
|
|
70
|
-
".html",
|
|
71
|
-
".ejs"
|
|
72
|
-
];
|
|
73
|
-
const FILE_SYSTEM_ROUTES_COMPONENTS_DIR = "internal_components";
|
|
74
|
-
const NESTED_ROUTE = {
|
|
75
|
-
LAYOUT_FILE: "layout",
|
|
76
|
-
LAYOUT_CONFIG_FILE: "layout.config",
|
|
77
|
-
LAYOUT_LOADER_FILE: "layout.loader",
|
|
78
|
-
LAYOUT_DATA_FILE: "layout.data",
|
|
79
|
-
LAYOUT_CLIENT_LOADER: "layout.data.client",
|
|
80
|
-
PAGE_FILE: "page",
|
|
81
|
-
PAGE_CONFIG_FILE: "page.config",
|
|
82
|
-
PAGE_LOADER_FILE: "page.loader",
|
|
83
|
-
PAGE_DATA_FILE: "page.data",
|
|
84
|
-
PAGE_CLIENT_LOADER: "page.data.client",
|
|
85
|
-
SPLATE_FILE: "$",
|
|
86
|
-
SPLATE_CONFIG_FILE: "$.config",
|
|
87
|
-
SPLATE_LOADER_FILE: "$.loader",
|
|
88
|
-
SPLATE_DATA_FILE: "$.data",
|
|
89
|
-
SPLATE_CLIENT_DATA: "$.data.client",
|
|
90
|
-
LOADING_FILE: "loading",
|
|
91
|
-
ERROR_FILE: "error",
|
|
92
|
-
LOADER_FILE: "loader"
|
|
93
|
-
};
|
|
94
|
-
const APP_CONFIG_NAME = "config";
|
|
95
|
-
const APP_INIT_EXPORTED = "init";
|
|
96
|
-
const APP_INIT_IMPORTED = "appInit";
|
|
97
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
98
|
-
0 && (module.exports = {
|
|
99
|
-
ACTION_EXPORT_NAME,
|
|
100
|
-
APP_CONFIG_NAME,
|
|
101
|
-
APP_FILE_NAME,
|
|
102
|
-
APP_INIT_EXPORTED,
|
|
103
|
-
APP_INIT_IMPORTED,
|
|
104
|
-
ENTRY_BOOTSTRAP_FILE_NAME,
|
|
105
|
-
ENTRY_POINT_FILE_NAME,
|
|
106
|
-
FILE_SYSTEM_ROUTES_COMPONENTS_DIR,
|
|
107
|
-
FILE_SYSTEM_ROUTES_DYNAMIC_REGEXP,
|
|
108
|
-
FILE_SYSTEM_ROUTES_FILE_NAME,
|
|
109
|
-
FILE_SYSTEM_ROUTES_GLOBAL_LAYOUT,
|
|
110
|
-
FILE_SYSTEM_ROUTES_IGNORED_REGEX,
|
|
111
|
-
FILE_SYSTEM_ROUTES_INDEX,
|
|
112
|
-
FILE_SYSTEM_ROUTES_LAYOUT,
|
|
113
|
-
HTML_PARTIALS_EXTENSIONS,
|
|
114
|
-
HTML_PARTIALS_FOLDER,
|
|
115
|
-
INDEX_FILE_NAME,
|
|
116
|
-
JS_EXTENSIONS,
|
|
117
|
-
LOADER_EXPORT_NAME,
|
|
118
|
-
NESTED_ROUTE,
|
|
119
|
-
NESTED_ROUTES_DIR,
|
|
120
|
-
PAGES_DIR_NAME,
|
|
121
|
-
TEMP_LOADERS_DIR
|
|
122
|
-
});
|
|
@@ -1,197 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var getRoutes_exports = {};
|
|
30
|
-
__export(getRoutes_exports, {
|
|
31
|
-
getClientRoutes: () => getClientRoutes
|
|
32
|
-
});
|
|
33
|
-
module.exports = __toCommonJS(getRoutes_exports);
|
|
34
|
-
var import_path = __toESM(require("path"));
|
|
35
|
-
var import_utils = require("@modern-js/utils");
|
|
36
|
-
var import_makeLegalIdentifier = require("../makeLegalIdentifier");
|
|
37
|
-
var import_constants = require("../constants");
|
|
38
|
-
var import_utils2 = require("../utils");
|
|
39
|
-
var import_utils3 = require("./utils");
|
|
40
|
-
const compName = (srcDirectory, filePath) => {
|
|
41
|
-
const legalCompName = (0, import_makeLegalIdentifier.makeLegalIdentifier)(import_path.default.relative(srcDirectory, filePath));
|
|
42
|
-
return `Comp_${legalCompName}`;
|
|
43
|
-
};
|
|
44
|
-
const layoutNameAbbr = (filePath) => {
|
|
45
|
-
const prefix = "L_";
|
|
46
|
-
const dirName = import_path.default.dirname(filePath).split("/").pop() || "";
|
|
47
|
-
return `${prefix}${(0, import_makeLegalIdentifier.makeLegalIdentifier)(dirName)}`;
|
|
48
|
-
};
|
|
49
|
-
const parents = [];
|
|
50
|
-
const recursiveReadDir = ({ dir, routes, basePath = "/", srcDirectory, srcAlias }) => {
|
|
51
|
-
let hasDynamicRoute = false;
|
|
52
|
-
let resetParent = false;
|
|
53
|
-
let parent = parents[parents.length - 1];
|
|
54
|
-
const layout = (0, import_utils3.findLayout)(dir);
|
|
55
|
-
if (layout) {
|
|
56
|
-
if (basePath === "/") {
|
|
57
|
-
throw new Error(`should use _app instead of _layout in ${dir}`);
|
|
58
|
-
} else {
|
|
59
|
-
const alias = (0, import_utils2.replaceWithAlias)(srcDirectory, layout, srcAlias);
|
|
60
|
-
const componentName = compName(srcDirectory, layout);
|
|
61
|
-
const route = {
|
|
62
|
-
path: `${basePath.substring(0, basePath.length - 1)}`,
|
|
63
|
-
children: [],
|
|
64
|
-
_component: alias,
|
|
65
|
-
component: componentName,
|
|
66
|
-
parent,
|
|
67
|
-
type: "page"
|
|
68
|
-
};
|
|
69
|
-
parent = route;
|
|
70
|
-
resetParent = true;
|
|
71
|
-
routes.push(route);
|
|
72
|
-
parents.push(route);
|
|
73
|
-
routes = route.children;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
for (const relative of import_utils.fs.readdirSync(dir)) {
|
|
77
|
-
const filePath = import_path.default.join(dir, relative);
|
|
78
|
-
if (!(0, import_utils3.shouldSkip)(filePath)) {
|
|
79
|
-
const filename = import_path.default.basename(filePath, import_path.default.extname(filePath));
|
|
80
|
-
const alias = (0, import_utils2.replaceWithAlias)(srcDirectory, filePath, srcAlias);
|
|
81
|
-
const componentName = compName(srcDirectory, filePath);
|
|
82
|
-
const dynamicRouteMatched = import_constants.FILE_SYSTEM_ROUTES_DYNAMIC_REGEXP.exec(filename);
|
|
83
|
-
if (dynamicRouteMatched) {
|
|
84
|
-
if (hasDynamicRoute) {
|
|
85
|
-
throw new Error(`Can't set two dynamic route in one directory: ${dir}`);
|
|
86
|
-
} else {
|
|
87
|
-
hasDynamicRoute = true;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
const route = {
|
|
91
|
-
path: `${basePath}${dynamicRouteMatched ? `:${dynamicRouteMatched[1].replace(/\$$/, "?")}${dynamicRouteMatched[2]}` : filename}`,
|
|
92
|
-
_component: alias,
|
|
93
|
-
component: componentName,
|
|
94
|
-
parent,
|
|
95
|
-
type: "page"
|
|
96
|
-
};
|
|
97
|
-
if (import_utils.fs.statSync(filePath).isDirectory()) {
|
|
98
|
-
recursiveReadDir({
|
|
99
|
-
dir: filePath,
|
|
100
|
-
routes,
|
|
101
|
-
basePath: `${route.path}/`,
|
|
102
|
-
srcDirectory,
|
|
103
|
-
srcAlias
|
|
104
|
-
});
|
|
105
|
-
continue;
|
|
106
|
-
}
|
|
107
|
-
if (filename === import_constants.FILE_SYSTEM_ROUTES_LAYOUT) {
|
|
108
|
-
continue;
|
|
109
|
-
}
|
|
110
|
-
if (filename === import_constants.FILE_SYSTEM_ROUTES_INDEX) {
|
|
111
|
-
route.path = basePath === "/" ? basePath : `${basePath.substring(0, basePath.length - 1)}`;
|
|
112
|
-
}
|
|
113
|
-
if (filename === "404" && basePath === "/") {
|
|
114
|
-
route.path = "*";
|
|
115
|
-
}
|
|
116
|
-
routes.push(route);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
if (resetParent) {
|
|
120
|
-
parents.pop();
|
|
121
|
-
}
|
|
122
|
-
};
|
|
123
|
-
const normalizeNestedRoutes = (nested, internalComponentsDir, internalDirectory, internalDirAlias) => {
|
|
124
|
-
const flat = (routes) => routes.reduce((memo, route) => memo.concat(Array.isArray(route.children) ? flat(route.children) : [
|
|
125
|
-
route
|
|
126
|
-
]), []);
|
|
127
|
-
const generate = (route) => {
|
|
128
|
-
const codes = [];
|
|
129
|
-
let lastComponent = route.component;
|
|
130
|
-
const imports = [
|
|
131
|
-
`import React from 'react';`,
|
|
132
|
-
`import ${lastComponent} from '${route._component}'`
|
|
133
|
-
];
|
|
134
|
-
while (route = route.parent) {
|
|
135
|
-
const layoutComponent = route.component;
|
|
136
|
-
const layoutComponentAbbr = layoutNameAbbr(route._component);
|
|
137
|
-
imports.push(`import ${layoutComponent} from '${route._component}';`);
|
|
138
|
-
const currentComponent = `${layoutComponentAbbr}_${lastComponent}`;
|
|
139
|
-
codes.push(`const ${currentComponent} = props => <${layoutComponent} Component={${lastComponent}} {...props} />;`);
|
|
140
|
-
lastComponent = currentComponent;
|
|
141
|
-
}
|
|
142
|
-
const file = import_path.default.resolve(internalComponentsDir, `${lastComponent}.jsx`);
|
|
143
|
-
import_utils.fs.outputFileSync(file, `${imports.join("\n")}
|
|
144
|
-
${codes.join("\n")}
|
|
145
|
-
export default ${lastComponent}`);
|
|
146
|
-
return {
|
|
147
|
-
component: lastComponent,
|
|
148
|
-
_component: (0, import_utils2.replaceWithAlias)(internalDirectory, file, internalDirAlias)
|
|
149
|
-
};
|
|
150
|
-
};
|
|
151
|
-
const normalized = flat(nested).map((route) => route.parent ? {
|
|
152
|
-
...route,
|
|
153
|
-
...generate(route),
|
|
154
|
-
parent: void 0
|
|
155
|
-
} : {
|
|
156
|
-
...route,
|
|
157
|
-
parent: void 0
|
|
158
|
-
});
|
|
159
|
-
return normalized;
|
|
160
|
-
};
|
|
161
|
-
const getClientRoutes = ({ entrypoint, srcDirectory, srcAlias, internalDirectory, internalDirAlias }) => {
|
|
162
|
-
const { entryName, pageRoutesEntry } = entrypoint;
|
|
163
|
-
if (!pageRoutesEntry) {
|
|
164
|
-
return [];
|
|
165
|
-
}
|
|
166
|
-
if (!import_utils.fs.existsSync(pageRoutesEntry)) {
|
|
167
|
-
throw new Error(`generate file system routes error, ${pageRoutesEntry} directory not found.`);
|
|
168
|
-
}
|
|
169
|
-
if (!(import_utils.fs.existsSync(pageRoutesEntry) && import_utils.fs.statSync(pageRoutesEntry).isDirectory())) {
|
|
170
|
-
throw new Error(`generate file system routes error, ${pageRoutesEntry} should be directory.`);
|
|
171
|
-
}
|
|
172
|
-
let routes = [];
|
|
173
|
-
recursiveReadDir({
|
|
174
|
-
dir: pageRoutesEntry,
|
|
175
|
-
routes,
|
|
176
|
-
basePath: "/",
|
|
177
|
-
srcDirectory,
|
|
178
|
-
srcAlias
|
|
179
|
-
});
|
|
180
|
-
const internalComponentsDir = import_path.default.resolve(internalDirectory, `${entryName}/${import_constants.FILE_SYSTEM_ROUTES_COMPONENTS_DIR}`);
|
|
181
|
-
import_utils.fs.emptyDirSync(internalComponentsDir);
|
|
182
|
-
routes = normalizeNestedRoutes(routes, internalComponentsDir, internalDirectory, internalDirAlias);
|
|
183
|
-
parents.length = 0;
|
|
184
|
-
routes.sort((a, b) => {
|
|
185
|
-
const delta = (0, import_utils3.getRouteWeight)(a.path) - (0, import_utils3.getRouteWeight)(b.path);
|
|
186
|
-
if (delta === 0) {
|
|
187
|
-
return a.path.length - b.path.length;
|
|
188
|
-
}
|
|
189
|
-
return delta;
|
|
190
|
-
});
|
|
191
|
-
(0, import_utils3.debug)(`fileSystem routes: %o`, routes);
|
|
192
|
-
return routes;
|
|
193
|
-
};
|
|
194
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
195
|
-
0 && (module.exports = {
|
|
196
|
-
getClientRoutes
|
|
197
|
-
});
|