@modern-js/app-tools 2.3.1-alpha.2 → 3.0.0-beta.0
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +87 -0
- package/README.md +14 -18
- package/dist/js/modern/analyze/getServerRoutes.js +5 -2
- package/dist/js/modern/analyze/index.js +47 -46
- package/dist/js/modern/builder/builder-rspack/index.js +8 -0
- package/dist/js/modern/builder/builder-webpack/builderPlugins/compatModern.js +41 -0
- package/dist/js/modern/builder/builder-webpack/index.js +93 -0
- package/dist/js/modern/builder/{webpackPlugins/routerPlugin.js → builder-webpack/webpackPlugins/RouterPlugin.js} +4 -1
- package/dist/js/modern/builder/builder-webpack/webpackPlugins/index.js +1 -0
- package/dist/js/modern/builder/generator/createBuilderOptions.js +24 -0
- package/dist/js/modern/builder/generator/createBuilderProviderConfig.js +39 -0
- package/dist/js/modern/builder/generator/getBuilderTargets.js +21 -0
- package/dist/js/modern/builder/generator/index.js +53 -0
- package/dist/js/modern/builder/index.js +13 -133
- package/dist/js/modern/builder/{builderPlugins/compatModern.js → shared/builderPlugins/adapterModern.js} +102 -116
- package/dist/js/modern/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +27 -0
- package/dist/js/modern/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +34 -0
- package/dist/js/modern/builder/{share.js → shared/createCopyPattern.js} +0 -0
- package/dist/js/modern/builder/shared/index.js +3 -0
- package/dist/js/modern/builder/{loaders → shared/loaders}/serverModuleLoader.js +0 -0
- package/dist/js/modern/builder/shared/types.js +0 -0
- package/dist/js/modern/config/default.js +2 -2
- package/dist/js/modern/config/index.js +3 -8
- package/dist/js/modern/config/initialize/index.js +12 -0
- package/dist/js/modern/config/{initial → initialize}/inits.js +4 -2
- package/dist/js/modern/config/{initial → legacy}/createHtmlConfig.js +0 -0
- package/dist/js/modern/config/{initial → legacy}/createOutputConfig.js +0 -0
- package/dist/js/modern/config/{initial → legacy}/createSourceConfig.js +0 -0
- package/dist/js/modern/config/{initial → legacy}/createToolsConfig.js +0 -0
- package/dist/js/modern/config/{initial/transformNormalizedConfig.js → legacy/index.js} +4 -0
- package/dist/js/modern/index.js +18 -8
- package/dist/js/modern/initialize/index.js +36 -28
- package/dist/js/modern/locale/zh.js +1 -1
- package/dist/js/modern/types/utils.js +0 -0
- package/dist/js/node/analyze/getServerRoutes.js +3 -1
- package/dist/js/node/analyze/index.js +48 -47
- package/dist/js/node/builder/builder-rspack/index.js +31 -0
- package/dist/js/node/builder/builder-webpack/builderPlugins/compatModern.js +64 -0
- package/dist/js/node/builder/builder-webpack/index.js +118 -0
- package/dist/js/node/builder/{webpackPlugins/routerPlugin.js → builder-webpack/webpackPlugins/RouterPlugin.js} +10 -5
- package/dist/js/node/builder/builder-webpack/webpackPlugins/index.js +17 -0
- package/dist/js/node/builder/generator/createBuilderOptions.js +47 -0
- package/dist/js/node/builder/generator/createBuilderProviderConfig.js +60 -0
- package/dist/js/node/builder/generator/getBuilderTargets.js +39 -0
- package/dist/js/node/builder/generator/index.js +82 -0
- package/dist/js/node/builder/index.js +14 -123
- package/dist/js/node/builder/{builderPlugins/compatModern.js → shared/builderPlugins/adapterModern.js} +107 -120
- package/dist/js/node/builder/{webpackPlugins/htmlAsyncChunkPlugin.js → shared/bundlerPlugins/HtmlAsyncChunkPlugin.js} +17 -20
- package/dist/js/node/builder/{webpackPlugins/htmlBottomTemplate.js → shared/bundlerPlugins/HtmlBottomTemplate.js} +21 -24
- package/dist/js/node/builder/{share.js → shared/createCopyPattern.js} +3 -3
- package/dist/js/node/builder/shared/index.js +19 -0
- package/dist/js/node/builder/{loaders → shared/loaders}/serverModuleLoader.js +0 -0
- package/dist/js/node/builder/shared/types.js +15 -0
- package/dist/js/node/config/default.js +2 -2
- package/dist/js/node/config/index.js +4 -19
- package/dist/js/node/config/{initial → initialize}/index.js +10 -16
- package/dist/js/node/config/{initial → initialize}/inits.js +4 -2
- package/dist/js/node/config/{initial → legacy}/createHtmlConfig.js +0 -0
- package/dist/js/node/config/{initial → legacy}/createOutputConfig.js +0 -0
- package/dist/js/node/config/{initial → legacy}/createSourceConfig.js +0 -0
- package/dist/js/node/config/{initial → legacy}/createToolsConfig.js +0 -0
- package/dist/js/node/config/{initial/transformNormalizedConfig.js → legacy/index.js} +8 -3
- package/dist/js/node/index.js +18 -8
- package/dist/js/node/initialize/index.js +35 -28
- package/dist/js/node/locale/zh.js +1 -1
- package/dist/js/node/types/utils.js +15 -0
- package/dist/js/treeshaking/analyze/generateCode.js +14 -14
- package/dist/js/treeshaking/analyze/getBundleEntry.js +2 -2
- package/dist/js/treeshaking/analyze/getClientRoutes/getRoutes.js +1 -1
- package/dist/js/treeshaking/analyze/getClientRoutes/getRoutesLegacy.js +1 -1
- package/dist/js/treeshaking/analyze/getFileSystemEntry.js +1 -1
- package/dist/js/treeshaking/analyze/getServerRoutes.js +8 -6
- package/dist/js/treeshaking/analyze/index.js +142 -137
- package/dist/js/treeshaking/analyze/nestedRoutes.js +5 -5
- package/dist/js/treeshaking/analyze/templates.js +6 -6
- package/dist/js/treeshaking/analyze/utils.js +3 -3
- package/dist/js/treeshaking/builder/builder-rspack/index.js +6 -0
- package/dist/js/treeshaking/builder/builder-webpack/builderPlugins/compatModern.js +64 -0
- package/dist/js/treeshaking/builder/builder-webpack/index.js +301 -0
- package/dist/js/treeshaking/builder/{webpackPlugins/routerPlugin.js → builder-webpack/webpackPlugins/RouterPlugin.js} +6 -3
- package/dist/js/treeshaking/builder/builder-webpack/webpackPlugins/index.js +1 -0
- package/dist/js/treeshaking/builder/generator/createBuilderOptions.js +41 -0
- package/dist/js/treeshaking/builder/generator/createBuilderProviderConfig.js +70 -0
- package/dist/js/treeshaking/builder/generator/getBuilderTargets.js +16 -0
- package/dist/js/treeshaking/builder/generator/index.js +199 -0
- package/dist/js/treeshaking/builder/index.js +29 -228
- package/dist/js/treeshaking/builder/{builderPlugins/compatModern.js → shared/builderPlugins/adapterModern.js} +138 -142
- package/dist/js/treeshaking/builder/{webpackPlugins/htmlAsyncChunkPlugin.js → shared/bundlerPlugins/HtmlAsyncChunkPlugin.js} +0 -0
- package/dist/js/treeshaking/builder/{webpackPlugins/htmlBottomTemplate.js → shared/bundlerPlugins/HtmlBottomTemplate.js} +2 -2
- package/dist/js/treeshaking/builder/{share.js → shared/createCopyPattern.js} +0 -0
- package/dist/js/treeshaking/builder/shared/index.js +3 -0
- package/dist/js/treeshaking/builder/{loaders → shared/loaders}/serverModuleLoader.js +0 -0
- package/dist/js/treeshaking/builder/shared/types.js +1 -0
- package/dist/js/treeshaking/commands/dev.js +2 -2
- package/dist/js/treeshaking/commands/serve.js +2 -2
- package/dist/js/treeshaking/config/default.js +2 -2
- package/dist/js/treeshaking/config/index.js +3 -3
- package/dist/js/treeshaking/config/initialize/index.js +10 -0
- package/dist/js/treeshaking/config/{initial → initialize}/inits.js +6 -4
- package/dist/js/treeshaking/config/legacy/createHtmlConfig.js +19 -0
- package/dist/js/treeshaking/config/{initial → legacy}/createOutputConfig.js +1 -1
- package/dist/js/treeshaking/config/{initial → legacy}/createSourceConfig.js +1 -1
- package/dist/js/treeshaking/config/{initial → legacy}/createToolsConfig.js +1 -1
- package/dist/js/treeshaking/config/{initial/transformNormalizedConfig.js → legacy/index.js} +4 -1
- package/dist/js/treeshaking/index.js +19 -12
- package/dist/js/treeshaking/initialize/index.js +36 -28
- package/dist/js/treeshaking/locale/zh.js +1 -1
- package/dist/js/treeshaking/types/utils.js +1 -0
- package/dist/js/treeshaking/utils/config.js +2 -2
- package/dist/js/treeshaking/utils/getServerInternalPlugins.js +2 -2
- package/dist/types/analyze/generateCode.d.ts +1 -1
- package/dist/types/analyze/getBundleEntry.d.ts +1 -1
- package/dist/types/analyze/getFileSystemEntry.d.ts +1 -1
- package/dist/types/analyze/getHtmlTemplate.d.ts +2 -2
- package/dist/types/analyze/getServerRoutes.d.ts +1 -1
- package/dist/types/analyze/index.d.ts +5 -1
- package/dist/types/builder/builder-rspack/index.d.ts +2 -0
- package/dist/types/builder/{builderPlugins → builder-webpack/builderPlugins}/compatModern.d.ts +2 -2
- package/dist/types/builder/builder-webpack/index.d.ts +4 -0
- package/dist/types/builder/{webpackPlugins/routerPlugin.d.ts → builder-webpack/webpackPlugins/RouterPlugin.d.ts} +1 -1
- package/dist/types/builder/builder-webpack/webpackPlugins/index.d.ts +1 -0
- package/dist/types/builder/generator/createBuilderOptions.d.ts +3 -0
- package/dist/types/builder/generator/createBuilderProviderConfig.d.ts +2 -0
- package/dist/types/builder/generator/getBuilderTargets.d.ts +3 -0
- package/dist/types/builder/generator/index.d.ts +17 -0
- package/dist/types/builder/index.d.ts +1 -18
- package/dist/types/builder/shared/builderPlugins/adapterModern.d.ts +13 -0
- package/dist/types/builder/{webpackPlugins/htmlAsyncChunkPlugin.d.ts → shared/bundlerPlugins/HtmlAsyncChunkPlugin.d.ts} +2 -1
- package/dist/types/builder/{webpackPlugins/htmlBottomTemplate.d.ts → shared/bundlerPlugins/HtmlBottomTemplate.d.ts} +2 -1
- package/dist/types/builder/{share.d.ts → shared/createCopyPattern.d.ts} +1 -1
- package/dist/types/builder/shared/index.d.ts +3 -0
- package/dist/types/builder/shared/loaders/serverModuleLoader.d.ts +4 -0
- package/dist/types/builder/shared/types.d.ts +16 -0
- package/dist/types/commands/build.d.ts +1 -1
- package/dist/types/commands/deploy.d.ts +1 -1
- package/dist/types/commands/dev.d.ts +1 -1
- package/dist/types/commands/inspect.d.ts +1 -1
- package/dist/types/commands/serve.d.ts +1 -1
- package/dist/types/config/default.d.ts +1 -1
- package/dist/types/config/index.d.ts +3 -2
- package/dist/types/config/initialize/index.d.ts +2 -0
- package/dist/types/config/{initial → initialize}/inits.d.ts +3 -3
- package/dist/types/config/{initial → legacy}/createHtmlConfig.d.ts +1 -1
- package/dist/types/config/{initial → legacy}/createOutputConfig.d.ts +1 -1
- package/dist/types/config/{initial → legacy}/createSourceConfig.d.ts +1 -1
- package/dist/types/config/{initial → legacy}/createToolsConfig.d.ts +1 -1
- package/dist/types/config/legacy/index.d.ts +3 -0
- package/dist/types/defineConfig.d.ts +2 -2
- package/dist/types/index.d.ts +7 -3
- package/dist/types/initialize/index.d.ts +6 -2
- package/dist/types/types/config/deploy.d.ts +1 -2
- package/dist/types/types/config/dev.d.ts +2 -3
- package/dist/types/types/config/experiments.d.ts +1 -2
- package/dist/types/types/config/html.d.ts +5 -3
- package/dist/types/types/config/index.d.ts +41 -48
- package/dist/types/types/config/output.d.ts +8 -3
- package/dist/types/types/config/performance.d.ts +6 -3
- package/dist/types/types/config/security.d.ts +3 -3
- package/dist/types/types/config/source.d.ts +7 -3
- package/dist/types/types/config/tools.d.ts +10 -4
- package/dist/types/types/hooks.d.ts +6 -4
- package/dist/types/types/index.d.ts +19 -7
- package/dist/types/types/utils.d.ts +7 -0
- package/dist/types/utils/config.d.ts +1 -1
- package/dist/types/utils/getServerInternalPlugins.d.ts +1 -1
- package/dist/types/utils/printInstructions.d.ts +1 -1
- package/package.json +34 -25
- package/dist/js/modern/builder/webpackPlugins/htmlAsyncChunkPlugin.js +0 -30
- package/dist/js/modern/builder/webpackPlugins/htmlBottomTemplate.js +0 -37
- package/dist/js/modern/config/initial/index.js +0 -16
- package/dist/js/treeshaking/config/initial/createHtmlConfig.js +0 -19
- package/dist/js/treeshaking/config/initial/index.js +0 -12
- package/dist/types/builder/loaders/serverModuleLoader.d.ts +0 -3
- package/dist/types/config/initial/index.d.ts +0 -4
- package/dist/types/config/initial/transformNormalizedConfig.d.ts +0 -2
@@ -44,19 +44,21 @@ import {
|
|
44
44
|
isDevCommand
|
45
45
|
} from "@modern-js/utils";
|
46
46
|
import { legacySchema, schema } from "../schema";
|
47
|
-
import { transformNormalizedConfig } from "../config/initial/transformNormalizedConfig";
|
48
47
|
import {
|
49
48
|
checkIsLegacyConfig,
|
50
49
|
createDefaultConfig,
|
51
|
-
createLegacyDefaultConfig
|
50
|
+
createLegacyDefaultConfig,
|
51
|
+
transformNormalizedConfig
|
52
52
|
} from "../config";
|
53
|
-
var initialize_default = (
|
53
|
+
var initialize_default = ({
|
54
|
+
bundler
|
55
|
+
}) => ({
|
54
56
|
name: "@modern-js/plugin-initialize",
|
55
57
|
setup(api) {
|
56
58
|
const config = () => {
|
57
59
|
const appContext = api.useAppContext();
|
58
60
|
const userConfig = api.useConfigContext();
|
59
|
-
return checkIsLegacyConfig(userConfig) ? createLegacyDefaultConfig(appContext) : createDefaultConfig(appContext);
|
61
|
+
return checkIsLegacyConfig(userConfig) ? createLegacyDefaultConfig(appContext) : createDefaultConfig(appContext, bundler);
|
60
62
|
};
|
61
63
|
const validateSchema = () => {
|
62
64
|
const userConfig = api.useConfigContext();
|
@@ -81,35 +83,41 @@ var initialize_default = () => ({
|
|
81
83
|
});
|
82
84
|
api.setAppContext(appContext);
|
83
85
|
const normalizedConfig = checkIsLegacyConfig(resolved) ? transformNormalizedConfig(resolved) : resolved;
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
}
|
86
|
+
resolved._raw = userConfig;
|
87
|
+
resolved.server = __spreadProps(__spreadValues({}, normalizedConfig.server || {}), {
|
88
|
+
port
|
89
|
+
});
|
90
|
+
resolved.autoLoadPlugins = normalizedConfig.autoLoadPlugins || false;
|
91
|
+
stabilizeConfig(resolved, normalizedConfig, [
|
92
|
+
"source",
|
93
|
+
"bff",
|
94
|
+
"dev",
|
95
|
+
"html",
|
96
|
+
"output",
|
97
|
+
"tools",
|
98
|
+
"testing",
|
99
|
+
"plugins",
|
100
|
+
"builderPlugins",
|
101
|
+
"runtime",
|
102
|
+
"runtimeByEntries",
|
103
|
+
"deploy",
|
104
|
+
"performance"
|
105
|
+
]);
|
106
|
+
if (bundler === "webpack") {
|
107
|
+
resolved.security = normalizedConfig.security || {};
|
108
|
+
resolved.experiments = normalizedConfig.experiments;
|
109
|
+
}
|
110
|
+
return { resolved };
|
108
111
|
});
|
109
112
|
}
|
110
113
|
};
|
111
114
|
}
|
112
115
|
});
|
116
|
+
function stabilizeConfig(resolve, config, keys) {
|
117
|
+
keys.forEach((key) => {
|
118
|
+
resolve[key] = config[key] || {};
|
119
|
+
});
|
120
|
+
}
|
113
121
|
function getServerPort(config) {
|
114
122
|
return __async(this, null, function* () {
|
115
123
|
const prodPort = config.server.port || 8080;
|
@@ -17,7 +17,7 @@ const ZH_LOCALE = {
|
|
17
17
|
serve: { describe: "应用启动命令" },
|
18
18
|
deploy: { describe: "部署应用命令" },
|
19
19
|
new: {
|
20
|
-
describe: "
|
20
|
+
describe: "Web App 项目中执行生成器",
|
21
21
|
debug: "开启 Debug 模式,打印调试日志信息",
|
22
22
|
config: "生成器运行默认配置(JSON 字符串)",
|
23
23
|
distTag: "生成器使用特殊的 npm Tag 版本",
|
File without changes
|
@@ -119,7 +119,7 @@ const collectHtmlRoutes = (entrypoints, appContext, config) => {
|
|
119
119
|
const {
|
120
120
|
html: { disableHtmlFolder },
|
121
121
|
output: { distPath: { html: htmlPath } = {} },
|
122
|
-
server: { baseUrl, routes, ssr, ssrByEntries }
|
122
|
+
server: { baseUrl, routes, ssr, ssrByEntries, worker }
|
123
123
|
} = config;
|
124
124
|
const { packageName } = appContext;
|
125
125
|
let htmlRoutes = entrypoints.reduce(
|
@@ -131,6 +131,7 @@ const collectHtmlRoutes = (entrypoints, appContext, config) => {
|
|
131
131
|
packageName
|
132
132
|
);
|
133
133
|
const isSSR = Boolean(entryOptions);
|
134
|
+
const isWorker = Boolean(worker);
|
134
135
|
const { resHeaders } = (routes == null ? void 0 : routes[entryName]) || {};
|
135
136
|
let route = {
|
136
137
|
urlPath: `/${entryName === import_utils.MAIN_ENTRY_NAME ? "" : entryName}`,
|
@@ -143,6 +144,7 @@ const collectHtmlRoutes = (entrypoints, appContext, config) => {
|
|
143
144
|
isSPA: true,
|
144
145
|
isSSR,
|
145
146
|
responseHeaders: resHeaders,
|
147
|
+
worker: isWorker ? `${import_utils.SERVER_WORKER_BUNDLE_DIRECTORY}/${entryName}.js` : void 0,
|
146
148
|
bundle: isSSR ? `${import_utils.SERVER_BUNDLE_DIRECTORY}/${entryName}.js` : void 0
|
147
149
|
};
|
148
150
|
if (routes == null ? void 0 : routes.hasOwnProperty(entryName)) {
|
@@ -66,16 +66,18 @@ module.exports = __toCommonJS(analyze_exports);
|
|
66
66
|
var path = __toESM(require("path"));
|
67
67
|
var import_utils = require("@modern-js/utils");
|
68
68
|
var import_lodash = require("@modern-js/utils/lodash");
|
69
|
-
var import_builder = require("../builder");
|
70
69
|
var import_printInstructions = require("../utils/printInstructions");
|
71
70
|
var import_routes = require("../utils/routes");
|
72
71
|
var import_config = require("../utils/config");
|
73
72
|
var import_getSelectedEntries = require("../utils/getSelectedEntries");
|
74
73
|
var import_config2 = require("../config");
|
74
|
+
var import_builder = require("../builder");
|
75
75
|
var import_utils2 = require("./utils");
|
76
76
|
var import_constants = require("./constants");
|
77
77
|
const debug = (0, import_utils.createDebugger)("plugin-analyze");
|
78
|
-
var analyze_default = (
|
78
|
+
var analyze_default = ({
|
79
|
+
bundler
|
80
|
+
}) => ({
|
79
81
|
name: "@modern-js/plugin-analyze",
|
80
82
|
setup: (api) => {
|
81
83
|
let pagesDir = [];
|
@@ -167,56 +169,55 @@ var analyze_default = () => ({
|
|
167
169
|
if (buildCommands.includes(command)) {
|
168
170
|
let _b;
|
169
171
|
const normalizedConfig = api.useResolvedConfigContext();
|
170
|
-
const
|
172
|
+
const createBuilderForModern = yield (0, import_builder.createBuilderGenerator)(bundler);
|
173
|
+
const builder = yield createBuilderForModern({
|
171
174
|
normalizedConfig,
|
172
175
|
appContext,
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
});
|
180
|
-
},
|
181
|
-
onAfterBuild(_0) {
|
182
|
-
return __async(this, arguments, function* ({ stats }) {
|
183
|
-
const hookRunners2 = api.useHookRunners();
|
184
|
-
yield hookRunners2.afterBuild({ stats });
|
185
|
-
yield (0, import_config.emitResolvedConfig)(
|
186
|
-
appContext.appDirectory,
|
187
|
-
normalizedConfig
|
188
|
-
);
|
176
|
+
onBeforeBuild(_0) {
|
177
|
+
return __async(this, arguments, function* ({ bundlerConfigs }) {
|
178
|
+
const hookRunners2 = api.useHookRunners();
|
179
|
+
yield (0, import_routes.generateRoutes)(appContext);
|
180
|
+
yield hookRunners2.beforeBuild({
|
181
|
+
bundlerConfigs
|
189
182
|
});
|
190
|
-
}
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
183
|
+
});
|
184
|
+
},
|
185
|
+
onAfterBuild(_0) {
|
186
|
+
return __async(this, arguments, function* ({ stats }) {
|
187
|
+
const hookRunners2 = api.useHookRunners();
|
188
|
+
yield hookRunners2.afterBuild({ stats });
|
189
|
+
yield (0, import_config.emitResolvedConfig)(
|
190
|
+
appContext.appDirectory,
|
191
|
+
normalizedConfig
|
192
|
+
);
|
193
|
+
});
|
194
|
+
},
|
195
|
+
onDevCompileDone(_0) {
|
196
|
+
return __async(this, arguments, function* ({ isFirstCompile }) {
|
197
|
+
const hookRunners2 = api.useHookRunners();
|
198
|
+
if (process.stdout.isTTY || isFirstCompile) {
|
199
|
+
hookRunners2.afterDev();
|
200
|
+
if (isFirstCompile) {
|
201
|
+
(0, import_printInstructions.printInstructions)(hookRunners2, appContext, normalizedConfig);
|
203
202
|
}
|
203
|
+
}
|
204
|
+
});
|
205
|
+
},
|
206
|
+
onBeforeCreateCompiler(_0) {
|
207
|
+
return __async(this, arguments, function* ({ bundlerConfigs }) {
|
208
|
+
const hookRunners2 = api.useHookRunners();
|
209
|
+
yield hookRunners2.beforeCreateCompiler({
|
210
|
+
bundlerConfigs
|
204
211
|
});
|
205
|
-
}
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
});
|
213
|
-
},
|
214
|
-
onAfterCreateCompiler(_0) {
|
215
|
-
return __async(this, arguments, function* ({ compiler }) {
|
216
|
-
const hookRunners2 = api.useHookRunners();
|
217
|
-
yield hookRunners2.afterCreateCompiler({ compiler });
|
212
|
+
});
|
213
|
+
},
|
214
|
+
onAfterCreateCompiler(_0) {
|
215
|
+
return __async(this, arguments, function* ({ compiler }) {
|
216
|
+
const hookRunners2 = api.useHookRunners();
|
217
|
+
yield hookRunners2.afterCreateCompiler({
|
218
|
+
compiler
|
218
219
|
});
|
219
|
-
}
|
220
|
+
});
|
220
221
|
}
|
221
222
|
});
|
222
223
|
builder.addPlugins(resolvedConfig.builderPlugins);
|
@@ -259,7 +260,7 @@ var analyze_default = () => ({
|
|
259
260
|
},
|
260
261
|
resolvedConfig({ resolved }) {
|
261
262
|
const appContext = api.useAppContext();
|
262
|
-
const config = (0, import_config2.initialNormalizedConfig)(resolved, appContext);
|
263
|
+
const config = (0, import_config2.initialNormalizedConfig)(resolved, appContext, bundler);
|
263
264
|
return {
|
264
265
|
resolved: config
|
265
266
|
};
|
@@ -0,0 +1,31 @@
|
|
1
|
+
var __defProp = Object.defineProperty;
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
5
|
+
var __export = (target, all) => {
|
6
|
+
for (var name in all)
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
8
|
+
};
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
11
|
+
for (let key of __getOwnPropNames(from))
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
14
|
+
}
|
15
|
+
return to;
|
16
|
+
};
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
18
|
+
var builder_rspack_exports = {};
|
19
|
+
__export(builder_rspack_exports, {
|
20
|
+
createRspackBuilderForModern: () => createRspackBuilderForModern
|
21
|
+
});
|
22
|
+
module.exports = __toCommonJS(builder_rspack_exports);
|
23
|
+
var import_builder_rspack_provider = require("@modern-js/builder-rspack-provider");
|
24
|
+
var import_generator = require("../generator");
|
25
|
+
function createRspackBuilderForModern(options) {
|
26
|
+
return (0, import_generator.generateBuilder)(options, import_builder_rspack_provider.builderRspackProvider);
|
27
|
+
}
|
28
|
+
// Annotate the CommonJS export names for ESM import in node:
|
29
|
+
0 && (module.exports = {
|
30
|
+
createRspackBuilderForModern
|
31
|
+
});
|
@@ -0,0 +1,64 @@
|
|
1
|
+
var __defProp = Object.defineProperty;
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
5
|
+
var __export = (target, all) => {
|
6
|
+
for (var name in all)
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
8
|
+
};
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
11
|
+
for (let key of __getOwnPropNames(from))
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
14
|
+
}
|
15
|
+
return to;
|
16
|
+
};
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
18
|
+
var compatModern_exports = {};
|
19
|
+
__export(compatModern_exports, {
|
20
|
+
PluginCompatModern: () => PluginCompatModern
|
21
|
+
});
|
22
|
+
module.exports = __toCommonJS(compatModern_exports);
|
23
|
+
var import_path = require("path");
|
24
|
+
var import_shared = require("../../shared");
|
25
|
+
var import_webpackPlugins = require("../webpackPlugins");
|
26
|
+
const PluginCompatModern = (options) => ({
|
27
|
+
name: "builder-plugin-compat-modern",
|
28
|
+
setup(api) {
|
29
|
+
const { normalizedConfig: modernConfig, appContext } = options;
|
30
|
+
api.modifyWebpackChain((chain, { CHAIN_ID }) => {
|
31
|
+
var _a;
|
32
|
+
chain.resolve.modules.add("node_modules").add((0, import_path.join)(api.context.rootPath, "node_modules"));
|
33
|
+
if (chain.plugins.has(CHAIN_ID.PLUGIN.COPY)) {
|
34
|
+
const defaultCopyPattern = (0, import_shared.createCopyPattern)(
|
35
|
+
appContext,
|
36
|
+
modernConfig,
|
37
|
+
"public",
|
38
|
+
chain
|
39
|
+
);
|
40
|
+
chain.plugin(CHAIN_ID.PLUGIN.COPY).tap((args) => {
|
41
|
+
var _a2;
|
42
|
+
return [
|
43
|
+
{
|
44
|
+
patterns: [...((_a2 = args[0]) == null ? void 0 : _a2.patterns) || [], defaultCopyPattern]
|
45
|
+
}
|
46
|
+
];
|
47
|
+
});
|
48
|
+
}
|
49
|
+
const { entrypoints } = appContext;
|
50
|
+
const existNestedRoutes = entrypoints.some(
|
51
|
+
(entrypoint) => entrypoint.nestedRoutesEntry
|
52
|
+
);
|
53
|
+
const routerConfig = (_a = modernConfig == null ? void 0 : modernConfig.runtime) == null ? void 0 : _a.router;
|
54
|
+
const routerManifest = Boolean(routerConfig == null ? void 0 : routerConfig.manifest);
|
55
|
+
if (existNestedRoutes || routerManifest) {
|
56
|
+
chain.plugin("route-plugin").use(import_webpackPlugins.RouterPlugin);
|
57
|
+
}
|
58
|
+
});
|
59
|
+
}
|
60
|
+
});
|
61
|
+
// Annotate the CommonJS export names for ESM import in node:
|
62
|
+
0 && (module.exports = {
|
63
|
+
PluginCompatModern
|
64
|
+
});
|
@@ -0,0 +1,118 @@
|
|
1
|
+
var __create = Object.create;
|
2
|
+
var __defProp = Object.defineProperty;
|
3
|
+
var __defProps = Object.defineProperties;
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
5
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
7
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
8
|
+
var __getProtoOf = Object.getPrototypeOf;
|
9
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
10
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
11
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
12
|
+
var __spreadValues = (a, b) => {
|
13
|
+
for (var prop in b || (b = {}))
|
14
|
+
if (__hasOwnProp.call(b, prop))
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
16
|
+
if (__getOwnPropSymbols)
|
17
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
18
|
+
if (__propIsEnum.call(b, prop))
|
19
|
+
__defNormalProp(a, prop, b[prop]);
|
20
|
+
}
|
21
|
+
return a;
|
22
|
+
};
|
23
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
24
|
+
var __export = (target, all) => {
|
25
|
+
for (var name in all)
|
26
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
27
|
+
};
|
28
|
+
var __copyProps = (to, from, except, desc) => {
|
29
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
30
|
+
for (let key of __getOwnPropNames(from))
|
31
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
32
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
33
|
+
}
|
34
|
+
return to;
|
35
|
+
};
|
36
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
37
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
38
|
+
mod
|
39
|
+
));
|
40
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
41
|
+
var __async = (__this, __arguments, generator) => {
|
42
|
+
return new Promise((resolve, reject) => {
|
43
|
+
var fulfilled = (value) => {
|
44
|
+
try {
|
45
|
+
step(generator.next(value));
|
46
|
+
} catch (e) {
|
47
|
+
reject(e);
|
48
|
+
}
|
49
|
+
};
|
50
|
+
var rejected = (value) => {
|
51
|
+
try {
|
52
|
+
step(generator.throw(value));
|
53
|
+
} catch (e) {
|
54
|
+
reject(e);
|
55
|
+
}
|
56
|
+
};
|
57
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
58
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
59
|
+
});
|
60
|
+
};
|
61
|
+
var builder_webpack_exports = {};
|
62
|
+
__export(builder_webpack_exports, {
|
63
|
+
createWebpackBuilderForModern: () => createWebpackBuilderForModern
|
64
|
+
});
|
65
|
+
module.exports = __toCommonJS(builder_webpack_exports);
|
66
|
+
var import_builder_webpack_provider = require("@modern-js/builder-webpack-provider");
|
67
|
+
var import_utils = require("@modern-js/utils");
|
68
|
+
var import_shared = require("../shared");
|
69
|
+
var import_generator = require("../generator");
|
70
|
+
var import_compatModern = require("./builderPlugins/compatModern");
|
71
|
+
function createWebpackBuilderForModern(options) {
|
72
|
+
return (0, import_generator.generateBuilder)(options, import_builder_webpack_provider.builderWebpackProvider, {
|
73
|
+
modifyBuilderConfig(config) {
|
74
|
+
modifyOutputConfig(config, options.appContext);
|
75
|
+
},
|
76
|
+
modifyBuilderInstance(builder) {
|
77
|
+
return __async(this, null, function* () {
|
78
|
+
yield applyBuilderPlugins(builder, options);
|
79
|
+
});
|
80
|
+
}
|
81
|
+
});
|
82
|
+
}
|
83
|
+
function modifyOutputConfig(config, appContext) {
|
84
|
+
config.output = createOutputConfig(config, appContext);
|
85
|
+
function createOutputConfig(config2, appContext2) {
|
86
|
+
const defaultCopyPattern = (0, import_shared.createCopyPattern)(appContext2, config2, "upload");
|
87
|
+
const { copy } = config2.output;
|
88
|
+
const copyOptions = Array.isArray(copy) ? copy : copy == null ? void 0 : copy.patterns;
|
89
|
+
const builderCopy = [...copyOptions || [], defaultCopyPattern];
|
90
|
+
return __spreadProps(__spreadValues({}, config2.output), {
|
91
|
+
copy: builderCopy
|
92
|
+
});
|
93
|
+
}
|
94
|
+
}
|
95
|
+
function applyBuilderPlugins(builder, options) {
|
96
|
+
return __async(this, null, function* () {
|
97
|
+
const { normalizedConfig } = options;
|
98
|
+
if (!normalizedConfig.output.disableNodePolyfill) {
|
99
|
+
const { PluginNodePolyfill } = yield Promise.resolve().then(() => __toESM(require("@modern-js/builder-plugin-node-polyfill")));
|
100
|
+
builder.addPlugins([PluginNodePolyfill()]);
|
101
|
+
}
|
102
|
+
if (normalizedConfig.tools.esbuild) {
|
103
|
+
const { esbuild: esbuildOptions } = normalizedConfig.tools;
|
104
|
+
const { PluginEsbuild } = yield Promise.resolve().then(() => __toESM(require("@modern-js/builder-plugin-esbuild")));
|
105
|
+
builder.addPlugins([
|
106
|
+
PluginEsbuild({
|
107
|
+
loader: false,
|
108
|
+
minimize: (0, import_utils.applyOptionsChain)({}, esbuildOptions)
|
109
|
+
})
|
110
|
+
]);
|
111
|
+
}
|
112
|
+
builder.addPlugins([(0, import_compatModern.PluginCompatModern)(options)]);
|
113
|
+
});
|
114
|
+
}
|
115
|
+
// Annotate the CommonJS export names for ESM import in node:
|
116
|
+
0 && (module.exports = {
|
117
|
+
createWebpackBuilderForModern
|
118
|
+
});
|
@@ -41,11 +41,11 @@ var __async = (__this, __arguments, generator) => {
|
|
41
41
|
step((generator = generator.apply(__this, __arguments)).next());
|
42
42
|
});
|
43
43
|
};
|
44
|
-
var
|
45
|
-
__export(
|
46
|
-
|
44
|
+
var RouterPlugin_exports = {};
|
45
|
+
__export(RouterPlugin_exports, {
|
46
|
+
RouterPlugin: () => RouterPlugin
|
47
47
|
});
|
48
|
-
module.exports = __toCommonJS(
|
48
|
+
module.exports = __toCommonJS(RouterPlugin_exports);
|
49
49
|
var import_path = __toESM(require("path"));
|
50
50
|
var import_utils = require("@modern-js/utils");
|
51
51
|
const PLUGIN_NAME = "ModernjsRoutePlugin";
|
@@ -55,6 +55,9 @@ class RouterPlugin {
|
|
55
55
|
if (target === "node" || Array.isArray(target) && target.includes("node")) {
|
56
56
|
return;
|
57
57
|
}
|
58
|
+
if (target === "webworker" || Array.isArray(target) && target.includes("webworker")) {
|
59
|
+
return;
|
60
|
+
}
|
58
61
|
const { webpack } = compiler;
|
59
62
|
const { Compilation, sources } = webpack;
|
60
63
|
const { RawSource } = sources;
|
@@ -132,4 +135,6 @@ class RouterPlugin {
|
|
132
135
|
}
|
133
136
|
}
|
134
137
|
// Annotate the CommonJS export names for ESM import in node:
|
135
|
-
0 && (module.exports = {
|
138
|
+
0 && (module.exports = {
|
139
|
+
RouterPlugin
|
140
|
+
});
|
@@ -0,0 +1,17 @@
|
|
1
|
+
var __defProp = Object.defineProperty;
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
7
|
+
for (let key of __getOwnPropNames(from))
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
10
|
+
}
|
11
|
+
return to;
|
12
|
+
};
|
13
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
15
|
+
var webpackPlugins_exports = {};
|
16
|
+
module.exports = __toCommonJS(webpackPlugins_exports);
|
17
|
+
__reExport(webpackPlugins_exports, require("./RouterPlugin"), module.exports);
|
@@ -0,0 +1,47 @@
|
|
1
|
+
var __defProp = Object.defineProperty;
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
5
|
+
var __export = (target, all) => {
|
6
|
+
for (var name in all)
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
8
|
+
};
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
11
|
+
for (let key of __getOwnPropNames(from))
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
14
|
+
}
|
15
|
+
return to;
|
16
|
+
};
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
18
|
+
var createBuilderOptions_exports = {};
|
19
|
+
__export(createBuilderOptions_exports, {
|
20
|
+
createBuilderOptions: () => createBuilderOptions
|
21
|
+
});
|
22
|
+
module.exports = __toCommonJS(createBuilderOptions_exports);
|
23
|
+
function createBuilderOptions(target, appContext) {
|
24
|
+
const entries = {};
|
25
|
+
const { entrypoints = [], checkedEntries } = appContext;
|
26
|
+
for (const { entryName, entry } of entrypoints) {
|
27
|
+
if (checkedEntries && !checkedEntries.includes(entryName)) {
|
28
|
+
continue;
|
29
|
+
}
|
30
|
+
if (entryName in entries) {
|
31
|
+
entries[entryName].push(entry);
|
32
|
+
} else {
|
33
|
+
entries[entryName] = [entry];
|
34
|
+
}
|
35
|
+
}
|
36
|
+
return {
|
37
|
+
cwd: appContext.appDirectory,
|
38
|
+
target,
|
39
|
+
configPath: appContext.configFile || void 0,
|
40
|
+
entry: entries,
|
41
|
+
framework: appContext.metaName
|
42
|
+
};
|
43
|
+
}
|
44
|
+
// Annotate the CommonJS export names for ESM import in node:
|
45
|
+
0 && (module.exports = {
|
46
|
+
createBuilderOptions
|
47
|
+
});
|
@@ -0,0 +1,60 @@
|
|
1
|
+
var __defProp = Object.defineProperty;
|
2
|
+
var __defProps = Object.defineProperties;
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
6
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
8
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
9
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
10
|
+
var __spreadValues = (a, b) => {
|
11
|
+
for (var prop in b || (b = {}))
|
12
|
+
if (__hasOwnProp.call(b, prop))
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
14
|
+
if (__getOwnPropSymbols)
|
15
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
16
|
+
if (__propIsEnum.call(b, prop))
|
17
|
+
__defNormalProp(a, prop, b[prop]);
|
18
|
+
}
|
19
|
+
return a;
|
20
|
+
};
|
21
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
22
|
+
var __export = (target, all) => {
|
23
|
+
for (var name in all)
|
24
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
25
|
+
};
|
26
|
+
var __copyProps = (to, from, except, desc) => {
|
27
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
28
|
+
for (let key of __getOwnPropNames(from))
|
29
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
30
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
31
|
+
}
|
32
|
+
return to;
|
33
|
+
};
|
34
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
35
|
+
var createBuilderProviderConfig_exports = {};
|
36
|
+
__export(createBuilderProviderConfig_exports, {
|
37
|
+
createBuilderProviderConfig: () => createBuilderProviderConfig
|
38
|
+
});
|
39
|
+
module.exports = __toCommonJS(createBuilderProviderConfig_exports);
|
40
|
+
function createBuilderProviderConfig(resolveConfig, appContext, modifyBuilderConfig) {
|
41
|
+
const htmlConfig = __spreadValues({}, resolveConfig.html);
|
42
|
+
if (!htmlConfig.template) {
|
43
|
+
htmlConfig.templateByEntries = __spreadValues(__spreadValues({}, htmlConfig.templateByEntries), appContext.htmlTemplates);
|
44
|
+
}
|
45
|
+
const config = __spreadProps(__spreadValues({}, resolveConfig), {
|
46
|
+
dev: __spreadProps(__spreadValues({}, resolveConfig.dev), {
|
47
|
+
port: appContext.port
|
48
|
+
}),
|
49
|
+
html: htmlConfig,
|
50
|
+
output: __spreadProps(__spreadValues({}, resolveConfig.output), {
|
51
|
+
cleanDistPath: false
|
52
|
+
})
|
53
|
+
});
|
54
|
+
modifyBuilderConfig == null ? void 0 : modifyBuilderConfig(config);
|
55
|
+
return config;
|
56
|
+
}
|
57
|
+
// Annotate the CommonJS export names for ESM import in node:
|
58
|
+
0 && (module.exports = {
|
59
|
+
createBuilderProviderConfig
|
60
|
+
});
|