vitend 0.2.1 → 0.2.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/index.d.ts +50 -3
- package/dist/index.js +21 -2
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +20 -2
- package/dist/index.mjs.map +1 -0
- package/dist/node.d.ts +16 -3
- package/dist/node.js +1 -1
- package/dist/runtime.js +1 -1
- package/dist/vite.d.ts +214 -3
- package/dist/vite.js +276 -2
- package/dist/vite.js.map +1 -0
- package/dist/vite.mjs +247 -2
- package/dist/vite.mjs.map +1 -0
- package/package.json +11 -2
- package/dist/@types/node.d.ts +0 -16
- package/dist/@types/options/complete.d.ts +0 -158
- package/dist/@types/options/default.d.ts +0 -39
- package/dist/@types/server.d.ts +0 -32
- package/dist/_virtual/_rolldown/runtime.js +0 -27
- package/dist/functions/define.d.ts +0 -21
- package/dist/functions/define.js +0 -22
- package/dist/functions/define.js.map +0 -1
- package/dist/functions/define.mjs +0 -21
- package/dist/functions/define.mjs.map +0 -1
- package/dist/functions/entry.js +0 -20
- package/dist/functions/entry.js.map +0 -1
- package/dist/functions/entry.mjs +0 -17
- package/dist/functions/entry.mjs.map +0 -1
- package/dist/functions/options.js +0 -43
- package/dist/functions/options.js.map +0 -1
- package/dist/functions/options.mjs +0 -42
- package/dist/functions/options.mjs.map +0 -1
- package/dist/functions/package-json.js +0 -15
- package/dist/functions/package-json.js.map +0 -1
- package/dist/functions/package-json.mjs +0 -12
- package/dist/functions/package-json.mjs.map +0 -1
- package/dist/vite/build.js +0 -72
- package/dist/vite/build.js.map +0 -1
- package/dist/vite/build.mjs +0 -71
- package/dist/vite/build.mjs.map +0 -1
- package/dist/vite/dev.js +0 -90
- package/dist/vite/dev.js.map +0 -1
- package/dist/vite/dev.mjs +0 -89
- package/dist/vite/dev.mjs.map +0 -1
- package/dist/vite/vitend.d.ts +0 -23
- package/dist/vite/vitend.js +0 -45
- package/dist/vite/vitend.js.map +0 -1
- package/dist/vite/vitend.mjs +0 -42
- package/dist/vite/vitend.mjs.map +0 -1
package/dist/vite.mjs
CHANGED
|
@@ -1,3 +1,248 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { builtinModules } from "node:module";
|
|
2
|
+
import * as Path from "node:path";
|
|
3
|
+
import copy from "rollup-plugin-copy";
|
|
4
|
+
import { toMerged } from "es-toolkit";
|
|
5
|
+
import * as Fs from "node:fs";
|
|
6
|
+
import { serve } from "srvx";
|
|
2
7
|
|
|
3
|
-
|
|
8
|
+
const ENTRY_DEFAULT = ["./src/index.ts", "./src/index.js"];
|
|
9
|
+
const getEntry = (cwd, entry) => {
|
|
10
|
+
if (!entry) {
|
|
11
|
+
for (const ent of ENTRY_DEFAULT) if (Fs.existsSync(Path.resolve(cwd, ent))) {
|
|
12
|
+
entry = ent;
|
|
13
|
+
break;
|
|
14
|
+
}
|
|
15
|
+
if (!entry) throw new Error("No entry file found");
|
|
16
|
+
}
|
|
17
|
+
return Path.resolve(cwd, entry);
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const OPTIONS_BUILD_VERCEL = {
|
|
21
|
+
target: "vercel",
|
|
22
|
+
outputDir: "./dist",
|
|
23
|
+
outputFile: "index.js",
|
|
24
|
+
minify: false
|
|
25
|
+
};
|
|
26
|
+
const OPTIONS_BUILD_DEFAULT = {
|
|
27
|
+
target: "default",
|
|
28
|
+
host: "localhost",
|
|
29
|
+
port: 3e3,
|
|
30
|
+
outputDir: "./dist",
|
|
31
|
+
outputFile: "index.js",
|
|
32
|
+
minify: false,
|
|
33
|
+
publicDir: "./public",
|
|
34
|
+
copyPublicDir: false
|
|
35
|
+
};
|
|
36
|
+
const OPTIONS_DEFAULT = {
|
|
37
|
+
cwd: process.cwd(),
|
|
38
|
+
dev: {
|
|
39
|
+
host: "localhost",
|
|
40
|
+
port: 3001
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
const getDefaultOptions = (isVercel) => {
|
|
44
|
+
return {
|
|
45
|
+
...OPTIONS_DEFAULT,
|
|
46
|
+
build: isVercel ? OPTIONS_BUILD_VERCEL : OPTIONS_BUILD_DEFAULT
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
const createOptions = (options) => {
|
|
50
|
+
const merged = toMerged(getDefaultOptions(options?.build?.target === "vercel"), options ?? {});
|
|
51
|
+
return {
|
|
52
|
+
...merged,
|
|
53
|
+
entry: getEntry(merged.cwd, options?.entry)
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const getPackageJson = (cwd) => {
|
|
58
|
+
const path = Path.resolve(cwd, "package.json");
|
|
59
|
+
if (!Fs.existsSync(path)) throw new Error("Failed to find package.json");
|
|
60
|
+
const rawPackageJson = Fs.readFileSync(path, "utf-8");
|
|
61
|
+
return JSON.parse(rawPackageJson);
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const VIRTUAL_ENTRY = "virtual:vitend-entry";
|
|
65
|
+
const VIRTUAL_ENTRY_RESOLVED = `\0${VIRTUAL_ENTRY}`;
|
|
66
|
+
const buildPlugin = (opts) => {
|
|
67
|
+
const build = opts.build;
|
|
68
|
+
const packageJson = getPackageJson(opts.cwd);
|
|
69
|
+
return {
|
|
70
|
+
name: "vitend/build",
|
|
71
|
+
apply: "build",
|
|
72
|
+
config: (config) => {
|
|
73
|
+
let result = {};
|
|
74
|
+
result = toMerged({
|
|
75
|
+
ssr: {
|
|
76
|
+
external: true,
|
|
77
|
+
noExternal: void 0,
|
|
78
|
+
target: "webworker"
|
|
79
|
+
},
|
|
80
|
+
build: { copyPublicDir: false }
|
|
81
|
+
}, config);
|
|
82
|
+
const overrideConfig = { build: {
|
|
83
|
+
ssr: true,
|
|
84
|
+
outDir: build.outputDir,
|
|
85
|
+
rollupOptions: {
|
|
86
|
+
input: VIRTUAL_ENTRY,
|
|
87
|
+
output: {
|
|
88
|
+
entryFileNames: build.outputFile,
|
|
89
|
+
format: packageJson.type === "module" ? "esm" : "cjs"
|
|
90
|
+
},
|
|
91
|
+
external: [...builtinModules, /^node:/]
|
|
92
|
+
},
|
|
93
|
+
minify: build.minify
|
|
94
|
+
} };
|
|
95
|
+
result = toMerged(result, overrideConfig);
|
|
96
|
+
return result;
|
|
97
|
+
},
|
|
98
|
+
resolveId: (id) => {
|
|
99
|
+
if (id !== VIRTUAL_ENTRY) return void 0;
|
|
100
|
+
return VIRTUAL_ENTRY_RESOLVED;
|
|
101
|
+
},
|
|
102
|
+
load: async (id) => {
|
|
103
|
+
if (id !== VIRTUAL_ENTRY_RESOLVED) return void 0;
|
|
104
|
+
let code = "";
|
|
105
|
+
code += `import options from "${opts.entry}";`;
|
|
106
|
+
code += `import { serve } from "vitend/runtime";`;
|
|
107
|
+
if (build.target === "vercel") {
|
|
108
|
+
code += `const server = serve({ ...options, manual: true });`;
|
|
109
|
+
code += `export default server;`;
|
|
110
|
+
return code;
|
|
111
|
+
}
|
|
112
|
+
code += `serve({`;
|
|
113
|
+
code += `...options,`;
|
|
114
|
+
if (build.host !== "localhost") code += `hostname: "${build.host}",`;
|
|
115
|
+
if (build.port !== 3e3) code += `port: ${build.port},`;
|
|
116
|
+
if (build.https) {
|
|
117
|
+
code += `tls: {`;
|
|
118
|
+
if (build.https.cert) code += `cert: "${build.https.cert}",`;
|
|
119
|
+
if (build.https.key) code += `key: "${build.https.key}",`;
|
|
120
|
+
if (build.https.passphrase) code += `passphrase: "${build.https.passphrase}",`;
|
|
121
|
+
code += `},`;
|
|
122
|
+
}
|
|
123
|
+
code += `});`;
|
|
124
|
+
return code;
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
const createMiddleware = ({ vite, server }) => {
|
|
130
|
+
return async (req, res, _next) => {
|
|
131
|
+
const protocol = `http${vite.config.server.https?.cert !== void 0 && vite.config.server.https?.key !== void 0 ? "s" : ""}`;
|
|
132
|
+
const host = process.env.HOST ?? "localhost";
|
|
133
|
+
const port = vite.config.server.port;
|
|
134
|
+
const path = req.url ?? "";
|
|
135
|
+
const url = new URL(`${protocol}://${host}:${port}${path}`);
|
|
136
|
+
const body = req.method !== "GET" && req.method !== "HEAD" ? req : void 0;
|
|
137
|
+
const request = new Request(url, {
|
|
138
|
+
method: req.method,
|
|
139
|
+
headers: req.headers,
|
|
140
|
+
body,
|
|
141
|
+
duplex: "half"
|
|
142
|
+
});
|
|
143
|
+
const response = await server.fetch(request);
|
|
144
|
+
res.statusCode = response.status;
|
|
145
|
+
response.headers.forEach((value, key) => {
|
|
146
|
+
res.setHeader(key, value);
|
|
147
|
+
});
|
|
148
|
+
if (!response.body) {
|
|
149
|
+
res.end();
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
const reader = response.body.getReader();
|
|
153
|
+
const stream = async () => {
|
|
154
|
+
try {
|
|
155
|
+
while (true) {
|
|
156
|
+
const { done, value } = await reader.read();
|
|
157
|
+
if (done) break;
|
|
158
|
+
res.write(value);
|
|
159
|
+
}
|
|
160
|
+
res.end();
|
|
161
|
+
} catch {
|
|
162
|
+
res.end();
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
await stream();
|
|
166
|
+
};
|
|
167
|
+
};
|
|
168
|
+
const devPlugin = (opts) => {
|
|
169
|
+
const dev = opts.dev;
|
|
170
|
+
const https = opts.dev.https ?? {};
|
|
171
|
+
return {
|
|
172
|
+
name: "vitend/dev",
|
|
173
|
+
apply: "serve",
|
|
174
|
+
config(config) {
|
|
175
|
+
return toMerged(config, {
|
|
176
|
+
build: {
|
|
177
|
+
ssr: true,
|
|
178
|
+
rollupOptions: { input: opts.entry }
|
|
179
|
+
},
|
|
180
|
+
server: {
|
|
181
|
+
host: dev.host,
|
|
182
|
+
port: dev.port,
|
|
183
|
+
...https.cert !== void 0 && https.key !== void 0 ? { https: {
|
|
184
|
+
cert: https.cert,
|
|
185
|
+
key: https.key,
|
|
186
|
+
passphrase: https.passphrase
|
|
187
|
+
} } : {}
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
},
|
|
191
|
+
configureServer: async (vite) => {
|
|
192
|
+
const serverOptions = (await vite.ssrLoadModule(opts.entry)).default;
|
|
193
|
+
const middleware = createMiddleware({
|
|
194
|
+
vite,
|
|
195
|
+
server: serve({
|
|
196
|
+
gracefulShutdown: false,
|
|
197
|
+
...serverOptions,
|
|
198
|
+
manual: true,
|
|
199
|
+
hostname: dev.host,
|
|
200
|
+
port: dev.port,
|
|
201
|
+
tls: {
|
|
202
|
+
cert: https.cert,
|
|
203
|
+
key: https.key,
|
|
204
|
+
passphrase: https.passphrase
|
|
205
|
+
}
|
|
206
|
+
})
|
|
207
|
+
});
|
|
208
|
+
vite.middlewares.use(middleware);
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* The `vitend` plugin.
|
|
215
|
+
*
|
|
216
|
+
* ### Example
|
|
217
|
+
*
|
|
218
|
+
* ```ts
|
|
219
|
+
* // ./vite.config.ts
|
|
220
|
+
*
|
|
221
|
+
* import { defineConfig } from "vite";
|
|
222
|
+
* import { vitend } from "vitend/vite";
|
|
223
|
+
*
|
|
224
|
+
* export default defineConfig({
|
|
225
|
+
* plugins: [
|
|
226
|
+
* vitend(),
|
|
227
|
+
* ],
|
|
228
|
+
* });
|
|
229
|
+
* ```
|
|
230
|
+
*/
|
|
231
|
+
const vitend = (options) => {
|
|
232
|
+
const opts = createOptions(options);
|
|
233
|
+
const build = opts.build;
|
|
234
|
+
return [
|
|
235
|
+
devPlugin({ ...opts }),
|
|
236
|
+
buildPlugin({ ...opts }),
|
|
237
|
+
...build.target === "default" && build.copyPublicDir ? [copy({
|
|
238
|
+
hook: "closeBundle",
|
|
239
|
+
targets: [{
|
|
240
|
+
src: Path.resolve(build.publicDir, "**", "*"),
|
|
241
|
+
dest: Path.resolve(build.outputDir, build.publicDir)
|
|
242
|
+
}]
|
|
243
|
+
})] : []
|
|
244
|
+
];
|
|
245
|
+
};
|
|
246
|
+
|
|
247
|
+
export { vitend };
|
|
248
|
+
//# sourceMappingURL=vite.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vite.mjs","names":[],"sources":["../src/functions/entry.ts","../src/functions/options.ts","../src/functions/package-json.ts","../src/vite/build.ts","../src/vite/dev.ts","../src/vite/vitend.ts"],"sourcesContent":["import * as Fs from \"node:fs\";\nimport * as Path from \"node:path\";\n\nconst ENTRY_DEFAULT: string[] = [\n \"./src/index.ts\",\n \"./src/index.js\",\n];\n\nconst getEntry = (cwd: string, entry?: string): string => {\n if (!entry) {\n for (const ent of ENTRY_DEFAULT) {\n if (Fs.existsSync(Path.resolve(cwd, ent))) {\n entry = ent;\n break;\n }\n }\n\n if (!entry) {\n throw new Error(\"No entry file found\");\n }\n }\n\n return Path.resolve(cwd, entry);\n};\n\nexport { getEntry };\n","import type { Omit } from \"ts-vista\";\n\nimport type { VitendOptions } from \"#/@types/options/default\";\nimport type {\n ResolvedDefaultBuildOptions,\n ResolvedVercelBuildOptions,\n ResolvedVitendOptions,\n} from \"#/@types/options/resolved\";\n\nimport { toMerged } from \"es-toolkit\";\n\nimport { getEntry } from \"#/functions/entry\";\n\nconst OPTIONS_BUILD_VERCEL: ResolvedVercelBuildOptions = {\n target: \"vercel\",\n outputDir: \"./dist\",\n outputFile: \"index.js\",\n minify: false,\n};\n\nconst OPTIONS_BUILD_DEFAULT: ResolvedDefaultBuildOptions = {\n target: \"default\",\n host: \"localhost\",\n port: 3000,\n outputDir: \"./dist\",\n outputFile: \"index.js\",\n minify: false,\n publicDir: \"./public\",\n copyPublicDir: false,\n};\n\nconst OPTIONS_DEFAULT: Omit<ResolvedVitendOptions, \"entry\" | \"build\"> = {\n cwd: process.cwd(),\n dev: {\n host: \"localhost\",\n port: 3001,\n },\n};\n\nconst getDefaultOptions = (\n isVercel: boolean,\n): Omit<ResolvedVitendOptions, \"entry\"> => {\n return {\n ...OPTIONS_DEFAULT,\n build: isVercel ? OPTIONS_BUILD_VERCEL : OPTIONS_BUILD_DEFAULT,\n };\n};\n\nconst createOptions = (options?: VitendOptions): ResolvedVitendOptions => {\n const isVercel: boolean = options?.build?.target === \"vercel\";\n\n const merged = toMerged(getDefaultOptions(isVercel), options ?? {});\n\n return {\n ...merged,\n entry: getEntry(merged.cwd, options?.entry),\n };\n};\n\nexport { createOptions };\n","import type { Format, Partial } from \"ts-vista\";\n\nimport * as Fs from \"node:fs\";\nimport * as Path from \"node:path\";\n\ntype CompletePackageJson = {\n type: \"module\" | \"commonjs\";\n dependencies: Record<string, string>;\n devDependencies: Record<string, string>;\n peerDependencies: Record<string, string>;\n};\n\ntype PackageJson = Format<Partial<CompletePackageJson>>;\n\nconst getPackageJson = (cwd: string): PackageJson => {\n const path: string = Path.resolve(cwd, \"package.json\");\n\n if (!Fs.existsSync(path)) {\n throw new Error(\"Failed to find package.json\");\n }\n\n const rawPackageJson: string = Fs.readFileSync(path, \"utf-8\");\n\n return JSON.parse(rawPackageJson);\n};\n\nexport type { CompletePackageJson, PackageJson };\nexport { getPackageJson };\n","import type { LoadResult, ResolveIdResult } from \"rollup\";\nimport type { Plugin, UserConfig } from \"vite\";\n\nimport type {\n ResolvedBuildOptions,\n ResolvedVitendOptions,\n} from \"#/@types/options/resolved\";\nimport type { PackageJson } from \"#/functions/package-json\";\n\nimport { builtinModules } from \"node:module\";\n\nimport { toMerged } from \"es-toolkit\";\n\nimport { getPackageJson } from \"#/functions/package-json\";\n\nconst VIRTUAL_ENTRY = \"virtual:vitend-entry\" as const;\n\nconst VIRTUAL_ENTRY_RESOLVED = `\\0${VIRTUAL_ENTRY}` as const;\n\nconst buildPlugin = (opts: ResolvedVitendOptions): Plugin => {\n const build: ResolvedBuildOptions = opts.build;\n\n const packageJson: PackageJson = getPackageJson(opts.cwd);\n\n return {\n name: \"vitend/build\",\n apply: \"build\",\n config: (config: UserConfig): UserConfig => {\n let result: UserConfig = {};\n\n const baseConfig: UserConfig = {\n ssr: {\n external: true,\n noExternal: void 0,\n target: \"webworker\",\n },\n build: {\n copyPublicDir: false,\n },\n };\n\n result = toMerged(baseConfig, config);\n\n const overrideConfig: UserConfig = {\n build: {\n ssr: true,\n outDir: build.outputDir,\n rollupOptions: {\n input: VIRTUAL_ENTRY,\n output: {\n entryFileNames: build.outputFile,\n format:\n packageJson.type === \"module\" ? \"esm\" : \"cjs\",\n },\n external: [\n ...builtinModules,\n /^node:/,\n ],\n },\n minify: build.minify,\n },\n };\n\n result = toMerged(result, overrideConfig);\n\n return result;\n },\n resolveId: (id: string): ResolveIdResult => {\n if (id !== VIRTUAL_ENTRY) return void 0;\n return VIRTUAL_ENTRY_RESOLVED;\n },\n load: async (id: string): Promise<LoadResult> => {\n if (id !== VIRTUAL_ENTRY_RESOLVED) return void 0;\n\n let code: string = \"\";\n\n code += `import options from \"${opts.entry}\";`;\n code += `import { serve } from \"vitend/runtime\";`;\n\n // vercel export\n\n if (build.target === \"vercel\") {\n code += `const server = serve({ ...options, manual: true });`;\n code += `export default server;`;\n\n return code;\n }\n\n // default export\n\n code += `serve({`;\n code += `...options,`;\n\n if (build.host !== \"localhost\")\n code += `hostname: \"${build.host}\",`;\n if (build.port !== 3000) code += `port: ${build.port},`;\n\n if (build.https) {\n code += `tls: {`;\n if (build.https.cert) code += `cert: \"${build.https.cert}\",`;\n if (build.https.key) code += `key: \"${build.https.key}\",`;\n if (build.https.passphrase)\n code += `passphrase: \"${build.https.passphrase}\",`;\n code += `},`;\n }\n\n code += `});`;\n\n return code;\n },\n };\n};\n\nexport { buildPlugin };\n","import type HTTP from \"node:http\";\n\nimport type { Server, ServerHandler, ServerOptions } from \"srvx\";\nimport type { Connect, Plugin, UserConfig, ViteDevServer } from \"vite\";\n\nimport type {\n ResolvedDevOptions,\n ResolvedHttpsOptions,\n ResolvedVitendOptions,\n} from \"#/@types/options/resolved\";\n\nimport { toMerged } from \"es-toolkit\";\nimport { serve } from \"srvx\";\n\ntype CreateMiddlewareOptions = {\n vite: ViteDevServer;\n server: Server;\n};\n\nconst createMiddleware = ({ vite, server }: CreateMiddlewareOptions) => {\n return async (\n req: Connect.IncomingMessage,\n res: HTTP.ServerResponse,\n _next: Connect.NextFunction,\n ): Promise<void> => {\n const isHttps: boolean =\n vite.config.server.https?.cert !== void 0 &&\n vite.config.server.https?.key !== void 0;\n\n const protocol: string = `http${isHttps ? \"s\" : \"\"}`;\n\n const host: string = process.env.HOST ?? \"localhost\";\n\n const port: number = vite.config.server.port;\n\n const path: string = req.url ?? \"\";\n\n const url: URL = new URL(`${protocol}://${host}:${port}${path}`);\n\n const body: Connect.IncomingMessage | undefined =\n req.method !== \"GET\" && req.method !== \"HEAD\" ? req : void 0;\n\n const request: Request = new Request(url, {\n method: req.method,\n headers: req.headers,\n body,\n duplex: \"half\",\n } as RequestInit);\n\n const response: Response = await server.fetch(request);\n\n res.statusCode = response.status;\n\n response.headers.forEach((value: string, key: string): void => {\n res.setHeader(key, value);\n });\n\n if (!response.body) {\n res.end();\n return void 0;\n }\n\n const reader: ReadableStreamDefaultReader<Uint8Array<ArrayBuffer>> =\n response.body.getReader();\n\n const stream = async (): Promise<void> => {\n try {\n while (true) {\n const { done, value } = await reader.read();\n\n if (done) break;\n\n res.write(value);\n }\n\n res.end();\n } catch {\n res.end();\n }\n };\n\n await stream();\n };\n};\n\ntype Middleware = ReturnType<typeof createMiddleware>;\n\nconst devPlugin = (opts: ResolvedVitendOptions): Plugin => {\n const dev: ResolvedDevOptions = opts.dev;\n const https: ResolvedHttpsOptions = opts.dev.https ?? {};\n\n return {\n name: \"vitend/dev\",\n apply: \"serve\",\n config(config: UserConfig): UserConfig {\n const devConfig: UserConfig = {\n build: {\n ssr: true,\n rollupOptions: {\n input: opts.entry,\n },\n },\n server: {\n host: dev.host,\n port: dev.port,\n ...(https.cert !== void 0 && https.key !== void 0\n ? {\n https: {\n cert: https.cert,\n key: https.key,\n passphrase: https.passphrase,\n },\n }\n : {}),\n },\n };\n\n return toMerged(config, devConfig);\n },\n configureServer: async (vite: ViteDevServer): Promise<void> => {\n const serverOptions: ServerOptions = (\n await vite.ssrLoadModule(opts.entry)\n ).default;\n\n const server: Server<ServerHandler> = serve({\n // base\n gracefulShutdown: false,\n // user\n ...serverOptions,\n // override\n manual: true,\n hostname: dev.host,\n port: dev.port,\n tls: {\n cert: https.cert,\n key: https.key,\n passphrase: https.passphrase,\n },\n });\n\n const middleware: Middleware = createMiddleware({\n vite,\n server,\n });\n\n vite.middlewares.use(middleware);\n },\n };\n};\n\nexport { devPlugin };\n","import type { Plugin } from \"vite\";\n\nimport type { VitendOptions } from \"#/@types/options/default\";\nimport type {\n ResolvedBuildOptions,\n ResolvedVitendOptions,\n} from \"#/@types/options/resolved\";\n\nimport * as Path from \"node:path\";\n\nimport copy from \"rollup-plugin-copy\";\n\nimport { createOptions } from \"#/functions/options\";\nimport { buildPlugin } from \"#/vite/build\";\nimport { devPlugin } from \"#/vite/dev\";\n\n/**\n * The `vitend` plugin.\n *\n * ### Example\n *\n * ```ts\n * // ./vite.config.ts\n *\n * import { defineConfig } from \"vite\";\n * import { vitend } from \"vitend/vite\";\n *\n * export default defineConfig({\n * plugins: [\n * vitend(),\n * ],\n * });\n * ```\n */\nconst vitend = (options?: VitendOptions): Plugin[] => {\n const opts: ResolvedVitendOptions = createOptions(options);\n\n const build: ResolvedBuildOptions = opts.build;\n\n return [\n devPlugin({\n ...opts,\n }),\n buildPlugin({\n ...opts,\n }),\n ...(build.target === \"default\" && build.copyPublicDir\n ? ([\n copy({\n hook: \"closeBundle\",\n targets: [\n {\n src: Path.resolve(build.publicDir, \"**\", \"*\"),\n dest: Path.resolve(\n build.outputDir,\n build.publicDir,\n ),\n },\n ],\n }),\n ] as Plugin[])\n : []),\n ];\n};\n\nexport { vitend };\n"],"mappings":";;;;;;;AAGA,MAAM,gBAA0B,CAC5B,kBACA,iBACH;AAED,MAAM,YAAY,KAAa,UAA2B;AACtD,KAAI,CAAC,OAAO;AACR,OAAK,MAAM,OAAO,cACd,KAAI,GAAG,WAAW,KAAK,Q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AM,KAAK,cAAc,KAAK,MAAM,EACtC;GAkBF,MAAM,aAAyB,iBAAiB;IAC5C;IACA,QAlBkC,MAAM;KAExC,kBAAkB;KAElB,GAAG;KAEH,QAAQ;KACR,UAAU,IAAI;KACd,MAAM,IAAI;KACV,KAAK;MACD,MAAM,MAAM;MACZ,KAAK,MAAM;MACX,YAAY,MAAM;MACrB;KACJ,CAAC;IAKD,CAAC;AAEF,QAAK,YAAY,IAAI,WAAW;;EAEvC;;;;;;;;;;;;;;;;;;;;;ACjHL,MAAM,UAAU,YAAsC;CAClD,MAAM,OAA8B,cAAc,QAAQ;CAE1D,MAAM,QAA8B,KAAK;AAEzC,QAAO;EACH,UAAU,EACN,GAAG,MACN,CAAC;EACF,YAAY,EACR,GAAG,MACN,CAAC;EACF,GAAI,MAAM,WAAW,aAAa,MAAM,gBACjC,CACG,KAAK;GACD,MAAM;GACN,SAAS,CACL;IACI,KAAK,KAAK,QAAQ,MAAM,WAAW,MAAM,IAAI;IAC7C,MAAM,KAAK,QACP,MAAM,WACN,MAAM,UACT;IACJ,CACJ;GACJ,CAAC,CACL,GACD,EAAE;EACX"}
|
package/package.json
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
{
|
|
2
|
+
"$schema": "https://raw.githubusercontent.com/vitejs/vite-plugin-registry/refs/heads/main/data/schema/extended-package-json.schema.json",
|
|
2
3
|
"name": "vitend",
|
|
3
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.2",
|
|
4
5
|
"description": "A library for backend development with Vite",
|
|
5
6
|
"keywords": [
|
|
6
7
|
"vitend",
|
|
8
|
+
"vite-plugin",
|
|
7
9
|
"vite",
|
|
8
10
|
"plugin",
|
|
9
11
|
"backend",
|
|
@@ -64,6 +66,13 @@
|
|
|
64
66
|
"vite": "7.0.0"
|
|
65
67
|
},
|
|
66
68
|
"peerDependencies": {
|
|
67
|
-
"vite": "^7.0.0"
|
|
69
|
+
"vite": "^7.0.0 || ^8.0.0"
|
|
70
|
+
},
|
|
71
|
+
"compatiblePackages": {
|
|
72
|
+
"schemaVersion": 1,
|
|
73
|
+
"vite": {
|
|
74
|
+
"type": "compatible",
|
|
75
|
+
"versions": "^7.0.0 || ^8.0.0"
|
|
76
|
+
}
|
|
68
77
|
}
|
|
69
78
|
}
|
package/dist/@types/node.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { FetchHandler, NodeHttpHandler } from "srvx";
|
|
2
|
-
import { AdapterMeta } from "srvx/node";
|
|
3
|
-
/**
|
|
4
|
-
* Node HTTP handler based on Node.js implementation.
|
|
5
|
-
*/
|
|
6
|
-
type NodeHttpHandler$1 = NodeHttpHandler;
|
|
7
|
-
/**
|
|
8
|
-
* Fetch handler based on Web API.
|
|
9
|
-
*/
|
|
10
|
-
type FetchHandler$1 = FetchHandler;
|
|
11
|
-
/**
|
|
12
|
-
* Adapter meta.
|
|
13
|
-
*/
|
|
14
|
-
type AdapterMeta$1 = AdapterMeta;
|
|
15
|
-
export { type AdapterMeta$1 as AdapterMeta, type FetchHandler$1 as FetchHandler, type NodeHttpHandler$1 as NodeHttpHandler };
|
|
16
|
-
//# sourceMappingURL=node.d.ts.map
|
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Complete HTTPS server options.
|
|
3
|
-
*/
|
|
4
|
-
type CompleteHttpsOptions = {
|
|
5
|
-
/**
|
|
6
|
-
* File path or inlined TLS certificate in PEM format (required).
|
|
7
|
-
*/
|
|
8
|
-
cert: string;
|
|
9
|
-
/**
|
|
10
|
-
* File path or inlined TLS private key in PEM format (required).
|
|
11
|
-
*/
|
|
12
|
-
key: string;
|
|
13
|
-
/**
|
|
14
|
-
* Passphrase for the private key (optional).
|
|
15
|
-
*/
|
|
16
|
-
passphrase: string;
|
|
17
|
-
};
|
|
18
|
-
/**
|
|
19
|
-
* Complete development server options.
|
|
20
|
-
*/
|
|
21
|
-
type CompleteDevOptions = {
|
|
22
|
-
/**
|
|
23
|
-
* The host for the development server.
|
|
24
|
-
*
|
|
25
|
-
* By default, it is `localhost`.
|
|
26
|
-
*/
|
|
27
|
-
host: string;
|
|
28
|
-
/**
|
|
29
|
-
* The port number for the development server.
|
|
30
|
-
*
|
|
31
|
-
* By default, it is `3001`.
|
|
32
|
-
*/
|
|
33
|
-
port: number;
|
|
34
|
-
/**
|
|
35
|
-
* HTTPS server options.
|
|
36
|
-
*/
|
|
37
|
-
https: CompleteHttpsOptions;
|
|
38
|
-
};
|
|
39
|
-
/**
|
|
40
|
-
* Complete default build server options.
|
|
41
|
-
*/
|
|
42
|
-
type CompleteDefaultBuildOptions = {
|
|
43
|
-
/**
|
|
44
|
-
* Build target.
|
|
45
|
-
*
|
|
46
|
-
* By default, it is `default`.
|
|
47
|
-
*/
|
|
48
|
-
target: "default";
|
|
49
|
-
/**
|
|
50
|
-
* The host for the production server.
|
|
51
|
-
*
|
|
52
|
-
* By default, it is `localhost`.
|
|
53
|
-
*/
|
|
54
|
-
host: string;
|
|
55
|
-
/**
|
|
56
|
-
* The port number for the production server.
|
|
57
|
-
*
|
|
58
|
-
* By default, it is `3000`.
|
|
59
|
-
*/
|
|
60
|
-
port: number;
|
|
61
|
-
/**
|
|
62
|
-
* HTTPS server options.
|
|
63
|
-
*/
|
|
64
|
-
https: CompleteHttpsOptions;
|
|
65
|
-
/**
|
|
66
|
-
* The output directory for the application.
|
|
67
|
-
*
|
|
68
|
-
* By default, it is `./dist`.
|
|
69
|
-
*/
|
|
70
|
-
outputDir: string;
|
|
71
|
-
/**
|
|
72
|
-
* The output file name for the application.
|
|
73
|
-
*
|
|
74
|
-
* By default, it is `index.js`.
|
|
75
|
-
*/
|
|
76
|
-
outputFile: string;
|
|
77
|
-
/**
|
|
78
|
-
* Whether to minify the output.
|
|
79
|
-
*
|
|
80
|
-
* By default, it is `false`.
|
|
81
|
-
*/
|
|
82
|
-
minify: boolean;
|
|
83
|
-
/**
|
|
84
|
-
* The public directory for the application.
|
|
85
|
-
*
|
|
86
|
-
* By default, it is `./public`.
|
|
87
|
-
*/
|
|
88
|
-
publicDir: string;
|
|
89
|
-
/**
|
|
90
|
-
* Whether to copy the public directory to the output directory.
|
|
91
|
-
*
|
|
92
|
-
* When this is `true`, the public directory will be copied
|
|
93
|
-
* into the directory with same name inside the output directory.
|
|
94
|
-
*
|
|
95
|
-
* By default, it is `false`.
|
|
96
|
-
*/
|
|
97
|
-
copyPublicDir: boolean;
|
|
98
|
-
};
|
|
99
|
-
/**
|
|
100
|
-
* Complete Vercel build server options.
|
|
101
|
-
*/
|
|
102
|
-
type CompleteVercelBuildOptions = {
|
|
103
|
-
/**
|
|
104
|
-
* Build target.
|
|
105
|
-
*
|
|
106
|
-
* By default, it is `default`.
|
|
107
|
-
*/
|
|
108
|
-
target: "vercel";
|
|
109
|
-
/**
|
|
110
|
-
* The output directory for the application.
|
|
111
|
-
*
|
|
112
|
-
* By default, it is `./dist`.
|
|
113
|
-
*/
|
|
114
|
-
outputDir: string;
|
|
115
|
-
/**
|
|
116
|
-
* The output file name for the application.
|
|
117
|
-
*
|
|
118
|
-
* By default, it is `index.js`.
|
|
119
|
-
*/
|
|
120
|
-
outputFile: string;
|
|
121
|
-
/**
|
|
122
|
-
* Whether to minify the output.
|
|
123
|
-
*
|
|
124
|
-
* By default, it is `false`.
|
|
125
|
-
*/
|
|
126
|
-
minify: boolean;
|
|
127
|
-
};
|
|
128
|
-
/**
|
|
129
|
-
* Complete build server options.
|
|
130
|
-
*/
|
|
131
|
-
type CompleteBuildOptions = CompleteDefaultBuildOptions | CompleteVercelBuildOptions;
|
|
132
|
-
/**
|
|
133
|
-
* Complete options for the `vitend` plugin.
|
|
134
|
-
*/
|
|
135
|
-
type CompleteVitendOptions = {
|
|
136
|
-
/**
|
|
137
|
-
* The current working directory.
|
|
138
|
-
*
|
|
139
|
-
* By default, it is `process.cwd()`.
|
|
140
|
-
*/
|
|
141
|
-
cwd: string;
|
|
142
|
-
/**
|
|
143
|
-
* The entry file for the application.
|
|
144
|
-
*
|
|
145
|
-
* By default, it is `./src/index.ts` or `./src/index.js`.
|
|
146
|
-
*/
|
|
147
|
-
entry: string;
|
|
148
|
-
/**
|
|
149
|
-
* The options for the development server.
|
|
150
|
-
*/
|
|
151
|
-
dev: CompleteDevOptions;
|
|
152
|
-
/**
|
|
153
|
-
* The options for the production server.
|
|
154
|
-
*/
|
|
155
|
-
build: CompleteBuildOptions;
|
|
156
|
-
};
|
|
157
|
-
export { type CompleteDefaultBuildOptions, type CompleteDevOptions, type CompleteHttpsOptions, type CompleteVercelBuildOptions, type CompleteVitendOptions };
|
|
158
|
-
//# sourceMappingURL=complete.d.ts.map
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { CompleteDefaultBuildOptions, CompleteDevOptions, CompleteHttpsOptions, CompleteVercelBuildOptions, CompleteVitendOptions } from "./complete.js";
|
|
2
|
-
import { Format, Omit, Partial } from "ts-vista";
|
|
3
|
-
/**
|
|
4
|
-
* HTTPS server options.
|
|
5
|
-
*/
|
|
6
|
-
type HttpsOptions = Format<Partial<CompleteHttpsOptions>>;
|
|
7
|
-
/**
|
|
8
|
-
* Development server options.
|
|
9
|
-
*/
|
|
10
|
-
type DevOptions = Format<Partial<Omit<CompleteDevOptions, "https">> & {
|
|
11
|
-
/**
|
|
12
|
-
* HTTPS server options.
|
|
13
|
-
*/
|
|
14
|
-
https?: HttpsOptions;
|
|
15
|
-
}>;
|
|
16
|
-
/**
|
|
17
|
-
* Build server options.
|
|
18
|
-
*/
|
|
19
|
-
type BuildOptions = Format<(Partial<Omit<CompleteDefaultBuildOptions, "https">> & {
|
|
20
|
-
/**
|
|
21
|
-
* HTTPS server options.
|
|
22
|
-
*/
|
|
23
|
-
https?: HttpsOptions;
|
|
24
|
-
}) | (Pick<CompleteVercelBuildOptions, "target"> & Partial<Omit<CompleteVercelBuildOptions, "target">>)>;
|
|
25
|
-
/**
|
|
26
|
-
* Options for the `vitend` plugin.
|
|
27
|
-
*/
|
|
28
|
-
type VitendOptions = Format<Partial<Omit<CompleteVitendOptions, "dev" | "build">> & {
|
|
29
|
-
/**
|
|
30
|
-
* The options for the development server.
|
|
31
|
-
*/
|
|
32
|
-
dev?: DevOptions;
|
|
33
|
-
/**
|
|
34
|
-
* The options for the production server.
|
|
35
|
-
*/
|
|
36
|
-
build?: BuildOptions;
|
|
37
|
-
}>;
|
|
38
|
-
export { type BuildOptions, type DevOptions, type HttpsOptions, type VitendOptions };
|
|
39
|
-
//# sourceMappingURL=default.d.ts.map
|
package/dist/@types/server.d.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { ErrorHandler, Server, ServerHandler, ServerMiddleware, ServerOptions, ServerPlugin, ServerRequest } from "srvx";
|
|
2
|
-
import { Format, Omit } from "ts-vista";
|
|
3
|
-
/**
|
|
4
|
-
* Server request extended from `Request`.
|
|
5
|
-
*/
|
|
6
|
-
type ServerRequest$1 = ServerRequest;
|
|
7
|
-
/**
|
|
8
|
-
* Server handler based on Web API.
|
|
9
|
-
*/
|
|
10
|
-
type ServerHandler$1 = ServerHandler;
|
|
11
|
-
/**
|
|
12
|
-
* Error handler for the server.
|
|
13
|
-
*/
|
|
14
|
-
type ErrorHandler$1 = ErrorHandler;
|
|
15
|
-
/**
|
|
16
|
-
* Server middleware for extending the server.
|
|
17
|
-
*/
|
|
18
|
-
type ServerMiddleware$1 = ServerMiddleware;
|
|
19
|
-
/**
|
|
20
|
-
* Server type.
|
|
21
|
-
*/
|
|
22
|
-
type Server$1 = Server;
|
|
23
|
-
/**
|
|
24
|
-
* Server plugin for extending the server.
|
|
25
|
-
*/
|
|
26
|
-
type ServerPlugin$1 = ServerPlugin;
|
|
27
|
-
/**
|
|
28
|
-
* Server options.
|
|
29
|
-
*/
|
|
30
|
-
type ServerOptions$1 = Format<Omit<ServerOptions, "manual" | "hostname" | "port" | "protocol" | "tls">>;
|
|
31
|
-
export { type ErrorHandler$1 as ErrorHandler, type Server$1 as Server, type ServerHandler$1 as ServerHandler, type ServerMiddleware$1 as ServerMiddleware, type ServerOptions$1 as ServerOptions, type ServerPlugin$1 as ServerPlugin, type ServerRequest$1 as ServerRequest };
|
|
32
|
-
//# sourceMappingURL=server.d.ts.map
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __copyProps = (to, from, except, desc) => {
|
|
8
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
9
|
-
for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
10
|
-
key = keys[i];
|
|
11
|
-
if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
12
|
-
__defProp(to, key, {
|
|
13
|
-
get: ((k) => from[k]).bind(null, key),
|
|
14
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
return to;
|
|
20
|
-
};
|
|
21
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
22
|
-
value: mod,
|
|
23
|
-
enumerable: true
|
|
24
|
-
}) : target, mod));
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
exports.__toESM = __toESM;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { ServerOptions } from "../@types/server.js";
|
|
2
|
-
/**
|
|
3
|
-
* A function to define server options.
|
|
4
|
-
*
|
|
5
|
-
* ### Example
|
|
6
|
-
*
|
|
7
|
-
* ```ts
|
|
8
|
-
* // ./src/index.ts
|
|
9
|
-
*
|
|
10
|
-
* import { defineServer } from "vitend";
|
|
11
|
-
*
|
|
12
|
-
* export default defineServer({
|
|
13
|
-
* fetch: (req: Request): Response => {
|
|
14
|
-
* return new Response("Hello, World!");
|
|
15
|
-
* },
|
|
16
|
-
* });
|
|
17
|
-
* ```
|
|
18
|
-
*/
|
|
19
|
-
declare const defineServer: (options: ServerOptions) => ServerOptions;
|
|
20
|
-
export { defineServer };
|
|
21
|
-
//# sourceMappingURL=define.d.ts.map
|
package/dist/functions/define.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* A function to define server options.
|
|
4
|
-
*
|
|
5
|
-
* ### Example
|
|
6
|
-
*
|
|
7
|
-
* ```ts
|
|
8
|
-
* // ./src/index.ts
|
|
9
|
-
*
|
|
10
|
-
* import { defineServer } from "vitend";
|
|
11
|
-
*
|
|
12
|
-
* export default defineServer({
|
|
13
|
-
* fetch: (req: Request): Response => {
|
|
14
|
-
* return new Response("Hello, World!");
|
|
15
|
-
* },
|
|
16
|
-
* });
|
|
17
|
-
* ```
|
|
18
|
-
*/
|
|
19
|
-
const defineServer = (options) => options;
|
|
20
|
-
|
|
21
|
-
exports.defineServer = defineServer;
|
|
22
|
-
//# sourceMappingURL=define.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"define.js","names":[],"sources":["../../src/functions/define.ts"],"sourcesContent":["import type { ServerOptions } from \"#/@types/server\";\n\n/**\n * A function to define server options.\n *\n * ### Example\n *\n * ```ts\n * // ./src/index.ts\n *\n * import { defineServer } from \"vitend\";\n *\n * export default defineServer({\n * fetch: (req: Request): Response => {\n * return new Response(\"Hello, World!\");\n * },\n * });\n * ```\n */\nconst defineServer = (options: ServerOptions): ServerOptions => options;\n\nexport { defineServer };\n"],"mappings":";;;;;;;;;;;;;;;;;;AAmBA,MAAM,gBAAgB,YAA0C"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A function to define server options.
|
|
3
|
-
*
|
|
4
|
-
* ### Example
|
|
5
|
-
*
|
|
6
|
-
* ```ts
|
|
7
|
-
* // ./src/index.ts
|
|
8
|
-
*
|
|
9
|
-
* import { defineServer } from "vitend";
|
|
10
|
-
*
|
|
11
|
-
* export default defineServer({
|
|
12
|
-
* fetch: (req: Request): Response => {
|
|
13
|
-
* return new Response("Hello, World!");
|
|
14
|
-
* },
|
|
15
|
-
* });
|
|
16
|
-
* ```
|
|
17
|
-
*/
|
|
18
|
-
const defineServer = (options) => options;
|
|
19
|
-
|
|
20
|
-
export { defineServer };
|
|
21
|
-
//# sourceMappingURL=define.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"define.mjs","names":[],"sources":["../../src/functions/define.ts"],"sourcesContent":["import type { ServerOptions } from \"#/@types/server\";\n\n/**\n * A function to define server options.\n *\n * ### Example\n *\n * ```ts\n * // ./src/index.ts\n *\n * import { defineServer } from \"vitend\";\n *\n * export default defineServer({\n * fetch: (req: Request): Response => {\n * return new Response(\"Hello, World!\");\n * },\n * });\n * ```\n */\nconst defineServer = (options: ServerOptions): ServerOptions => options;\n\nexport { defineServer };\n"],"mappings":";;;;;;;;;;;;;;;;;AAmBA,MAAM,gBAAgB,YAA0C"}
|