@vixt/core 0.1.0 → 0.1.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,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.28e7fb8c.mjs';
4
+ import { f as VixtAppConfig } from '../shared/core.66c5bb58.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.28e7fb8c.js';
4
+ import { f as VixtAppConfig } from '../shared/core.66c5bb58.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.28e7fb8c.mjs';
2
- export { g as ModuleMeta, P as PluginOptions, f as VixtAppConfig, e as VixtConfigLayerMeta } from './shared/core.28e7fb8c.mjs';
1
+ import { V as VixtModule, M as ModuleOptions, a as Vixt, b as VixtOptions, c as VixtConfigLayer, d as ModuleDefinition } from './shared/core.66c5bb58.mjs';
2
+ export { g as ModuleMeta, P as PluginOptions, f as VixtAppConfig, e as VixtConfigLayerMeta } from './shared/core.66c5bb58.mjs';
3
3
  import { TSConfig } from 'pkg-types';
4
4
  import Checker from 'vite-plugin-checker';
5
5
  import * as c12 from 'c12';
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.28e7fb8c.js';
2
- export { g as ModuleMeta, P as PluginOptions, f as VixtAppConfig, e as VixtConfigLayerMeta } from './shared/core.28e7fb8c.js';
1
+ import { V as VixtModule, M as ModuleOptions, a as Vixt, b as VixtOptions, c as VixtConfigLayer, d as ModuleDefinition } from './shared/core.66c5bb58.js';
2
+ export { g as ModuleMeta, P as PluginOptions, f as VixtAppConfig, e as VixtConfigLayerMeta } from './shared/core.66c5bb58.js';
3
3
  import { TSConfig } from 'pkg-types';
4
4
  import Checker from 'vite-plugin-checker';
5
5
  import * as c12 from 'c12';
package/dist/index.mjs CHANGED
@@ -1,9 +1,9 @@
1
1
  import path from 'pathe';
2
- import { cwd } from 'node:process';
3
2
  import fs from 'fs-extra';
4
3
  import 'tsx/esm';
5
4
  import { pathToFileURL } from 'mlly';
6
5
  import defu from 'defu';
6
+ import { cwd } from 'node:process';
7
7
  import { loadConfig } from 'c12';
8
8
  import Checker from 'vite-plugin-checker';
9
9
 
@@ -65,7 +65,8 @@ function mapLayers(layers) {
65
65
  return layers.map((layer) => {
66
66
  const meta = layer.config?.meta ?? {};
67
67
  const layerName = meta.name || layer.cwd.split("/").pop();
68
- meta.name && (meta.alias = `#/layers/${meta.name}`);
68
+ if (!isSamePath(layer.cwd, path.resolve(rootDir)))
69
+ meta.alias = `#/layers/${layerName}`;
69
70
  if (layer.cwd?.includes("node_modules")) {
70
71
  const newCwd = path.resolve(rootDir, buildLayersDir, layerName);
71
72
  fs.copySync(layer.cwd, newCwd, {
@@ -77,7 +78,7 @@ function mapLayers(layers) {
77
78
  });
78
79
  layer.cwd = newCwd;
79
80
  }
80
- meta.relative = path.join("./", path.relative(`${rootDir}/src`, layer.cwd));
81
+ meta.relative = path.join(path.relative(`${rootDir}/src`, `${layer.cwd}/src`));
81
82
  return { ...layer, meta };
82
83
  });
83
84
  }
@@ -163,8 +164,7 @@ function generateIndexHtml(options, vixt) {
163
164
  }
164
165
  }
165
166
  }
166
- const code = `
167
- <!doctype html>
167
+ const code = `<!DOCTYPE html>
168
168
  <html>
169
169
  <head>
170
170
  ${headTemplate}
