@vixt/core 0.1.0 → 0.1.2
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/client/index.d.mts +1 -1
- package/dist/client/index.d.ts +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.mjs +18 -17
- package/dist/shared/{core.28e7fb8c.d.mts → core.66c5bb58.d.mts} +1 -1
- package/dist/shared/{core.28e7fb8c.d.ts → core.66c5bb58.d.ts} +1 -1
- package/package.json +1 -1
package/dist/client/index.d.mts
CHANGED
|
@@ -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.
|
|
4
|
+
import { f as VixtAppConfig } from '../shared/core.66c5bb58.mjs';
|
|
5
5
|
import 'vite';
|
|
6
6
|
import 'c12';
|
|
7
7
|
|
package/dist/client/index.d.ts
CHANGED
|
@@ -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.
|
|
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.
|
|
2
|
-
export { g as ModuleMeta, P as PluginOptions, f as VixtAppConfig, e as VixtConfigLayerMeta } from './shared/core.
|
|
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.
|
|
2
|
-
export { g as ModuleMeta, P as PluginOptions, f as VixtAppConfig, e as VixtConfigLayerMeta } from './shared/core.
|
|
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
|
-
|
|
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(
|
|
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.
|
|
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, "
|
|
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, "
|
|
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, "
|
|
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
|
|
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
|
|
260
|
+
return mainTsCode;
|
|
261
261
|
}
|
|
262
262
|
}
|
|
263
263
|
};
|
|
@@ -286,7 +286,8 @@ 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
|
-
|
|
289
|
+
const layerRelativePath = `./${path.relative(path.resolve(rootDir, buildDir), layer.cwd)}/*`;
|
|
290
|
+
layersAlias[`${layer.meta.alias}/*`] = [layerRelativePath];
|
|
290
291
|
}
|
|
291
292
|
}
|
|
292
293
|
const tsConfig = defu(options.tsConfig, { compilerOptions: { paths: layersAlias }, include: layersDirs });
|
|
@@ -306,7 +307,8 @@ function generateVixtDts(options, vixt) {
|
|
|
306
307
|
return "";
|
|
307
308
|
}
|
|
308
309
|
}).concat("export {}").join("\n");
|
|
309
|
-
|
|
310
|
+
if (code)
|
|
311
|
+
fs.outputFileSync(codePath, code);
|
|
310
312
|
}
|
|
311
313
|
function genarateShims(options, vixt) {
|
|
312
314
|
const { buildTypesDir, rootDir } = vixt.options;
|
|
@@ -353,7 +355,6 @@ const defaults = {
|
|
|
353
355
|
tsConfig: {
|
|
354
356
|
extends: "@vue/tsconfig/tsconfig.dom.json",
|
|
355
357
|
compilerOptions: {
|
|
356
|
-
baseUrl: "./",
|
|
357
358
|
paths: {
|
|
358
359
|
"@/*": ["../src/*"],
|
|
359
360
|
"~/*": ["../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
|
|
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
|
|
57
|
+
/** relative path from `<layer.cwd>/src` to `<rootDir>/src` */
|
|
58
58
|
relative?: string;
|
|
59
59
|
}
|
|
60
60
|
interface VixtConfigLayer extends ConfigLayer<VixtOptions, VixtConfigLayerMeta> {
|