@modern-js/app-tools 2.35.1 → 2.36.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/analyze/constants.js +68 -75
- package/dist/cjs/analyze/generateCode.js +74 -57
- package/dist/cjs/analyze/getBundleEntry.js +53 -27
- package/dist/cjs/analyze/getClientRoutes/getRoutes.js +63 -37
- package/dist/cjs/analyze/getClientRoutes/getRoutesLegacy.js +63 -37
- package/dist/cjs/analyze/getClientRoutes/index.js +27 -17
- package/dist/cjs/analyze/getClientRoutes/utils.js +47 -30
- package/dist/cjs/analyze/getFileSystemEntry.js +58 -32
- package/dist/cjs/analyze/getHtmlTemplate.js +45 -20
- package/dist/cjs/analyze/getServerRoutes.js +55 -29
- package/dist/cjs/analyze/index.js +81 -61
- package/dist/cjs/analyze/isDefaultExportFunction.js +42 -17
- package/dist/cjs/analyze/makeLegalIdentifier.js +24 -7
- package/dist/cjs/analyze/nestedRoutes.js +111 -65
- package/dist/cjs/analyze/templates.js +135 -53
- package/dist/cjs/analyze/utils.js +101 -67
- package/dist/cjs/builder/builder-rspack/adapterCopy.js +60 -30
- package/dist/cjs/builder/builder-rspack/index.js +29 -12
- package/dist/cjs/builder/builder-webpack/adapterModern.js +26 -11
- package/dist/cjs/builder/builder-webpack/createCopyPattern.js +30 -20
- package/dist/cjs/builder/builder-webpack/index.js +40 -14
- package/dist/cjs/builder/generator/createBuilderOptions.js +24 -7
- package/dist/cjs/builder/generator/createBuilderProviderConfig.js +26 -9
- package/dist/cjs/builder/generator/getBuilderTargets.js +27 -10
- package/dist/cjs/builder/generator/index.js +44 -18
- package/dist/cjs/builder/index.js +39 -13
- package/dist/cjs/builder/shared/builderPlugins/adapterBasic.js +36 -7
- package/dist/cjs/builder/shared/builderPlugins/adapterHtml.js +36 -19
- package/dist/cjs/builder/shared/builderPlugins/adapterSSR.js +47 -21
- package/dist/cjs/builder/shared/builderPlugins/index.js +24 -6
- package/dist/cjs/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +27 -10
- package/dist/cjs/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +29 -12
- package/dist/cjs/builder/shared/bundlerPlugins/RouterPlugin.js +42 -25
- package/dist/cjs/builder/shared/bundlerPlugins/index.js +24 -6
- package/dist/cjs/builder/shared/createCopyInfo.js +38 -12
- package/dist/cjs/builder/shared/index.js +24 -6
- package/dist/cjs/builder/shared/loaders/serverModuleLoader.js +21 -8
- package/dist/cjs/builder/shared/types.js +15 -3
- package/dist/cjs/commands/build.js +33 -16
- package/dist/cjs/commands/deploy.js +24 -7
- package/dist/cjs/commands/dev.js +40 -23
- package/dist/cjs/commands/index.js +24 -6
- package/dist/cjs/commands/inspect.js +26 -9
- package/dist/cjs/commands/serve.js +48 -22
- package/dist/cjs/config/default.js +33 -23
- package/dist/cjs/config/index.js +24 -6
- package/dist/cjs/config/initialize/index.js +27 -10
- package/dist/cjs/config/initialize/inits.js +40 -37
- package/dist/cjs/config/legacy/createHtmlConfig.js +24 -7
- package/dist/cjs/config/legacy/createOutputConfig.js +24 -7
- package/dist/cjs/config/legacy/createSourceConfig.js +24 -7
- package/dist/cjs/config/legacy/createToolsConfig.js +24 -7
- package/dist/cjs/config/legacy/index.js +34 -23
- package/dist/cjs/defineConfig.js +25 -15
- package/dist/cjs/exports/server.js +25 -8
- package/dist/cjs/hooks.js +50 -33
- package/dist/cjs/index.js +95 -80
- package/dist/cjs/initialize/index.js +30 -17
- package/dist/cjs/locale/en.js +24 -7
- package/dist/cjs/locale/index.js +31 -21
- package/dist/cjs/locale/zh.js +24 -7
- package/dist/cjs/schema/Schema.js +28 -11
- package/dist/cjs/schema/index.js +40 -21
- package/dist/cjs/schema/legacy.js +30 -17
- package/dist/cjs/types/config/deploy.js +15 -3
- package/dist/cjs/types/config/dev.js +15 -3
- package/dist/cjs/types/config/experiments.js +15 -3
- package/dist/cjs/types/config/html.js +15 -3
- package/dist/cjs/types/config/index.js +20 -4
- package/dist/cjs/types/config/output.js +15 -3
- package/dist/cjs/types/config/performance.js +15 -3
- package/dist/cjs/types/config/security.js +15 -3
- package/dist/cjs/types/config/source.js +15 -3
- package/dist/cjs/types/config/testing.js +15 -3
- package/dist/cjs/types/config/tools.js +15 -3
- package/dist/cjs/types/hooks.js +15 -3
- package/dist/cjs/types/index.js +24 -6
- package/dist/cjs/types/legacyConfig/deploy.js +15 -3
- package/dist/cjs/types/legacyConfig/dev.js +15 -3
- package/dist/cjs/types/legacyConfig/index.js +15 -3
- package/dist/cjs/types/legacyConfig/output.js +15 -3
- package/dist/cjs/types/legacyConfig/source.js +15 -3
- package/dist/cjs/types/legacyConfig/testing.js +15 -3
- package/dist/cjs/types/legacyConfig/tools.js +15 -3
- package/dist/cjs/types/utils.js +15 -3
- package/dist/cjs/utils/config.js +50 -33
- package/dist/cjs/utils/createServer.js +43 -26
- package/dist/cjs/utils/env.js +26 -9
- package/dist/cjs/utils/generateWatchFiles.js +41 -22
- package/dist/cjs/utils/getSelectedEntries.js +30 -13
- package/dist/cjs/utils/getServerInternalPlugins.js +24 -7
- package/dist/cjs/utils/printInstructions.js +27 -10
- package/dist/cjs/utils/restart.js +30 -13
- package/dist/cjs/utils/routes.js +37 -11
- package/dist/cjs/utils/types.js +15 -3
- package/dist/esm/analyze/constants.js +48 -22
- package/dist/esm/analyze/generateCode.js +38 -33
- package/dist/esm/analyze/getBundleEntry.js +4 -1
- package/dist/esm/analyze/getClientRoutes/getRoutes.js +12 -9
- package/dist/esm/analyze/getClientRoutes/getRoutesLegacy.js +12 -9
- package/dist/esm/analyze/getClientRoutes/index.js +6 -2
- package/dist/esm/analyze/getClientRoutes/utils.js +9 -4
- package/dist/esm/analyze/getFileSystemEntry.js +10 -7
- package/dist/esm/analyze/getHtmlTemplate.js +7 -4
- package/dist/esm/analyze/getServerRoutes.js +8 -5
- package/dist/esm/analyze/index.js +31 -30
- package/dist/esm/analyze/isDefaultExportFunction.js +4 -1
- package/dist/esm/analyze/makeLegalIdentifier.js +4 -1
- package/dist/esm/analyze/nestedRoutes.js +93 -30
- package/dist/esm/analyze/templates.js +121 -30
- package/dist/esm/analyze/utils.js +103 -18
- package/dist/esm/builder/builder-rspack/adapterCopy.js +16 -9
- package/dist/esm/builder/builder-rspack/index.js +4 -1
- package/dist/esm/builder/builder-webpack/adapterModern.js +4 -3
- package/dist/esm/builder/builder-webpack/createCopyPattern.js +8 -4
- package/dist/esm/builder/builder-webpack/index.js +4 -1
- package/dist/esm/builder/generator/createBuilderOptions.js +5 -2
- package/dist/esm/builder/generator/createBuilderProviderConfig.js +4 -1
- package/dist/esm/builder/generator/getBuilderTargets.js +4 -1
- package/dist/esm/builder/generator/index.js +5 -2
- package/dist/esm/builder/index.js +4 -1
- package/dist/esm/builder/shared/builderPlugins/adapterBasic.js +6 -1
- package/dist/esm/builder/shared/builderPlugins/adapterHtml.js +11 -8
- package/dist/esm/builder/shared/builderPlugins/adapterSSR.js +10 -7
- package/dist/esm/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +4 -1
- package/dist/esm/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +4 -1
- package/dist/esm/builder/shared/bundlerPlugins/RouterPlugin.js +7 -4
- package/dist/esm/builder/shared/createCopyInfo.js +7 -4
- package/dist/esm/builder/shared/loaders/serverModuleLoader.js +4 -1
- package/dist/esm/builder/shared/types.js +0 -1
- package/dist/esm/commands/build.js +6 -3
- package/dist/esm/commands/deploy.js +4 -1
- package/dist/esm/commands/dev.js +12 -9
- package/dist/esm/commands/inspect.js +4 -1
- package/dist/esm/commands/serve.js +7 -4
- package/dist/esm/config/default.js +12 -8
- package/dist/esm/config/initialize/index.js +4 -1
- package/dist/esm/config/initialize/inits.js +8 -19
- package/dist/esm/config/legacy/createHtmlConfig.js +17 -14
- package/dist/esm/config/legacy/createOutputConfig.js +19 -16
- package/dist/esm/config/legacy/createSourceConfig.js +14 -11
- package/dist/esm/config/legacy/createToolsConfig.js +18 -15
- package/dist/esm/config/legacy/index.js +21 -16
- package/dist/esm/defineConfig.js +6 -2
- package/dist/esm/exports/server.js +4 -1
- package/dist/esm/hooks.js +4 -1
- package/dist/esm/index.js +19 -11
- package/dist/esm/initialize/index.js +9 -6
- package/dist/esm/locale/en.js +4 -1
- package/dist/esm/locale/index.js +4 -1
- package/dist/esm/locale/zh.js +4 -1
- package/dist/esm/schema/Schema.js +6 -3
- package/dist/esm/schema/index.js +5 -2
- package/dist/esm/schema/legacy.js +4 -1
- package/dist/esm/types/config/deploy.js +0 -1
- package/dist/esm/types/config/dev.js +0 -1
- package/dist/esm/types/config/experiments.js +0 -1
- package/dist/esm/types/config/html.js +0 -1
- package/dist/esm/types/config/output.js +0 -1
- package/dist/esm/types/config/performance.js +0 -1
- package/dist/esm/types/config/security.js +0 -1
- package/dist/esm/types/config/source.js +0 -1
- package/dist/esm/types/config/testing.js +0 -1
- package/dist/esm/types/config/tools.js +0 -1
- package/dist/esm/types/hooks.js +0 -1
- package/dist/esm/types/legacyConfig/deploy.js +0 -1
- package/dist/esm/types/legacyConfig/dev.js +0 -1
- package/dist/esm/types/legacyConfig/index.js +0 -1
- package/dist/esm/types/legacyConfig/output.js +0 -1
- package/dist/esm/types/legacyConfig/source.js +0 -1
- package/dist/esm/types/legacyConfig/testing.js +0 -1
- package/dist/esm/types/legacyConfig/tools.js +0 -1
- package/dist/esm/types/utils.js +0 -1
- package/dist/esm/utils/config.js +12 -6
- package/dist/esm/utils/createServer.js +12 -5
- package/dist/esm/utils/env.js +4 -1
- package/dist/esm/utils/generateWatchFiles.js +6 -2
- package/dist/esm/utils/getSelectedEntries.js +4 -1
- package/dist/esm/utils/getServerInternalPlugins.js +5 -2
- package/dist/esm/utils/printInstructions.js +4 -1
- package/dist/esm/utils/restart.js +4 -1
- package/dist/esm/utils/routes.js +3 -1
- package/dist/esm/utils/types.js +0 -1
- package/dist/esm-node/analyze/constants.js +48 -22
- package/dist/esm-node/analyze/generateCode.js +8 -3
- package/dist/esm-node/analyze/getBundleEntry.js +4 -1
- package/dist/esm-node/analyze/getClientRoutes/getRoutes.js +4 -1
- package/dist/esm-node/analyze/getClientRoutes/getRoutesLegacy.js +4 -1
- package/dist/esm-node/analyze/getClientRoutes/index.js +6 -2
- package/dist/esm-node/analyze/getClientRoutes/utils.js +9 -4
- package/dist/esm-node/analyze/getFileSystemEntry.js +4 -1
- package/dist/esm-node/analyze/getHtmlTemplate.js +4 -1
- package/dist/esm-node/analyze/getServerRoutes.js +4 -1
- package/dist/esm-node/analyze/index.js +9 -8
- package/dist/esm-node/analyze/isDefaultExportFunction.js +4 -1
- package/dist/esm-node/analyze/makeLegalIdentifier.js +4 -1
- package/dist/esm-node/analyze/nestedRoutes.js +42 -9
- package/dist/esm-node/analyze/templates.js +93 -18
- package/dist/esm-node/analyze/utils.js +48 -16
- package/dist/esm-node/builder/builder-rspack/adapterCopy.js +18 -11
- package/dist/esm-node/builder/builder-rspack/index.js +4 -1
- package/dist/esm-node/builder/builder-webpack/adapterModern.js +4 -3
- package/dist/esm-node/builder/builder-webpack/createCopyPattern.js +6 -2
- package/dist/esm-node/builder/builder-webpack/index.js +4 -1
- package/dist/esm-node/builder/generator/createBuilderOptions.js +4 -1
- package/dist/esm-node/builder/generator/createBuilderProviderConfig.js +4 -1
- package/dist/esm-node/builder/generator/getBuilderTargets.js +4 -1
- package/dist/esm-node/builder/generator/index.js +4 -1
- package/dist/esm-node/builder/index.js +4 -1
- package/dist/esm-node/builder/shared/builderPlugins/adapterBasic.js +6 -1
- package/dist/esm-node/builder/shared/builderPlugins/adapterHtml.js +4 -1
- package/dist/esm-node/builder/shared/builderPlugins/adapterSSR.js +4 -1
- package/dist/esm-node/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +4 -1
- package/dist/esm-node/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +4 -1
- package/dist/esm-node/builder/shared/bundlerPlugins/RouterPlugin.js +4 -1
- package/dist/esm-node/builder/shared/createCopyInfo.js +4 -1
- package/dist/esm-node/builder/shared/loaders/serverModuleLoader.js +4 -1
- package/dist/esm-node/builder/shared/types.js +0 -1
- package/dist/esm-node/commands/build.js +4 -1
- package/dist/esm-node/commands/deploy.js +4 -1
- package/dist/esm-node/commands/dev.js +4 -1
- package/dist/esm-node/commands/inspect.js +4 -1
- package/dist/esm-node/commands/serve.js +4 -1
- package/dist/esm-node/config/default.js +6 -2
- package/dist/esm-node/config/initialize/index.js +4 -1
- package/dist/esm-node/config/initialize/inits.js +8 -20
- package/dist/esm-node/config/legacy/createHtmlConfig.js +4 -1
- package/dist/esm-node/config/legacy/createOutputConfig.js +4 -1
- package/dist/esm-node/config/legacy/createSourceConfig.js +4 -1
- package/dist/esm-node/config/legacy/createToolsConfig.js +4 -1
- package/dist/esm-node/config/legacy/index.js +7 -2
- package/dist/esm-node/defineConfig.js +6 -2
- package/dist/esm-node/exports/server.js +4 -1
- package/dist/esm-node/hooks.js +4 -1
- package/dist/esm-node/index.js +14 -6
- package/dist/esm-node/initialize/index.js +4 -1
- package/dist/esm-node/locale/en.js +4 -1
- package/dist/esm-node/locale/index.js +4 -1
- package/dist/esm-node/locale/zh.js +4 -1
- package/dist/esm-node/schema/Schema.js +4 -1
- package/dist/esm-node/schema/index.js +5 -2
- package/dist/esm-node/schema/legacy.js +4 -1
- package/dist/esm-node/types/config/deploy.js +0 -1
- package/dist/esm-node/types/config/dev.js +0 -1
- package/dist/esm-node/types/config/experiments.js +0 -1
- package/dist/esm-node/types/config/html.js +0 -1
- package/dist/esm-node/types/config/output.js +0 -1
- package/dist/esm-node/types/config/performance.js +0 -1
- package/dist/esm-node/types/config/security.js +0 -1
- package/dist/esm-node/types/config/source.js +0 -1
- package/dist/esm-node/types/config/testing.js +0 -1
- package/dist/esm-node/types/config/tools.js +0 -1
- package/dist/esm-node/types/hooks.js +0 -1
- package/dist/esm-node/types/legacyConfig/deploy.js +0 -1
- package/dist/esm-node/types/legacyConfig/dev.js +0 -1
- package/dist/esm-node/types/legacyConfig/index.js +0 -1
- package/dist/esm-node/types/legacyConfig/output.js +0 -1
- package/dist/esm-node/types/legacyConfig/source.js +0 -1
- package/dist/esm-node/types/legacyConfig/testing.js +0 -1
- package/dist/esm-node/types/legacyConfig/tools.js +0 -1
- package/dist/esm-node/types/utils.js +0 -1
- package/dist/esm-node/utils/config.js +10 -4
- package/dist/esm-node/utils/createServer.js +12 -5
- package/dist/esm-node/utils/env.js +4 -1
- package/dist/esm-node/utils/generateWatchFiles.js +6 -2
- package/dist/esm-node/utils/getSelectedEntries.js +4 -1
- package/dist/esm-node/utils/getServerInternalPlugins.js +4 -1
- package/dist/esm-node/utils/printInstructions.js +4 -1
- package/dist/esm-node/utils/restart.js +4 -1
- package/dist/esm-node/utils/routes.js +3 -1
- package/dist/esm-node/utils/types.js +0 -1
- package/dist/types/analyze/constants.d.ts +1 -0
- package/dist/types/analyze/utils.d.ts +2 -1
- package/dist/types/types/config/index.d.ts +3 -2
- package/package.json +24 -24
@@ -1 +0,0 @@
|
|
1
|
-
export {};
|
@@ -2,7 +2,7 @@ import { ResolvedConfigContext } from "@modern-js/core";
|
|
2
2
|
import { logger } from "@modern-js/utils";
|
3
3
|
import { generateRoutes } from "../utils/routes";
|
4
4
|
import { buildServerConfig } from "../utils/config";
|
5
|
-
|
5
|
+
const build = async (api, options) => {
|
6
6
|
if (options === null || options === void 0 ? void 0 : options.analyze) {
|
7
7
|
process.env.BUNDLE_ANALYZE = "true";
|
8
8
|
}
|
@@ -45,3 +45,6 @@ export const build = async (api, options) => {
|
|
45
45
|
}
|
46
46
|
await appContext.builder.build();
|
47
47
|
};
|
48
|
+
export {
|
49
|
+
build
|
50
|
+
};
|
@@ -5,7 +5,7 @@ import { setServer, createServer, injectDataLoaderPlugin } from "../utils/create
|
|
5
5
|
import { generateRoutes } from "../utils/routes";
|
6
6
|
import { buildServerConfig } from "../utils/config";
|
7
7
|
import { getServerInternalPlugins } from "../utils/getServerInternalPlugins";
|
8
|
-
|
8
|
+
const dev = async (api, options, devServerOptions = {}) => {
|
9
9
|
var _normalizedConfig_tools;
|
10
10
|
if (options.analyze) {
|
11
11
|
process.env.BUNDLE_ANALYZE = "true";
|
@@ -75,3 +75,6 @@ export const dev = async (api, options, devServerOptions = {}) => {
|
|
75
75
|
setServer(server);
|
76
76
|
}
|
77
77
|
};
|
78
|
+
export {
|
79
|
+
dev
|
80
|
+
};
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { join } from "path";
|
2
|
-
|
2
|
+
const inspect = async (api, options) => {
|
3
3
|
const appContext = api.useAppContext();
|
4
4
|
if (!appContext.builder) {
|
5
5
|
throw new Error("Expect the Builder to have been initialized, But the appContext.builder received `undefined`");
|
@@ -11,3 +11,6 @@ export const inspect = async (api, options) => {
|
|
11
11
|
writeToDisk: true
|
12
12
|
});
|
13
13
|
};
|
14
|
+
export {
|
15
|
+
inspect
|
16
|
+
};
|
@@ -3,7 +3,7 @@ import server from "@modern-js/prod-server";
|
|
3
3
|
import { printInstructions } from "../utils/printInstructions";
|
4
4
|
import { injectDataLoaderPlugin } from "../utils/createServer";
|
5
5
|
import { getServerInternalPlugins } from "../utils/getServerInternalPlugins";
|
6
|
-
|
6
|
+
const start = async (api) => {
|
7
7
|
var _userConfig_source, _userConfig_output_distPath;
|
8
8
|
const appContext = api.useAppContext();
|
9
9
|
const userConfig = api.useResolvedConfigContext();
|
@@ -39,3 +39,6 @@ export const start = async (api) => {
|
|
39
39
|
await printInstructions(hookRunners, appContext, userConfig);
|
40
40
|
});
|
41
41
|
};
|
42
|
+
export {
|
43
|
+
start
|
44
|
+
};
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { createDefaultConfig as createDefaultBuilderConfig } from "@modern-js/builder-webpack-provider";
|
2
2
|
import { MAIN_ENTRY_NAME } from "@modern-js/utils";
|
3
3
|
import { getAutoInjectEnv } from "../utils/env";
|
4
|
-
|
4
|
+
function createDefaultConfig(appContext, bundler) {
|
5
5
|
const defaultBuilderConfig = createDefaultBuilderConfig();
|
6
6
|
const dev = {
|
7
7
|
...defaultBuilderConfig.dev,
|
@@ -85,7 +85,7 @@ export function createDefaultConfig(appContext, bundler) {
|
|
85
85
|
runtimeByEntries: {}
|
86
86
|
};
|
87
87
|
}
|
88
|
-
|
88
|
+
function createLegacyDefaultConfig(appContext) {
|
89
89
|
const defaultAlias = appContext ? {
|
90
90
|
[appContext.internalDirAlias]: appContext.internalDirectory,
|
91
91
|
[appContext.internalSrcAlias]: appContext.srcDirectory,
|
@@ -189,3 +189,7 @@ export function createLegacyDefaultConfig(appContext) {
|
|
189
189
|
runtimeByEntries: {}
|
190
190
|
};
|
191
191
|
}
|
192
|
+
export {
|
193
|
+
createDefaultConfig,
|
194
|
+
createLegacyDefaultConfig
|
195
|
+
};
|
@@ -1,6 +1,9 @@
|
|
1
1
|
import { initHtmlConfig, initSourceConfig } from "./inits";
|
2
|
-
|
2
|
+
function initialNormalizedConfig(config, appContext, bundler) {
|
3
3
|
initHtmlConfig(config, appContext);
|
4
4
|
initSourceConfig(config, appContext, bundler);
|
5
5
|
return config;
|
6
6
|
}
|
7
|
+
export {
|
8
|
+
initialNormalizedConfig
|
9
|
+
};
|
@@ -1,6 +1,6 @@
|
|
1
|
-
import path, {
|
2
|
-
import { findExists
|
3
|
-
|
1
|
+
import path, { isAbsolute } from "path";
|
2
|
+
import { findExists } from "@modern-js/utils";
|
3
|
+
function initHtmlConfig(config, appContext) {
|
4
4
|
const ICON_EXTENSIONS = [
|
5
5
|
"png",
|
6
6
|
"jpg",
|
@@ -23,7 +23,7 @@ export function initHtmlConfig(config, appContext) {
|
|
23
23
|
return favicon || defaultFavicon || void 0;
|
24
24
|
}
|
25
25
|
}
|
26
|
-
|
26
|
+
function initSourceConfig(config, appContext, bundler) {
|
27
27
|
config.source.include = createBuilderInclude(config, appContext);
|
28
28
|
if (bundler === "webpack") {
|
29
29
|
config.source.moduleScopes = createBuilderModuleScope(config);
|
@@ -42,22 +42,6 @@ export function initSourceConfig(config, appContext, bundler) {
|
|
42
42
|
}
|
43
43
|
return include2;
|
44
44
|
}).concat(defaultInclude);
|
45
|
-
const root = findMonorepoRoot(appContext2.appDirectory);
|
46
|
-
if (!root) {
|
47
|
-
return transformInclude;
|
48
|
-
}
|
49
|
-
const modernjsMonorepo = isModernjsMonorepo(root);
|
50
|
-
if (modernjsMonorepo) {
|
51
|
-
const paths = globby.sync(posix.join(root, "features", "**", "package.json"), {
|
52
|
-
ignore: [
|
53
|
-
"**/node_modules/**/*"
|
54
|
-
]
|
55
|
-
}).map((pathname) => dirname(pathname) + sep);
|
56
|
-
return [
|
57
|
-
...paths,
|
58
|
-
...transformInclude
|
59
|
-
];
|
60
|
-
}
|
61
45
|
return transformInclude;
|
62
46
|
}
|
63
47
|
function createBuilderModuleScope(config2) {
|
@@ -93,3 +77,7 @@ export function initSourceConfig(config, appContext, bundler) {
|
|
93
77
|
}
|
94
78
|
}
|
95
79
|
}
|
80
|
+
export {
|
81
|
+
initHtmlConfig,
|
82
|
+
initSourceConfig
|
83
|
+
};
|
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
function createHtmlConfig(config) {
|
2
2
|
const { disableHtmlFolder, favicon, faviconByEntries, inject, injectByEntries, meta, metaByEntries, mountId, title, titleByEntries, templateParameters, templateParametersByEntries, crossorigin } = config.output;
|
3
3
|
return {
|
4
4
|
disableHtmlFolder,
|
@@ -16,3 +16,6 @@ export function createHtmlConfig(config) {
|
|
16
16
|
templateParametersByEntries
|
17
17
|
};
|
18
18
|
}
|
19
|
+
export {
|
20
|
+
createHtmlConfig
|
21
|
+
};
|
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
function createOutputConfig(config) {
|
2
2
|
const { assetPrefix, copy, cssModuleLocalIdentName, cssPath, jsPath, htmlPath, mediaPath, enableTsLoader, path, disableInlineRuntimeChunk, disableCssExtract, disableMinimize, disableSourceMap, disableTsChecker, enableCssModuleTSDeclaration, enableInlineScripts, enableInlineStyles, polyfill, dataUriLimit, disableAssetsCache, enableLatestDecorators, disableCssModuleExtension, ssg, disableNodePolyfill } = config.output;
|
3
3
|
return {
|
4
4
|
assetPrefix,
|
@@ -40,3 +40,6 @@ export function createOutputConfig(config) {
|
|
40
40
|
disableNodePolyfill
|
41
41
|
};
|
42
42
|
}
|
43
|
+
export {
|
44
|
+
createOutputConfig
|
45
|
+
};
|
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
function createSourceConfig(config) {
|
2
2
|
const { alias, envVars, globalVars, include, moduleScopes, preEntry, entries, mainEntryName, enableAsyncEntry, disableDefaultEntries, entriesDir, configDir } = config.source;
|
3
3
|
const builderGlobalVars = globalVars || {};
|
4
4
|
for (const envVar of envVars || []) {
|
@@ -23,3 +23,6 @@ export function createSourceConfig(config) {
|
|
23
23
|
}
|
24
24
|
};
|
25
25
|
}
|
26
|
+
export {
|
27
|
+
createSourceConfig
|
28
|
+
};
|
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
function createToolsConfig(config) {
|
2
2
|
const { autoprefixer, babel, minifyCss, terser, webpack, webpackChain, tsLoader, styledComponents, sass, postcss, less, htmlPlugin, devServer, tailwindcss, jest, esbuild } = config.tools;
|
3
3
|
const { enableTsLoader } = config.output;
|
4
4
|
return {
|
@@ -23,3 +23,6 @@ export function createToolsConfig(config) {
|
|
23
23
|
}
|
24
24
|
};
|
25
25
|
}
|
26
|
+
export {
|
27
|
+
createToolsConfig
|
28
|
+
};
|
@@ -2,7 +2,7 @@ import { createToolsConfig } from "./createToolsConfig";
|
|
2
2
|
import { createSourceConfig } from "./createSourceConfig";
|
3
3
|
import { createOutputConfig } from "./createOutputConfig";
|
4
4
|
import { createHtmlConfig } from "./createHtmlConfig";
|
5
|
-
|
5
|
+
function transformNormalizedConfig(config) {
|
6
6
|
const html = createHtmlConfig(config);
|
7
7
|
const output = createOutputConfig(config);
|
8
8
|
const source = createSourceConfig(config);
|
@@ -21,6 +21,7 @@ export function transformNormalizedConfig(config) {
|
|
21
21
|
server,
|
22
22
|
cliOptions,
|
23
23
|
testing,
|
24
|
+
devtools: {},
|
24
25
|
builderPlugins: [],
|
25
26
|
plugins,
|
26
27
|
security: {},
|
@@ -32,6 +33,10 @@ export function transformNormalizedConfig(config) {
|
|
32
33
|
}
|
33
34
|
};
|
34
35
|
}
|
35
|
-
|
36
|
+
function checkIsLegacyConfig(config) {
|
36
37
|
return Boolean(config.legacy);
|
37
38
|
}
|
39
|
+
export {
|
40
|
+
checkIsLegacyConfig,
|
41
|
+
transformNormalizedConfig
|
42
|
+
};
|
@@ -1,7 +1,11 @@
|
|
1
|
-
|
1
|
+
const defineConfig = (config) => config;
|
2
2
|
var _config_autoLoadPlugins;
|
3
|
-
|
3
|
+
const defineLegacyConfig = (config) => ({
|
4
4
|
...config,
|
5
5
|
legacy: true,
|
6
6
|
autoLoadPlugins: (_config_autoLoadPlugins = config.autoLoadPlugins) !== null && _config_autoLoadPlugins !== void 0 ? _config_autoLoadPlugins : true
|
7
7
|
});
|
8
|
+
export {
|
9
|
+
defineConfig,
|
10
|
+
defineLegacyConfig
|
11
|
+
};
|
package/dist/esm-node/hooks.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import { createAsyncWaterfall, createAsyncWorkflow, createParallelWorkflow } from "@modern-js/plugin";
|
2
|
-
|
2
|
+
const hooks = {
|
3
3
|
modifyEntryExport: createAsyncWaterfall(),
|
4
4
|
modifyEntryImports: createAsyncWaterfall(),
|
5
5
|
modifyEntryRuntimePlugins: createAsyncWaterfall(),
|
@@ -26,3 +26,6 @@ export const hooks = {
|
|
26
26
|
registerBuildPlatform: createParallelWorkflow(),
|
27
27
|
beforeBuildPlatform: createParallelWorkflow()
|
28
28
|
};
|
29
|
+
export {
|
30
|
+
hooks
|
31
|
+
};
|
package/dist/esm-node/index.js
CHANGED
@@ -9,11 +9,11 @@ import { hooks } from "./hooks";
|
|
9
9
|
import { i18n, localeKeys } from "./locale";
|
10
10
|
import { restart } from "./utils/restart";
|
11
11
|
import { generateWatchFiles } from "./utils/generateWatchFiles";
|
12
|
-
|
13
|
-
|
12
|
+
import { mergeConfig } from "@modern-js/core";
|
13
|
+
import { dev } from "./commands";
|
14
14
|
export * from "./defineConfig";
|
15
15
|
export * from "./types";
|
16
|
-
|
16
|
+
const devCommand = async (program, api) => {
|
17
17
|
const runner = api.useHookRunners();
|
18
18
|
const devToolMetas = await runner.registerDev();
|
19
19
|
const devProgram = program.command("dev").alias("start").usage("[options]").description(i18n.t(localeKeys.command.dev.describe)).option("-c --config <config>", i18n.t(localeKeys.command.shared.config)).option("-e --entry [entry...]", i18n.t(localeKeys.command.dev.entry)).option("--analyze", i18n.t(localeKeys.command.shared.analyze)).option("--api-only", i18n.t(localeKeys.command.dev.apiOnly)).option("--web-only", i18n.t(localeKeys.command.dev.webOnly)).action(async (options) => {
|
@@ -36,7 +36,7 @@ export const devCommand = async (program, api) => {
|
|
36
36
|
}
|
37
37
|
}
|
38
38
|
};
|
39
|
-
|
39
|
+
const buildCommand = async (program, api) => {
|
40
40
|
const runner = api.useHookRunners();
|
41
41
|
const platformBuilders = await runner.registerBuildPlatform();
|
42
42
|
const buildProgram = program.command("build").usage("[options]").description(i18n.t(localeKeys.command.build.describe)).option("-c --config <config>", i18n.t(localeKeys.command.shared.config)).option("--analyze", i18n.t(localeKeys.command.shared.analyze)).action(async (options) => {
|
@@ -57,7 +57,7 @@ export const buildCommand = async (program, api) => {
|
|
57
57
|
}
|
58
58
|
}
|
59
59
|
};
|
60
|
-
|
60
|
+
const appTools = (options = {
|
61
61
|
bundler: "webpack"
|
62
62
|
}) => ({
|
63
63
|
name: "@modern-js/app-tools",
|
@@ -192,4 +192,12 @@ export const appTools = (options = {
|
|
192
192
|
};
|
193
193
|
}
|
194
194
|
});
|
195
|
-
|
195
|
+
var src_default = appTools;
|
196
|
+
export {
|
197
|
+
appTools,
|
198
|
+
buildCommand,
|
199
|
+
src_default as default,
|
200
|
+
dev,
|
201
|
+
devCommand,
|
202
|
+
mergeConfig
|
203
|
+
};
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { ensureAbsolutePath, getPort, isDev, isDevCommand } from "@modern-js/utils";
|
2
2
|
import { legacySchema, schema } from "../schema";
|
3
3
|
import { checkIsLegacyConfig, createDefaultConfig, createLegacyDefaultConfig, transformNormalizedConfig } from "../config";
|
4
|
-
|
4
|
+
var initialize_default = ({ bundler }) => ({
|
5
5
|
name: "@modern-js/plugin-initialize",
|
6
6
|
post: [
|
7
7
|
"@modern-js/plugin-ssr",
|
@@ -86,3 +86,6 @@ async function getServerPort(config) {
|
|
86
86
|
}
|
87
87
|
return prodPort;
|
88
88
|
}
|
89
|
+
export {
|
90
|
+
initialize_default as default
|
91
|
+
};
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { _ as _define_property } from "@swc/helpers/_/_define_property";
|
2
2
|
import { merge } from "@modern-js/utils/lodash";
|
3
|
-
|
3
|
+
class Schema extends Map {
|
4
4
|
setSchema(key, object) {
|
5
5
|
Object.entries(object).forEach(([k, v]) => {
|
6
6
|
const target = `${key}.${k}`;
|
@@ -37,3 +37,6 @@ export class Schema extends Map {
|
|
37
37
|
this.schema = baseSchema;
|
38
38
|
}
|
39
39
|
}
|
40
|
+
export {
|
41
|
+
Schema
|
42
|
+
};
|
@@ -163,5 +163,8 @@ const builderPlugins = {
|
|
163
163
|
};
|
164
164
|
const schema = new Schema();
|
165
165
|
schema.setSchema("bff", bff).setSchema("dev", dev).setSchema("server", server).setSchema("source", source).setSchema("output", output).setSchema("tools", tools).setSchema("deploy", deploy).set("builderPlugin", builderPlugins);
|
166
|
-
|
167
|
-
export {
|
166
|
+
import { default as default2 } from "./legacy";
|
167
|
+
export {
|
168
|
+
default2 as legacySchema,
|
169
|
+
schema
|
170
|
+
};
|
@@ -338,4 +338,7 @@ const bff = {
|
|
338
338
|
};
|
339
339
|
const schema = new Schema();
|
340
340
|
schema.setSchema("bff", bff).setSchema("dev", dev).setSchema("server", server).setSchema("source", source).setSchema("output", output).setSchema("tools", tools).setSchema("deploy", deploy);
|
341
|
-
|
341
|
+
var legacy_default = schema;
|
342
|
+
export {
|
343
|
+
legacy_default as default
|
344
|
+
};
|
@@ -1 +0,0 @@
|
|
1
|
-
export {};
|
@@ -1 +0,0 @@
|
|
1
|
-
export {};
|
@@ -1 +0,0 @@
|
|
1
|
-
export {};
|
@@ -1 +0,0 @@
|
|
1
|
-
export {};
|
@@ -1 +0,0 @@
|
|
1
|
-
export {};
|
@@ -1 +0,0 @@
|
|
1
|
-
export {};
|
@@ -1 +0,0 @@
|
|
1
|
-
export {};
|
@@ -1 +0,0 @@
|
|
1
|
-
export {};
|
@@ -1 +0,0 @@
|
|
1
|
-
export {};
|
@@ -1 +0,0 @@
|
|
1
|
-
export {};
|
@@ -1 +0,0 @@
|
|
1
|
-
export {};
|
@@ -1 +0,0 @@
|
|
1
|
-
export {};
|
@@ -1 +0,0 @@
|
|
1
|
-
export {};
|
@@ -1 +0,0 @@
|
|
1
|
-
export {};
|
@@ -1 +0,0 @@
|
|
1
|
-
export {};
|
@@ -1 +0,0 @@
|
|
1
|
-
export {};
|
@@ -1 +0,0 @@
|
|
1
|
-
export {};
|
@@ -1 +0,0 @@
|
|
1
|
-
export {};
|
@@ -1 +0,0 @@
|
|
1
|
-
export {};
|
@@ -1,8 +1,8 @@
|
|
1
1
|
import * as path from "path";
|
2
2
|
import { bundle } from "@modern-js/node-bundle-require";
|
3
3
|
import { fs, getServerConfig, ensureAbsolutePath, OUTPUT_CONFIG_FILE, CONFIG_FILE_EXTENSIONS } from "@modern-js/utils";
|
4
|
-
|
5
|
-
|
4
|
+
const defineServerConfig = (config) => config;
|
5
|
+
const buildServerConfig = async ({ appDirectory, distDirectory, configFile, options, watch }) => {
|
6
6
|
const configFilePath = await getServerConfig(appDirectory, configFile);
|
7
7
|
const getOutputFile = async (filepath) => path.resolve(distDirectory, `${filepath.replace(new RegExp(CONFIG_FILE_EXTENSIONS.join("|")), "")}.js`);
|
8
8
|
if (configFilePath) {
|
@@ -33,7 +33,7 @@ export const buildServerConfig = async ({ appDirectory, distDirectory, configFil
|
|
33
33
|
});
|
34
34
|
}
|
35
35
|
};
|
36
|
-
|
36
|
+
const safeReplacer = () => {
|
37
37
|
const cache = [];
|
38
38
|
const keyCache = [];
|
39
39
|
return function(key, value) {
|
@@ -48,7 +48,7 @@ export const safeReplacer = () => {
|
|
48
48
|
return value;
|
49
49
|
};
|
50
50
|
};
|
51
|
-
|
51
|
+
const emitResolvedConfig = async (appDirectory, resolvedConfig) => {
|
52
52
|
var _resolvedConfig_output_distPath;
|
53
53
|
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));
|
54
54
|
await fs.writeJSON(outputPath, resolvedConfig, {
|
@@ -56,3 +56,9 @@ export const emitResolvedConfig = async (appDirectory, resolvedConfig) => {
|
|
56
56
|
replacer: safeReplacer()
|
57
57
|
});
|
58
58
|
};
|
59
|
+
export {
|
60
|
+
buildServerConfig,
|
61
|
+
defineServerConfig,
|
62
|
+
emitResolvedConfig,
|
63
|
+
safeReplacer
|
64
|
+
};
|
@@ -1,16 +1,16 @@
|
|
1
1
|
import { Server } from "@modern-js/server";
|
2
2
|
let server = null;
|
3
|
-
|
4
|
-
|
3
|
+
const getServer = () => server;
|
4
|
+
const setServer = (newServer) => {
|
5
5
|
server = newServer;
|
6
6
|
};
|
7
|
-
|
7
|
+
const closeServer = async () => {
|
8
8
|
if (server) {
|
9
9
|
await server.close();
|
10
10
|
server = null;
|
11
11
|
}
|
12
12
|
};
|
13
|
-
|
13
|
+
const createServer = async (options) => {
|
14
14
|
if (server) {
|
15
15
|
await server.close();
|
16
16
|
}
|
@@ -18,7 +18,7 @@ export const createServer = async (options) => {
|
|
18
18
|
const app = await server.init();
|
19
19
|
return app;
|
20
20
|
};
|
21
|
-
|
21
|
+
const injectDataLoaderPlugin = (internalPlugins) => {
|
22
22
|
const DataLoaderPlugin = require.resolve("@modern-js/plugin-data-loader/server");
|
23
23
|
return {
|
24
24
|
...internalPlugins,
|
@@ -28,3 +28,10 @@ export const injectDataLoaderPlugin = (internalPlugins) => {
|
|
28
28
|
}
|
29
29
|
};
|
30
30
|
};
|
31
|
+
export {
|
32
|
+
closeServer,
|
33
|
+
createServer,
|
34
|
+
getServer,
|
35
|
+
injectDataLoaderPlugin,
|
36
|
+
setServer
|
37
|
+
};
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { cutNameByHyphen } from "@modern-js/utils";
|
2
|
-
|
2
|
+
function getAutoInjectEnv(appContext) {
|
3
3
|
const { metaName } = appContext;
|
4
4
|
const prefix = `${cutNameByHyphen(metaName)}_`.toUpperCase();
|
5
5
|
const envReg = new RegExp(`^${prefix}`);
|
@@ -11,3 +11,6 @@ export function getAutoInjectEnv(appContext) {
|
|
11
11
|
return prev;
|
12
12
|
}, {});
|
13
13
|
}
|
14
|
+
export {
|
15
|
+
getAutoInjectEnv
|
16
|
+
};
|
@@ -5,13 +5,13 @@ const getPackageConfig = (appDirectory, packageJsonConfig) => {
|
|
5
5
|
const json = JSON.parse(fs.readFileSync(path.resolve(appDirectory, "./package.json"), "utf8"));
|
6
6
|
return json[packageJsonConfig !== null && packageJsonConfig !== void 0 ? packageJsonConfig : PACKAGE_JSON_CONFIG_NAME];
|
7
7
|
};
|
8
|
-
|
8
|
+
const addServerConfigToDeps = async (dependencies, appDirectory, serverConfigFile) => {
|
9
9
|
const serverConfig = await getServerConfig(appDirectory, serverConfigFile);
|
10
10
|
if (serverConfig) {
|
11
11
|
dependencies.push(serverConfig);
|
12
12
|
}
|
13
13
|
};
|
14
|
-
|
14
|
+
async function generateWatchFiles(appContext, configDir) {
|
15
15
|
const { appDirectory, configFile } = appContext;
|
16
16
|
const configPath = path.join(appDirectory, configDir || "");
|
17
17
|
const dependencies = getPackageConfig(appContext.appDirectory, appContext.packageName) ? [
|
@@ -24,3 +24,7 @@ export async function generateWatchFiles(appContext, configDir) {
|
|
24
24
|
...dependencies
|
25
25
|
];
|
26
26
|
}
|
27
|
+
export {
|
28
|
+
addServerConfigToDeps,
|
29
|
+
generateWatchFiles
|
30
|
+
};
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { chalk, inquirer } from "@modern-js/utils";
|
2
2
|
import { i18n, localeKeys } from "../locale";
|
3
|
-
|
3
|
+
const getSelectedEntries = async (entry, entrypoints) => {
|
4
4
|
const entryNames = entrypoints.map((e) => e.entryName);
|
5
5
|
if (!entry) {
|
6
6
|
return entryNames;
|
@@ -29,3 +29,6 @@ export const getSelectedEntries = async (entry, entrypoints) => {
|
|
29
29
|
});
|
30
30
|
return entry;
|
31
31
|
};
|
32
|
+
export {
|
33
|
+
getSelectedEntries
|
34
|
+
};
|
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
async function getServerInternalPlugins(api) {
|
2
2
|
const hookRunners = api.useHookRunners();
|
3
3
|
const { plugins: serverPlugins } = await hookRunners.collectServerPlugins({
|
4
4
|
plugins: []
|
@@ -10,3 +10,6 @@ export async function getServerInternalPlugins(api) {
|
|
10
10
|
});
|
11
11
|
return serverInternalPlugins;
|
12
12
|
}
|
13
|
+
export {
|
14
|
+
getServerInternalPlugins
|
15
|
+
};
|
@@ -1,8 +1,11 @@
|
|
1
1
|
import { prettyInstructions, logger } from "@modern-js/utils";
|
2
|
-
|
2
|
+
const printInstructions = async (hookRunners, appContext, config) => {
|
3
3
|
const message = prettyInstructions(appContext, config);
|
4
4
|
const { instructions } = await hookRunners.beforePrintInstructions({
|
5
5
|
instructions: message
|
6
6
|
});
|
7
7
|
logger.log(instructions);
|
8
8
|
};
|
9
|
+
export {
|
10
|
+
printInstructions
|
11
|
+
};
|