@vixt/core 0.6.4 → 0.6.6
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/node/index.mjs +65 -64
- package/package.json +2 -1
package/dist/node/index.mjs
CHANGED
|
@@ -12,6 +12,7 @@ import Legacy from "@vitejs/plugin-legacy";
|
|
|
12
12
|
import Analyzer from "vite-bundle-analyzer";
|
|
13
13
|
import Ssl from "@vitejs/plugin-basic-ssl";
|
|
14
14
|
import Checker from "vite-plugin-checker";
|
|
15
|
+
import { builders, parseExpression, parseModule } from "magicast";
|
|
15
16
|
|
|
16
17
|
//#region src/node/env.ts
|
|
17
18
|
function loadCLIOptions() {
|
|
@@ -259,28 +260,31 @@ var app_default = defineVixtModule({
|
|
|
259
260
|
},
|
|
260
261
|
transformIndexHtml: {
|
|
261
262
|
order,
|
|
262
|
-
handler() {
|
|
263
|
+
handler(html = "") {
|
|
263
264
|
if (!transformIndexHtml) return;
|
|
264
265
|
const { rootTag, rootId, head } = options;
|
|
265
266
|
const tags = Object.entries(head ?? {}).map(([tag, attrs]) => attrs.map((attr) => resolveHead(tag, attr))).flat();
|
|
266
267
|
const loadingTemplate = resolveLoadingTemplate(options, vixt);
|
|
267
|
-
return
|
|
268
|
-
{
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
tag: "script",
|
|
276
|
-
attrs: {
|
|
277
|
-
type: "module",
|
|
278
|
-
src: relativeEntryPath
|
|
268
|
+
return {
|
|
269
|
+
html: `<!DOCTYPE html>\n${html}`,
|
|
270
|
+
tags: [
|
|
271
|
+
{
|
|
272
|
+
tag: rootTag,
|
|
273
|
+
attrs: { id: rootId },
|
|
274
|
+
children: loadingTemplate,
|
|
275
|
+
injectTo: "body"
|
|
279
276
|
},
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
277
|
+
{
|
|
278
|
+
tag: "script",
|
|
279
|
+
attrs: {
|
|
280
|
+
type: "module",
|
|
281
|
+
src: relativeEntryPath
|
|
282
|
+
},
|
|
283
|
+
injectTo: "body"
|
|
284
|
+
},
|
|
285
|
+
...tags
|
|
286
|
+
]
|
|
287
|
+
};
|
|
284
288
|
}
|
|
285
289
|
}
|
|
286
290
|
};
|
|
@@ -464,33 +468,35 @@ const resolvedVirtualModuleId$2 = `\0${virtualModuleId$2}`;
|
|
|
464
468
|
var virtual_app_config_default = defineVixtModule({
|
|
465
469
|
meta: { name: name$3 },
|
|
466
470
|
setup(_, vixt) {
|
|
467
|
-
let appConfigsImportTemplate = "";
|
|
468
|
-
let appConfigsMergeTemplate = "";
|
|
469
|
-
let i = 0;
|
|
470
|
-
for (const layer of vixt._layers) {
|
|
471
|
-
const appConfigPath = path.resolve(layer.config.srcDir, "app.config.ts");
|
|
472
|
-
if (fs.existsSync(appConfigPath)) {
|
|
473
|
-
const appConfigName = `__app_config_${i}`;
|
|
474
|
-
appConfigsImportTemplate += `import ${appConfigName} from '${appConfigPath}'\n`;
|
|
475
|
-
appConfigsMergeTemplate += `${appConfigName}, `;
|
|
476
|
-
i++;
|
|
477
|
-
}
|
|
478
|
-
}
|
|
479
471
|
return {
|
|
480
472
|
name: name$3,
|
|
481
473
|
resolveId(id) {
|
|
482
474
|
if (id === virtualModuleId$2) return resolvedVirtualModuleId$2;
|
|
483
475
|
},
|
|
484
476
|
load(id) {
|
|
485
|
-
if (id
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
477
|
+
if (id !== resolvedVirtualModuleId$2) return;
|
|
478
|
+
const { baseURL = "/", rootId = "app" } = vixt.options.app ?? {};
|
|
479
|
+
const code = parseModule("import { defu } from \"defu\"");
|
|
480
|
+
const defuCall = builders.functionCall("defu");
|
|
481
|
+
let i = 0;
|
|
482
|
+
for (const layer of vixt._layers) {
|
|
483
|
+
const appConfigPath = path.resolve(layer.config.srcDir, "app.config.ts");
|
|
484
|
+
if (fs.existsSync(appConfigPath)) {
|
|
485
|
+
const appConfigName = `__app_config_${i++}`;
|
|
486
|
+
code.imports.$append({
|
|
487
|
+
local: appConfigName,
|
|
488
|
+
imported: "default",
|
|
489
|
+
from: appConfigPath
|
|
490
|
+
});
|
|
491
|
+
defuCall.$args.push(parseExpression(appConfigName));
|
|
492
|
+
}
|
|
493
493
|
}
|
|
494
|
+
defuCall.$args.push({
|
|
495
|
+
baseURL,
|
|
496
|
+
rootId
|
|
497
|
+
});
|
|
498
|
+
code.exports.default = defuCall;
|
|
499
|
+
return code.generate();
|
|
494
500
|
}
|
|
495
501
|
};
|
|
496
502
|
}
|
|
@@ -504,14 +510,13 @@ const resolvedVirtualModuleId$1 = `\0${virtualModuleId$1}`;
|
|
|
504
510
|
var virtual_css_default = defineVixtModule({
|
|
505
511
|
meta: { name: name$2 },
|
|
506
512
|
setup(_, vixt) {
|
|
507
|
-
const cssTemplate = vixt.options.app?.css?.map((css) => `import '${css}'`).join("\n") ?? "";
|
|
508
513
|
return {
|
|
509
514
|
name: name$2,
|
|
510
515
|
resolveId(id) {
|
|
511
516
|
if (id === virtualModuleId$1) return resolvedVirtualModuleId$1;
|
|
512
517
|
},
|
|
513
518
|
load(id) {
|
|
514
|
-
if (id === resolvedVirtualModuleId$1) return
|
|
519
|
+
if (id === resolvedVirtualModuleId$1) return vixt.options.app?.css?.map((css) => `import '${css}'`).join("\n") ?? "";
|
|
515
520
|
}
|
|
516
521
|
};
|
|
517
522
|
}
|
|
@@ -525,37 +530,33 @@ const resolvedVirtualModuleId = `\0${virtualModuleId}`;
|
|
|
525
530
|
var virtual_plugins_default = defineVixtModule({
|
|
526
531
|
meta: { name: name$1 },
|
|
527
532
|
setup(_, vixt) {
|
|
528
|
-
const { plugins: pluginsDirs = [] } = resolveLayersDirs(vixt._layers);
|
|
529
|
-
let pluginsImportTemplate = "";
|
|
530
|
-
let pluginsMergeTemplate = "";
|
|
531
|
-
let i = 0;
|
|
532
|
-
for (const plugin of vixt.options.plugins ?? []) {
|
|
533
|
-
const pluginName = `__plugin_${i}`;
|
|
534
|
-
pluginsImportTemplate += `import ${pluginName} from '${plugin}'\n`;
|
|
535
|
-
pluginsMergeTemplate += `${pluginName}, `;
|
|
536
|
-
i++;
|
|
537
|
-
}
|
|
538
|
-
for (const pluginsDir of pluginsDirs.reverse()) {
|
|
539
|
-
const files = fs.existsSync(pluginsDir) ? fs.readdirSync(pluginsDir) : [];
|
|
540
|
-
for (const f of files.filter((f$1) => /[jt]sx?$/.test(f$1))) {
|
|
541
|
-
const p = path.resolve(pluginsDir, f);
|
|
542
|
-
const pluginName = `__plugin_${i}`;
|
|
543
|
-
pluginsImportTemplate += `import ${pluginName} from '${p}'\n`;
|
|
544
|
-
pluginsMergeTemplate += `${pluginName}, `;
|
|
545
|
-
i++;
|
|
546
|
-
}
|
|
547
|
-
}
|
|
548
533
|
return {
|
|
549
534
|
name: name$1,
|
|
550
535
|
resolveId(id) {
|
|
551
536
|
if (id === virtualModuleId) return resolvedVirtualModuleId;
|
|
552
537
|
},
|
|
553
538
|
load(id) {
|
|
554
|
-
if (id
|
|
555
|
-
|
|
556
|
-
const
|
|
557
|
-
|
|
558
|
-
|
|
539
|
+
if (id !== resolvedVirtualModuleId) return;
|
|
540
|
+
const { plugins: pluginsDirs = [] } = resolveLayersDirs(vixt._layers);
|
|
541
|
+
const code = parseModule("");
|
|
542
|
+
const pluginsArray = parseExpression("[]");
|
|
543
|
+
let i = 0;
|
|
544
|
+
function addPlugin(from) {
|
|
545
|
+
const pluginName = `__plugin_${i++}`;
|
|
546
|
+
code.imports.$append({
|
|
547
|
+
local: pluginName,
|
|
548
|
+
imported: "default",
|
|
549
|
+
from
|
|
550
|
+
});
|
|
551
|
+
pluginsArray.push(parseExpression(pluginName));
|
|
552
|
+
}
|
|
553
|
+
for (const pluginPath of vixt.options.plugins ?? []) addPlugin(pluginPath);
|
|
554
|
+
for (const pluginsDir of pluginsDirs.reverse()) {
|
|
555
|
+
const files = fs.existsSync(pluginsDir) ? fs.readdirSync(pluginsDir) : [];
|
|
556
|
+
for (const file of files.filter((f) => /[jt]sx?$/.test(f))) addPlugin(path.resolve(pluginsDir, file));
|
|
557
|
+
}
|
|
558
|
+
code.exports.default = pluginsArray;
|
|
559
|
+
return code.generate();
|
|
559
560
|
}
|
|
560
561
|
};
|
|
561
562
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vixt/core",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.6.
|
|
4
|
+
"version": "0.6.6",
|
|
5
5
|
"author": "SoulLyoko<https://github.com/SoulLyoko>",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://soullyoko.github.io/vixt/",
|
|
@@ -37,6 +37,7 @@
|
|
|
37
37
|
"find-up": "^8.0.0",
|
|
38
38
|
"fs-extra": "^11.3.3",
|
|
39
39
|
"jiti": "^2.6.1",
|
|
40
|
+
"magicast": "^0.5.1",
|
|
40
41
|
"mlly": "^1.8.0",
|
|
41
42
|
"pathe": "^2.0.3",
|
|
42
43
|
"pkg-types": "^2.3.0",
|