@solid-tui/vite 0.1.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 solid-tui contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,64 @@
1
+ # @solid-tui/vite
2
+
3
+ Vite plugin for solid-tui: an in-process terminal dev server with HMR, plus a
4
+ production build, for Solid apps that render to the terminal via
5
+ `@solid-tui/runtime`.
6
+
7
+ ## Install
8
+
9
+ ```sh
10
+ npm install -D @solid-tui/vite
11
+ # peer deps: vite ^8, @solid-tui/runtime, solid-js ^1.9
12
+ ```
13
+
14
+ ## Usage
15
+
16
+ ```ts
17
+ import { defineConfig } from "vite";
18
+ import { solidTui } from "@solid-tui/vite";
19
+
20
+ export default defineConfig({
21
+ plugins: [solidTui()],
22
+ });
23
+ ```
24
+
25
+ - `vite` boots the app in-process through Vite's SSR module runner and renders it
26
+ to the terminal with HMR.
27
+ - `vite build` bundles a Node entry (`dist/main.js` by default).
28
+
29
+ ### Options
30
+
31
+ ```ts
32
+ solidTui({
33
+ entry: "src/main.tsx",
34
+ solid: {
35
+ // vite-plugin-solid options; generate/moduleName are forced for solid-tui.
36
+ },
37
+ });
38
+ ```
39
+
40
+ ## Build output
41
+
42
+ By default the production build externalizes bare dependencies, while bundling
43
+ relative, absolute, virtual, and Solid runtime ids required by the terminal
44
+ renderer. To produce a self-contained single file, set your own
45
+ `build.rolldownOptions.external`; the plugin will yield to it.
46
+
47
+ ```ts
48
+ import { isBuiltin } from "node:module";
49
+
50
+ export default defineConfig({
51
+ plugins: [solidTui()],
52
+ build: {
53
+ rolldownOptions: {
54
+ external: (id) => isBuiltin(id),
55
+ platform: "node",
56
+ output: { inlineDynamicImports: true },
57
+ },
58
+ },
59
+ });
60
+ ```
61
+
62
+ ## License
63
+
64
+ MIT
@@ -0,0 +1,11 @@
1
+ import solid from "vite-plugin-solid";
2
+ import { Plugin } from "vite";
3
+
4
+ //#region src/index.d.ts
5
+ interface SolidTuiOptions {
6
+ solid?: Parameters<typeof solid>[0];
7
+ entry?: string;
8
+ }
9
+ declare function solidTui(options?: SolidTuiOptions): Plugin[];
10
+ //#endregion
11
+ export { SolidTuiOptions, solidTui as default, solidTui };
package/dist/index.mjs ADDED
@@ -0,0 +1,164 @@
1
+ import solid from "vite-plugin-solid";
2
+ import { isRunnableDevEnvironment } from "vite";
3
+ import { posix, win32 } from "node:path";
4
+ //#region src/dev-vmod.ts
5
+ const DEV_VMOD_ID = "virtual:solid-tui/dev";
6
+ const RESOLVED_DEV_VMOD_ID = "\0virtual:solid-tui/dev";
7
+ const SNIPPET = "import { connectDevtools } from \"@solid-tui/runtime/internal\";\nif (import.meta.hot) connectDevtools(import.meta.hot);\n";
8
+ function devVmodPlugin() {
9
+ return {
10
+ name: "solid-tui:dev-vmod",
11
+ apply: "serve",
12
+ resolveId(id) {
13
+ if (id === "virtual:solid-tui/dev") return RESOLVED_DEV_VMOD_ID;
14
+ },
15
+ load(id) {
16
+ if (id === "\0virtual:solid-tui/dev") return SNIPPET;
17
+ }
18
+ };
19
+ }
20
+ //#endregion
21
+ //#region src/bridge-hmr.ts
22
+ function bridgeHmrEventsToRunner(server) {
23
+ const ssr = server.environments.ssr;
24
+ if (!ssr) return;
25
+ const ws = server.ws;
26
+ const original = ws.send.bind(ws);
27
+ ws.send = (...args) => {
28
+ const payload = typeof args[0] === "string" ? {
29
+ type: "custom",
30
+ event: args[0],
31
+ data: args[1]
32
+ } : args[0];
33
+ if (payload.type === "custom" || payload.type === "error") ssr.hot.send(payload);
34
+ original(...args);
35
+ };
36
+ }
37
+ //#endregion
38
+ //#region src/dev.ts
39
+ function devPlugin(opts) {
40
+ const entry = opts.entry ?? "/src/main.tsx";
41
+ return {
42
+ name: "solid-tui:dev",
43
+ apply: "serve",
44
+ config() {
45
+ return {
46
+ clearScreen: false,
47
+ logLevel: "error",
48
+ server: { ws: false }
49
+ };
50
+ },
51
+ transform(code, id) {
52
+ const q = id.indexOf("?");
53
+ if ((q === -1 ? id : id.slice(0, q)).endsWith(entry)) return {
54
+ code: `import ${JSON.stringify(DEV_VMOD_ID)};\n` + code,
55
+ map: null
56
+ };
57
+ },
58
+ configureServer(server) {
59
+ if (server.config.mode === "test" || process.env.VITEST) return;
60
+ server.bindCLIShortcuts = () => {};
61
+ bridgeHmrEventsToRunner(server);
62
+ server.environments.ssr?.hot.on("solid-tui:exit", () => {
63
+ server.close();
64
+ });
65
+ return () => {
66
+ const env = server.environments.ssr;
67
+ if (!isRunnableDevEnvironment(env)) {
68
+ server.config.logger.error("[solid-tui] the \"ssr\" environment is not runnable");
69
+ return;
70
+ }
71
+ env.runner.import(entry).catch((err) => {
72
+ server.config.logger.error(`[solid-tui] failed to launch ${entry}`);
73
+ console.error(err);
74
+ });
75
+ };
76
+ }
77
+ };
78
+ }
79
+ //#endregion
80
+ //#region src/external.ts
81
+ function isExternalId(id) {
82
+ if (id.startsWith("\0") || id.startsWith("virtual:")) return false;
83
+ if (id === "solid-js") return false;
84
+ if (id === "solid-js/store" || id.startsWith("solid-js/store/")) return false;
85
+ if (id.startsWith(".")) return false;
86
+ if (posix.isAbsolute(id) || win32.isAbsolute(id)) return false;
87
+ return true;
88
+ }
89
+ //#endregion
90
+ //#region src/build.ts
91
+ function buildConfigPlugin(opts) {
92
+ const entry = opts.entry ?? "src/main.tsx";
93
+ return {
94
+ name: "solid-tui:build",
95
+ apply: "build",
96
+ config(userConfig) {
97
+ const userBuild = userConfig?.build;
98
+ return { build: {
99
+ target: "esnext",
100
+ modulePreload: false,
101
+ rolldownOptions: {
102
+ input: entry,
103
+ ...userBuild?.rolldownOptions?.external !== void 0 || userBuild?.rollupOptions?.external !== void 0 ? {} : { external: (id) => isExternalId(id) },
104
+ output: { entryFileNames: "[name].js" }
105
+ }
106
+ } };
107
+ }
108
+ };
109
+ }
110
+ //#endregion
111
+ //#region src/solid-runtime-config.ts
112
+ const solidClientEntry = "solid-js/dist/solid.js";
113
+ const solidStoreEntry = "solid-js/store/dist/store.js";
114
+ function solidRuntimeConfigPlugin() {
115
+ return {
116
+ name: "solid-tui:solid-runtime-config",
117
+ config() {
118
+ return {
119
+ resolve: { alias: [{
120
+ find: /^solid-js\/store$/,
121
+ replacement: solidStoreEntry
122
+ }, {
123
+ find: /^solid-js$/,
124
+ replacement: solidClientEntry
125
+ }] },
126
+ ssr: { noExternal: ["solid-js", "@solid-tui/runtime"] }
127
+ };
128
+ }
129
+ };
130
+ }
131
+ //#endregion
132
+ //#region src/index.ts
133
+ function solidTui(options = {}) {
134
+ const { dev, build } = normalizeEntry(options.entry);
135
+ const solidOptions = {
136
+ ...options.solid,
137
+ solid: {
138
+ ...options.solid?.solid,
139
+ generate: "universal",
140
+ moduleName: "@solid-tui/runtime"
141
+ }
142
+ };
143
+ return [
144
+ solidRuntimeConfigPlugin(),
145
+ devPlugin({ entry: dev }),
146
+ buildConfigPlugin({ entry: build }),
147
+ devVmodPlugin(),
148
+ solid(solidOptions)
149
+ ];
150
+ }
151
+ function normalizeEntry(entry) {
152
+ const e = (entry ?? "src/main.tsx").replace(/\\/g, "/");
153
+ if (e.startsWith("/") || /^[a-zA-Z]:\//.test(e)) return {
154
+ dev: e,
155
+ build: e
156
+ };
157
+ const bare = e.replace(/^(?:\.\/)+/, "");
158
+ return {
159
+ dev: `/${bare}`,
160
+ build: bare
161
+ };
162
+ }
163
+ //#endregion
164
+ export { solidTui as default, solidTui };
package/package.json ADDED
@@ -0,0 +1,51 @@
1
+ {
2
+ "name": "@solid-tui/vite",
3
+ "version": "0.1.0",
4
+ "description": "Vite plugin for solid-tui: universal Solid TSX, in-process terminal dev server, and Node builds.",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/solidjs-ai/solid-tui.git",
9
+ "directory": "packages/vite"
10
+ },
11
+ "files": [
12
+ "dist",
13
+ "LICENSE",
14
+ "README.md"
15
+ ],
16
+ "type": "module",
17
+ "exports": {
18
+ ".": "./dist/index.mjs",
19
+ "./package.json": "./package.json"
20
+ },
21
+ "publishConfig": {
22
+ "access": "public"
23
+ },
24
+ "dependencies": {
25
+ "vite-plugin-solid": "^2.11.12"
26
+ },
27
+ "devDependencies": {
28
+ "@types/node": "^24.12.4",
29
+ "solid-js": "^1.9.14",
30
+ "typescript": "^5",
31
+ "vite": "8.1.0",
32
+ "vite-plus": "^0.1.22",
33
+ "@solid-tui/runtime": "0.1.0"
34
+ },
35
+ "peerDependencies": {
36
+ "solid-js": "^1.9.0",
37
+ "vite": "^8",
38
+ "@solid-tui/runtime": "^0.1.0"
39
+ },
40
+ "peerDependenciesMeta": {
41
+ "vite": {
42
+ "optional": true
43
+ }
44
+ },
45
+ "scripts": {
46
+ "build": "vp pack",
47
+ "dev": "vp pack --watch",
48
+ "test": "vp test --passWithNoTests",
49
+ "check:type": "tsc --noEmit"
50
+ }
51
+ }