@evjs/cli 0.0.32 → 0.1.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.
Files changed (2) hide show
  1. package/dist/index.js +15 -4
  2. 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 config = resolveConfig(userConfig);
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)) {
@@ -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 config = resolveConfig(userConfig);
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)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@evjs/cli",
3
- "version": "0.0.32",
3
+ "version": "0.1.0",
4
4
  "description": "CLI and configuration layer for the evjs framework",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",