@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
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import * as path from "path";
|
|
2
2
|
import { createDebugger, findExists, fs, isApiOnly, minimist, isDevCommand, getArgv } from "@modern-js/utils";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import { checkIsBuildCommands, isPageComponentFile, parseModule, replaceWithAlias } from "./utils";
|
|
3
|
+
import { printInstructions } from "../../utils/printInstructions";
|
|
4
|
+
import { generateRoutes, getPathWithoutExt } from "../../utils/routes";
|
|
5
|
+
import { emitResolvedConfig } from "../../utils/config";
|
|
6
|
+
import { getSelectedEntries } from "../../utils/getSelectedEntries";
|
|
7
|
+
import { initialNormalizedConfig } from "../../config";
|
|
8
|
+
import { createBuilderGenerator } from "../../builder";
|
|
9
|
+
import { checkIsBuildCommands, parseModule, replaceWithAlias } from "./utils";
|
|
11
10
|
import { APP_CONFIG_NAME, APP_INIT_EXPORTED, APP_INIT_IMPORTED } from "./constants";
|
|
12
11
|
import { generateIndexCode } from "./generateCode";
|
|
13
12
|
const debug = createDebugger("plugin-analyze");
|
|
@@ -16,7 +15,6 @@ var analyze_default = ({ bundler }) => ({
|
|
|
16
15
|
setup: (api) => {
|
|
17
16
|
let pagesDir = [];
|
|
18
17
|
let nestedRouteEntries = [];
|
|
19
|
-
let originEntrypoints = [];
|
|
20
18
|
return {
|
|
21
19
|
async prepare() {
|
|
22
20
|
var _resolvedConfig_source;
|
|
@@ -50,7 +48,9 @@ var analyze_default = ({ bundler }) => ({
|
|
|
50
48
|
import("./generateCode"),
|
|
51
49
|
import("./getHtmlTemplate")
|
|
52
50
|
]);
|
|
53
|
-
const entrypoints =
|
|
51
|
+
const { entrypoints } = await hookRunners.modifyEntrypoints({
|
|
52
|
+
entrypoints: await getBundleEntry(hookRunners, appContext, resolvedConfig)
|
|
53
|
+
});
|
|
54
54
|
debug(`entrypoints: %o`, entrypoints);
|
|
55
55
|
const initialRoutes = getServerRoutes(entrypoints, {
|
|
56
56
|
appContext,
|
|
@@ -68,7 +68,6 @@ var analyze_default = ({ bundler }) => ({
|
|
|
68
68
|
api.setAppContext(appContext);
|
|
69
69
|
nestedRouteEntries = entrypoints.map((point) => point.nestedRoutesEntry).filter(Boolean);
|
|
70
70
|
pagesDir = entrypoints.map((point) => point.entry).filter((entry) => entry && !path.extname(entry)).concat(nestedRouteEntries);
|
|
71
|
-
originEntrypoints = cloneDeep(entrypoints);
|
|
72
71
|
const { importsStatemets } = await generateCode(appContext, resolvedConfig, entrypoints, api);
|
|
73
72
|
const htmlTemplates = await getHtmlTemplate(entrypoints, api, {
|
|
74
73
|
appContext,
|
|
@@ -212,20 +211,6 @@ var analyze_default = ({ bundler }) => ({
|
|
|
212
211
|
entrypoint,
|
|
213
212
|
imports
|
|
214
213
|
};
|
|
215
|
-
},
|
|
216
|
-
async fileChange(e) {
|
|
217
|
-
const appContext = api.useAppContext();
|
|
218
|
-
const { appDirectory } = appContext;
|
|
219
|
-
const { filename, eventType } = e;
|
|
220
|
-
const isPageFile = (name) => pagesDir.some((pageDir) => name.includes(pageDir));
|
|
221
|
-
const absoluteFilePath = path.resolve(appDirectory, filename);
|
|
222
|
-
const isRouteComponent = isPageFile(absoluteFilePath) && isPageComponentFile(absoluteFilePath);
|
|
223
|
-
if (isRouteComponent && (eventType === "add" || eventType === "unlink")) {
|
|
224
|
-
const resolvedConfig = api.useResolvedConfigContext();
|
|
225
|
-
const { generateCode } = await import("./generateCode");
|
|
226
|
-
const entrypoints = cloneDeep(originEntrypoints);
|
|
227
|
-
generateCode(appContext, resolvedConfig, entrypoints, api);
|
|
228
|
-
}
|
|
229
214
|
}
|
|
230
215
|
};
|
|
231
216
|
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { APP_CONFIG_NAME } from "./constants";
|
|
2
|
+
const index = ({ mountId, imports, renderFunction: renderFunction2, exportStatement }) => `
|
|
3
|
+
const IS_BROWSER = typeof window !== 'undefined' && window.name !== 'nodejs';
|
|
4
|
+
const IS_REACT18 = process.env.IS_REACT18 === 'true';
|
|
5
|
+
const MOUNT_ID = '${mountId}';
|
|
6
|
+
|
|
7
|
+
${imports}
|
|
8
|
+
|
|
9
|
+
let AppWrapper = null;
|
|
10
|
+
|
|
11
|
+
let root = null;
|
|
12
|
+
|
|
13
|
+
function render() {
|
|
14
|
+
${renderFunction2}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
AppWrapper = render();
|
|
18
|
+
|
|
19
|
+
${exportStatement};
|
|
20
|
+
`;
|
|
21
|
+
const renderFunction = ({ plugins, customBootstrap, fileSystemRoutes, customRuntimeConfig }) => {
|
|
22
|
+
const bootstrap = "bootstrap(AppWrapper, MOUNT_ID, root, ReactDOM)";
|
|
23
|
+
const runtimePlugins = `...(runtimeConfig?.plugins || []),`;
|
|
24
|
+
return `
|
|
25
|
+
const finalAppConfig = {
|
|
26
|
+
...App.config,
|
|
27
|
+
...typeof ${APP_CONFIG_NAME} === 'function' ? ${APP_CONFIG_NAME}() : {},
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
AppWrapper = createApp({
|
|
31
|
+
plugins: [
|
|
32
|
+
${plugins.map(({ name, options, args }) => `${name}({...${options}, ...finalAppConfig?.${args || name}}),`).join("\n")}
|
|
33
|
+
${customRuntimeConfig ? runtimePlugins : ""}
|
|
34
|
+
]
|
|
35
|
+
})(${fileSystemRoutes ? "" : `App`})
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
if(!AppWrapper.init && typeof appInit !== 'undefined') {
|
|
39
|
+
AppWrapper.init = appInit;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
if (IS_BROWSER) {
|
|
44
|
+
${customBootstrap ? `customBootstrap(AppWrapper, () => ${bootstrap});` : `${bootstrap};`}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return AppWrapper
|
|
48
|
+
`;
|
|
49
|
+
};
|
|
50
|
+
const html = (partials) => `
|
|
51
|
+
<!DOCTYPE html>
|
|
52
|
+
<html>
|
|
53
|
+
<head>
|
|
54
|
+
|
|
55
|
+
${partials.top.join("\n")}
|
|
56
|
+
|
|
57
|
+
${partials.head.join("\n")}
|
|
58
|
+
|
|
59
|
+
</head>
|
|
60
|
+
|
|
61
|
+
<body>
|
|
62
|
+
<div id="<%= mountId %>"><!--<?- html ?>--></div>
|
|
63
|
+
${partials.body.join("\n")}
|
|
64
|
+
<!--<?- chunksMap.js ?>-->
|
|
65
|
+
<!--<?- SSRDataScript ?>-->
|
|
66
|
+
<!--<?- bottomTemplate ?>-->
|
|
67
|
+
</body>
|
|
68
|
+
|
|
69
|
+
</html>
|
|
70
|
+
`;
|
|
71
|
+
export {
|
|
72
|
+
html,
|
|
73
|
+
index,
|
|
74
|
+
renderFunction
|
|
75
|
+
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import fs from "fs";
|
|
2
2
|
import path from "path";
|
|
3
|
-
import { isReact18, normalizeToPosixPath,
|
|
3
|
+
import { isReact18, normalizeToPosixPath, getCommand, JS_EXTENSIONS } from "@modern-js/utils";
|
|
4
4
|
import { transform } from "esbuild";
|
|
5
5
|
import { parse } from "es-module-lexer";
|
|
6
|
-
import {
|
|
6
|
+
import { FILE_SYSTEM_ROUTES_FILE_NAME } from "./constants";
|
|
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()) {
|
|
@@ -18,7 +18,7 @@ const walkDirectory = (dir) => fs.readdirSync(dir).reduce((previous, filename) =
|
|
|
18
18
|
];
|
|
19
19
|
}
|
|
20
20
|
}, []);
|
|
21
|
-
const getDefaultImports = ({ entrypoint, srcDirectory, appDirectory, internalSrcAlias, internalDirAlias }) => {
|
|
21
|
+
const getDefaultImports = ({ entrypoint, srcDirectory, appDirectory, internalSrcAlias, internalDirAlias, runtimeConfigFile, customRuntimeConfig }) => {
|
|
22
22
|
const { entryName, fileSystemRoutes, customBootstrap, entry } = entrypoint;
|
|
23
23
|
const imports = [
|
|
24
24
|
{
|
|
@@ -89,21 +89,17 @@ const getDefaultImports = ({ entrypoint, srcDirectory, appDirectory, internalSrc
|
|
|
89
89
|
value: normalizeToPosixPath(entry.replace(srcDirectory, internalSrcAlias))
|
|
90
90
|
});
|
|
91
91
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
".ts",
|
|
102
|
-
".tsx"
|
|
103
|
-
].includes(path.extname(filePath))) {
|
|
104
|
-
return true;
|
|
92
|
+
if (customRuntimeConfig) {
|
|
93
|
+
imports.push({
|
|
94
|
+
specifiers: [
|
|
95
|
+
{
|
|
96
|
+
local: "runtimeConfig"
|
|
97
|
+
}
|
|
98
|
+
],
|
|
99
|
+
value: path.join(internalSrcAlias, runtimeConfigFile || "")
|
|
100
|
+
});
|
|
105
101
|
}
|
|
106
|
-
return
|
|
102
|
+
return imports;
|
|
107
103
|
};
|
|
108
104
|
const replaceWithAlias = (base, filePath, alias) => {
|
|
109
105
|
if (filePath.includes(base)) {
|
|
@@ -123,37 +119,6 @@ const parseModule = async ({ source, filename }) => {
|
|
|
123
119
|
}
|
|
124
120
|
return await parse(content);
|
|
125
121
|
};
|
|
126
|
-
const hasLoader = async (filename, source) => {
|
|
127
|
-
let content = source;
|
|
128
|
-
if (!source) {
|
|
129
|
-
content = (await fse.readFile(filename, "utf-8")).toString();
|
|
130
|
-
}
|
|
131
|
-
if (content) {
|
|
132
|
-
const [, moduleExports] = await parseModule({
|
|
133
|
-
source: content.toString(),
|
|
134
|
-
filename
|
|
135
|
-
});
|
|
136
|
-
return moduleExports.some((e) => e.n === LOADER_EXPORT_NAME);
|
|
137
|
-
}
|
|
138
|
-
return false;
|
|
139
|
-
};
|
|
140
|
-
const hasAction = async (filename, source) => {
|
|
141
|
-
let content = source;
|
|
142
|
-
if (!source) {
|
|
143
|
-
content = (await fse.readFile(filename, "utf-8")).toString();
|
|
144
|
-
}
|
|
145
|
-
if (content) {
|
|
146
|
-
const [, moduleExports] = await parseModule({
|
|
147
|
-
source: content.toString(),
|
|
148
|
-
filename
|
|
149
|
-
});
|
|
150
|
-
return moduleExports.some((e) => e.n === ACTION_EXPORT_NAME);
|
|
151
|
-
}
|
|
152
|
-
return false;
|
|
153
|
-
};
|
|
154
|
-
const getServerLoadersFile = (internalDirectory, entryName) => {
|
|
155
|
-
return path.join(internalDirectory, entryName, "route-server-loaders.js");
|
|
156
|
-
};
|
|
157
122
|
const getServerCombinedModueFile = (internalDirectory, entryName) => {
|
|
158
123
|
return path.join(internalDirectory, entryName, "server-loader-combined.js");
|
|
159
124
|
};
|
|
@@ -181,10 +146,6 @@ export {
|
|
|
181
146
|
checkIsBuildCommands,
|
|
182
147
|
getDefaultImports,
|
|
183
148
|
getServerCombinedModueFile,
|
|
184
|
-
getServerLoadersFile,
|
|
185
|
-
hasAction,
|
|
186
|
-
hasLoader,
|
|
187
|
-
isPageComponentFile,
|
|
188
149
|
isSubDirOrEqual,
|
|
189
150
|
parseModule,
|
|
190
151
|
replaceWithAlias,
|
|
@@ -1,11 +1,21 @@
|
|
|
1
|
-
import path from "node:path";
|
|
1
|
+
import path, { isAbsolute } from "node:path";
|
|
2
2
|
import { fs as fse, pkgUp, semver } from "@modern-js/utils";
|
|
3
3
|
import { readPackageJSON } from "pkg-types";
|
|
4
4
|
import { parseNodeModulePath } from "mlly";
|
|
5
|
-
import { linkPackage, writePackage, isFile, findEntryFiles, traceFiles, findPackageParents, resolveTracedPath
|
|
6
|
-
const handleDependencies = async (
|
|
5
|
+
import { linkPackage, writePackage, isFile, findEntryFiles, traceFiles, findPackageParents, resolveTracedPath } from "./utils";
|
|
6
|
+
const handleDependencies = async (appDir, serverRootDir, include, entryFilter) => {
|
|
7
7
|
const base = "/";
|
|
8
8
|
const entryFiles = await findEntryFiles(serverRootDir, entryFilter);
|
|
9
|
+
const includeEntries = include.map((item) => {
|
|
10
|
+
if (isAbsolute(item)) {
|
|
11
|
+
return item;
|
|
12
|
+
}
|
|
13
|
+
try {
|
|
14
|
+
return require.resolve(item);
|
|
15
|
+
} catch (error) {
|
|
16
|
+
}
|
|
17
|
+
return item;
|
|
18
|
+
});
|
|
9
19
|
const fileTrace = await traceFiles(entryFiles.concat(includeEntries), serverRootDir, base);
|
|
10
20
|
const currentProjectModules = path.join(appDir, "node_modules");
|
|
11
21
|
const tracedFiles = Object.fromEntries(await Promise.all([
|
|
@@ -100,17 +110,9 @@ const handleDependencies = async ({ appDir, serverRootDir, includeEntries, entry
|
|
|
100
110
|
}
|
|
101
111
|
tracedPackage.versions[pkgJSON.version] = tracedPackageVersion;
|
|
102
112
|
}
|
|
113
|
+
tracedFile.path.startsWith(tracedFile.pkgPath) && tracedPackageVersion.path === tracedFile.pkgPath && tracedPackageVersion.files.push(tracedFile.path);
|
|
103
114
|
tracedFile.pkgName = pkgName;
|
|
104
115
|
tracedFile.pkgVersion = pkgJSON.version;
|
|
105
|
-
const shouldCopyWholePackage = copyWholePackage === null || copyWholePackage === void 0 ? void 0 : copyWholePackage(pkgName);
|
|
106
|
-
if (tracedFile.path.startsWith(tracedFile.pkgPath) && tracedPackageVersion.path === tracedFile.pkgPath) {
|
|
107
|
-
if (shouldCopyWholePackage) {
|
|
108
|
-
const allFiles = await readDirRecursive(tracedFile.pkgPath);
|
|
109
|
-
tracedPackageVersion.files.push(...allFiles);
|
|
110
|
-
} else {
|
|
111
|
-
tracedPackageVersion.files.push(tracedFile.path);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
116
|
}
|
|
115
117
|
const multiVersionPkgs = {};
|
|
116
118
|
const singleVersionPackages = [];
|
|
@@ -128,11 +130,7 @@ const handleDependencies = async ({ appDir, serverRootDir, includeEntries, entry
|
|
|
128
130
|
await Promise.all(singleVersionPackages.map((pkgName) => {
|
|
129
131
|
const pkg = tracedPackages[pkgName];
|
|
130
132
|
const version = Object.keys(pkg.versions)[0];
|
|
131
|
-
return writePackage(
|
|
132
|
-
pkg,
|
|
133
|
-
version,
|
|
134
|
-
projectDir: serverRootDir
|
|
135
|
-
});
|
|
133
|
+
return writePackage(pkg, version, serverRootDir);
|
|
136
134
|
}));
|
|
137
135
|
const projectPkgJson = await readPackageJSON(serverRootDir).catch(() => ({}));
|
|
138
136
|
for (const [pkgName, pkgVersions] of Object.entries(multiVersionPkgs)) {
|
|
@@ -159,12 +157,7 @@ const handleDependencies = async ({ appDir, serverRootDir, includeEntries, entry
|
|
|
159
157
|
for (const [version, parentPkgs] of versionEntires) {
|
|
160
158
|
const pkg = tracedPackages[pkgName];
|
|
161
159
|
const pkgDestPath = `.modernjs/${pkgName}@${version}/node_modules/${pkgName}`;
|
|
162
|
-
await writePackage(
|
|
163
|
-
pkg,
|
|
164
|
-
version,
|
|
165
|
-
projectDir: serverRootDir,
|
|
166
|
-
_pkgPath: pkgDestPath
|
|
167
|
-
});
|
|
160
|
+
await writePackage(pkg, version, serverRootDir, pkgDestPath);
|
|
168
161
|
await linkPackage(pkgDestPath, `${pkgName}`, serverRootDir);
|
|
169
162
|
for (const parentPkg of parentPkgs) {
|
|
170
163
|
const parentPkgName = parentPkg.replace(/@[^@]+$/, "");
|
|
@@ -173,7 +166,7 @@ const handleDependencies = async ({ appDir, serverRootDir, includeEntries, entry
|
|
|
173
166
|
}
|
|
174
167
|
}
|
|
175
168
|
const outputPkgPath = path.join(serverRootDir, "package.json");
|
|
176
|
-
|
|
169
|
+
await fse.writeJSON(outputPkgPath, {
|
|
177
170
|
name: `${projectPkgJson.name || "modernjs-project"}-prod`,
|
|
178
171
|
version: projectPkgJson.version || "0.0.0",
|
|
179
172
|
private: true,
|
|
@@ -183,9 +176,7 @@ const handleDependencies = async ({ appDir, serverRootDir, includeEntries, entry
|
|
|
183
176
|
Object.keys(pkg.versions)[0]
|
|
184
177
|
])
|
|
185
178
|
].sort(([a], [b]) => a.localeCompare(b)))
|
|
186
|
-
};
|
|
187
|
-
const finalPkgJson = (modifyPackageJson === null || modifyPackageJson === void 0 ? void 0 : modifyPackageJson(newPkgJson)) || newPkgJson;
|
|
188
|
-
await fse.writeJSON(outputPkgPath, finalPkgJson);
|
|
179
|
+
});
|
|
189
180
|
};
|
|
190
181
|
export {
|
|
191
182
|
handleDependencies
|
|
@@ -10,8 +10,7 @@ function applyPublicCondition(pkg) {
|
|
|
10
10
|
pkg.exports = pkg === null || pkg === void 0 ? void 0 : (_pkg_publishConfig1 = pkg.publishConfig) === null || _pkg_publishConfig1 === void 0 ? void 0 : _pkg_publishConfig1.exports;
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
|
-
const writePackage = async (
|
|
14
|
-
const { pkg, version, projectDir, _pkgPath } = options;
|
|
13
|
+
const writePackage = async (pkg, version, projectDir, _pkgPath) => {
|
|
15
14
|
const pkgPath = _pkgPath || pkg.name;
|
|
16
15
|
for (const src of pkg.versions[version].files) {
|
|
17
16
|
if (src.includes("node_modules")) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
|
-
import { ROUTE_SPEC_FILE, DEFAULT_SERVER_CONFIG, fs as fse
|
|
2
|
+
import { ROUTE_SPEC_FILE, DEFAULT_SERVER_CONFIG, fs as fse } from "@modern-js/utils";
|
|
3
3
|
import { isMainEntry } from "../../../utils/routes";
|
|
4
4
|
import { genPluginImportsCode, serverAppContenxtTemplate } from "../utils";
|
|
5
5
|
import { handleDependencies } from "../dependencies";
|
|
@@ -17,8 +17,8 @@ async function cleanDistDirectory(dir) {
|
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
const createNetlifyPreset = (appContext, modernConfig, needModernServer) => {
|
|
20
|
-
const { appDirectory, distDirectory,
|
|
21
|
-
const plugins =
|
|
20
|
+
const { appDirectory, distDirectory, entrypoints, serverPlugins } = appContext;
|
|
21
|
+
const plugins = serverPlugins.map((plugin) => plugin.name);
|
|
22
22
|
const netlifyOutput = path.join(appDirectory, ".netlify");
|
|
23
23
|
const funcsDirectory = path.join(netlifyOutput, "functions");
|
|
24
24
|
const entryFilePath = path.join(funcsDirectory, "index.js");
|
|
@@ -91,13 +91,9 @@ const createNetlifyPreset = (appContext, modernConfig, needModernServer) => {
|
|
|
91
91
|
if (!needModernServer) {
|
|
92
92
|
return;
|
|
93
93
|
}
|
|
94
|
-
await handleDependencies(
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
includeEntries: [
|
|
98
|
-
require.resolve("@modern-js/prod-server")
|
|
99
|
-
]
|
|
100
|
-
});
|
|
94
|
+
await handleDependencies(appDirectory, funcsDirectory, [
|
|
95
|
+
"@modern-js/prod-server"
|
|
96
|
+
]);
|
|
101
97
|
}
|
|
102
98
|
};
|
|
103
99
|
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
|
-
import { ROUTE_SPEC_FILE, DEFAULT_SERVER_CONFIG, fs as fse,
|
|
2
|
+
import { ROUTE_SPEC_FILE, DEFAULT_SERVER_CONFIG, fs as fse, chalk } from "@modern-js/utils";
|
|
3
3
|
import { genPluginImportsCode, serverAppContenxtTemplate } from "../utils";
|
|
4
4
|
import { handleDependencies } from "../dependencies";
|
|
5
5
|
const createNodePreset = (appContext, config) => {
|
|
6
|
-
const { appDirectory, distDirectory,
|
|
7
|
-
const plugins =
|
|
6
|
+
const { appDirectory, distDirectory, serverPlugins } = appContext;
|
|
7
|
+
const plugins = serverPlugins.map((plugin) => plugin.name);
|
|
8
8
|
const outputDirectory = path.join(appDirectory, ".output");
|
|
9
9
|
const staticDirectory = path.join(outputDirectory, "static");
|
|
10
10
|
const entryFilePath = path.join(outputDirectory, "index.js");
|
|
@@ -45,17 +45,9 @@ const createNodePreset = (appContext, config) => {
|
|
|
45
45
|
const filter = (filePath) => {
|
|
46
46
|
return !filePath.startsWith(staticDirectory);
|
|
47
47
|
};
|
|
48
|
-
await handleDependencies(
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
includeEntries: [
|
|
52
|
-
require.resolve("@modern-js/prod-server")
|
|
53
|
-
],
|
|
54
|
-
entryFilter: filter,
|
|
55
|
-
copyWholePackage: (pkgName) => {
|
|
56
|
-
return pkgName === "koa";
|
|
57
|
-
}
|
|
58
|
-
});
|
|
48
|
+
await handleDependencies(appDirectory, outputDirectory, [
|
|
49
|
+
"@modern-js/prod-server"
|
|
50
|
+
], filter);
|
|
59
51
|
}
|
|
60
52
|
};
|
|
61
53
|
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
|
-
import { ROUTE_SPEC_FILE, DEFAULT_SERVER_CONFIG, fs as fse
|
|
2
|
+
import { ROUTE_SPEC_FILE, DEFAULT_SERVER_CONFIG, fs as fse } from "@modern-js/utils";
|
|
3
3
|
import { isMainEntry } from "../../../utils/routes";
|
|
4
4
|
import { genPluginImportsCode, serverAppContenxtTemplate } from "../utils";
|
|
5
5
|
import { handleDependencies } from "../dependencies";
|
|
6
6
|
const createVercelPreset = (appContext, modernConfig, needModernServer) => {
|
|
7
|
-
const { appDirectory, distDirectory,
|
|
8
|
-
const plugins =
|
|
7
|
+
const { appDirectory, distDirectory, entrypoints, serverPlugins } = appContext;
|
|
8
|
+
const plugins = serverPlugins.map((plugin) => plugin.name);
|
|
9
9
|
const vercelOutput = path.join(appDirectory, ".vercel");
|
|
10
10
|
const outputDirectory = path.join(vercelOutput, "output");
|
|
11
11
|
const funcsDirectory = path.join(outputDirectory, "functions", "index.func");
|
|
@@ -103,13 +103,9 @@ const createVercelPreset = (appContext, modernConfig, needModernServer) => {
|
|
|
103
103
|
if (!needModernServer) {
|
|
104
104
|
return;
|
|
105
105
|
}
|
|
106
|
-
await handleDependencies(
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
includeEntries: [
|
|
110
|
-
require.resolve("@modern-js/prod-server")
|
|
111
|
-
]
|
|
112
|
-
});
|
|
106
|
+
await handleDependencies(appDirectory, funcsDirectory, [
|
|
107
|
+
"@modern-js/prod-server"
|
|
108
|
+
]);
|
|
113
109
|
}
|
|
114
110
|
};
|
|
115
111
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ensureAbsolutePath, getPort, isDev, isDevCommand } from "@modern-js/utils";
|
|
2
|
-
import { checkIsLegacyConfig, createDefaultConfig, createLegacyDefaultConfig, transformNormalizedConfig } from "
|
|
2
|
+
import { checkIsLegacyConfig, createDefaultConfig, createLegacyDefaultConfig, transformNormalizedConfig } from "../../config";
|
|
3
3
|
var initialize_default = ({ bundler }) => ({
|
|
4
4
|
name: "@modern-js/plugin-initialize",
|
|
5
5
|
post: [
|
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
import path from "path";
|
|
2
2
|
import fs from "fs";
|
|
3
|
-
import { SERVER_DIR, SHARED_DIR } from "@modern-js/utils";
|
|
3
|
+
import { SERVER_DIR, SHARED_DIR, getMeta } from "@modern-js/utils";
|
|
4
4
|
import { compile } from "@modern-js/server-utils";
|
|
5
5
|
const TS_CONFIG_FILENAME = "tsconfig.json";
|
|
6
6
|
function checkHasCache(appDir) {
|
|
7
|
-
const tsFilepath = path.resolve(appDir,
|
|
8
|
-
const jsfilepath = path.resolve(appDir,
|
|
7
|
+
const tsFilepath = path.resolve(appDir, SERVER_DIR, "cache.ts");
|
|
8
|
+
const jsfilepath = path.resolve(appDir, SERVER_DIR, "cache.js");
|
|
9
|
+
return fs.existsSync(tsFilepath) || fs.existsSync(jsfilepath);
|
|
10
|
+
}
|
|
11
|
+
function checkHasConfig(appDir, metaName = "modern-js") {
|
|
12
|
+
const meta = getMeta(metaName);
|
|
13
|
+
const tsFilepath = path.resolve(appDir, SERVER_DIR, `${meta}.server.ts`);
|
|
14
|
+
const jsfilepath = path.resolve(appDir, SERVER_DIR, `${meta}.server.js`);
|
|
9
15
|
return fs.existsSync(tsFilepath) || fs.existsSync(jsfilepath);
|
|
10
16
|
}
|
|
11
17
|
var serverBuild_default = () => ({
|
|
@@ -13,8 +19,8 @@ var serverBuild_default = () => ({
|
|
|
13
19
|
setup(api) {
|
|
14
20
|
return {
|
|
15
21
|
async afterBuild() {
|
|
16
|
-
const { appDirectory, distDirectory } = api.useAppContext();
|
|
17
|
-
if (!checkHasCache(appDirectory)) {
|
|
22
|
+
const { appDirectory, distDirectory, metaName } = api.useAppContext();
|
|
23
|
+
if (!checkHasCache(appDirectory) && !checkHasConfig(appDirectory, metaName)) {
|
|
18
24
|
return;
|
|
19
25
|
}
|
|
20
26
|
const modernConfig = api.useResolvedConfigContext();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createDevServer } from "@modern-js/server";
|
|
2
|
-
import {
|
|
2
|
+
import { applyPlugins } from "@modern-js/prod-server";
|
|
3
3
|
let server = null;
|
|
4
4
|
const getServer = () => server;
|
|
5
5
|
const setServer = (newServer) => {
|
|
@@ -15,7 +15,7 @@ const createServer = async (options) => {
|
|
|
15
15
|
if (server) {
|
|
16
16
|
server.close();
|
|
17
17
|
}
|
|
18
|
-
server = await createDevServer(options,
|
|
18
|
+
server = await createDevServer(options, applyPlugins);
|
|
19
19
|
return server;
|
|
20
20
|
};
|
|
21
21
|
export {
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { loadServerPlugins as loadServerPluginInstances } from "@modern-js/prod-server";
|
|
2
|
+
async function getServerPlugins(api) {
|
|
3
|
+
const runner = api.useHookRunners();
|
|
4
|
+
const { plugins } = await runner._internalServerPlugins({
|
|
5
|
+
plugins: []
|
|
6
|
+
});
|
|
7
|
+
api.setAppContext({
|
|
8
|
+
...api.useAppContext(),
|
|
9
|
+
serverPlugins: plugins
|
|
10
|
+
});
|
|
11
|
+
return plugins;
|
|
12
|
+
}
|
|
13
|
+
async function loadServerPlugins(api, appDirectory) {
|
|
14
|
+
const plugins = await getServerPlugins(api);
|
|
15
|
+
const instances = loadServerPluginInstances(plugins, appDirectory);
|
|
16
|
+
return instances;
|
|
17
|
+
}
|
|
18
|
+
export {
|
|
19
|
+
getServerPlugins,
|
|
20
|
+
loadServerPlugins
|
|
21
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import { CopyPluginOptions,
|
|
2
|
+
import { CopyPluginOptions, RspackChain } from '@modern-js/uni-builder';
|
|
3
3
|
import type { AppNormalizedConfig, Bundler, IAppContext } from '../../types';
|
|
4
|
-
export declare function createPublicPattern(appContext: IAppContext, config: AppNormalizedConfig, chain:
|
|
4
|
+
export declare function createPublicPattern(appContext: IAppContext, config: AppNormalizedConfig, chain: RspackChain): {
|
|
5
5
|
info: (file: {
|
|
6
6
|
sourceFilename: string;
|
|
7
7
|
}) => {
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { PluginAPI } from '@modern-js/core';
|
|
2
|
+
import { Command } from '@modern-js/utils';
|
|
3
|
+
import { AppTools } from '../types';
|
|
4
|
+
export declare const devCommand: (program: Command, api: PluginAPI<AppTools<'shared'>>) => Promise<void>;
|
|
5
|
+
export declare const buildCommand: (program: Command, api: PluginAPI<AppTools<'shared'>>) => Promise<void>;
|
|
6
|
+
export declare const serverCommand: (program: Command, api: PluginAPI<AppTools<'shared'>>) => void;
|
|
7
|
+
export declare const deployCommand: (program: Command, api: PluginAPI<AppTools<'shared'>>) => void;
|
|
8
|
+
export declare const newCommand: (program: Command, locale: string) => void;
|
|
9
|
+
export declare const inspectCommand: (program: Command, api: PluginAPI<AppTools<'shared'>>) => void;
|
|
10
|
+
export declare const upgradeCommand: (program: Command) => void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { AppNormalizedConfig, IAppContext } from '../../types';
|
|
2
2
|
export declare function initHtmlConfig(config: AppNormalizedConfig<'shared'>, appContext: IAppContext): AppNormalizedConfig<'shared'>['html'];
|
|
3
3
|
export declare function initSourceConfig(config: AppNormalizedConfig<'shared'>, appContext: IAppContext, bundler: 'webpack' | 'rspack'): void;
|
|
4
|
-
export declare function createBuilderModuleScope(config: AppNormalizedConfig<'webpack'>):
|
|
4
|
+
export declare function createBuilderModuleScope(config: AppNormalizedConfig<'webpack'>): (string | RegExp)[] | undefined;
|
|
@@ -1 +1,5 @@
|
|
|
1
|
+
import { UnstableMiddleware, UnstableMiddlewareContext, UnstableNext } from '@modern-js/types';
|
|
2
|
+
export type RenderMiddleware = UnstableMiddleware;
|
|
3
|
+
export type RenderMiddlewareContext = UnstableMiddlewareContext;
|
|
4
|
+
export type RenderNext = UnstableNext;
|
|
1
5
|
export { defineServerConfig as defineConfig } from '../utils/config';
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { CliPlugin, PluginAPI } from '@modern-js/core';
|
|
1
|
+
import { CliPlugin } from '@modern-js/core';
|
|
3
2
|
import { AppTools } from './types';
|
|
3
|
+
export { dev } from './commands/dev';
|
|
4
4
|
export { mergeConfig } from '@modern-js/core';
|
|
5
|
-
export { dev } from './commands';
|
|
6
5
|
export * from './defineConfig';
|
|
7
6
|
export * from './types';
|
|
8
7
|
export type { RuntimeUserConfig } from './types/config';
|
|
9
|
-
export declare const devCommand: (program: Command, api: PluginAPI<AppTools<'shared'>>) => Promise<void>;
|
|
10
|
-
export declare const buildCommand: (program: Command, api: PluginAPI<AppTools<'shared'>>) => Promise<void>;
|
|
11
8
|
export type AppToolsOptions = {
|
|
12
9
|
/**
|
|
13
10
|
* Specify which bundler to use for the build.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const INDEX_FILE_NAME = "index";
|
|
2
|
+
export declare const FILE_SYSTEM_ROUTES_FILE_NAME = "routes.js";
|
|
3
|
+
export declare const ENTRY_POINT_FILE_NAME = "index.jsx";
|
|
4
|
+
export declare const ENTRY_BOOTSTRAP_FILE_NAME = "bootstrap.jsx";
|
|
5
|
+
export declare const HTML_PARTIALS_FOLDER = "html";
|
|
6
|
+
export declare const HTML_PARTIALS_EXTENSIONS: string[];
|
|
7
|
+
export declare const APP_CONFIG_NAME = "config";
|
|
8
|
+
export declare const APP_INIT_EXPORTED = "init";
|
|
9
|
+
export declare const APP_INIT_IMPORTED = "appInit";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { IAppContext, PluginAPI } from '@modern-js/core';
|
|
2
2
|
import type { Entrypoint } from '@modern-js/types';
|
|
3
3
|
import { RspackConfig, WebpackConfig } from '@rsbuild/shared';
|
|
4
|
-
import { AppNormalizedConfig, AppTools, ImportStatement } from '
|
|
4
|
+
import { AppNormalizedConfig, AppTools, ImportStatement } from '../../types';
|
|
5
5
|
export declare const createImportStatements: (statements: ImportStatement[]) => string;
|
|
6
6
|
export declare const generateCode: (appContext: IAppContext, config: AppNormalizedConfig<'shared'>, entrypoints: Entrypoint[], api: PluginAPI<AppTools<'shared'>>) => Promise<{
|
|
7
7
|
importsStatemets: Map<string, ImportStatement[]>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Entrypoint } from '@modern-js/types';
|
|
2
|
+
import { CliHooksRunner } from '@modern-js/core';
|
|
3
|
+
import type { AppNormalizedConfig, AppTools, IAppContext } from '../../types';
|
|
4
|
+
export declare const getBundleEntry: (hookRunners: CliHooksRunner<AppTools<'shared'>>, appContext: IAppContext, config: AppNormalizedConfig<'shared'>) => Promise<Entrypoint[]>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Entrypoint } from '@modern-js/types';
|
|
2
|
+
import { CliHooksRunner } from '@modern-js/core';
|
|
3
|
+
import type { AppNormalizedConfig, AppTools, IAppContext } from '../../types';
|
|
4
|
+
export type { Entrypoint };
|
|
5
|
+
export declare const getFileSystemEntry: (hookRunners: CliHooksRunner<AppTools<'shared'>>, appContext: IAppContext, config: AppNormalizedConfig<'shared'>) => Promise<Entrypoint[]>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Entrypoint, HtmlTemplates } from '@modern-js/types';
|
|
2
|
-
import type { AppNormalizedConfig, AppTools, IAppContext, PluginAPI } from '
|
|
2
|
+
import type { AppNormalizedConfig, AppTools, IAppContext, PluginAPI } from '../../types';
|
|
3
3
|
export declare const getHtmlTemplate: (entrypoints: Entrypoint[], api: PluginAPI<AppTools<'shared'>>, { appContext, config, }: {
|
|
4
4
|
appContext: IAppContext;
|
|
5
5
|
config: AppNormalizedConfig<'shared'>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { IAppContext } from '@modern-js/core';
|
|
2
2
|
import type { Entrypoint, ServerRoute } from '@modern-js/types';
|
|
3
|
-
import type { AppNormalizedConfig } from '
|
|
3
|
+
import type { AppNormalizedConfig } from '../../types';
|
|
4
4
|
export declare const getServerRoutes: (entrypoints: Entrypoint[], { appContext, config, }: {
|
|
5
5
|
appContext: IAppContext;
|
|
6
6
|
config: AppNormalizedConfig<'shared'>;
|