@modern-js/app-tools 2.35.0 → 2.35.1
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 +1 -0
- package/dist/cjs/analyze/generateCode.js +3 -4
- package/dist/cjs/analyze/getFileSystemEntry.js +1 -2
- package/dist/cjs/analyze/getServerRoutes.js +4 -5
- package/dist/cjs/analyze/nestedRoutes.js +11 -2
- package/dist/cjs/analyze/templates.js +4 -4
- package/dist/cjs/builder/generator/createBuilderProviderConfig.js +1 -2
- package/dist/cjs/builder/index.js +1 -1
- package/dist/cjs/builder/shared/builderPlugins/adapterHtml.js +4 -20
- package/dist/cjs/builder/shared/builderPlugins/adapterSSR.js +12 -14
- package/dist/cjs/builder/shared/bundlerPlugins/RouterPlugin.js +2 -2
- package/dist/cjs/commands/build.js +2 -3
- package/dist/cjs/commands/inspect.js +1 -2
- package/dist/cjs/commands/serve.js +3 -3
- package/dist/cjs/index.js +127 -130
- package/dist/cjs/utils/config.js +1 -1
- package/dist/cjs/utils/printInstructions.js +1 -1
- package/dist/esm/analyze/constants.js +1 -0
- package/dist/esm/analyze/generateCode.js +4 -4
- package/dist/esm/analyze/getFileSystemEntry.js +1 -2
- package/dist/esm/analyze/getServerRoutes.js +4 -5
- package/dist/esm/analyze/nestedRoutes.js +11 -2
- package/dist/esm/analyze/templates.js +4 -4
- package/dist/esm/builder/generator/createBuilderProviderConfig.js +1 -2
- package/dist/esm/builder/index.js +1 -1
- package/dist/esm/builder/shared/builderPlugins/adapterHtml.js +12 -43
- package/dist/esm/builder/shared/builderPlugins/adapterSSR.js +12 -14
- package/dist/esm/builder/shared/bundlerPlugins/RouterPlugin.js +2 -2
- package/dist/esm/commands/build.js +3 -3
- package/dist/esm/commands/inspect.js +2 -2
- package/dist/esm/commands/serve.js +4 -4
- package/dist/esm/index.js +2 -3
- package/dist/esm/utils/config.js +2 -2
- package/dist/esm/utils/printInstructions.js +1 -1
- package/dist/esm-node/analyze/constants.js +1 -0
- package/dist/esm-node/analyze/generateCode.js +3 -4
- package/dist/esm-node/analyze/getFileSystemEntry.js +1 -2
- package/dist/esm-node/analyze/getServerRoutes.js +4 -5
- package/dist/esm-node/analyze/nestedRoutes.js +11 -2
- package/dist/esm-node/analyze/templates.js +4 -4
- package/dist/esm-node/builder/generator/createBuilderProviderConfig.js +1 -2
- package/dist/esm-node/builder/index.js +1 -1
- package/dist/esm-node/builder/shared/builderPlugins/adapterHtml.js +4 -19
- package/dist/esm-node/builder/shared/builderPlugins/adapterSSR.js +12 -14
- package/dist/esm-node/builder/shared/bundlerPlugins/RouterPlugin.js +2 -2
- package/dist/esm-node/commands/build.js +2 -3
- package/dist/esm-node/commands/inspect.js +1 -2
- package/dist/esm-node/commands/serve.js +4 -4
- package/dist/esm-node/index.js +127 -130
- package/dist/esm-node/utils/config.js +2 -2
- package/dist/esm-node/utils/printInstructions.js +1 -1
- package/dist/types/analyze/constants.d.ts +1 -0
- package/dist/types/builder/shared/bundlerPlugins/RouterPlugin.d.ts +1 -0
- package/package.json +24 -25
package/dist/esm-node/index.js
CHANGED
@@ -59,140 +59,137 @@ export const buildCommand = async (program, api) => {
|
|
59
59
|
};
|
60
60
|
export const appTools = (options = {
|
61
61
|
bundler: "webpack"
|
62
|
-
}) => {
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
...appContext2,
|
105
|
-
internalDirectory: path.resolve(appContext2.appDirectory, userConfig.output.tempDir)
|
106
|
-
});
|
107
|
-
}
|
108
|
-
},
|
109
|
-
async commands({ program }) {
|
110
|
-
await devCommand(program, api);
|
111
|
-
await buildCommand(program, api);
|
112
|
-
program.command("serve").usage("[options]").description(i18n.t(localeKeys.command.serve.describe)).option("--api-only", i18n.t(localeKeys.command.dev.apiOnly)).option("-c --config <config>", i18n.t(localeKeys.command.shared.config)).action(async () => {
|
113
|
-
const { start } = await import("./commands/serve");
|
114
|
-
await start(api);
|
115
|
-
});
|
116
|
-
program.command("deploy").usage("[options]").option("-c --config <config>", i18n.t(localeKeys.command.shared.config)).option("-s --skip-build", i18n.t(localeKeys.command.shared.skipBuild)).description(i18n.t(localeKeys.command.deploy.describe)).action(async (options2) => {
|
117
|
-
if (!options2.skipBuild) {
|
118
|
-
const { build } = await import("./commands/build");
|
119
|
-
await build(api);
|
120
|
-
}
|
121
|
-
const { deploy } = await import("./commands/deploy");
|
122
|
-
await deploy(api, options2);
|
123
|
-
process.exit(0);
|
62
|
+
}) => ({
|
63
|
+
name: "@modern-js/app-tools",
|
64
|
+
post: [
|
65
|
+
"@modern-js/plugin-initialize",
|
66
|
+
"@modern-js/plugin-analyze",
|
67
|
+
"@modern-js/plugin-ssr",
|
68
|
+
"@modern-js/plugin-document",
|
69
|
+
"@modern-js/plugin-state",
|
70
|
+
"@modern-js/plugin-router",
|
71
|
+
"@modern-js/plugin-router-v5",
|
72
|
+
"@modern-js/plugin-polyfill"
|
73
|
+
],
|
74
|
+
registerHook: hooks,
|
75
|
+
usePlugins: [
|
76
|
+
initializePlugin({
|
77
|
+
bundler: (options === null || options === void 0 ? void 0 : options.bundler) === "experimental-rspack" ? "rspack" : "webpack"
|
78
|
+
}),
|
79
|
+
analyzePlugin({
|
80
|
+
bundler: (options === null || options === void 0 ? void 0 : options.bundler) === "experimental-rspack" ? "rspack" : "webpack"
|
81
|
+
}),
|
82
|
+
lintPlugin()
|
83
|
+
],
|
84
|
+
setup: (api) => {
|
85
|
+
const appContext = api.useAppContext();
|
86
|
+
api.setAppContext({
|
87
|
+
...appContext,
|
88
|
+
toolsType: "app-tools"
|
89
|
+
});
|
90
|
+
const nestedRoutes = {};
|
91
|
+
const locale = getLocaleLanguage();
|
92
|
+
i18n.changeLanguage({
|
93
|
+
locale
|
94
|
+
});
|
95
|
+
return {
|
96
|
+
async beforeConfig() {
|
97
|
+
var _userConfig_output;
|
98
|
+
const userConfig = api.useConfigContext();
|
99
|
+
const appContext2 = api.useAppContext();
|
100
|
+
if ((_userConfig_output = userConfig.output) === null || _userConfig_output === void 0 ? void 0 : _userConfig_output.tempDir) {
|
101
|
+
api.setAppContext({
|
102
|
+
...appContext2,
|
103
|
+
internalDirectory: path.resolve(appContext2.appDirectory, userConfig.output.tempDir)
|
124
104
|
});
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
105
|
+
}
|
106
|
+
},
|
107
|
+
async commands({ program }) {
|
108
|
+
await devCommand(program, api);
|
109
|
+
await buildCommand(program, api);
|
110
|
+
program.command("serve").usage("[options]").description(i18n.t(localeKeys.command.serve.describe)).option("--api-only", i18n.t(localeKeys.command.dev.apiOnly)).option("-c --config <config>", i18n.t(localeKeys.command.shared.config)).action(async () => {
|
111
|
+
const { start } = await import("./commands/serve");
|
112
|
+
await start(api);
|
113
|
+
});
|
114
|
+
program.command("deploy").usage("[options]").option("-c --config <config>", i18n.t(localeKeys.command.shared.config)).option("-s --skip-build", i18n.t(localeKeys.command.shared.skipBuild)).description(i18n.t(localeKeys.command.deploy.describe)).action(async (options2) => {
|
115
|
+
if (!options2.skipBuild) {
|
116
|
+
const { build } = await import("./commands/build");
|
117
|
+
await build(api);
|
118
|
+
}
|
119
|
+
const { deploy } = await import("./commands/deploy");
|
120
|
+
await deploy(api, options2);
|
121
|
+
process.exit(0);
|
122
|
+
});
|
123
|
+
program.command("new").usage("[options]").description(i18n.t(localeKeys.command.new.describe)).option("--config-file <configFile>", i18n.t(localeKeys.command.shared.config)).option("--lang <lang>", i18n.t(localeKeys.command.new.lang)).option("-c, --config <config>", i18n.t(localeKeys.command.new.config)).option("-d, --debug", i18n.t(localeKeys.command.new.debug), false).option("--dist-tag <tag>", i18n.t(localeKeys.command.new.distTag)).option("--registry", i18n.t(localeKeys.command.new.registry)).option("--no-need-install", i18n.t(localeKeys.command.shared.noNeedInstall)).action(async (options2) => {
|
124
|
+
const { MWANewAction } = await import("@modern-js/new-action");
|
125
|
+
await MWANewAction({
|
126
|
+
...options2,
|
127
|
+
locale: options2.lang || locale
|
131
128
|
});
|
132
|
-
|
133
|
-
|
134
|
-
|
129
|
+
});
|
130
|
+
program.command("inspect").description("inspect the internal configs").option(`--env <env>`, i18n.t(localeKeys.command.inspect.env), "development").option("--output <output>", i18n.t(localeKeys.command.inspect.output), "/").option("--verbose", i18n.t(localeKeys.command.inspect.verbose)).option("-c --config <config>", i18n.t(localeKeys.command.shared.config)).action(async (options2) => {
|
131
|
+
const { inspect } = await import("./commands/inspect");
|
132
|
+
inspect(api, options2);
|
133
|
+
});
|
134
|
+
const { defineCommand } = await import("@modern-js/upgrade");
|
135
|
+
defineCommand(program.command("upgrade").option("-c --config <config>", i18n.t(localeKeys.command.shared.config)).option("--no-need-install", i18n.t(localeKeys.command.shared.noNeedInstall)));
|
136
|
+
},
|
137
|
+
async prepare() {
|
138
|
+
const command = getCommand();
|
139
|
+
if (command === "deploy") {
|
140
|
+
const isSkipBuild = [
|
141
|
+
"-s",
|
142
|
+
"--skip-build"
|
143
|
+
].some((tag) => {
|
144
|
+
return getArgv().includes(tag);
|
135
145
|
});
|
136
|
-
|
137
|
-
|
138
|
-
},
|
139
|
-
async prepare() {
|
140
|
-
const command = getCommand();
|
141
|
-
if (command === "deploy") {
|
142
|
-
const isSkipBuild = [
|
143
|
-
"-s",
|
144
|
-
"--skip-build"
|
145
|
-
].some((tag) => {
|
146
|
-
return getArgv().includes(tag);
|
147
|
-
});
|
148
|
-
if (isSkipBuild) {
|
149
|
-
return;
|
150
|
-
}
|
146
|
+
if (isSkipBuild) {
|
147
|
+
return;
|
151
148
|
}
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
}
|
159
|
-
},
|
160
|
-
async watchFiles() {
|
161
|
-
const appContext2 = api.useAppContext();
|
162
|
-
const config = api.useResolvedConfigContext();
|
163
|
-
return await generateWatchFiles(appContext2, config.source.configDir);
|
164
|
-
},
|
165
|
-
// 这里会被 core/initWatcher 监听的文件变动触发,如果是 src 目录下的文件变动,则不做 restart
|
166
|
-
async fileChange(e) {
|
167
|
-
const { filename, eventType, isPrivate } = e;
|
168
|
-
if (!isPrivate && (eventType === "change" || eventType === "unlink")) {
|
169
|
-
const { closeServer } = await import("./utils/createServer");
|
170
|
-
await closeServer();
|
171
|
-
await restart(api.useHookRunners(), filename);
|
149
|
+
}
|
150
|
+
if (command === "dev" || command === "start" || command === "build" || command === "deploy") {
|
151
|
+
const resolvedConfig = api.useResolvedConfigContext();
|
152
|
+
if (resolvedConfig.output.cleanDistPath) {
|
153
|
+
const appContext2 = api.useAppContext();
|
154
|
+
await emptyDir(appContext2.distDirectory);
|
172
155
|
}
|
173
|
-
},
|
174
|
-
async beforeRestart() {
|
175
|
-
cleanRequireCache([
|
176
|
-
require.resolve("./analyze")
|
177
|
-
]);
|
178
|
-
},
|
179
|
-
async modifyFileSystemRoutes({ entrypoint, routes }) {
|
180
|
-
nestedRoutes[entrypoint.entryName] = routes;
|
181
|
-
return {
|
182
|
-
entrypoint,
|
183
|
-
routes
|
184
|
-
};
|
185
|
-
},
|
186
|
-
async beforeGenerateRoutes({ entrypoint, code }) {
|
187
|
-
const { distDirectory } = api.useAppContext();
|
188
|
-
await fs.outputJSON(path.resolve(distDirectory, NESTED_ROUTE_SPEC_FILE), nestedRoutes);
|
189
|
-
return {
|
190
|
-
entrypoint,
|
191
|
-
code
|
192
|
-
};
|
193
156
|
}
|
194
|
-
}
|
195
|
-
|
196
|
-
|
197
|
-
|
157
|
+
},
|
158
|
+
async watchFiles() {
|
159
|
+
const appContext2 = api.useAppContext();
|
160
|
+
const config = api.useResolvedConfigContext();
|
161
|
+
return await generateWatchFiles(appContext2, config.source.configDir);
|
162
|
+
},
|
163
|
+
// 这里会被 core/initWatcher 监听的文件变动触发,如果是 src 目录下的文件变动,则不做 restart
|
164
|
+
async fileChange(e) {
|
165
|
+
const { filename, eventType, isPrivate } = e;
|
166
|
+
if (!isPrivate && (eventType === "change" || eventType === "unlink")) {
|
167
|
+
const { closeServer } = await import("./utils/createServer");
|
168
|
+
await closeServer();
|
169
|
+
await restart(api.useHookRunners(), filename);
|
170
|
+
}
|
171
|
+
},
|
172
|
+
async beforeRestart() {
|
173
|
+
cleanRequireCache([
|
174
|
+
require.resolve("./analyze")
|
175
|
+
]);
|
176
|
+
},
|
177
|
+
async modifyFileSystemRoutes({ entrypoint, routes }) {
|
178
|
+
nestedRoutes[entrypoint.entryName] = routes;
|
179
|
+
return {
|
180
|
+
entrypoint,
|
181
|
+
routes
|
182
|
+
};
|
183
|
+
},
|
184
|
+
async beforeGenerateRoutes({ entrypoint, code }) {
|
185
|
+
const { distDirectory } = api.useAppContext();
|
186
|
+
await fs.outputJSON(path.resolve(distDirectory, NESTED_ROUTE_SPEC_FILE), nestedRoutes);
|
187
|
+
return {
|
188
|
+
entrypoint,
|
189
|
+
code
|
190
|
+
};
|
191
|
+
}
|
192
|
+
};
|
193
|
+
}
|
194
|
+
});
|
198
195
|
export default appTools;
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import * as path from "path";
|
2
2
|
import { bundle } from "@modern-js/node-bundle-require";
|
3
|
-
import {
|
3
|
+
import { fs, getServerConfig, ensureAbsolutePath, OUTPUT_CONFIG_FILE, CONFIG_FILE_EXTENSIONS } from "@modern-js/utils";
|
4
4
|
export const defineServerConfig = (config) => config;
|
5
5
|
export const buildServerConfig = async ({ appDirectory, distDirectory, configFile, options, watch }) => {
|
6
6
|
const configFilePath = await getServerConfig(appDirectory, configFile);
|
@@ -50,7 +50,7 @@ export const safeReplacer = () => {
|
|
50
50
|
};
|
51
51
|
export const emitResolvedConfig = async (appDirectory, resolvedConfig) => {
|
52
52
|
var _resolvedConfig_output_distPath;
|
53
|
-
const outputPath =
|
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, {
|
55
55
|
spaces: 2,
|
56
56
|
replacer: safeReplacer()
|
package/package.json
CHANGED
@@ -15,7 +15,7 @@
|
|
15
15
|
"modern",
|
16
16
|
"modern.js"
|
17
17
|
],
|
18
|
-
"version": "2.35.
|
18
|
+
"version": "2.35.1",
|
19
19
|
"jsnext:source": "./src/index.ts",
|
20
20
|
"types": "./dist/types/index.d.ts",
|
21
21
|
"main": "./dist/cjs/index.js",
|
@@ -71,26 +71,25 @@
|
|
71
71
|
"@babel/types": "^7.22.15",
|
72
72
|
"es-module-lexer": "^1.1.0",
|
73
73
|
"esbuild": "0.17.19",
|
74
|
-
"rspack-plugin-virtual-module": "0.1.7",
|
75
74
|
"@swc/helpers": "0.5.1",
|
76
|
-
"@modern-js/builder": "2.35.
|
77
|
-
"@modern-js/builder-plugin-esbuild": "2.35.
|
78
|
-
"@modern-js/builder-plugin-node-polyfill": "2.35.
|
79
|
-
"@modern-js/builder-shared": "2.35.
|
80
|
-
"@modern-js/builder-webpack-provider": "2.35.
|
81
|
-
"@modern-js/core": "2.35.
|
82
|
-
"@modern-js/new-action": "2.35.
|
83
|
-
"@modern-js/node-bundle-require": "2.35.
|
84
|
-
"@modern-js/plugin": "2.35.
|
85
|
-
"@modern-js/plugin-data-loader": "2.35.
|
86
|
-
"@modern-js/plugin-i18n": "2.35.
|
87
|
-
"@modern-js/plugin-lint": "2.35.
|
88
|
-
"@modern-js/prod-server": "2.35.
|
89
|
-
"@modern-js/server": "2.35.
|
90
|
-
"@modern-js/types": "2.35.
|
91
|
-
"@modern-js/upgrade": "2.35.
|
92
|
-
"@modern-js/utils": "2.35.
|
93
|
-
"@modern-js/server-core": "2.35.
|
75
|
+
"@modern-js/builder": "2.35.1",
|
76
|
+
"@modern-js/builder-plugin-esbuild": "2.35.1",
|
77
|
+
"@modern-js/builder-plugin-node-polyfill": "2.35.1",
|
78
|
+
"@modern-js/builder-shared": "2.35.1",
|
79
|
+
"@modern-js/builder-webpack-provider": "2.35.1",
|
80
|
+
"@modern-js/core": "2.35.1",
|
81
|
+
"@modern-js/new-action": "2.35.1",
|
82
|
+
"@modern-js/node-bundle-require": "2.35.1",
|
83
|
+
"@modern-js/plugin": "2.35.1",
|
84
|
+
"@modern-js/plugin-data-loader": "2.35.1",
|
85
|
+
"@modern-js/plugin-i18n": "2.35.1",
|
86
|
+
"@modern-js/plugin-lint": "2.35.1",
|
87
|
+
"@modern-js/prod-server": "2.35.1",
|
88
|
+
"@modern-js/server": "2.35.1",
|
89
|
+
"@modern-js/types": "2.35.1",
|
90
|
+
"@modern-js/upgrade": "2.35.1",
|
91
|
+
"@modern-js/utils": "2.35.1",
|
92
|
+
"@modern-js/server-core": "2.35.1"
|
94
93
|
},
|
95
94
|
"devDependencies": {
|
96
95
|
"@types/babel__traverse": "^7.14.2",
|
@@ -99,13 +98,13 @@
|
|
99
98
|
"jest": "^29",
|
100
99
|
"typescript": "^5",
|
101
100
|
"webpack": "^5.88.1",
|
102
|
-
"@modern-js/builder-plugin-swc": "2.35.
|
103
|
-
"@modern-js/builder-rspack-provider": "2.35.
|
104
|
-
"@scripts/build": "2.35.
|
105
|
-
"@scripts/jest-config": "2.35.
|
101
|
+
"@modern-js/builder-plugin-swc": "2.35.1",
|
102
|
+
"@modern-js/builder-rspack-provider": "2.35.1",
|
103
|
+
"@scripts/build": "2.35.1",
|
104
|
+
"@scripts/jest-config": "2.35.1"
|
106
105
|
},
|
107
106
|
"peerDependencies": {
|
108
|
-
"@modern-js/builder-rspack-provider": "^2.35.
|
107
|
+
"@modern-js/builder-rspack-provider": "^2.35.1"
|
109
108
|
},
|
110
109
|
"peerDependenciesMeta": {
|
111
110
|
"@modern-js/builder-rspack-provider": {
|