@ubean/cli 0.4.3 → 0.4.4
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/cli.js +22 -3
- package/package.json +12 -12
package/dist/cli.js
CHANGED
|
@@ -19,7 +19,6 @@ import { createServer as createServer$1 } from "vite";
|
|
|
19
19
|
import vue from "@vitejs/plugin-vue";
|
|
20
20
|
import { ubeanPlugin } from "@ubean/build/vite";
|
|
21
21
|
import { VUE_PLUGIN_INCLUDE, ubeanVite } from "@ubean/build/vue";
|
|
22
|
-
import { createVueRenderer } from "@ubean/client/ssr";
|
|
23
22
|
import { getVueLocaleParam, toVueRouterLocalePath } from "@ubean/i18n";
|
|
24
23
|
import { ubeanIslandsPlugin } from "@ubean/islands/vite";
|
|
25
24
|
import { findAvailablePort, findUserViteConfig, waitForPort } from "@ubean/shared/node";
|
|
@@ -501,6 +500,23 @@ function loadScaffoldOps() {
|
|
|
501
500
|
recoverScaffold
|
|
502
501
|
};
|
|
503
502
|
}
|
|
503
|
+
/** Vite's browser-facing prefix for virtual module ids (see `wrapId`). */
|
|
504
|
+
const VALID_ID_PREFIX = "/@id/";
|
|
505
|
+
/** Vite's URL-safe encoding of the `\0` virtual-module marker. */
|
|
506
|
+
const NULL_BYTE_PLACEHOLDER = "__x00__";
|
|
507
|
+
/**
|
|
508
|
+
* Encode a module-graph URL into a browser-servable path.
|
|
509
|
+
*
|
|
510
|
+
* Virtual module ids carry a raw `\0` marker in the module graph (e.g.
|
|
511
|
+
* UnoCSS's `\0/__uno.css`). A literal NUL is invalid inside HTML — parse5
|
|
512
|
+
* rejects it with `unexpected-null-character`, which surfaces as a warning
|
|
513
|
+
* in `transformIndexHtml`. Mirror Vite's own import-analysis rewriting
|
|
514
|
+
* (`wrapId`: `/@id/` prefix + `\0` → `__x00__`) so the href stays valid
|
|
515
|
+
* and resolvable by the dev server.
|
|
516
|
+
*/
|
|
517
|
+
function toDevCssHref(url) {
|
|
518
|
+
return url.includes("\0") ? `${VALID_ID_PREFIX}${url.replace(/\0/g, NULL_BYTE_PLACEHOLDER)}` : url;
|
|
519
|
+
}
|
|
504
520
|
/**
|
|
505
521
|
* Collect render-blocking CSS URLs from the Vite dev module graph.
|
|
506
522
|
*
|
|
@@ -520,7 +536,7 @@ function collectDevCssLinks(moduleGraph) {
|
|
|
520
536
|
for (const mod of moduleGraph.idToModuleMap.values()) {
|
|
521
537
|
const { url, id } = mod;
|
|
522
538
|
if (!url || url.includes("?")) continue;
|
|
523
|
-
if (id?.endsWith(".css") || url.endsWith(".css")) links.add(`${url}?direct`);
|
|
539
|
+
if (id?.endsWith(".css") || url.endsWith(".css")) links.add(`${toDevCssHref(url)}?direct`);
|
|
524
540
|
}
|
|
525
541
|
return [...links];
|
|
526
542
|
}
|
|
@@ -658,6 +674,7 @@ async function createViteDevServer(options) {
|
|
|
658
674
|
let viteDevtoolsPlugins = [];
|
|
659
675
|
if (devtoolsEnabled) try {
|
|
660
676
|
const { DevTools } = await import("@vitejs/devtools");
|
|
677
|
+
// @vitejs/devtools 也解析到含 @vitejs+devtools peer 上下文的 vite-plus-core
|
|
661
678
|
viteDevtoolsPlugins = await DevTools({ builtinDevTools: false });
|
|
662
679
|
} catch {}
|
|
663
680
|
const userViteConfig = findUserViteConfig(cwd);
|
|
@@ -692,6 +709,7 @@ async function createViteDevServer(options) {
|
|
|
692
709
|
viteServer = await createServer$1({
|
|
693
710
|
root: cwd,
|
|
694
711
|
configFile: userViteConfig ?? false,
|
|
712
|
+
resolve: { dedupe: ["vue", "vue-router"] },
|
|
695
713
|
server: {
|
|
696
714
|
middlewareMode: { server: httpServer },
|
|
697
715
|
hmr: { port: actualPort + 1e3 }
|
|
@@ -715,10 +733,11 @@ async function createViteDevServer(options) {
|
|
|
715
733
|
"#ubean-client-entry"
|
|
716
734
|
] },
|
|
717
735
|
ssr: {
|
|
718
|
-
noExternal: ["ubean"],
|
|
736
|
+
noExternal: ["ubean", /^@ubean\//],
|
|
719
737
|
external: ["@ubean/i18n"]
|
|
720
738
|
}
|
|
721
739
|
});
|
|
740
|
+
const { createVueRenderer } = await viteServer.ssrLoadModule("@ubean/client/ssr");
|
|
722
741
|
function enhanceAppWithVite(app, layouts = []) {
|
|
723
742
|
app.options.layouts = layouts;
|
|
724
743
|
const routeLoaders = {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ubean/cli",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.4",
|
|
4
4
|
"description": "CLI for ubean (ubean-next binary: dev, build, prepare, init, preview, page, env, config, devtools, api/layout/middleware/cron/plugin scaffolds) plus the Vite dev server runner",
|
|
5
5
|
"bin": {
|
|
6
6
|
"ubean-next": "./bin/ubean-next.mjs"
|
|
@@ -24,15 +24,15 @@
|
|
|
24
24
|
}
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@ubean/app": "0.4.
|
|
28
|
-
"@ubean/build": "0.4.
|
|
29
|
-
"@ubean/client": "0.4.
|
|
30
|
-
"@ubean/config": "0.4.
|
|
31
|
-
"@ubean/i18n": "0.4.
|
|
32
|
-
"@ubean/islands": "0.4.
|
|
33
|
-
"@ubean/preset": "0.4.
|
|
34
|
-
"@ubean/scan": "0.4.
|
|
35
|
-
"@ubean/shared": "0.4.
|
|
27
|
+
"@ubean/app": "0.4.4",
|
|
28
|
+
"@ubean/build": "0.4.4",
|
|
29
|
+
"@ubean/client": "0.4.4",
|
|
30
|
+
"@ubean/config": "0.4.4",
|
|
31
|
+
"@ubean/i18n": "0.4.4",
|
|
32
|
+
"@ubean/islands": "0.4.4",
|
|
33
|
+
"@ubean/preset": "0.4.4",
|
|
34
|
+
"@ubean/scan": "0.4.4",
|
|
35
|
+
"@ubean/shared": "0.4.4",
|
|
36
36
|
"citty": "^0.2.2",
|
|
37
37
|
"kolorist": "^1.8.0",
|
|
38
38
|
"pathe": "^2.0.3"
|
|
@@ -45,8 +45,8 @@
|
|
|
45
45
|
"vite-plus": "0.3.0"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
|
-
"@ubean/content": "0.4.
|
|
49
|
-
"@ubean/devtools": "0.4.
|
|
48
|
+
"@ubean/content": "0.4.4",
|
|
49
|
+
"@ubean/devtools": "0.4.4",
|
|
50
50
|
"@vitejs/plugin-vue": "^6.0.8",
|
|
51
51
|
"vite": "npm:@voidzero-dev/vite-plus-core@0.3.0"
|
|
52
52
|
},
|