@vixt/core 0.0.10 → 0.0.12

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.d.mts CHANGED
@@ -43,6 +43,10 @@ interface VixtOptions extends Record<string, any> {
43
43
  * @default '.vixt/types'
44
44
  */
45
45
  buildTypesDir?: string;
46
+ /**
47
+ * @default '.vixt/layers'
48
+ */
49
+ buildLayersDir?: string;
46
50
  /** layers */
47
51
  extends?: string[];
48
52
  /** modules */
@@ -116,6 +120,7 @@ declare function defineVixtConfig(input: VixtOptions): VixtOptions;
116
120
  declare const rootDir: string;
117
121
  declare const buildDir = ".vixt";
118
122
  declare const buildTypesDir = ".vixt/types";
123
+ declare const buildLayersDir = ".vixt/layers";
119
124
  declare function loadVixtConfig(opts?: LoadConfigOptions<VixtOptions>): Promise<c12.ResolvedConfig<VixtOptions, c12.ConfigLayerMeta>>;
120
125
  declare function resolveLayersDirs(layers?: VixtConfigLayer[]): Record<string, string[] | undefined>;
121
126
 
@@ -127,4 +132,4 @@ declare function applyLayerModules(layers?: VixtConfigLayer[]): Promise<VixtModu
127
132
  declare function loadVixt(opts?: LoadConfigOptions<VixtOptions>): Promise<Vixt>;
128
133
  declare function createVixtPlugin(loadOptions: LoadConfigOptions<VixtOptions>): (options?: VixtOptions | undefined) => vite.PluginOption;
129
134
 
130
- export { type AppHead, type AppOptions, type ModuleDefinition, type ModuleMeta, type ModuleOptions, type PluginOptions, type TypescriptOptions, type Vixt, type VixtConfigLayer, type VixtModule, type VixtOptions, alias, app, applyLayerModules, buildDir, buildTypesDir, config, createVixtPlugin, defineVitePlugin, defineVixtConfig, defineVixtModule, installModule, loadVixt, loadVixtConfig, resolveLayersDirs, rootDir, typescript };
135
+ export { type AppHead, type AppOptions, type ModuleDefinition, type ModuleMeta, type ModuleOptions, type PluginOptions, type TypescriptOptions, type Vixt, type VixtConfigLayer, type VixtModule, type VixtOptions, alias, app, applyLayerModules, buildDir, buildLayersDir, buildTypesDir, config, createVixtPlugin, defineVitePlugin, defineVixtConfig, defineVixtModule, installModule, loadVixt, loadVixtConfig, resolveLayersDirs, rootDir, typescript };
package/dist/index.d.ts CHANGED
@@ -43,6 +43,10 @@ interface VixtOptions extends Record<string, any> {
43
43
  * @default '.vixt/types'
44
44
  */
45
45
  buildTypesDir?: string;
46
+ /**
47
+ * @default '.vixt/layers'
48
+ */
49
+ buildLayersDir?: string;
46
50
  /** layers */
47
51
  extends?: string[];
48
52
  /** modules */
@@ -116,6 +120,7 @@ declare function defineVixtConfig(input: VixtOptions): VixtOptions;
116
120
  declare const rootDir: string;
117
121
  declare const buildDir = ".vixt";
118
122
  declare const buildTypesDir = ".vixt/types";
123
+ declare const buildLayersDir = ".vixt/layers";
119
124
  declare function loadVixtConfig(opts?: LoadConfigOptions<VixtOptions>): Promise<c12.ResolvedConfig<VixtOptions, c12.ConfigLayerMeta>>;
120
125
  declare function resolveLayersDirs(layers?: VixtConfigLayer[]): Record<string, string[] | undefined>;
121
126
 
@@ -127,4 +132,4 @@ declare function applyLayerModules(layers?: VixtConfigLayer[]): Promise<VixtModu
127
132
  declare function loadVixt(opts?: LoadConfigOptions<VixtOptions>): Promise<Vixt>;
128
133
  declare function createVixtPlugin(loadOptions: LoadConfigOptions<VixtOptions>): (options?: VixtOptions | undefined) => vite.PluginOption;
129
134
 
130
- export { type AppHead, type AppOptions, type ModuleDefinition, type ModuleMeta, type ModuleOptions, type PluginOptions, type TypescriptOptions, type Vixt, type VixtConfigLayer, type VixtModule, type VixtOptions, alias, app, applyLayerModules, buildDir, buildTypesDir, config, createVixtPlugin, defineVitePlugin, defineVixtConfig, defineVixtModule, installModule, loadVixt, loadVixtConfig, resolveLayersDirs, rootDir, typescript };
135
+ export { type AppHead, type AppOptions, type ModuleDefinition, type ModuleMeta, type ModuleOptions, type PluginOptions, type TypescriptOptions, type Vixt, type VixtConfigLayer, type VixtModule, type VixtOptions, alias, app, applyLayerModules, buildDir, buildLayersDir, buildTypesDir, config, createVixtPlugin, defineVitePlugin, defineVixtConfig, defineVixtModule, installModule, loadVixt, loadVixtConfig, resolveLayersDirs, rootDir, typescript };
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { cwd } from 'node:process';
2
1
  import path from 'pathe';
2
+ import { cwd } from 'node:process';
3
3
  import fs from 'fs-extra';
4
4
  import 'tsx/esm';
5
5
  import { pathToFileURL } from 'mlly';
@@ -11,17 +11,19 @@ const name$3 = "vixt:alias";
11
11
  const alias = defineVixtModule({
12
12
  meta: { name: name$3 },
13
13
  setup(_, vixt) {
14
+ const { rootDir, buildDir } = vixt.options;
14
15
  return {
15
16
  name: name$3,
16
17
  config() {
17
18
  return {
18
- root: vixt.options.rootDir,
19
+ root: rootDir,
19
20
  resolve: {
20
21
  alias: {
21
- "@": `${path.resolve(cwd(), "src")}`,
22
- "~": `${path.resolve(cwd(), "src")}`,
23
- "@@": path.resolve(cwd()),
24
- "~~": path.resolve(cwd())
22
+ "@": `${path.resolve(rootDir, "src")}`,
23
+ "~": `${path.resolve(rootDir, "src")}`,
24
+ "@@": path.resolve(rootDir),
25
+ "~~": path.resolve(rootDir),
26
+ "#": path.resolve(rootDir, buildDir)
25
27
  }
26
28
  }
27
29
  };
@@ -33,9 +35,10 @@ const alias = defineVixtModule({
33
35
  function defineVixtConfig(input) {
34
36
  return input;
35
37
  }
36
- const rootDir = cwd();
38
+ const rootDir = path.resolve(cwd());
37
39
  const buildDir = ".vixt";
38
40
  const buildTypesDir = `${buildDir}/types`;
41
+ const buildLayersDir = `${buildDir}/layers`;
39
42
  async function loadVixtConfig(opts) {
40
43
  const result = await loadConfig({
41
44
  name: "vixt",
@@ -45,12 +48,28 @@ async function loadVixtConfig(opts) {
45
48
  rootDir,
46
49
  buildDir,
47
50
  buildTypesDir,
51
+ buildLayersDir,
48
52
  ...opts?.defaults
49
53
  }
50
54
  });
51
- result.layers = result.layers?.filter((e) => e.cwd);
55
+ result.layers = result.layers?.filter((e) => e.cwd).map((e) => {
56
+ if (e.cwd !== rootDir) {
57
+ const layerRootDir = e.cwd.split("/").pop();
58
+ const newCwd = path.resolve(rootDir, buildLayersDir, layerRootDir);
59
+ fs.copySync(e.cwd, newCwd, { filter: (src) => {
60
+ const nodeModulesPath = path.resolve(e.cwd, "node_modules");
61
+ const tsConfigPath = path.resolve(e.cwd, "tsconfig.json");
62
+ return !isSamePath(src, nodeModulesPath) && !isSamePath(src, tsConfigPath);
63
+ } });
64
+ return { ...e, relatedCwd: e.cwd, cwd: newCwd };
65
+ }
66
+ return e;
67
+ });
52
68
  return result;
53
69
  }
70
+ function isSamePath(a, b) {
71
+ return path.resolve(a) === path.resolve(b);
72
+ }
54
73
  function resolveLayersDirs(layers = []) {
55
74
  const dirs = {};
56
75
  for (const layer of layers) {
@@ -271,7 +290,9 @@ const defaults = {
271
290
  "@": ["../src"],
272
291
  "@/*": ["../src/*"],
273
292
  "~": ["../src"],
274
- "~/*": ["../src/*"]
293
+ "~/*": ["../src/*"],
294
+ "#": ["."],
295
+ "#/*": ["./*"]
275
296
  },
276
297
  types: ["vite/client"]
277
298
  },
@@ -323,4 +344,4 @@ function createVixtPlugin(loadOptions) {
323
344
  });
324
345
  }
325
346
 
326
- export { alias, app, applyLayerModules, buildDir, buildTypesDir, config, createVixtPlugin, defineVitePlugin, defineVixtConfig, defineVixtModule, installModule, loadVixt, loadVixtConfig, resolveLayersDirs, rootDir, typescript };
347
+ export { alias, app, applyLayerModules, buildDir, buildLayersDir, buildTypesDir, config, createVixtPlugin, defineVitePlugin, defineVixtConfig, defineVixtModule, installModule, loadVixt, loadVixtConfig, resolveLayersDirs, rootDir, typescript };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vixt/core",
3
3
  "type": "module",
4
- "version": "0.0.10",
4
+ "version": "0.0.12",
5
5
  "author": "SoulLyoko<https://github.com/SoulLyoko>",
6
6
  "license": "MIT",
7
7
  "homepage": "https://github.com/SoulLyoko/vixt#readme",