@vixt/core 0.12.2 → 0.13.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.
@@ -1,5 +1,6 @@
1
1
  import { ConfigLayer, ConfigLayerMeta, LoadConfigOptions, ResolvedConfig } from "c12";
2
- import { HtmlTagDescriptor, InlineConfig, LogLevel, PluginOption, ServerOptions, UserConfig } from "vite";
2
+ import { commands } from "@vixt/cli";
3
+ import { HtmlTagDescriptor, PluginOption, ServerOptions, UserConfig } from "vite";
3
4
  import Legacy from "@vitejs/plugin-legacy";
4
5
  import Analyzer from "vite-bundle-analyzer";
5
6
  import Ssl from "@vitejs/plugin-basic-ssl";
@@ -27,7 +28,7 @@ interface Vixt {
27
28
  _layers: VixtConfigLayer[];
28
29
  _modules: VixtModule[];
29
30
  }
30
- type ExtractPluginOptions<Options = any> = (Options extends ((...args: any[]) => any) ? Parameters<Options>[0] : Options);
31
+ type ExtractPluginOptions<Options = any> = Options extends ((...args: any[]) => any) ? Parameters<Options>[0] : Options;
31
32
  //#endregion
32
33
  //#region src/node/types/module.d.ts
33
34
  type ModuleOptions = Record<string, any>;
@@ -179,24 +180,24 @@ interface BuildOptions {
179
180
  /**
180
181
  * Set to true to enable bundle analysis, or pass an object with `enabled: true` and options: [vite-bundle-analyzer](https://github.com/nonzzz/vite-bundle-analyzer)
181
182
  */
182
- analyze?: boolean | ExtractPluginOptions<typeof Analyzer> & {
183
+ analyze?: boolean | (ExtractPluginOptions<typeof Analyzer> & {
183
184
  enabled?: boolean;
184
- };
185
+ });
185
186
  /**
186
187
  * Set to true to enable legacy mode, or pass an object with `enabled: true` and options: [@vitejs/plugin-legacy](https://github.com/vitejs/vite/tree/main/packages/plugin-legacy)
187
188
  */
188
- legacy?: boolean | ExtractPluginOptions<typeof Legacy> & {
189
+ legacy?: boolean | (ExtractPluginOptions<typeof Legacy> & {
189
190
  enabled?: boolean;
190
- };
191
+ });
191
192
  }
192
193
  interface DevServerOptions extends Pick<ServerOptions, 'port' | 'host' | 'cors'> {
193
194
  /**
194
195
  * Whether to enable HTTPS by using [@vitejs/plugin-basic-ssl](https://github.com/vitejs/vite-plugin-basic-ssl).
195
196
  * @default false
196
197
  */
197
- https?: boolean | ExtractPluginOptions<typeof Ssl> & {
198
+ https?: boolean | (ExtractPluginOptions<typeof Ssl> & {
198
199
  enabled?: boolean;
199
- };
200
+ });
200
201
  /**
201
202
  * The watch property lets you define patterns that will restart the dev server when changed.
202
203
  */
@@ -402,26 +403,24 @@ declare function isSamePath(a: string, b: string): boolean;
402
403
  declare function resolveLayersDirs(layers?: VixtConfigLayer[]): Record<string, string[] | undefined>;
403
404
  //#endregion
404
405
  //#region src/node/env.d.ts
405
- /** https://github.com/vitejs/vite/blob/main/packages/vite/src/node/cli.ts */
406
- interface GlobalCLIOptions {
407
- '--'?: string[];
408
- 'c'?: boolean | string;
409
- 'config'?: string;
410
- 'base'?: string;
411
- 'l'?: LogLevel;
412
- 'logLevel'?: LogLevel;
413
- 'clearScreen'?: boolean;
414
- 'configLoader'?: InlineConfig['configLoader'];
415
- 'd'?: boolean | string;
416
- 'debug'?: boolean | string;
417
- 'f'?: string;
418
- 'filter'?: string;
419
- 'm'?: string;
420
- 'mode'?: string;
421
- 'force'?: boolean;
422
- 'w'?: boolean;
423
- }
424
- declare function loadCLIOptions(): GlobalCLIOptions;
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
+ };
425
424
  declare function loadMode(): string | undefined;
