@vixt/core 0.1.14 → 0.1.15

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,7 +1,7 @@
1
1
  import { App, Plugin } from 'vue';
2
2
  import { Router, RouteRecord } from 'vue-router';
3
3
  import { Pinia } from 'pinia';
4
- import { f as VixtAppConfig } from '../shared/core.a9343bb9.mjs';
4
+ import { f as VixtAppConfig } from '../shared/core.c818f21a.mjs';
5
5
  import 'vite';
6
6
  import 'c12';
7
7
 
@@ -1,7 +1,7 @@
1
1
  import { App, Plugin } from 'vue';
2
2
  import { Router, RouteRecord } from 'vue-router';
3
3
  import { Pinia } from 'pinia';
4
- import { f as VixtAppConfig } from '../shared/core.a9343bb9.js';
4
+ import { f as VixtAppConfig } from '../shared/core.c818f21a.js';
5
5
  import 'vite';
6
6
  import 'c12';
7
7
 
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { V as VixtModule, M as ModuleOptions, a as Vixt, b as VixtOptions, c as VixtConfigLayer, d as ModuleDefinition } from './shared/core.a9343bb9.mjs';
2
- export { g as ModuleMeta, P as PluginOptions, f as VixtAppConfig, e as VixtConfigLayerMeta } from './shared/core.a9343bb9.mjs';
1
+ import { V as Vixt, a as VixtModule, M as ModuleOptions, b as VixtOptions, c as VixtConfigLayer, d as ModuleDefinition } from './shared/core.c818f21a.mjs';
2
+ export { g as ModuleMeta, P as PluginOptions, f as VixtAppConfig, e as VixtConfigLayerMeta } from './shared/core.c818f21a.mjs';
3
3
  import { TSConfig } from 'pkg-types';
4
4
  import { RawVueCompilerOptions } from '@vue/language-core';
5
5
  import Checker from 'vite-plugin-checker';
@@ -8,8 +8,6 @@ import { LoadConfigOptions } from 'c12';
8
8
  import * as vite from 'vite';
9
9
  import { PluginOption } from 'vite';
10
10
 