@@ -193,17 +193,17 @@ function generateMainTs(options, vixt) {
193
193
  let pluginsImportTemplate = "";
194
194
  let pluginsMergeTemplate = "";
195
195
  vixt._layers.forEach((layer, i) => {
196
- const appComponentPath = path.join(layer.cwd, "/src/App.vue");
196
+ const appComponentPath = path.resolve(layer.cwd, "src", "App.vue");
197
197
  if (fs.existsSync(appComponentPath) && !appComponentImportTempate) {
198
- const appComponentRelativePath = path.join(layer.meta.relative, "/src/App.vue");
198
+ const appComponentRelativePath = `./${path.join(layer.meta.relative, "App.vue")}`;
199
199
  appComponentImportTempate = `import App from '${appComponentRelativePath}'`;
200
200
  }
201
- const appConfigPath = path.join(layer.meta.relative, "/src/app.config.ts");
201
+ const appConfigPath = `./${path.join(layer.meta.relative, "app.config.ts")}`;
202
202
  const appConfigsName = `__app_config__${i}`;
203
203
  appConfigsImportTemplate += `const ${appConfigsName} = Object.values(import.meta.glob('${appConfigPath}', { import: 'default', eager: true }))[0]
204
204
  `;
205
205
  appConfigsMergeTemplate += `${appConfigsName}, `;
206
- const pluginsPath = path.join(layer.meta.relative, "/src/plugins/*.ts");
206
+ const pluginsPath = `./${path.join(layer.meta.relative, "plugins/*.ts")}`;
207
207
  const pluginsName = `__plugins__${i}`;
208
208
  pluginsImportTemplate += `const ${pluginsName} = Object.values(import.meta.glob('${pluginsPath}', { import: 'default', eager: true }))
209
209
  `;
@@ -223,6 +223,7 @@ const plugins = [${pluginsMergeTemplate}].reverse()
223
223
  `;
224
224
  code = options.transformMain?.(code, vixt) || code;
225
225
  fs.outputFileSync(path.resolve(rootDir, buildDir, "main.ts"), code);
226
+ return code;
226
227
  }
227
228
  const name$2 = "vixt:app";
228
229
  const defaults$1 = {
@@ -241,15 +242,14 @@ const app = defineVixtModule({
241
242
  meta: { name: name$2, configKey: "app" },
242
243
  defaults: defaults$1,
243
244
  setup(options, vixt) {
244
- generateIndexHtml(options, vixt);
245
- generateMainTs(options, vixt);
246
- const { rootDir, buildDir } = vixt.options;
245
+ const indexHtmlCode = generateIndexHtml(options, vixt);
246
+ const mainTsCode = generateMainTs(options, vixt);
247
247
  return {
248
248
  name: name$2,
249
249
  transformIndexHtml: {
250
250
  order: "pre",
251
251
  handler() {
252
- return fs.readFileSync(path.resolve(cwd(), `${buildDir}/index.html`), { encoding: "utf-8" });
252
+ return indexHtmlCode;
253
253
  }
254
254
  },
255
255
  transform: {
@@ -257,7 +257,7 @@ const app = defineVixtModule({
257
257
  handler(code, id) {
258
258
  if (!id.includes("/src/main.ts"))
259
259
  return;
260
- return fs.readFileSync(path.resolve(rootDir, buildDir, "main.ts"), "utf-8");
260
+ return mainTsCode;
261
261
  }
262
262
  }
263
263
  };
@@ -286,7 +286,7 @@ function generateTsConfig(options, vixt) {
286
286
  for (const layer of vixt._layers) {
287
287
  layersDirs.push(layer.cwd);
288
288
  if (layer.meta?.alias) {
289
- layersAlias[`${layer.meta.alias}/*`] = [`${layer.cwd}/*`];
289
+ layersAlias[`${layer.meta.alias}/*`] = [`${path.relative(path.resolve(rootDir, buildDir), layer.cwd)}/*`];
290
290
  }
291
291
  }
292
292
  const tsConfig = defu(options.tsConfig, { compilerOptions: { paths: layersAlias }, include: layersDirs });
@@ -306,7 +306,8 @@ function generateVixtDts(options, vixt) {
306
306
  return "";
307
307
  }
308
308
  }).concat("export {}").join("\n");
309
- code && fs.outputFileSync(codePath, code);
309
+ if (code)
310
+ fs.outputFileSync(codePath, code);
310
311
  }
311
312
  function genarateShims(options, vixt) {
312
313
  const { buildTypesDir, rootDir } = vixt.options;
@@ -353,7 +354,6 @@ const defaults = {
353
354
  tsConfig: {
354
355
  extends: "@vue/tsconfig/tsconfig.dom.json",
355
356
  compilerOptions: {
356
- baseUrl: "./",
357
357
  paths: {
358
358
  "@/*": ["../src/*"],
359
359
  "~/*": ["../src/*"],
@@ -54,7 +54,7 @@ interface VixtConfigLayerMeta extends ConfigLayerMeta {
54
54
  name?: string;
55
55
  /** layer alias */
56
56
  alias?: string;
57
- /** relative path from layer cwd to <rootDir>/src */
57
+ /** relative path from `<layer.cwd>/src` to `<rootDir>/src` */
58
58
  relative?: string;
59
59
  }
60
60
  interface VixtConfigLayer extends ConfigLayer<VixtOptions, VixtConfigLayerMeta> {
@@ -54,7 +54,7 @@ interface VixtConfigLayerMeta extends ConfigLayerMeta {
54
54
  name?: string;
55
55
  /** layer alias */
56
56
  alias?: string;
57
- /** relative path from layer cwd to <rootDir>/src */
57
+ /** relative path from `<layer.cwd>/src` to `<rootDir>/src` */
58
58
  relative?: string;
59
59
  }
60
60
  interface VixtConfigLayer extends ConfigLayer<VixtOptions, VixtConfigLayerMeta> {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vixt/core",
3
3
  "type": "module",
4
- "version": "0.1.0",
4
+ "version": "0.1.1",
5
5
  "author": "SoulLyoko<https://github.com/SoulLyoko>",
6
6
  "license": "MIT",
7
7
  "homepage": "https://github.com/SoulLyoko/vixt#readme",