426
425
  /**
427
426
  * Load workspace and cwd env variables by default
@@ -508,4 +507,4 @@ declare const builtinModules: (VixtModule<ModuleOptions> | VixtModule<AliasOptio
508
507
  declare function loadVixt(opts?: LoadConfigOptions<VixtOptions>): Promise<Vixt>;
509
508
  declare function createVixtPlugin(loadOptions: LoadConfigOptions<VixtOptions>): (options?: VixtOptions | undefined) => import("vite").PluginOption;
510
509
  //#endregion
511
- export { AliasOptions, AppHead, AppHeadAttrs, AppOptions, BuildOptions, DevServerOptions, ExtractPluginOptions, GlobalCLIOptions, ImportsOptions, LoadVixtConfigOptions, ModuleDefinition, ModuleMeta, ModuleOptions, NitroOptions, ResolvedVixtConfig, TypescriptOptions, Vixt, VixtConfig, VixtConfigLayer, VixtConfigLayerMeta, VixtModule, VixtOptions, applyLayerModules, applyLayers, builtinModules, createVixtPlugin, defineVitePlugin, defineVixtConfig, defineVixtModule, findUpWorkspaceDir, installModule, isSamePath, loadCLIOptions, loadEnv, loadMode, loadVixt, loadVixtConfig, loadWorkspaceEnv, resolveLayersDirs, virtualModuleIds };
510
+ export { AliasOptions, AppHead, AppHeadAttrs, AppOptions, BuildOptions, DevServerOptions, ExtractPluginOptions, ImportsOptions, LoadVixtConfigOptions, ModuleDefinition, ModuleMeta, ModuleOptions, NitroOptions, ResolvedVixtConfig, TypescriptOptions, Vixt, VixtConfig, VixtConfigLayer, VixtConfigLayerMeta, VixtModule, VixtOptions, applyLayerModules, applyLayers, builtinModules, createVixtPlugin, defineVitePlugin, defineVixtConfig, defineVixtModule, findUpWorkspaceDir, installModule, isSamePath, loadCLIOptions, loadEnv, loadMode, loadVixt, loadVixtConfig, loadWorkspaceEnv, resolveLayersDirs, virtualModuleIds };
@@ -1,8 +1,8 @@
1
+ import { cwd, env } from "node:process";
1
2
  import { loadConfig } from "c12";
2
3
  import fs from "fs-extra";
3
4
  import path, { normalize, resolve } from "pathe";
4
- import { cwd, env } from "node:process";
5
- import { cac } from "cac";
5
+ import { parseVixtArgs } from "@vixt/cli";
6
6
  import { findUpSync } from "find-up";
7
7
  import { loadEnv as loadEnv$1, mergeConfig, parseAst } from "vite";
8
8
  import defu from "defu";
@@ -18,11 +18,14 @@ 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 cac().parse().options ?? {};
21
+ return {
22
+ command: process.argv[2],
23
+ ...parseVixtArgs()
24
+ };
22
25
  }
23
26
  function loadMode() {
24
- const { mode, m } = loadCLIOptions();
25
- return mode || m || env.NODE_ENV;
27
+ const { mode } = loadCLIOptions();
28
+ return mode || env.NODE_ENV;
26
29
  }
27
30
  /**
28
31
  * Load workspace and cwd env variables by default
@@ -69,10 +72,12 @@ function defineVixtConfig(input) {
69
72
  return input;
70
73
  }
71
74
  async function loadVixtConfig(opts) {
75
+ const cliOptions = loadCLIOptions();
72
76
  const result = await loadConfig({
73
77
  name: "vixt",
74
78
  rcFile: false,
75
- ...opts
79
+ ...opts,
80
+ ...cliOptions.root ? { cwd: cliOptions.root } : {}
76
81
  });
77
82
  const { config, cwd } = result;
78
83
  config.rootDir ??= cwd;
@@ -83,6 +88,11 @@ async function loadVixtConfig(opts) {
83
88
  config.srcDir ??= resolve(config.rootDir, "src");
84
89
  config.modulesDir ??= resolve(config.srcDir, "modules");
85
90
  config.pluginsDir ??= resolve(config.srcDir, "plugins");
91
+ config.debug = !!cliOptions.debug;
92
+ config.dev = env.NODE_ENV !== "production";
93
+ config.test = env.NODE_ENV === "test";
94
+ config._prepare = cliOptions.command === "prepare";
95
+ cliOptions.force && fs.removeSync(config.buildDir);
86
96
  return result;
87
97
  }
88
98
  function applyLayers({ config, layers = [] }) {
@@ -201,7 +211,9 @@ function defineVixtModule(definition) {
201
211
  const module = definition;
202
212
  function getOptions(inlineOptions, vixt) {
203
213
  const configKey = module.meta?.configKey || module.meta?.name;
204
- const resolvedOptions = defu(inlineOptions, configKey ? vixt.options[configKey] : {}, typeof module.defaults === "function" ? module.defaults(vixt) : module.defaults);
214
+ const configOptions = configKey ? vixt.options[configKey] : {};
215
+ const defaultOptions = typeof module.defaults === "function" ? module.defaults(vixt) : module.defaults;
216
+ const resolvedOptions = defu(inlineOptions, configOptions, defaultOptions);
205
217
  if (configKey) vixt.options[configKey] = resolvedOptions;
206
218
  return resolvedOptions;
207
219
  }
@@ -360,13 +372,16 @@ var build_default = defineVixtModule({
360
372
  configKey: "build"
361
373
  },
362
374
  setup(options) {
375
+ const cliOptions = loadCLIOptions();
363
376
  const analyzeOptions = {
364
377
  enabled: !!options.analyze,
365
- ...typeof options.analyze === "object" ? options.analyze : {}
378
+ ...typeof options.analyze === "object" ? options.analyze : {},
379
+ ...cliOptions.analyze ? { enabled: true } : {}
366
380
  };
367
381
  const legacyOptions = {
368
382
  enabled: !!options.legacy,
369
- ...typeof options.legacy === "object" ? options.legacy : {}
383
+ ...typeof options.legacy === "object" ? options.legacy : {},
384
+ ...cliOptions.legacy ? { enabled: true } : {}
370
385
  };
371
386
  return [analyzeOptions.enabled && Analyzer(analyzeOptions), legacyOptions.enabled && Legacy(legacyOptions)];
372
387
  }
@@ -398,9 +413,11 @@ var dev_server_default = defineVixtModule({
398
413
  return { watch: watchFiles };
399
414
  },
400
415
  setup(options) {
416
+ const cliOptions = loadCLIOptions();
401
417
  const sslOptions = {
402
418
  enabled: !!options.https,
403
- ...typeof options.https === "object" ? options.https : {}
419
+ ...typeof options.https === "object" ? options.https : {},
420
+ ...cliOptions.https ? { enabled: true } : {}
404
421
  };
405
422
  const watchFiles = options.watch ?? [];
406
423
  let timer;
@@ -761,13 +778,8 @@ const builtinModules = [
761
778
  ];
762
779
  //#endregion
763
780
  //#region src/node/vixt.ts
764
- async function loadVixt(opts) {
781
+ async function loadVixt(opts = {}) {
765
782
  const result = await loadVixtConfig(opts);
766
- const cliOptions = loadCLIOptions();
767
- cliOptions.force && fs.removeSync(result.config.buildDir);
768
- result.config.debug = !!cliOptions.debug;
769
- result.config.dev = env.NODE_ENV !== "production";
770
- result.config.test = env.NODE_ENV === "test";
771
783
  result.layers = applyLayers(result);
772
784
  const layerModules = await applyLayerModules(result);
773
785
  return {
package/package.json CHANGED
@@ -1,54 +1,53 @@
1
1
  {
2
2
  "name": "@vixt/core",
3
- "type": "module",
4
- "version": "0.12.2",
5
- "author": "SoulLyoko<https://github.com/SoulLyoko>",
6
- "license": "MIT",
3
+ "version": "0.13.1",
4
+ "keywords": [
5
+ "nuxt",
6
+ "react",
7
+ "uni",
8
+ "vite",
9
+ "vitepress",
10
+ "vixt",
11
+ "vue"
12
+ ],
7
13
  "homepage": "https://soullyoko.github.io/vixt/",
14
+ "license": "MIT",
15
+ "author": "SoulLyoko<https://github.com/SoulLyoko>",
8
16
  "repository": {
9
17
  "type": "git",
10
18
  "url": "https://github.com/SoulLyoko/vixt.git"
11
19
  },
12
- "keywords": [
13
- "vixt",
14
- "vite",
15
- "nuxt",
16
- "vue",
17
- "uni",
18
- "vitepress",
19
- "react"
20
+ "files": [
21
+ "dist"
20
22
  ],
23
+ "type": "module",
24
+ "main": "./dist/node/index.mjs",
25
+ "browser": "./dist/client/index.js",
26
+ "types": "./dist/node/index.d.mts",
21
27
  "exports": {
22
28
  ".": "./dist/node/index.mjs",
23
- "./cli": "./dist/cli/index.mjs",
24
29
  "./client": "./dist/client/index.js",
25
30
  "./package.json": "./package.json"
26
31
  },
27
- "main": "./dist/node/index.mjs",
28
- "types": "./dist/node/index.d.mts",
29
- "browser": "./dist/client/index.js",
30
- "files": [
31
- "dist"
32
- ],
33
32
  "dependencies": {
33
+ "@types/fs-extra": "^11.0.4",
34
34
  "@vitejs/plugin-basic-ssl": "^2.3.0",
35
- "@vitejs/plugin-legacy": "^8.2.1",
35
+ "@vitejs/plugin-legacy": "^8.2.3",
36
+ "@vixt/cli": "0.13.1",
36
37
  "@vue/tsconfig": "^0.9.1",
37
38
  "c12": "^3.3.4",
38
- "cac": "^7.0.0",
39
- "citty": "^0.2.2",
40
39
  "defu": "^6.1.7",
41
40
  "find-up": "^8.0.0",
42
- "fs-extra": "^11.3.6",
41
+ "fs-extra": "^11.4.0",
43
42
  "jiti": "^2.7.0",
44
- "magicast": "^0.5.3",
43
+ "magicast": "^0.5.4",
45
44
  "mlly": "^1.8.2",
46
45
  "nitro": "^3.0.260610-beta",
47
46
  "pathe": "^2.0.3",
48
47
  "pkg-types": "^2.3.1",
49
- "unplugin-auto-import": "^21.0.0",
50
- "vite": "^8.1.5",
48
+ "unplugin-auto-import": "^21.1.0",
49
+ "vite": "^8.2.2",
51
50
  "vite-bundle-analyzer": "^1.3.9",
52
- "vite-plugin-checker": "^0.14.4"
51
+ "vite-plugin-checker": "^0.14.5"
53
52
  }
54
53
  }
@@ -1 +0,0 @@
1
- export { };
@@ -1,27 +0,0 @@
1
- import { defineCommand, runMain } from "citty";
2
- //#region src/cli/index.ts
3
- runMain(defineCommand({
4
- meta: {
5
- name: "vixt",
6
- description: "Vixt CLI"
7
- },
8
- args: { command: {
9
- type: "positional",
10
- required: true
11
- } },
12
- subCommands: { prepare: defineCommand({
13
- meta: {
14
- name: "prepare",
15
- description: "Prepare Vixt"
16
- },
17
- async run() {
18
- const { loadConfigFromFile } = await import("vite");
19
- await loadConfigFromFile({
20
- command: "serve",
21
- mode: "dev"
22
- }, void 0, void 0, void 0, void 0, "native");
23
- }
24
- }) }
25
- }));
26
- //#endregion
27
- export {};