@vixt/core 0.13.1 → 0.13.3

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.
@@ -1,5 +1,4 @@
1
1
  import { ConfigLayer, ConfigLayerMeta, LoadConfigOptions, ResolvedConfig } from "c12";
2
- import { commands } from "@vixt/cli";
3
2
  import { HtmlTagDescriptor, PluginOption, ServerOptions, UserConfig } from "vite";
4
3
  import Legacy from "@vitejs/plugin-legacy";
5
4
  import Analyzer from "vite-bundle-analyzer";
@@ -372,6 +371,15 @@ interface VixtConfig {
372
371
  * Define the monorepo workspace directory of your application.
373
372
  */
374
373
  workspaceDir?: string;
374
+ /**
375
+ * Whether your app is running in with vixt-cli.
376
+ * @internal
377
+ */
378
+ _cli?: boolean;
379
+ /**
380
+ * @internal
381
+ */
382
+ _prepare?: boolean;
375
383
  }
376
384
  /**
377
385
  * This is a global declared interface for module `@vixt/core`,
@@ -403,24 +411,7 @@ declare function isSamePath(a: string, b: string): boolean;
403
411
  declare function resolveLayersDirs(layers?: VixtConfigLayer[]): Record<string, string[] | undefined>;
404
412
  //#endregion
405
413
  //#region src/node/env.d.ts
406
- declare function loadCLIOptions(): {
407
- _: string[];
408
- https: boolean | undefined;
409
- host: string | undefined;
410
- port: string | undefined;
411
- open: boolean;
412
- cors: boolean | undefined;
413
- strictPort: boolean | undefined;
414
- root: string | undefined;
415
- debug: boolean;
416
- mode: string | undefined;
417
- logLevel: "error" | "warn" | "info" | "silent" | undefined;
418
- clear: boolean;
419
- force: boolean;
420
- legacy: boolean | undefined;
421
- analyze: boolean | undefined;
422
- command: keyof typeof commands;
423
- };
414
+ declare function loadCLIOptions(): Partial<import("@vixt/cli").VixtArgs>;
424
415
  declare function loadMode(): string | undefined;
425
416
  /**
426
417
  * Load workspace and cwd env variables by default
@@ -18,10 +18,11 @@ import Checker from "vite-plugin-checker";
18
18
  import { builders, parseExpression, parseModule } from "magicast";
19
19
  //#region src/node/env.ts
20
20
  function loadCLIOptions() {
21
- return {
22
- command: process.argv[2],
23
- ...parseVixtArgs()
24
- };
21
+ try {
22
+ return parseVixtArgs();
23
+ } catch {
24
+ return {};
25
+ }
25
26
  }
26
27
  function loadMode() {
27
28
  const { mode } = loadCLIOptions();
@@ -72,12 +73,13 @@ function defineVixtConfig(input) {
72
73
  return input;
73
74
  }
74
75
  async function loadVixtConfig(opts) {
76
+ const _cli = process.argv[1]?.endsWith("vixt.mjs");
75
77
  const cliOptions = loadCLIOptions();
76
78
  const result = await loadConfig({
77
79
  name: "vixt",
78
80
  rcFile: false,
79
81
  ...opts,
80
- ...cliOptions.root ? { cwd: cliOptions.root } : {}
82
+ ..._cli && cliOptions.root ? { cwd: cliOptions.root } : {}
81
83
  });
82
84
  const { config, cwd } = result;
83
85
  config.rootDir ??= cwd;
@@ -88,9 +90,10 @@ async function loadVixtConfig(opts) {
88
90
  config.srcDir ??= resolve(config.rootDir, "src");
89
91
  config.modulesDir ??= resolve(config.srcDir, "modules");
90
92
  config.pluginsDir ??= resolve(config.srcDir, "plugins");
91
- config.debug = !!cliOptions.debug;
92
- config.dev = env.NODE_ENV !== "production";
93
+ config.debug ??= cliOptions.debug;
94
+ config.dev = env.NODE_ENV === "development";
93
95
  config.test = env.NODE_ENV === "test";
96
+ config._cli = _cli;
94
97
  config._prepare = cliOptions.command === "prepare";
95
98
  cliOptions.force && fs.removeSync(config.buildDir);
96
99
  return result;
@@ -471,8 +474,10 @@ var imports_default = defineVixtModule({
471
474
  ].flat()
472
475
  };
473
476
  },
474
- setup(options) {
475
- return AutoImport(options);
477
+ setup(options, vixt) {
478
+ const autoImportPlugin = AutoImport(options);
479
+ if (vixt.options._prepare) autoImportPlugin.buildStart();
480
+ return autoImportPlugin;
476
481
  }
477
482
  });
478
483
  //#endregion
@@ -499,7 +504,10 @@ var nitro_default = defineVixtModule({
499
504
  serverDir: "./server",
500
505
  typescript: { generatedTypesDir: vixt.options.buildTypesDir },
501
506
  modules: [(nitro) => {
502
- nitro.hooks.hook("build:before", setNitroCtx);
507
+ nitro.hooks.hook("build:before", (ctx) => {
508
+ setNitroCtx(ctx);
509
+ writeTypes$1();
510
+ });
503
511
  }]
504
512
  };
505
513
  },
@@ -510,7 +518,6 @@ var nitro_default = defineVixtModule({
510
518
  {
511
519
  name: "vixt:nitro-types",
512
520
  configureServer(server) {
513
- writeTypes$1();
514
521
  const routesDirs = vixt._layers.map((e) => `${e.cwd}/server/routes`);
515
522
  const watcher = server.watcher;
516
523
  watcher.add(routesDirs);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vixt/core",
3
- "version": "0.13.1",
3
+ "version": "0.13.3",
4
4
  "keywords": [
5
5
  "nuxt",
6
6
  "react",
@@ -33,7 +33,7 @@
33
33
  "@types/fs-extra": "^11.0.4",
34
34
  "@vitejs/plugin-basic-ssl": "^2.3.0",
35
35
  "@vitejs/plugin-legacy": "^8.2.3",
36
- "@vixt/cli": "0.13.1",
36
+ "@vixt/cli": "0.13.3",
37
37
  "@vue/tsconfig": "^0.9.1",
38
38
  "c12": "^3.3.4",
39
39
  "defu": "^6.1.7",