@evjs/cli 0.0.30 → 0.0.33
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/index.js +16 -5
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -17,6 +17,15 @@ async function getBundlerAdapter(config) {
|
|
|
17
17
|
const { utoopackAdapter } = await import("@evjs/bundler-utoopack");
|
|
18
18
|
return utoopackAdapter;
|
|
19
19
|
}
|
|
20
|
+
function withActiveBundler(config, bundler) {
|
|
21
|
+
if (config.bundler === bundler) {
|
|
22
|
+
return config;
|
|
23
|
+
}
|
|
24
|
+
return {
|
|
25
|
+
...config,
|
|
26
|
+
bundler,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
20
29
|
/**
|
|
21
30
|
* Run plugin setup() hooks and collect lifecycle hooks.
|
|
22
31
|
*/
|
|
@@ -90,15 +99,16 @@ function readBuildResult(cwd, serverEnabled, isRebuild) {
|
|
|
90
99
|
* @param options - additional options like `cwd`
|
|
91
100
|
*/
|
|
92
101
|
export async function dev(userConfig, options) {
|
|
93
|
-
const
|
|
102
|
+
const resolvedConfig = resolveConfig(userConfig);
|
|
94
103
|
const cwd = options?.cwd ?? process.cwd();
|
|
95
104
|
process.env.NODE_ENV ??= "development";
|
|
105
|
+
const bundler = await getBundlerAdapter(resolvedConfig);
|
|
106
|
+
const config = withActiveBundler(resolvedConfig, bundler);
|
|
96
107
|
// Collect plugin hooks
|
|
97
108
|
const pluginCtx = { mode: "development", cwd, config };
|
|
98
109
|
const hooks = await collectPluginHooks(config.plugins, pluginCtx);
|
|
99
110
|
// Run buildStart hooks
|
|
100
111
|
await runBuildStartHooks(hooks);
|
|
101
|
-
const bundler = await getBundlerAdapter(config);
|
|
102
112
|
// Validate HTML files exist
|
|
103
113
|
if (config.pages) {
|
|
104
114
|
for (const [name, page] of Object.entries(config.pages)) {
|
|
@@ -166,7 +176,7 @@ export async function dev(userConfig, options) {
|
|
|
166
176
|
fs.writeFileSync(bootstrapPath, [
|
|
167
177
|
`const handler = require(${JSON.stringify(serverBundlePath)}).default;`,
|
|
168
178
|
`const { serve } = require("@evjs/server/node");`,
|
|
169
|
-
`serve({ fetch: handler }, { port: ${serverPort}, https: ${JSON.stringify(config.server.dev.https)} });`,
|
|
179
|
+
`serve({ fetch: handler.fetch }, { port: ${serverPort}, https: ${JSON.stringify(config.server.dev.https)} });`,
|
|
170
180
|
].join("\n"));
|
|
171
181
|
const runtimeArgs = [bootstrapPath];
|
|
172
182
|
// Don't await execa here since it's a long-running watch process
|
|
@@ -196,15 +206,16 @@ export async function dev(userConfig, options) {
|
|
|
196
206
|
* @param options - additional options like `cwd`
|
|
197
207
|
*/
|
|
198
208
|
export async function build(userConfig, options) {
|
|
199
|
-
const
|
|
209
|
+
const resolvedConfig = resolveConfig(userConfig);
|
|
200
210
|
const cwd = options?.cwd ?? process.cwd();
|
|
201
211
|
process.env.NODE_ENV ??= "production";
|
|
212
|
+
const bundler = await getBundlerAdapter(resolvedConfig);
|
|
213
|
+
const config = withActiveBundler(resolvedConfig, bundler);
|
|
202
214
|
// Collect plugin hooks
|
|
203
215
|
const pluginCtx = { mode: "production", cwd, config };
|
|
204
216
|
const hooks = await collectPluginHooks(config.plugins, pluginCtx);
|
|
205
217
|
// Run buildStart hooks
|
|
206
218
|
await runBuildStartHooks(hooks);
|
|
207
|
-
const bundler = await getBundlerAdapter(config);
|
|
208
219
|
// Validate HTML files exist
|
|
209
220
|
if (config.pages) {
|
|
210
221
|
for (const [name, page] of Object.entries(config.pages)) {
|