@modern-js/app-tools 2.58.1-alpha.6 → 2.58.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/builder/builder-webpack/createCopyPattern.js +0 -1
- package/dist/cjs/builder/builder-webpack/index.js +1 -1
- package/dist/cjs/builder/generator/index.js +2 -2
- package/dist/cjs/builder/index.js +2 -2
- package/dist/cjs/builder/shared/bundlerPlugins/RouterPlugin.js +13 -4
- package/dist/cjs/commands/build.js +19 -0
- package/dist/cjs/commands/dev.js +9 -0
- package/dist/cjs/commands/index.js +8 -8
- package/dist/cjs/commands/inspect.js +1 -1
- package/dist/cjs/config/initialize/inits.js +4 -4
- package/dist/cjs/esm/esbuild-loader.mjs +20 -0
- package/dist/cjs/esm/register-esm.mjs +67 -0
- package/dist/cjs/esm/ts-node-loader.mjs +21 -0
- package/dist/cjs/esm/utils.mjs +43 -0
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/plugins/analyze/index.js +3 -3
- package/dist/cjs/plugins/deploy/dependencies/index.js +2 -15
- package/dist/cjs/plugins/deploy/dependencies/utils.js +13 -78
- package/dist/cjs/plugins/deploy/platforms/netlify-entry.js +3 -0
- package/dist/cjs/plugins/deploy/platforms/netlify-entry.mjs +1 -0
- package/dist/cjs/plugins/deploy/platforms/{netlifyEntry.js → netlify-handler.js} +6 -4
- package/dist/cjs/plugins/deploy/platforms/netlify.js +14 -5
- package/dist/cjs/plugins/deploy/platforms/node.js +13 -4
- package/dist/cjs/plugins/deploy/platforms/vercel-entry.js +3 -0
- package/dist/cjs/plugins/deploy/platforms/vercel-entry.mjs +3 -0
- package/dist/cjs/plugins/deploy/platforms/{vercelEntry.js → vercel-handler.js} +4 -1
- package/dist/cjs/plugins/deploy/platforms/vercel.js +14 -5
- package/dist/cjs/utils/config.js +1 -1
- package/dist/cjs/utils/loadPlugins.js +1 -1
- package/dist/cjs/utils/register.js +50 -23
- package/dist/types/builder/builder-rspack/adapterCopy.d.ts +2 -2
- package/dist/types/builder/builder-rspack/index.d.ts +1 -1
- package/dist/types/builder/builder-webpack/adapterModern.d.ts +2 -2
- package/dist/types/builder/builder-webpack/index.d.ts +1 -1
- package/dist/types/builder/generator/index.d.ts +2 -2
- package/dist/types/builder/index.d.ts +1 -1
- package/dist/types/builder/shared/builderPlugins/adapterHtml.d.ts +1 -1
- package/dist/types/builder/shared/builderPlugins/adapterSSR.d.ts +1 -1
- package/dist/types/builder/shared/createCopyInfo.d.ts +1 -1
- package/dist/types/commands/build.d.ts +1 -1
- package/dist/types/commands/dev.d.ts +3 -3
- package/dist/types/commands/index.d.ts +3 -3
- package/dist/types/config/default.d.ts +1 -1
- package/dist/types/config/initialize/inits.d.ts +1 -1
- package/dist/types/config/legacy/createHtmlConfig.d.ts +1 -1
- package/dist/types/config/legacy/createOutputConfig.d.ts +1 -1
- package/dist/types/config/legacy/createSourceConfig.d.ts +1 -1
- package/dist/types/config/legacy/createToolsConfig.d.ts +1 -1
- package/dist/types/esm/esbuild-loader.d.mts +6 -0
- package/dist/types/esm/register-esm.d.mts +5 -0
- package/dist/types/esm/ts-node-loader.d.mts +6 -0
- package/dist/types/esm/utils.d.mts +6 -0
- package/dist/types/exports/server.d.ts +1 -1
- package/dist/types/hooks.d.ts +1 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/types/plugins/analyze/getBundleEntry.d.ts +1 -1
- package/dist/types/plugins/analyze/getFileSystemEntry.d.ts +1 -1
- package/dist/types/plugins/analyze/index.d.ts +1 -1
- package/dist/types/plugins/deploy/dependencies/index.d.ts +3 -5
- package/dist/types/plugins/deploy/dependencies/utils.d.ts +2 -9
- package/dist/types/plugins/deploy/index.d.ts +2 -2
- package/dist/types/plugins/deploy/platforms/netlify-entry.d.cts +1 -0
- package/dist/types/plugins/deploy/platforms/netlify-entry.d.mts +1 -0
- package/dist/types/plugins/deploy/platforms/netlify-handler.d.cts +1 -0
- package/dist/types/plugins/deploy/platforms/netlify.d.ts +1 -1
- package/dist/types/plugins/deploy/platforms/node.d.ts +1 -1
- package/dist/types/plugins/deploy/platforms/platform.d.ts +2 -2
- package/dist/types/plugins/deploy/platforms/vercel-entry.d.mts +2 -0
- package/dist/types/plugins/deploy/platforms/vercel-entry.d.ts +2 -0
- package/dist/types/plugins/deploy/platforms/vercel-handler.d.cts +1 -0
- package/dist/types/plugins/deploy/platforms/vercel.d.ts +1 -1
- package/dist/types/plugins/deploy/utils.d.ts +1 -1
- package/dist/types/plugins/serverBuild.d.ts +1 -1
- package/dist/types/types/hooks.d.ts +1 -1
- package/dist/types/types/index.d.ts +1 -1
- package/dist/types/utils/createServer.d.ts +1 -1
- package/dist/types/utils/generateWatchFiles.d.ts +1 -1
- package/dist/types/utils/getSelectedEntries.d.ts +1 -1
- package/dist/types/utils/loadPlugins.d.ts +3 -3
- package/dist/types/utils/register.d.ts +2 -2
- package/dist/types/utils/restart.d.ts +2 -2
- package/lib/types.d.ts +15 -0
- package/package.json +20 -21
- package/dist/esm/builder/builder-rspack/adapterCopy.js +0 -166
- package/dist/esm/builder/builder-rspack/index.js +0 -34
- package/dist/esm/builder/builder-webpack/adapterModern.js +0 -29
- package/dist/esm/builder/builder-webpack/createCopyPattern.js +0 -44
- package/dist/esm/builder/builder-webpack/index.js +0 -52
- package/dist/esm/builder/generator/createBuilderProviderConfig.js +0 -37
- package/dist/esm/builder/generator/getBuilderEnvironments.js +0 -81
- package/dist/esm/builder/generator/index.js +0 -94
- package/dist/esm/builder/index.js +0 -45
- package/dist/esm/builder/shared/builderPlugins/adapterBasic.js +0 -85
- package/dist/esm/builder/shared/builderPlugins/adapterHtml.js +0 -126
- package/dist/esm/builder/shared/builderPlugins/adapterSSR.js +0 -270
- package/dist/esm/builder/shared/builderPlugins/adapterWorker.js +0 -43
- package/dist/esm/builder/shared/builderPlugins/index.js +0 -4
- package/dist/esm/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +0 -51
- package/dist/esm/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +0 -37
- package/dist/esm/builder/shared/bundlerPlugins/RouterPlugin.js +0 -288
- package/dist/esm/builder/shared/bundlerPlugins/index.js +0 -3
- package/dist/esm/builder/shared/createCopyInfo.js +0 -14
- package/dist/esm/builder/shared/index.js +0 -3
- package/dist/esm/builder/shared/loaders/serverModuleLoader.js +0 -7
- package/dist/esm/builder/shared/types.js +0 -0
- package/dist/esm/commands/build.js +0 -117
- package/dist/esm/commands/deploy.js +0 -48
- package/dist/esm/commands/dev.js +0 -169
- package/dist/esm/commands/index.js +0 -411
- package/dist/esm/commands/inspect.js +0 -28
- package/dist/esm/commands/serve.js +0 -93
- package/dist/esm/config/default.js +0 -190
- package/dist/esm/config/index.js +0 -3
- package/dist/esm/config/initialize/index.js +0 -9
- package/dist/esm/config/initialize/inits.js +0 -85
- package/dist/esm/config/legacy/createHtmlConfig.js +0 -21
- package/dist/esm/config/legacy/createOutputConfig.js +0 -45
- package/dist/esm/config/legacy/createSourceConfig.js +0 -46
- package/dist/esm/config/legacy/createToolsConfig.js +0 -28
- package/dist/esm/config/legacy/index.js +0 -43
- package/dist/esm/defineConfig.js +0 -16
- package/dist/esm/exports/server.js +0 -4
- package/dist/esm/hooks.js +0 -34
- package/dist/esm/index.js +0 -239
- package/dist/esm/locale/en.js +0 -43
- package/dist/esm/locale/index.js +0 -12
- package/dist/esm/locale/zh.js +0 -43
- package/dist/esm/plugins/analyze/constants.js +0 -14
- package/dist/esm/plugins/analyze/getBundleEntry.js +0 -102
- package/dist/esm/plugins/analyze/getFileSystemEntry.js +0 -238
- package/dist/esm/plugins/analyze/getHtmlTemplate.js +0 -178
- package/dist/esm/plugins/analyze/getServerRoutes.js +0 -132
- package/dist/esm/plugins/analyze/index.js +0 -380
- package/dist/esm/plugins/analyze/isDefaultExportFunction.js +0 -49
- package/dist/esm/plugins/analyze/templates.js +0 -6
- package/dist/esm/plugins/analyze/utils.js +0 -101
- package/dist/esm/plugins/deploy/dependencies/index.js +0 -629
- package/dist/esm/plugins/deploy/dependencies/utils.js +0 -643
- package/dist/esm/plugins/deploy/exports.js +0 -4
- package/dist/esm/plugins/deploy/index.js +0 -135
- package/dist/esm/plugins/deploy/platforms/netlify.js +0 -299
- package/dist/esm/plugins/deploy/platforms/netlifyEntry.js +0 -203
- package/dist/esm/plugins/deploy/platforms/node.js +0 -133
- package/dist/esm/plugins/deploy/platforms/nodeEntry.js +0 -108
- package/dist/esm/plugins/deploy/platforms/platform.js +0 -0
- package/dist/esm/plugins/deploy/platforms/vercel.js +0 -233
- package/dist/esm/plugins/deploy/platforms/vercelEntry.js +0 -203
- package/dist/esm/plugins/deploy/utils.js +0 -47
- package/dist/esm/plugins/initialize/index.js +0 -119
- package/dist/esm/plugins/serverBuild.js +0 -87
- package/dist/esm/types/config/deploy.js +0 -0
- package/dist/esm/types/config/dev.js +0 -0
- package/dist/esm/types/config/experiments.js +0 -0
- package/dist/esm/types/config/html.js +0 -0
- package/dist/esm/types/config/index.js +0 -1
- package/dist/esm/types/config/output.js +0 -0
- package/dist/esm/types/config/performance.js +0 -0
- package/dist/esm/types/config/security.js +0 -0
- package/dist/esm/types/config/source.js +0 -0
- package/dist/esm/types/config/testing.js +0 -0
- package/dist/esm/types/config/tools.js +0 -0
- package/dist/esm/types/hooks.js +0 -0
- package/dist/esm/types/index.js +0 -3
- package/dist/esm/types/legacyConfig/deploy.js +0 -0
- package/dist/esm/types/legacyConfig/dev.js +0 -0
- package/dist/esm/types/legacyConfig/index.js +0 -0
- package/dist/esm/types/legacyConfig/output.js +0 -0
- package/dist/esm/types/legacyConfig/source.js +0 -0
- package/dist/esm/types/legacyConfig/testing.js +0 -0
- package/dist/esm/types/legacyConfig/tools.js +0 -0
- package/dist/esm/types/utils.js +0 -0
- package/dist/esm/utils/config.js +0 -122
- package/dist/esm/utils/createServer.js +0 -58
- package/dist/esm/utils/env.js +0 -16
- package/dist/esm/utils/generateWatchFiles.js +0 -71
- package/dist/esm/utils/getSelectedEntries.js +0 -67
- package/dist/esm/utils/loadPlugins.js +0 -69
- package/dist/esm/utils/printInstructions.js +0 -32
- package/dist/esm/utils/register.js +0 -129
- package/dist/esm/utils/restart.js +0 -67
- package/dist/esm/utils/routes.js +0 -42
- package/dist/esm/utils/types.js +0 -0
- package/dist/esm-node/builder/builder-rspack/adapterCopy.js +0 -67
- package/dist/esm-node/builder/builder-rspack/index.js +0 -12
- package/dist/esm-node/builder/builder-webpack/adapterModern.js +0 -26
- package/dist/esm-node/builder/builder-webpack/createCopyPattern.js +0 -42
- package/dist/esm-node/builder/builder-webpack/index.js +0 -20
- package/dist/esm-node/builder/generator/createBuilderProviderConfig.js +0 -44
- package/dist/esm-node/builder/generator/getBuilderEnvironments.js +0 -60
- package/dist/esm-node/builder/generator/index.js +0 -37
- package/dist/esm-node/builder/index.js +0 -11
- package/dist/esm-node/builder/shared/builderPlugins/adapterBasic.js +0 -48
- package/dist/esm-node/builder/shared/builderPlugins/adapterHtml.js +0 -60
- package/dist/esm-node/builder/shared/builderPlugins/adapterSSR.js +0 -156
- package/dist/esm-node/builder/shared/builderPlugins/adapterWorker.js +0 -27
- package/dist/esm-node/builder/shared/builderPlugins/index.js +0 -4
- package/dist/esm-node/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +0 -30
- package/dist/esm-node/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +0 -31
- package/dist/esm-node/builder/shared/bundlerPlugins/RouterPlugin.js +0 -219
- package/dist/esm-node/builder/shared/bundlerPlugins/index.js +0 -3
- package/dist/esm-node/builder/shared/createCopyInfo.js +0 -14
- package/dist/esm-node/builder/shared/index.js +0 -3
- package/dist/esm-node/builder/shared/loaders/serverModuleLoader.js +0 -7
- package/dist/esm-node/builder/shared/types.js +0 -0
- package/dist/esm-node/commands/build.js +0 -55
- package/dist/esm-node/commands/deploy.js +0 -12
- package/dist/esm-node/commands/dev.js +0 -95
- package/dist/esm-node/commands/index.js +0 -92
- package/dist/esm-node/commands/inspect.js +0 -15
- package/dist/esm-node/commands/serve.js +0 -51
- package/dist/esm-node/config/default.js +0 -197
- package/dist/esm-node/config/index.js +0 -3
- package/dist/esm-node/config/initialize/index.js +0 -9
- package/dist/esm-node/config/initialize/inits.js +0 -79
- package/dist/esm-node/config/legacy/createHtmlConfig.js +0 -21
- package/dist/esm-node/config/legacy/createOutputConfig.js +0 -45
- package/dist/esm-node/config/legacy/createSourceConfig.js +0 -29
- package/dist/esm-node/config/legacy/createToolsConfig.js +0 -28
- package/dist/esm-node/config/legacy/index.js +0 -43
- package/dist/esm-node/defineConfig.js +0 -13
- package/dist/esm-node/exports/server.js +0 -4
- package/dist/esm-node/hooks.js +0 -34
- package/dist/esm-node/index.js +0 -124
- package/dist/esm-node/locale/en.js +0 -43
- package/dist/esm-node/locale/index.js +0 -12
- package/dist/esm-node/locale/zh.js +0 -43
- package/dist/esm-node/plugins/analyze/constants.js +0 -14
- package/dist/esm-node/plugins/analyze/getBundleEntry.js +0 -61
- package/dist/esm-node/plugins/analyze/getFileSystemEntry.js +0 -100
- package/dist/esm-node/plugins/analyze/getHtmlTemplate.js +0 -74
- package/dist/esm-node/plugins/analyze/getServerRoutes.js +0 -132
- package/dist/esm-node/plugins/analyze/index.js +0 -166
- package/dist/esm-node/plugins/analyze/isDefaultExportFunction.js +0 -47
- package/dist/esm-node/plugins/analyze/templates.js +0 -24
- package/dist/esm-node/plugins/analyze/utils.js +0 -68
- package/dist/esm-node/plugins/deploy/dependencies/index.js +0 -215
- package/dist/esm-node/plugins/deploy/dependencies/utils.js +0 -202
- package/dist/esm-node/plugins/deploy/exports.js +0 -4
- package/dist/esm-node/plugins/deploy/index.js +0 -44
- package/dist/esm-node/plugins/deploy/platforms/netlify.js +0 -108
- package/dist/esm-node/plugins/deploy/platforms/netlifyEntry.js +0 -69
- package/dist/esm-node/plugins/deploy/platforms/node.js +0 -63
- package/dist/esm-node/plugins/deploy/platforms/nodeEntry.js +0 -44
- package/dist/esm-node/plugins/deploy/platforms/platform.js +0 -0
- package/dist/esm-node/plugins/deploy/platforms/vercel.js +0 -120
- package/dist/esm-node/plugins/deploy/platforms/vercelEntry.js +0 -69
- package/dist/esm-node/plugins/deploy/utils.js +0 -44
- package/dist/esm-node/plugins/initialize/index.js +0 -84
- package/dist/esm-node/plugins/serverBuild.js +0 -58
- package/dist/esm-node/types/config/deploy.js +0 -0
- package/dist/esm-node/types/config/dev.js +0 -0
- package/dist/esm-node/types/config/experiments.js +0 -0
- package/dist/esm-node/types/config/html.js +0 -0
- package/dist/esm-node/types/config/index.js +0 -1
- package/dist/esm-node/types/config/output.js +0 -0
- package/dist/esm-node/types/config/performance.js +0 -0
- package/dist/esm-node/types/config/security.js +0 -0
- package/dist/esm-node/types/config/source.js +0 -0
- package/dist/esm-node/types/config/testing.js +0 -0
- package/dist/esm-node/types/config/tools.js +0 -0
- package/dist/esm-node/types/hooks.js +0 -0
- package/dist/esm-node/types/index.js +0 -3
- package/dist/esm-node/types/legacyConfig/deploy.js +0 -0
- package/dist/esm-node/types/legacyConfig/dev.js +0 -0
- package/dist/esm-node/types/legacyConfig/index.js +0 -0
- package/dist/esm-node/types/legacyConfig/output.js +0 -0
- package/dist/esm-node/types/legacyConfig/source.js +0 -0
- package/dist/esm-node/types/legacyConfig/testing.js +0 -0
- package/dist/esm-node/types/legacyConfig/tools.js +0 -0
- package/dist/esm-node/types/utils.js +0 -0
- package/dist/esm-node/utils/config.js +0 -49
- package/dist/esm-node/utils/createServer.js +0 -26
- package/dist/esm-node/utils/env.js +0 -16
- package/dist/esm-node/utils/generateWatchFiles.js +0 -30
- package/dist/esm-node/utils/getSelectedEntries.js +0 -34
- package/dist/esm-node/utils/loadPlugins.js +0 -22
- package/dist/esm-node/utils/printInstructions.js +0 -11
- package/dist/esm-node/utils/register.js +0 -69
- package/dist/esm-node/utils/restart.js +0 -22
- package/dist/esm-node/utils/routes.js +0 -21
- package/dist/esm-node/utils/types.js +0 -0
- package/dist/types/plugins/deploy/platforms/netlifyEntry.d.ts +0 -2
- package/dist/types/plugins/deploy/platforms/vercelEntry.d.ts +0 -2
- /package/dist/cjs/plugins/deploy/platforms/{nodeEntry.js → node-entry.js} +0 -0
- /package/dist/types/plugins/deploy/platforms/{nodeEntry.d.ts → node-entry.d.ts} +0 -0
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
2
|
-
var __commonJS = (cb, mod) => function __require() {
|
|
3
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
4
|
-
};
|
|
5
|
-
var require_vercelEntry = __commonJS({
|
|
6
|
-
"src/plugins/deploy/platforms/vercelEntry.js"(exports, module) {
|
|
7
|
-
const fs = require("node:fs/promises");
|
|
8
|
-
const path = require("node:path");
|
|
9
|
-
const { createProdServer } = require("@modern-js/prod-server");
|
|
10
|
-
p_genPluginImportsCode;
|
|
11
|
-
if (!process.env.NODE_ENV) {
|
|
12
|
-
process.env.NODE_ENV = "production";
|
|
13
|
-
}
|
|
14
|
-
let requestHandler = null;
|
|
15
|
-
let handlerCreationPromise = null;
|
|
16
|
-
async function loadRoutes(routeFilepath) {
|
|
17
|
-
try {
|
|
18
|
-
await fs.access(routeFilepath);
|
|
19
|
-
const content = await fs.readFile(routeFilepath, "utf-8");
|
|
20
|
-
const routeSpec = JSON.parse(content);
|
|
21
|
-
return routeSpec.routes || [];
|
|
22
|
-
} catch (error) {
|
|
23
|
-
console.warn("route.json not found or invalid, continuing with empty routes.");
|
|
24
|
-
return [];
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
async function initServer() {
|
|
28
|
-
const routeFilepath = path.join(__dirname, p_ROUTE_SPEC_FILE);
|
|
29
|
-
const routes = await loadRoutes(routeFilepath);
|
|
30
|
-
const dynamicProdOptions = p_dynamicProdOptions;
|
|
31
|
-
const prodServerOptions = {
|
|
32
|
-
pwd: __dirname,
|
|
33
|
-
routes,
|
|
34
|
-
disableCustomHook: true,
|
|
35
|
-
appContext: {
|
|
36
|
-
sharedDirectory: p_sharedDirectory,
|
|
37
|
-
apiDirectory: p_apiDirectory,
|
|
38
|
-
lambdaDirectory: p_lambdaDirectory
|
|
39
|
-
},
|
|
40
|
-
plugins: p_plugins,
|
|
41
|
-
...dynamicProdOptions
|
|
42
|
-
};
|
|
43
|
-
const app = await createProdServer(prodServerOptions);
|
|
44
|
-
return app.getRequestListener();
|
|
45
|
-
}
|
|
46
|
-
async function createHandler() {
|
|
47
|
-
if (!handlerCreationPromise) {
|
|
48
|
-
handlerCreationPromise = (async () => {
|
|
49
|
-
try {
|
|
50
|
-
requestHandler = await initServer();
|
|
51
|
-
} catch (error) {
|
|
52
|
-
console.error("Error creating server:", error);
|
|
53
|
-
process.exit(1);
|
|
54
|
-
}
|
|
55
|
-
})();
|
|
56
|
-
}
|
|
57
|
-
await handlerCreationPromise;
|
|
58
|
-
return requestHandler;
|
|
59
|
-
}
|
|
60
|
-
createHandler();
|
|
61
|
-
module.exports = async (req, res) => {
|
|
62
|
-
if (!requestHandler) {
|
|
63
|
-
await createHandler();
|
|
64
|
-
}
|
|
65
|
-
return requestHandler(req, res);
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
export default require_vercelEntry();
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import path from "path";
|
|
2
|
-
import { ROUTE_SPEC_FILE, fs as fse, isDepExists } from "@modern-js/utils";
|
|
3
|
-
const serverAppContenxtTemplate = (appContext) => {
|
|
4
|
-
const { appDirectory, sharedDirectory, apiDirectory, lambdaDirectory, metaName } = appContext;
|
|
5
|
-
return {
|
|
6
|
-
sharedDirectory: `path.join(__dirname, "${path.relative(appDirectory, sharedDirectory)}")`,
|
|
7
|
-
apiDirectory: `path.join(__dirname, "${path.relative(appDirectory, apiDirectory)}")`,
|
|
8
|
-
lambdaDirectory: `path.join(__dirname, "${path.relative(appDirectory, lambdaDirectory)}")`,
|
|
9
|
-
metaName
|
|
10
|
-
};
|
|
11
|
-
};
|
|
12
|
-
const getPluginsCode = (plugins) => `[${plugins.map((_, index) => `plugin_${index}()`).join(",")}]`;
|
|
13
|
-
const genPluginImportsCode = (plugins) => {
|
|
14
|
-
return plugins.map((plugin, index) => `
|
|
15
|
-
let plugin_${index} = require('${plugin}')
|
|
16
|
-
plugin_${index} = plugin_${index}.default || plugin_${index}
|
|
17
|
-
`).join(";\n");
|
|
18
|
-
};
|
|
19
|
-
const getProjectUsage = (appDirectory, distDirectory) => {
|
|
20
|
-
const routeJSON = path.join(distDirectory, ROUTE_SPEC_FILE);
|
|
21
|
-
const { routes } = fse.readJSONSync(routeJSON);
|
|
22
|
-
let useSSR = false;
|
|
23
|
-
let useAPI = false;
|
|
24
|
-
routes.forEach((route) => {
|
|
25
|
-
if (route.isSSR) {
|
|
26
|
-
useSSR = true;
|
|
27
|
-
}
|
|
28
|
-
if (route.isApi) {
|
|
29
|
-
useAPI = true;
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
const useWebServer = isDepExists(appDirectory, "@modern-js/plugin-server");
|
|
33
|
-
return {
|
|
34
|
-
useSSR,
|
|
35
|
-
useAPI,
|
|
36
|
-
useWebServer
|
|
37
|
-
};
|
|
38
|
-
};
|
|
39
|
-
export {
|
|
40
|
-
genPluginImportsCode,
|
|
41
|
-
getPluginsCode,
|
|
42
|
-
getProjectUsage,
|
|
43
|
-
serverAppContenxtTemplate
|
|
44
|
-
};
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import { ensureAbsolutePath, getPort, isDev, isDevCommand } from "@modern-js/utils";
|
|
2
|
-
import { checkIsLegacyConfig, createDefaultConfig, createLegacyDefaultConfig, transformNormalizedConfig } from "../../config";
|
|
3
|
-
var initialize_default = ({ bundler }) => ({
|
|
4
|
-
name: "@modern-js/plugin-initialize",
|
|
5
|
-
post: [
|
|
6
|
-
"@modern-js/plugin-ssr",
|
|
7
|
-
"@modern-js/plugin-document",
|
|
8
|
-
"@modern-js/plugin-state",
|
|
9
|
-
"@modern-js/plugin-router",
|
|
10
|
-
"@modern-js/plugin-router-v5",
|
|
11
|
-
"@modern-js/plugin-polyfill"
|
|
12
|
-
],
|
|
13
|
-
setup(api) {
|
|
14
|
-
const config = () => {
|
|
15
|
-
const appContext = api.useAppContext();
|
|
16
|
-
const userConfig = api.useConfigContext();
|
|
17
|
-
api.setAppContext({
|
|
18
|
-
...appContext,
|
|
19
|
-
bundlerType: bundler
|
|
20
|
-
});
|
|
21
|
-
return checkIsLegacyConfig(userConfig) ? createLegacyDefaultConfig(appContext) : createDefaultConfig(appContext);
|
|
22
|
-
};
|
|
23
|
-
return {
|
|
24
|
-
config,
|
|
25
|
-
async resolvedConfig({ resolved }) {
|
|
26
|
-
var _resolved_output_distPath;
|
|
27
|
-
let appContext = api.useAppContext();
|
|
28
|
-
const userConfig = api.useConfigContext();
|
|
29
|
-
const port = await getServerPort(resolved);
|
|
30
|
-
appContext = {
|
|
31
|
-
...appContext,
|
|
32
|
-
port,
|
|
33
|
-
distDirectory: ensureAbsolutePath(appContext.distDirectory, ((_resolved_output_distPath = resolved.output.distPath) === null || _resolved_output_distPath === void 0 ? void 0 : _resolved_output_distPath.root) || "dist")
|
|
34
|
-
};
|
|
35
|
-
api.setAppContext(appContext);
|
|
36
|
-
const normalizedConfig = checkIsLegacyConfig(resolved) ? transformNormalizedConfig(resolved) : resolved;
|
|
37
|
-
resolved._raw = userConfig;
|
|
38
|
-
resolved.server = {
|
|
39
|
-
...normalizedConfig.server || {},
|
|
40
|
-
port
|
|
41
|
-
};
|
|
42
|
-
var _normalizedConfig_autoLoadPlugins;
|
|
43
|
-
resolved.autoLoadPlugins = (_normalizedConfig_autoLoadPlugins = normalizedConfig.autoLoadPlugins) !== null && _normalizedConfig_autoLoadPlugins !== void 0 ? _normalizedConfig_autoLoadPlugins : false;
|
|
44
|
-
stabilizeConfig(resolved, normalizedConfig, [
|
|
45
|
-
"source",
|
|
46
|
-
"bff",
|
|
47
|
-
"dev",
|
|
48
|
-
"html",
|
|
49
|
-
"output",
|
|
50
|
-
"tools",
|
|
51
|
-
"testing",
|
|
52
|
-
"plugins",
|
|
53
|
-
"builderPlugins",
|
|
54
|
-
"runtime",
|
|
55
|
-
"runtimeByEntries",
|
|
56
|
-
"deploy",
|
|
57
|
-
"performance"
|
|
58
|
-
]);
|
|
59
|
-
if (bundler === "webpack") {
|
|
60
|
-
resolved.security = normalizedConfig.security || {};
|
|
61
|
-
resolved.experiments = normalizedConfig.experiments;
|
|
62
|
-
}
|
|
63
|
-
return {
|
|
64
|
-
resolved
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
function stabilizeConfig(resolve, config, keys) {
|
|
71
|
-
keys.forEach((key) => {
|
|
72
|
-
resolve[key] = config[key] || {};
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
async function getServerPort(config) {
|
|
76
|
-
const prodPort = Number(process.env.PORT) || config.server.port || 8080;
|
|
77
|
-
if (isDev() && isDevCommand()) {
|
|
78
|
-
return getPort(Number(process.env.PORT) || config.dev.port || prodPort);
|
|
79
|
-
}
|
|
80
|
-
return prodPort;
|
|
81
|
-
}
|
|
82
|
-
export {
|
|
83
|
-
initialize_default as default
|
|
84
|
-
};
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import path from "path";
|
|
2
|
-
import fs from "fs";
|
|
3
|
-
import { SERVER_DIR, SHARED_DIR, getMeta } from "@modern-js/utils";
|
|
4
|
-
import { compile } from "@modern-js/server-utils";
|
|
5
|
-
const TS_CONFIG_FILENAME = "tsconfig.json";
|
|
6
|
-
function checkHasCache(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`);
|
|
15
|
-
return fs.existsSync(tsFilepath) || fs.existsSync(jsfilepath);
|
|
16
|
-
}
|
|
17
|
-
var serverBuild_default = () => ({
|
|
18
|
-
name: "@modern-js/server-build",
|
|
19
|
-
setup(api) {
|
|
20
|
-
return {
|
|
21
|
-
async afterBuild() {
|
|
22
|
-
const { appDirectory, distDirectory, metaName } = api.useAppContext();
|
|
23
|
-
if (!checkHasCache(appDirectory) && !checkHasConfig(appDirectory, metaName)) {
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
const modernConfig = api.useResolvedConfigContext();
|
|
27
|
-
const distDir = path.resolve(distDirectory);
|
|
28
|
-
const serverDir = path.resolve(appDirectory, SERVER_DIR);
|
|
29
|
-
const sharedDir = path.resolve(appDirectory, SHARED_DIR);
|
|
30
|
-
const tsconfigPath = path.resolve(appDirectory, TS_CONFIG_FILENAME);
|
|
31
|
-
const sourceDirs = [];
|
|
32
|
-
if (fs.existsSync(serverDir)) {
|
|
33
|
-
sourceDirs.push(serverDir);
|
|
34
|
-
if (fs.existsSync(sharedDir)) {
|
|
35
|
-
sourceDirs.push(sharedDir);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
const { server } = modernConfig;
|
|
39
|
-
const { alias } = modernConfig.source;
|
|
40
|
-
const { babel } = modernConfig.tools;
|
|
41
|
-
if (sourceDirs.length > 0) {
|
|
42
|
-
await compile(appDirectory, {
|
|
43
|
-
server,
|
|
44
|
-
alias,
|
|
45
|
-
babelConfig: babel
|
|
46
|
-
}, {
|
|
47
|
-
sourceDirs,
|
|
48
|
-
distDir,
|
|
49
|
-
tsconfigPath
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
export {
|
|
57
|
-
serverBuild_default as default
|
|
58
|
-
};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./output";
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import * as path from "path";
|
|
2
|
-
import { bundle } from "@modern-js/node-bundle-require";
|
|
3
|
-
import { fs, getServerConfig, ensureAbsolutePath, OUTPUT_CONFIG_FILE, CONFIG_FILE_EXTENSIONS } from "@modern-js/utils";
|
|
4
|
-
import { stringify } from "flatted";
|
|
5
|
-
const defineServerConfig = (config) => config;
|
|
6
|
-
const buildServerConfig = async ({ appDirectory, distDirectory, configFile, options, watch }) => {
|
|
7
|
-
const configFilePath = await getServerConfig(appDirectory, configFile);
|
|
8
|
-
const getOutputFile = async (filepath) => path.resolve(distDirectory, `${filepath.replace(new RegExp(CONFIG_FILE_EXTENSIONS.join("|")), "")}.js`);
|
|
9
|
-
if (configFilePath) {
|
|
10
|
-
const configHelperFilePath = path.normalize(path.join(distDirectory, "./config-helper.js"));
|
|
11
|
-
const helperCode = `
|
|
12
|
-
export const defineConfig = (config) => config;
|
|
13
|
-
`;
|
|
14
|
-
await fs.ensureDir(distDirectory);
|
|
15
|
-
await fs.writeFile(configHelperFilePath, helperCode);
|
|
16
|
-
await bundle(configFilePath, {
|
|
17
|
-
...options,
|
|
18
|
-
watch,
|
|
19
|
-
getOutputFile,
|
|
20
|
-
esbuildPlugins: [
|
|
21
|
-
{
|
|
22
|
-
name: "native-build-config",
|
|
23
|
-
setup(ctx) {
|
|
24
|
-
ctx.onResolve({
|
|
25
|
-
filter: /app-tools\/server/
|
|
26
|
-
}, () => {
|
|
27
|
-
return {
|
|
28
|
-
path: configHelperFilePath
|
|
29
|
-
};
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
]
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
const emitResolvedConfig = async (appDirectory, resolvedConfig) => {
|
|
38
|
-
var _resolvedConfig_output_distPath;
|
|
39
|
-
const outputPath = ensureAbsolutePath(appDirectory, path.join(((_resolvedConfig_output_distPath = resolvedConfig.output.distPath) === null || _resolvedConfig_output_distPath === void 0 ? void 0 : _resolvedConfig_output_distPath.root) || "./dist", OUTPUT_CONFIG_FILE));
|
|
40
|
-
const output = stringify(resolvedConfig);
|
|
41
|
-
await fs.writeFile(outputPath, output, {
|
|
42
|
-
encoding: "utf-8"
|
|
43
|
-
});
|
|
44
|
-
};
|
|
45
|
-
export {
|
|
46
|
-
buildServerConfig,
|
|
47
|
-
defineServerConfig,
|
|
48
|
-
emitResolvedConfig
|
|
49
|
-
};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { createDevServer } from "@modern-js/server";
|
|
2
|
-
import { applyPlugins } from "@modern-js/prod-server";
|
|
3
|
-
let server = null;
|
|
4
|
-
const getServer = () => server;
|
|
5
|
-
const setServer = (newServer) => {
|
|
6
|
-
server = newServer;
|
|
7
|
-
};
|
|
8
|
-
const closeServer = async () => {
|
|
9
|
-
if (server) {
|
|
10
|
-
server.close();
|
|
11
|
-
server = null;
|
|
12
|
-
}
|
|
13
|
-
};
|
|
14
|
-
const createServer = async (options) => {
|
|
15
|
-
if (server) {
|
|
16
|
-
server.close();
|
|
17
|
-
}
|
|
18
|
-
server = (await createDevServer(options, applyPlugins)).server;
|
|
19
|
-
return server;
|
|
20
|
-
};
|
|
21
|
-
export {
|
|
22
|
-
closeServer,
|
|
23
|
-
createServer,
|
|
24
|
-
getServer,
|
|
25
|
-
setServer
|
|
26
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { cutNameByHyphen } from "@modern-js/utils/universal";
|
|
2
|
-
function getAutoInjectEnv(appContext) {
|
|
3
|
-
const { metaName } = appContext;
|
|
4
|
-
const prefix = `${cutNameByHyphen(metaName)}_`.toUpperCase();
|
|
5
|
-
const envReg = new RegExp(`^${prefix}`);
|
|
6
|
-
return Object.keys(process.env).reduce((prev, key) => {
|
|
7
|
-
const value = process.env[key];
|
|
8
|
-
if (envReg.test(key) && typeof value !== "undefined") {
|
|
9
|
-
prev[`process.env.${key}`] = value;
|
|
10
|
-
}
|
|
11
|
-
return prev;
|
|
12
|
-
}, {});
|
|
13
|
-
}
|
|
14
|
-
export {
|
|
15
|
-
getAutoInjectEnv
|
|
16
|
-
};
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import path from "path";
|
|
2
|
-
import { fs, getServerConfig } from "@modern-js/utils";
|
|
3
|
-
const getPackageConfig = (appDirectory, packageJsonConfig) => {
|
|
4
|
-
const PACKAGE_JSON_CONFIG_NAME = "modernConfig";
|
|
5
|
-
const json = JSON.parse(fs.readFileSync(path.resolve(appDirectory, "./package.json"), "utf8"));
|
|
6
|
-
return json[packageJsonConfig !== null && packageJsonConfig !== void 0 ? packageJsonConfig : PACKAGE_JSON_CONFIG_NAME];
|
|
7
|
-
};
|
|
8
|
-
const addServerConfigToDeps = async (dependencies, appDirectory, serverConfigFile) => {
|
|
9
|
-
const serverConfig = await getServerConfig(appDirectory, serverConfigFile);
|
|
10
|
-
if (serverConfig) {
|
|
11
|
-
dependencies.push(serverConfig);
|
|
12
|
-
}
|
|
13
|
-
};
|
|
14
|
-
async function generateWatchFiles(appContext, configDir) {
|
|
15
|
-
const { appDirectory, configFile } = appContext;
|
|
16
|
-
const configPath = path.join(appDirectory, configDir || "");
|
|
17
|
-
const dependencies = getPackageConfig(appContext.appDirectory, appContext.packageName) ? [
|
|
18
|
-
path.resolve(appDirectory, "./package.json")
|
|
19
|
-
] : [];
|
|
20
|
-
await addServerConfigToDeps(dependencies, appContext.appDirectory, appContext.serverConfigFile);
|
|
21
|
-
return [
|
|
22
|
-
`${configPath}/html`,
|
|
23
|
-
configFile || "./config",
|
|
24
|
-
...dependencies
|
|
25
|
-
];
|
|
26
|
-
}
|
|
27
|
-
export {
|
|
28
|
-
addServerConfigToDeps,
|
|
29
|
-
generateWatchFiles
|
|
30
|
-
};
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { chalk, inquirer } from "@modern-js/utils";
|
|
2
|
-
import { i18n, localeKeys } from "../locale";
|
|
3
|
-
const getSelectedEntries = async (entry, entrypoints) => {
|
|
4
|
-
const entryNames = entrypoints.map((e) => e.entryName);
|
|
5
|
-
if (!entry) {
|
|
6
|
-
return entryNames;
|
|
7
|
-
}
|
|
8
|
-
if (typeof entry === "boolean") {
|
|
9
|
-
const { selected } = await inquirer.prompt([
|
|
10
|
-
{
|
|
11
|
-
type: "checkbox",
|
|
12
|
-
name: "selected",
|
|
13
|
-
choices: entryNames,
|
|
14
|
-
message: i18n.t(localeKeys.command.dev.selectEntry),
|
|
15
|
-
validate(answer) {
|
|
16
|
-
if (answer.length < 1) {
|
|
17
|
-
return i18n.t(localeKeys.command.dev.requireEntry);
|
|
18
|
-
}
|
|
19
|
-
return true;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
]);
|
|
23
|
-
return selected;
|
|
24
|
-
}
|
|
25
|
-
entry.forEach((name) => {
|
|
26
|
-
if (!entryNames.includes(name)) {
|
|
27
|
-
throw new Error(`Can not found entry ${chalk.yellow(name)}, the entry should be one of ${chalk.yellow(entryNames.join(", "))}`);
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
return entry;
|
|
31
|
-
};
|
|
32
|
-
export {
|
|
33
|
-
getSelectedEntries
|
|
34
|
-
};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { loadServerPlugins as loadServerPluginInstances } from "@modern-js/prod-server";
|
|
2
|
-
async function getServerPlugins(api, metaName = "modern-js") {
|
|
3
|
-
const runner = api.useHookRunners();
|
|
4
|
-
const { plugins } = await runner._internalServerPlugins({
|
|
5
|
-
plugins: []
|
|
6
|
-
});
|
|
7
|
-
const filtedPlugins = plugins.filter((plugin) => plugin.name.includes(metaName));
|
|
8
|
-
api.setAppContext({
|
|
9
|
-
...api.useAppContext(),
|
|
10
|
-
serverPlugins: filtedPlugins
|
|
11
|
-
});
|
|
12
|
-
return filtedPlugins;
|
|
13
|
-
}
|
|
14
|
-
async function loadServerPlugins(api, appDirectory, metaName) {
|
|
15
|
-
const plugins = await getServerPlugins(api, metaName);
|
|
16
|
-
const instances = loadServerPluginInstances(plugins, appDirectory);
|
|
17
|
-
return instances;
|
|
18
|
-
}
|
|
19
|
-
export {
|
|
20
|
-
getServerPlugins,
|
|
21
|
-
loadServerPlugins
|
|
22
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { prettyInstructions, logger } from "@modern-js/utils";
|
|
2
|
-
const printInstructions = async (hookRunners, appContext, config) => {
|
|
3
|
-
const message = prettyInstructions(appContext, config);
|
|
4
|
-
const { instructions } = await hookRunners.beforePrintInstructions({
|
|
5
|
-
instructions: message
|
|
6
|
-
});
|
|
7
|
-
logger.log(instructions);
|
|
8
|
-
};
|
|
9
|
-
export {
|
|
10
|
-
printInstructions
|
|
11
|
-
};
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import path from "node:path";
|
|
2
|
-
import { fs, getAliasConfig, readTsConfigByFile } from "@modern-js/utils";
|
|
3
|
-
const registerCompiler = async (appDir = process.cwd(), distDir, alias) => {
|
|
4
|
-
const TS_CONFIG_FILENAME = `tsconfig.json`;
|
|
5
|
-
const tsconfigPath = path.resolve(appDir, TS_CONFIG_FILENAME);
|
|
6
|
-
const isTsProject = await fs.pathExists(tsconfigPath);
|
|
7
|
-
const aliasConfig = getAliasConfig(alias, {
|
|
8
|
-
appDirectory: appDir,
|
|
9
|
-
tsconfigPath
|
|
10
|
-
});
|
|
11
|
-
const { paths = {}, absoluteBaseUrl = "./" } = aliasConfig;
|
|
12
|
-
const tsPaths = Object.keys(paths).reduce((o, key) => {
|
|
13
|
-
let tsPath = paths[key];
|
|
14
|
-
if (typeof tsPath === "string" && path.isAbsolute(tsPath)) {
|
|
15
|
-
tsPath = path.relative(absoluteBaseUrl, tsPath);
|
|
16
|
-
}
|
|
17
|
-
if (typeof tsPath === "string") {
|
|
18
|
-
tsPath = [
|
|
19
|
-
tsPath
|
|
20
|
-
];
|
|
21
|
-
}
|
|
22
|
-
return {
|
|
23
|
-
...o,
|
|
24
|
-
[`${key}`]: tsPath
|
|
25
|
-
};
|
|
26
|
-
}, {});
|
|
27
|
-
let tsConfig = {};
|
|
28
|
-
if (isTsProject) {
|
|
29
|
-
tsConfig = readTsConfigByFile(tsconfigPath);
|
|
30
|
-
}
|
|
31
|
-
try {
|
|
32
|
-
const tsNode = await import("ts-node");
|
|
33
|
-
const tsNodeOptions = tsConfig["ts-node"];
|
|
34
|
-
if (isTsProject) {
|
|
35
|
-
tsNode.register({
|
|
36
|
-
project: tsconfigPath,
|
|
37
|
-
scope: true,
|
|
38
|
-
// for env.d.ts, https://www.npmjs.com/package/ts-node#missing-types
|
|
39
|
-
files: true,
|
|
40
|
-
transpileOnly: true,
|
|
41
|
-
ignore: [
|
|
42
|
-
"(?:^|/)node_modules/",
|
|
43
|
-
`(?:^|/)${path.relative(appDir, distDir)}/`
|
|
44
|
-
],
|
|
45
|
-
...tsNodeOptions
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
} catch (error) {
|
|
49
|
-
const esbuildRegister = await import("esbuild-register/dist/node");
|
|
50
|
-
esbuildRegister.register({
|
|
51
|
-
tsconfigRaw: isTsProject ? tsConfig : void 0,
|
|
52
|
-
hookIgnoreNodeModules: true,
|
|
53
|
-
hookMatcher: (fileName) => !fileName.startsWith(distDir)
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
const tsConfigPaths = await import("@modern-js/utils/tsconfig-paths");
|
|
57
|
-
if (await fs.pathExists(appDir)) {
|
|
58
|
-
const loaderRes = tsConfigPaths.loadConfig(appDir);
|
|
59
|
-
if (loaderRes.resultType === "success") {
|
|
60
|
-
tsConfigPaths.register({
|
|
61
|
-
baseUrl: absoluteBaseUrl || "./",
|
|
62
|
-
paths: tsPaths
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
};
|
|
67
|
-
export {
|
|
68
|
-
registerCompiler
|
|
69
|
-
};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { cli } from "@modern-js/core";
|
|
2
|
-
import { chalk, clearConsole, getFullArgv, logger, program } from "@modern-js/utils";
|
|
3
|
-
async function restart(hooksRunner, filename) {
|
|
4
|
-
clearConsole();
|
|
5
|
-
logger.info(`Restart because ${chalk.yellow(filename)} is changed...
|
|
6
|
-
`);
|
|
7
|
-
let hasGetError = false;
|
|
8
|
-
await hooksRunner.beforeRestart();
|
|
9
|
-
try {
|
|
10
|
-
await cli.init(cli.getPrevInitOptions());
|
|
11
|
-
} catch (err) {
|
|
12
|
-
console.error(err);
|
|
13
|
-
hasGetError = true;
|
|
14
|
-
} finally {
|
|
15
|
-
if (!hasGetError) {
|
|
16
|
-
program.parse(getFullArgv());
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
export {
|
|
21
|
-
restart
|
|
22
|
-
};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import path from "path";
|
|
2
|
-
import { fs, MAIN_ENTRY_NAME, ROUTE_SPEC_FILE } from "@modern-js/utils";
|
|
3
|
-
const generateRoutes = async (appContext) => {
|
|
4
|
-
const { serverRoutes, distDirectory } = appContext;
|
|
5
|
-
const output = JSON.stringify({
|
|
6
|
-
routes: serverRoutes
|
|
7
|
-
}, null, 2);
|
|
8
|
-
await fs.outputFile(path.join(distDirectory, ROUTE_SPEC_FILE), output);
|
|
9
|
-
};
|
|
10
|
-
const getPathWithoutExt = (filename) => {
|
|
11
|
-
const extname = path.extname(filename);
|
|
12
|
-
return filename.slice(0, -extname.length);
|
|
13
|
-
};
|
|
14
|
-
const isMainEntry = (entryName, mainEntryName) => {
|
|
15
|
-
return entryName === (mainEntryName || MAIN_ENTRY_NAME);
|
|
16
|
-
};
|
|
17
|
-
export {
|
|
18
|
-
generateRoutes,
|
|
19
|
-
getPathWithoutExt,
|
|
20
|
-
isMainEntry
|
|
21
|
-
};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|