11
- declare const alias: VixtModule<ModuleOptions>;
12
-
13
11
  declare module '@vixt/core' {
14
12
  interface VixtOptions {
15
13
  app?: AppOptions;
@@ -76,12 +74,17 @@ declare const typescript: VixtModule<TypescriptOptions>;
76
74
 
77
75
  declare function defineVixtConfig(input: VixtOptions): VixtOptions;
78
76
  declare function loadVixtConfig(opts?: LoadConfigOptions<VixtOptions>): Promise<c12.ResolvedConfig<VixtOptions, c12.ConfigLayerMeta>>;
77
+ declare function isSamePath(a: string, b: string): boolean;
79
78
  declare function resolveLayersDirs(layers: VixtConfigLayer[] | undefined, config: VixtOptions): Record<string, string[] | undefined>;
80
79
 
81
80
  /**
82
81
  * Load workspace and cwd env variables by default
83
82
  */
84
83
  declare function loadEnv(mode?: string, envDir?: string, prefixes?: string | string[]): ImportMeta["env"];
84
+ /**
85
+ * Load workspace env variables
86
+ */
87
+ declare function loadWorkspaceEnv(mode?: string, prefixes?: string | string[]): Record<string, string>;
85
88
 
86
89
  declare function defineVitePlugin<Options = any>(pluginFn: (options?: Options) => PluginOption): (options?: Options) => PluginOption;
87
90
  declare function defineVixtModule<T extends ModuleOptions>(definition: ModuleDefinition<T> | VixtModule<T>): VixtModule<T>;
@@ -91,4 +94,4 @@ declare function applyLayerModules(layers: VixtConfigLayer[], config: VixtOption
91
94
  declare function loadVixt(opts?: LoadConfigOptions<VixtOptions>): Promise<Vixt>;
92
95
  declare function createVixtPlugin(loadOptions: LoadConfigOptions<VixtOptions>): (options?: VixtOptions | undefined) => vite.PluginOption;
93
96
 
94
- export { type AppHead, type AppOptions, ModuleDefinition, ModuleOptions, type TypescriptOptions, Vixt, VixtConfigLayer, VixtModule, type VixtOptions, alias, app, applyLayerModules, config, createVixtPlugin, defineVitePlugin, defineVixtConfig, defineVixtModule, installModule, loadEnv, loadVixt, loadVixtConfig, resolveLayersDirs, typescript };
97
+ export { type AppHead, type AppOptions, ModuleDefinition, ModuleOptions, type TypescriptOptions, Vixt, VixtConfigLayer, VixtModule, type VixtOptions, app, applyLayerModules, config, createVixtPlugin, defineVitePlugin, defineVixtConfig, defineVixtModule, installModule, isSamePath, loadEnv, loadVixt, loadVixtConfig, loadWorkspaceEnv, resolveLayersDirs, typescript };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { V as VixtModule, M as ModuleOptions, a as Vixt, b as VixtOptions, c as VixtConfigLayer, d as ModuleDefinition } from './shared/core.a9343bb9.js';
2
- export { g as ModuleMeta, P as PluginOptions, f as VixtAppConfig, e as VixtConfigLayerMeta } from './shared/core.a9343bb9.js';
1
+ import { V as Vixt, a as VixtModule, M as ModuleOptions, b as VixtOptions, c as VixtConfigLayer, d as ModuleDefinition } from './shared/core.c818f21a.js';
2
+ export { g as ModuleMeta, P as PluginOptions, f as VixtAppConfig, e as VixtConfigLayerMeta } from './shared/core.c818f21a.js';
3
3
  import { TSConfig } from 'pkg-types';
4
4
  import { RawVueCompilerOptions } from '@vue/language-core';
5
5
  import Checker from 'vite-plugin-checker';
@@ -8,8 +8,6 @@ import { LoadConfigOptions } from 'c12';
8
8
  import * as vite from 'vite';
9
9
  import { PluginOption } from 'vite';
10
10
 
11
- declare const alias: VixtModule<ModuleOptions>;
12
-
13
11
  declare module '@vixt/core' {
14
12
  interface VixtOptions {
15
13
  app?: AppOptions;
@@ -76,12 +74,17 @@ declare const typescript: VixtModule<TypescriptOptions>;
76
74
 
77
75
  declare function defineVixtConfig(input: VixtOptions): VixtOptions;
78
76
  declare function loadVixtConfig(opts?: LoadConfigOptions<VixtOptions>): Promise<c12.ResolvedConfig<VixtOptions, c12.ConfigLayerMeta>>;
77
+ declare function isSamePath(a: string, b: string): boolean;
79
78
  declare function resolveLayersDirs(layers: VixtConfigLayer[] | undefined, config: VixtOptions): Record<string, string[] | undefined>;
80
79
 
81
80
  /**
82
81
  * Load workspace and cwd env variables by default
83
82
  */
84
83
  declare function loadEnv(mode?: string, envDir?: string, prefixes?: string | string[]): ImportMeta["env"];
84
+ /**
85
+ * Load workspace env variables
86
+ */
87
+ declare function loadWorkspaceEnv(mode?: string, prefixes?: string | string[]): Record<string, string>;
85
88
 
86
89
  declare function defineVitePlugin<Options = any>(pluginFn: (options?: Options) => PluginOption): (options?: Options) => PluginOption;
87
90
  declare function defineVixtModule<T extends ModuleOptions>(definition: ModuleDefinition<T> | VixtModule<T>): VixtModule<T>;
@@ -91,4 +94,4 @@ declare function applyLayerModules(layers: VixtConfigLayer[], config: VixtOption
91
94
  declare function loadVixt(opts?: LoadConfigOptions<VixtOptions>): Promise<Vixt>;
92
95
  declare function createVixtPlugin(loadOptions: LoadConfigOptions<VixtOptions>): (options?: VixtOptions | undefined) => vite.PluginOption;
93
96
 
94
- export { type AppHead, type AppOptions, ModuleDefinition, ModuleOptions, type TypescriptOptions, Vixt, VixtConfigLayer, VixtModule, type VixtOptions, alias, app, applyLayerModules, config, createVixtPlugin, defineVitePlugin, defineVixtConfig, defineVixtModule, installModule, loadEnv, loadVixt, loadVixtConfig, resolveLayersDirs, typescript };
97
+ export { type AppHead, type AppOptions, ModuleDefinition, ModuleOptions, type TypescriptOptions, Vixt, VixtConfigLayer, VixtModule, type VixtOptions, app, applyLayerModules, config, createVixtPlugin, defineVitePlugin, defineVixtConfig, defineVixtModule, installModule, isSamePath, loadEnv, loadVixt, loadVixtConfig, loadWorkspaceEnv, resolveLayersDirs, typescript };
package/dist/index.mjs CHANGED
@@ -5,40 +5,9 @@ import { pathToFileURL } from 'mlly';
5
5
  import defu from 'defu';
6
6
  import { cwd, env } from 'node:process';
7
7
  import { loadConfig } from 'c12';
8
- import Checker from 'vite-plugin-checker';
9
8
  import { cac } from 'cac';
10
9
  import { loadEnv as loadEnv$1 } from 'vite';
11
-
12
- const name$3 = "vixt:alias";
13
- const alias = defineVixtModule({
14
- meta: { name: name$3 },
15
- setup(_, vixt) {
16
- const { rootDir, buildDir, srcDir } = vixt.options;
17
- const defaultAlias = {
18
- "@": srcDir,
19
- "~": srcDir,
20
- "@@": rootDir,
21
- "~~": rootDir
22
- };
23
- for (const layer of vixt._layers) {
24
- if (layer.meta?.alias) {
25
- defaultAlias[layer.meta.alias] = layer.cwd;
26
- }
27
- }
28
- defaultAlias["#"] = buildDir;
29
- return {
30
- name: name$3,
31
- config() {
32
- return {
33
- root: rootDir,
34
- resolve: {
35
- alias: defaultAlias
36
- }
37
- };
38
- }
39
- };
40
- }
41
- });
10
+ import Checker from 'vite-plugin-checker';
42
11
 
43
12
  function defineVixtConfig(input) {
44
13
  return input;
@@ -93,7 +62,7 @@ function mapLayers(layers, config) {
93
62
  });
94
63
  }
95
64
  function isSamePath(a, b) {
96
- return path.resolve(a) === path.resolve(b);
65
+ return path.normalize(a) === path.normalize(b);
97
66
  }
98
67
  function resolveLayersDirs(layers = [], config) {
99
68
  const { srcDirName } = config;
@@ -330,6 +299,21 @@ const app = defineVixtModule({
330
299
  }
331
300
  });
332
301
 
302
+ function loadEnv(mode, envDir, prefixes) {
303
+ const parsedArgv = cac().parse();
304
+ mode = mode || parsedArgv.options.mode || parsedArgv.options.m || env.NODE_ENV;
305
+ return {
306
+ MODE: mode,
307
+ DEV: env.NODE_ENV !== "production",
308
+ PROD: env.NODE_ENV === "production",
309
+ ...loadWorkspaceEnv(mode, prefixes),
310
+ ...loadEnv$1(mode, envDir || cwd(), prefixes)
311
+ };
312
+ }
313
+ function loadWorkspaceEnv(mode, prefixes) {
314
+ return env.INIT_CWD ? loadEnv$1(mode, env.INIT_CWD, prefixes) : {};
315
+ }
316
+
333
317
  const name$1 = "vixt:config";
334
318
  const config = defineVixtModule({
335
319
  meta: { name: name$1 },
@@ -337,8 +321,39 @@ const config = defineVixtModule({
337
321
  return {
338
322
  name: name$1,
339
323
  enforce: "pre",
324
+ config() {
325
+ const { rootDir, buildDir, srcDir } = vixt.options;
326
+ const defaultAlias = {
327
+ "@": srcDir,
328
+ "~": srcDir,
329
+ "@@": rootDir,
330
+ "~~": rootDir
331
+ };
332
+ for (const layer of vixt._layers) {
333
+ if (layer.meta?.alias) {
334
+ defaultAlias[layer.meta.alias] = layer.cwd;
335
+ }
336
+ }
337
+ defaultAlias["#"] = buildDir;
338
+ return {
339
+ root: rootDir,
340
+ resolve: {
341
+ alias: defaultAlias
342
+ }
343
+ };
344
+ },
340
345
  configResolved(config2) {
346
+ Object.assign(config2.env, { ...loadWorkspaceEnv(config2.mode, config2.envPrefix), ...config2.env });
341
347
  vixt.options.vite = config2;
348
+ },
349
+ configureServer(server) {
350
+ const configFiles = vixt._layers.map((layer) => path.resolve(layer.cwd, "vixt.config.ts"));
351
+ server.watcher.add(configFiles);
352
+ server.watcher.on("change", (file) => {
353
+ if (configFiles.includes(path.normalize(file))) {
354
+ server.restart();
355
+ }
356
+ });
342
357
  }
343
358
  };
344
359
  }
@@ -455,28 +470,10 @@ const typescript = defineVixtModule({
455
470
  }
456
471
  });
457
472
 
458
- function loadEnv(mode, envDir, prefixes) {
459
- const parsedArgv = cac().parse();
460
- mode = mode || parsedArgv.options.mode || parsedArgv.options.m || env.NODE_ENV;
461
- const loadedEnv = {};
462
- if (envDir) {
463
- Object.assign(loadedEnv, loadEnv$1(mode, envDir, prefixes));
464
- } else {
465
- const workspaceDir = env.INIT_CWD;
466
- Object.assign(loadedEnv, loadEnv$1(mode, workspaceDir, prefixes), loadEnv$1(mode, cwd(), prefixes));
467
- }
468
- return {
469
- MODE: mode,
470
- DEV: env.NODE_ENV !== "production",
471
- PROD: env.NODE_ENV === "production",
472
- ...loadedEnv
473
- };
474
- }
475
-
476
473
  async function loadVixt(opts) {
477
474
  const result = await loadVixtConfig(defu(opts, {
478
475
  defaults: {
479
- modules: [alias, app, config, typescript]
476
+ modules: [config, app, typescript]
480
477
  }
481
478
  }));
482
479
  const parsedArgv = cac().parse();
@@ -500,4 +497,4 @@ function createVixtPlugin(loadOptions) {
500
497
  });
501
498
  }
502
499
 
503
- export { alias, app, applyLayerModules, config, createVixtPlugin, defineVitePlugin, defineVixtConfig, defineVixtModule, installModule, loadEnv, loadVixt, loadVixtConfig, resolveLayersDirs, typescript };
500
+ export { app, applyLayerModules, config, createVixtPlugin, defineVitePlugin, defineVixtConfig, defineVixtModule, installModule, isSamePath, loadEnv, loadVixt, loadVixtConfig, loadWorkspaceEnv, resolveLayersDirs, typescript };
@@ -78,4 +78,4 @@ interface VixtConfigLayer extends ConfigLayer<VixtOptions, VixtConfigLayerMeta>
78
78
  interface VixtAppConfig extends Record<string, any> {
79
79
  }
80
80
 
81
- export type { ModuleOptions as M, PluginOptions as P, VixtModule as V, Vixt as a, VixtOptions as b, VixtConfigLayer as c, ModuleDefinition as d, VixtConfigLayerMeta as e, VixtAppConfig as f, ModuleMeta as g };
81
+ export type { ModuleOptions as M, PluginOptions as P, Vixt as V, VixtModule as a, VixtOptions as b, VixtConfigLayer as c, ModuleDefinition as d, VixtConfigLayerMeta as e, VixtAppConfig as f, ModuleMeta as g };
@@ -78,4 +78,4 @@ interface VixtConfigLayer extends ConfigLayer<VixtOptions, VixtConfigLayerMeta>
78
78
  interface VixtAppConfig extends Record<string, any> {
79
79
  }
80
80
 
81
- export type { ModuleOptions as M, PluginOptions as P, VixtModule as V, Vixt as a, VixtOptions as b, VixtConfigLayer as c, ModuleDefinition as d, VixtConfigLayerMeta as e, VixtAppConfig as f, ModuleMeta as g };
81
+ export type { ModuleOptions as M, PluginOptions as P, Vixt as V, VixtModule as a, VixtOptions as b, VixtConfigLayer as c, ModuleDefinition as d, VixtConfigLayerMeta as e, VixtAppConfig as f, ModuleMeta as g };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vixt/core",
3
3
  "type": "module",
4
- "version": "0.1.14",
4
+ "version": "0.1.15",
5
5
  "author": "SoulLyoko<https://github.com/SoulLyoko>",
6
6
  "license": "MIT",
7
7
  "homepage": "https://github.com/SoulLyoko/vixt#readme",