vitend 0.1.0 → 0.2.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/dist/@types/options/complete.d.ts +42 -3
- package/dist/@types/options/default.d.ts +3 -3
- package/dist/functions/options.js +23 -10
- package/dist/functions/options.js.map +1 -1
- package/dist/functions/options.mjs +23 -10
- package/dist/functions/options.mjs.map +1 -1
- package/dist/vite/build.js +7 -2
- package/dist/vite/build.js.map +1 -1
- package/dist/vite/build.mjs +7 -2
- package/dist/vite/build.mjs.map +1 -1
- package/dist/vite/dev.js +3 -3
- package/dist/vite/dev.js.map +1 -1
- package/dist/vite/dev.mjs +3 -3
- package/dist/vite/dev.mjs.map +1 -1
- package/dist/vite/vitend.js +1 -1
- package/dist/vite/vitend.js.map +1 -1
- package/dist/vite/vitend.mjs +1 -1
- package/dist/vite/vitend.mjs.map +1 -1
- package/package.json +2 -1
|
@@ -37,9 +37,15 @@ type CompleteDevOptions = {
|
|
|
37
37
|
https: CompleteHttpsOptions;
|
|
38
38
|
};
|
|
39
39
|
/**
|
|
40
|
-
* Complete build server options.
|
|
40
|
+
* Complete default build server options.
|
|
41
41
|
*/
|
|
42
|
-
type
|
|
42
|
+
type CompleteDefaultBuildOptions = {
|
|
43
|
+
/**
|
|
44
|
+
* Build target.
|
|
45
|
+
*
|
|
46
|
+
* By default, it is `default`.
|
|
47
|
+
*/
|
|
48
|
+
target: "default";
|
|
43
49
|
/**
|
|
44
50
|
* The host for the production server.
|
|
45
51
|
*
|
|
@@ -91,6 +97,39 @@ type CompleteBuildOptions = {
|
|
|
91
97
|
copyPublicDir: boolean;
|
|
92
98
|
};
|
|
93
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
|
+
/**
|
|
94
133
|
* Complete options for the `vitend` plugin.
|
|
95
134
|
*/
|
|
96
135
|
type CompleteVitendOptions = {
|
|
@@ -115,5 +154,5 @@ type CompleteVitendOptions = {
|
|
|
115
154
|
*/
|
|
116
155
|
build: CompleteBuildOptions;
|
|
117
156
|
};
|
|
118
|
-
export { type
|
|
157
|
+
export { type CompleteDefaultBuildOptions, type CompleteDevOptions, type CompleteHttpsOptions, type CompleteVercelBuildOptions, type CompleteVitendOptions };
|
|
119
158
|
//# sourceMappingURL=complete.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CompleteDefaultBuildOptions, CompleteDevOptions, CompleteHttpsOptions, CompleteVercelBuildOptions, CompleteVitendOptions } from "./complete.js";
|
|
2
2
|
import { Format, Omit, Partial } from "ts-vista";
|
|
3
3
|
/**
|
|
4
4
|
* HTTPS server options.
|
|
@@ -16,12 +16,12 @@ type DevOptions = Format<Partial<Omit<CompleteDevOptions, "https">> & {
|
|
|
16
16
|
/**
|
|
17
17
|
* Build server options.
|
|
18
18
|
*/
|
|
19
|
-
type BuildOptions = Format<Partial<Omit<
|
|
19
|
+
type BuildOptions = Format<(Partial<Omit<CompleteDefaultBuildOptions, "https">> & {
|
|
20
20
|
/**
|
|
21
21
|
* HTTPS server options.
|
|
22
22
|
*/
|
|
23
23
|
https?: HttpsOptions;
|
|
24
|
-
}>;
|
|
24
|
+
}) | (Pick<CompleteVercelBuildOptions, "target"> & Partial<Omit<CompleteVercelBuildOptions, "target">>)>;
|
|
25
25
|
/**
|
|
26
26
|
* Options for the `vitend` plugin.
|
|
27
27
|
*/
|
|
@@ -2,24 +2,37 @@ const require_rolldown_runtime = require('../_virtual/rolldown_runtime.js');
|
|
|
2
2
|
const require_entry = require('./entry.js');
|
|
3
3
|
let es_toolkit = require("es-toolkit");
|
|
4
4
|
|
|
5
|
+
const OPTIONS_BUILD_VERCEL = {
|
|
6
|
+
target: "vercel",
|
|
7
|
+
outputDir: "./dist",
|
|
8
|
+
outputFile: "index.js",
|
|
9
|
+
minify: false
|
|
10
|
+
};
|
|
11
|
+
const OPTIONS_BUILD_DEFAULT = {
|
|
12
|
+
target: "default",
|
|
13
|
+
host: "localhost",
|
|
14
|
+
port: 3e3,
|
|
15
|
+
outputDir: "./dist",
|
|
16
|
+
outputFile: "index.js",
|
|
17
|
+
minify: false,
|
|
18
|
+
publicDir: "./public",
|
|
19
|
+
copyPublicDir: false
|
|
20
|
+
};
|
|
5
21
|
const OPTIONS_DEFAULT = {
|
|
6
22
|
cwd: process.cwd(),
|
|
7
23
|
dev: {
|
|
8
24
|
host: "localhost",
|
|
9
25
|
port: 3001
|
|
10
|
-
},
|
|
11
|
-
build: {
|
|
12
|
-
host: "localhost",
|
|
13
|
-
port: 3e3,
|
|
14
|
-
outputDir: "./dist",
|
|
15
|
-
outputFile: "index.js",
|
|
16
|
-
minify: false,
|
|
17
|
-
publicDir: "./public",
|
|
18
|
-
copyPublicDir: false
|
|
19
26
|
}
|
|
20
27
|
};
|
|
28
|
+
const getDefaultOptions = (isVercel) => {
|
|
29
|
+
return {
|
|
30
|
+
...OPTIONS_DEFAULT,
|
|
31
|
+
build: isVercel ? OPTIONS_BUILD_VERCEL : OPTIONS_BUILD_DEFAULT
|
|
32
|
+
};
|
|
33
|
+
};
|
|
21
34
|
const createOptions = (options) => {
|
|
22
|
-
const merged = (0, es_toolkit.toMerged)(
|
|
35
|
+
const merged = (0, es_toolkit.toMerged)(getDefaultOptions(options?.build?.target === "vercel"), options ?? {});
|
|
23
36
|
return {
|
|
24
37
|
...merged,
|
|
25
38
|
entry: require_entry.getEntry(merged.cwd, options?.entry)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.js","names":["getEntry"],"sources":["../../src/functions/options.ts"],"sourcesContent":["import type { Omit } from \"ts-vista\";\n\nimport type { VitendOptions } from \"#/@types/options/default\";\nimport type {
|
|
1
|
+
{"version":3,"file":"options.js","names":["getEntry"],"sources":["../../src/functions/options.ts"],"sourcesContent":["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"],"mappings":";;;;AAaA,MAAM,uBAAmD;CACrD,QAAQ;CACR,WAAW;CACX,YAAY;CACZ,QAAQ;CACX;AAED,MAAM,wBAAqD;CACvD,QAAQ;CACR,MAAM;CACN,MAAM;CACN,WAAW;CACX,YAAY;CACZ,QAAQ;CACR,WAAW;CACX,eAAe;CAClB;AAED,MAAM,kBAAkE;CACpE,KAAK,QAAQ,KAAK;CAClB,KAAK;EACD,MAAM;EACN,MAAM;EACT;CACJ;AAED,MAAM,qBACF,aACuC;AACvC,QAAO;EACH,GAAG;EACH,OAAO,WAAW,uBAAuB;EAC5C;;AAGL,MAAM,iBAAiB,YAAmD;CAGtE,MAAM,kCAAkB,kBAFE,SAAS,OAAO,WAAW,SAEF,EAAE,WAAW,EAAE,CAAC;AAEnE,QAAO;EACH,GAAG;EACH,OAAOA,uBAAS,OAAO,KAAK,SAAS,MAAM;EAC9C"}
|
|
@@ -1,24 +1,37 @@
|
|
|
1
1
|
import { getEntry } from "./entry.mjs";
|
|
2
2
|
import { toMerged } from "es-toolkit";
|
|
3
3
|
|
|
4
|
+
const OPTIONS_BUILD_VERCEL = {
|
|
5
|
+
target: "vercel",
|
|
6
|
+
outputDir: "./dist",
|
|
7
|
+
outputFile: "index.js",
|
|
8
|
+
minify: false
|
|
9
|
+
};
|
|
10
|
+
const OPTIONS_BUILD_DEFAULT = {
|
|
11
|
+
target: "default",
|
|
12
|
+
host: "localhost",
|
|
13
|
+
port: 3e3,
|
|
14
|
+
outputDir: "./dist",
|
|
15
|
+
outputFile: "index.js",
|
|
16
|
+
minify: false,
|
|
17
|
+
publicDir: "./public",
|
|
18
|
+
copyPublicDir: false
|
|
19
|
+
};
|
|
4
20
|
const OPTIONS_DEFAULT = {
|
|
5
21
|
cwd: process.cwd(),
|
|
6
22
|
dev: {
|
|
7
23
|
host: "localhost",
|
|
8
24
|
port: 3001
|
|
9
|
-
},
|
|
10
|
-
build: {
|
|
11
|
-
host: "localhost",
|
|
12
|
-
port: 3e3,
|
|
13
|
-
outputDir: "./dist",
|
|
14
|
-
outputFile: "index.js",
|
|
15
|
-
minify: false,
|
|
16
|
-
publicDir: "./public",
|
|
17
|
-
copyPublicDir: false
|
|
18
25
|
}
|
|
19
26
|
};
|
|
27
|
+
const getDefaultOptions = (isVercel) => {
|
|
28
|
+
return {
|
|
29
|
+
...OPTIONS_DEFAULT,
|
|
30
|
+
build: isVercel ? OPTIONS_BUILD_VERCEL : OPTIONS_BUILD_DEFAULT
|
|
31
|
+
};
|
|
32
|
+
};
|
|
20
33
|
const createOptions = (options) => {
|
|
21
|
-
const merged = toMerged(
|
|
34
|
+
const merged = toMerged(getDefaultOptions(options?.build?.target === "vercel"), options ?? {});
|
|
22
35
|
return {
|
|
23
36
|
...merged,
|
|
24
37
|
entry: getEntry(merged.cwd, options?.entry)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.mjs","names":[],"sources":["../../src/functions/options.ts"],"sourcesContent":["import type { Omit } from \"ts-vista\";\n\nimport type { VitendOptions } from \"#/@types/options/default\";\nimport type {
|
|
1
|
+
{"version":3,"file":"options.mjs","names":[],"sources":["../../src/functions/options.ts"],"sourcesContent":["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"],"mappings":";;;AAaA,MAAM,uBAAmD;CACrD,QAAQ;CACR,WAAW;CACX,YAAY;CACZ,QAAQ;CACX;AAED,MAAM,wBAAqD;CACvD,QAAQ;CACR,MAAM;CACN,MAAM;CACN,WAAW;CACX,YAAY;CACZ,QAAQ;CACR,WAAW;CACX,eAAe;CAClB;AAED,MAAM,kBAAkE;CACpE,KAAK,QAAQ,KAAK;CAClB,KAAK;EACD,MAAM;EACN,MAAM;EACT;CACJ;AAED,MAAM,qBACF,aACuC;AACvC,QAAO;EACH,GAAG;EACH,OAAO,WAAW,uBAAuB;EAC5C;;AAGL,MAAM,iBAAiB,YAAmD;CAGtE,MAAM,SAAS,SAAS,kBAFE,SAAS,OAAO,WAAW,SAEF,EAAE,WAAW,EAAE,CAAC;AAEnE,QAAO;EACH,GAAG;EACH,OAAO,SAAS,OAAO,KAAK,SAAS,MAAM;EAC9C"}
|
package/dist/vite/build.js
CHANGED
|
@@ -44,10 +44,15 @@ const buildPlugin = (opts) => {
|
|
|
44
44
|
load: async (id) => {
|
|
45
45
|
if (id !== VIRTUAL_ENTRY_RESOLVED) return void 0;
|
|
46
46
|
let code = "";
|
|
47
|
-
code += `import
|
|
47
|
+
code += `import options from "${opts.entry}";`;
|
|
48
48
|
code += `import { serve } from "vitend/runtime";`;
|
|
49
|
+
if (build.target === "vercel") {
|
|
50
|
+
code += `const server = serve({ ...options, manual: true });`;
|
|
51
|
+
code += `export default server;`;
|
|
52
|
+
return code;
|
|
53
|
+
}
|
|
49
54
|
code += `serve({`;
|
|
50
|
-
code += `...
|
|
55
|
+
code += `...options,`;
|
|
51
56
|
if (build.host !== "localhost") code += `hostname: "${build.host}",`;
|
|
52
57
|
if (build.port !== 3e3) code += `port: ${build.port},`;
|
|
53
58
|
if (build.https) {
|
package/dist/vite/build.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.js","names":["getPackageJson","builtinModules"],"sources":["../../src/vite/build.ts"],"sourcesContent":["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
|
|
1
|
+
{"version":3,"file":"build.js","names":["getPackageJson","builtinModules"],"sources":["../../src/vite/build.ts"],"sourcesContent":["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"],"mappings":";;;;;AAeA,MAAM,gBAAgB;AAEtB,MAAM,yBAAyB,KAAK;AAEpC,MAAM,eAAe,SAAwC;CACzD,MAAM,QAA8B,KAAK;CAEzC,MAAM,cAA2BA,oCAAe,KAAK,IAAI;AAEzD,QAAO;EACH,MAAM;EACN,OAAO;EACP,SAAS,WAAmC;GACxC,IAAI,SAAqB,EAAE;AAa3B,qCAX+B;IAC3B,KAAK;KACD,UAAU;KACV,YAAY,KAAK;KACjB,QAAQ;KACX;IACD,OAAO,EACH,eAAe,OAClB;IACJ,EAE6B,OAAO;GAErC,MAAM,iBAA6B,EAC/B,OAAO;IACH,KAAK;IACL,QAAQ,MAAM;IACd,eAAe;KACX,OAAO;KACP,QAAQ;MACJ,gBAAgB,MAAM;MACtB,QACI,YAAY,SAAS,WAAW,QAAQ;MAC/C;KACD,UAAU,CACN,GAAGC,4BACH,SACH;KACJ;IACD,QAAQ,MAAM;IACjB,EACJ;AAED,qCAAkB,QAAQ,eAAe;AAEzC,UAAO;;EAEX,YAAY,OAAgC;AACxC,OAAI,OAAO,cAAe,QAAO,KAAK;AACtC,UAAO;;EAEX,MAAM,OAAO,OAAoC;AAC7C,OAAI,OAAO,uBAAwB,QAAO,KAAK;GAE/C,IAAI,OAAe;AAEnB,WAAQ,wBAAwB,KAAK,MAAM;AAC3C,WAAQ;AAIR,OAAI,MAAM,WAAW,UAAU;AAC3B,YAAQ;AACR,YAAQ;AAER,WAAO;;AAKX,WAAQ;AACR,WAAQ;AAER,OAAI,MAAM,SAAS,YACf,SAAQ,cAAc,MAAM,KAAK;AACrC,OAAI,MAAM,SAAS,IAAM,SAAQ,SAAS,MAAM,KAAK;AAErD,OAAI,MAAM,OAAO;AACb,YAAQ;AACR,QAAI,MAAM,MAAM,KAAM,SAAQ,UAAU,MAAM,MAAM,KAAK;AACzD,QAAI,MAAM,MAAM,IAAK,SAAQ,SAAS,MAAM,MAAM,IAAI;AACtD,QAAI,MAAM,MAAM,WACZ,SAAQ,gBAAgB,MAAM,MAAM,WAAW;AACnD,YAAQ;;AAGZ,WAAQ;AAER,UAAO;;EAEd"}
|
package/dist/vite/build.mjs
CHANGED
|
@@ -43,10 +43,15 @@ const buildPlugin = (opts) => {
|
|
|
43
43
|
load: async (id) => {
|
|
44
44
|
if (id !== VIRTUAL_ENTRY_RESOLVED) return void 0;
|
|
45
45
|
let code = "";
|
|
46
|
-
code += `import
|
|
46
|
+
code += `import options from "${opts.entry}";`;
|
|
47
47
|
code += `import { serve } from "vitend/runtime";`;
|
|
48
|
+
if (build.target === "vercel") {
|
|
49
|
+
code += `const server = serve({ ...options, manual: true });`;
|
|
50
|
+
code += `export default server;`;
|
|
51
|
+
return code;
|
|
52
|
+
}
|
|
48
53
|
code += `serve({`;
|
|
49
|
-
code += `...
|
|
54
|
+
code += `...options,`;
|
|
50
55
|
if (build.host !== "localhost") code += `hostname: "${build.host}",`;
|
|
51
56
|
if (build.port !== 3e3) code += `port: ${build.port},`;
|
|
52
57
|
if (build.https) {
|
package/dist/vite/build.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.mjs","names":[],"sources":["../../src/vite/build.ts"],"sourcesContent":["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
|
|
1
|
+
{"version":3,"file":"build.mjs","names":[],"sources":["../../src/vite/build.ts"],"sourcesContent":["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"],"mappings":";;;;AAeA,MAAM,gBAAgB;AAEtB,MAAM,yBAAyB,KAAK;AAEpC,MAAM,eAAe,SAAwC;CACzD,MAAM,QAA8B,KAAK;CAEzC,MAAM,cAA2B,eAAe,KAAK,IAAI;AAEzD,QAAO;EACH,MAAM;EACN,OAAO;EACP,SAAS,WAAmC;GACxC,IAAI,SAAqB,EAAE;AAa3B,YAAS,SAXsB;IAC3B,KAAK;KACD,UAAU;KACV,YAAY,KAAK;KACjB,QAAQ;KACX;IACD,OAAO,EACH,eAAe,OAClB;IACJ,EAE6B,OAAO;GAErC,MAAM,iBAA6B,EAC/B,OAAO;IACH,KAAK;IACL,QAAQ,MAAM;IACd,eAAe;KACX,OAAO;KACP,QAAQ;MACJ,gBAAgB,MAAM;MACtB,QACI,YAAY,SAAS,WAAW,QAAQ;MAC/C;KACD,UAAU,CACN,GAAG,gBACH,SACH;KACJ;IACD,QAAQ,MAAM;IACjB,EACJ;AAED,YAAS,SAAS,QAAQ,eAAe;AAEzC,UAAO;;EAEX,YAAY,OAAgC;AACxC,OAAI,OAAO,cAAe,QAAO,KAAK;AACtC,UAAO;;EAEX,MAAM,OAAO,OAAoC;AAC7C,OAAI,OAAO,uBAAwB,QAAO,KAAK;GAE/C,IAAI,OAAe;AAEnB,WAAQ,wBAAwB,KAAK,MAAM;AAC3C,WAAQ;AAIR,OAAI,MAAM,WAAW,UAAU;AAC3B,YAAQ;AACR,YAAQ;AAER,WAAO;;AAKX,WAAQ;AACR,WAAQ;AAER,OAAI,MAAM,SAAS,YACf,SAAQ,cAAc,MAAM,KAAK;AACrC,OAAI,MAAM,SAAS,IAAM,SAAQ,SAAS,MAAM,KAAK;AAErD,OAAI,MAAM,OAAO;AACb,YAAQ;AACR,QAAI,MAAM,MAAM,KAAM,SAAQ,UAAU,MAAM,MAAM,KAAK;AACzD,QAAI,MAAM,MAAM,IAAK,SAAQ,SAAS,MAAM,MAAM,IAAI;AACtD,QAAI,MAAM,MAAM,WACZ,SAAQ,gBAAgB,MAAM,MAAM,WAAW;AACnD,YAAQ;;AAGZ,WAAQ;AAER,UAAO;;EAEd"}
|
package/dist/vite/dev.js
CHANGED
|
@@ -4,7 +4,7 @@ let srvx = require("srvx");
|
|
|
4
4
|
|
|
5
5
|
const createMiddleware = ({ vite, server }) => {
|
|
6
6
|
return async (req, res, _next) => {
|
|
7
|
-
const protocol = `http${vite.config.server.https !== void 0 ? "s" : ""}`;
|
|
7
|
+
const protocol = `http${vite.config.server.https?.cert !== void 0 && vite.config.server.https?.key !== void 0 ? "s" : ""}`;
|
|
8
8
|
const host = process.env.HOST ?? "localhost";
|
|
9
9
|
const port = vite.config.server.port;
|
|
10
10
|
const path = req.url ?? "";
|
|
@@ -56,11 +56,11 @@ const devPlugin = (opts) => {
|
|
|
56
56
|
server: {
|
|
57
57
|
host: dev.host,
|
|
58
58
|
port: dev.port,
|
|
59
|
-
https: {
|
|
59
|
+
...https.cert !== void 0 && https.key !== void 0 ? { https: {
|
|
60
60
|
cert: https.cert,
|
|
61
61
|
key: https.key,
|
|
62
62
|
passphrase: https.passphrase
|
|
63
|
-
}
|
|
63
|
+
} } : {}
|
|
64
64
|
}
|
|
65
65
|
});
|
|
66
66
|
},
|
package/dist/vite/dev.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dev.js","names":[],"sources":["../../src/vite/dev.ts"],"sourcesContent":["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
|
|
1
|
+
{"version":3,"file":"dev.js","names":[],"sources":["../../src/vite/dev.ts"],"sourcesContent":["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"],"mappings":";;;;AAmBA,MAAM,oBAAoB,EAAE,MAAM,aAAsC;AACpE,QAAO,OACH,KACA,KACA,UACgB;EAKhB,MAAM,WAAmB,OAHrB,KAAK,OAAO,OAAO,OAAO,SAAS,KAAK,KACxC,KAAK,OAAO,OAAO,OAAO,QAAQ,KAAK,IAED,MAAM;EAEhD,MAAM,OAAe,QAAQ,IAAI,QAAQ;EAEzC,MAAM,OAAe,KAAK,OAAO,OAAO;EAExC,MAAM,OAAe,IAAI,OAAO;EAEhC,MAAM,MAAW,IAAI,IAAI,GAAG,SAAS,KAAK,KAAK,GAAG,OAAO,OAAO;EAEhE,MAAM,OACF,IAAI,WAAW,SAAS,IAAI,WAAW,SAAS,MAAM,KAAK;EAE/D,MAAM,UAAmB,IAAI,QAAQ,KAAK;GACtC,QAAQ,IAAI;GACZ,SAAS,IAAI;GACb;GACA,QAAQ;GACX,CAAgB;EAEjB,MAAM,WAAqB,MAAM,OAAO,MAAM,QAAQ;AAEtD,MAAI,aAAa,SAAS;AAE1B,WAAS,QAAQ,SAAS,OAAe,QAAsB;AAC3D,OAAI,UAAU,KAAK,MAAM;IAC3B;AAEF,MAAI,CAAC,SAAS,MAAM;AAChB,OAAI,KAAK;AACT;;EAGJ,MAAM,SACF,SAAS,KAAK,WAAW;EAE7B,MAAM,SAAS,YAA2B;AACtC,OAAI;AACA,WAAO,MAAM;KACT,MAAM,EAAE,MAAM,UAAU,MAAM,OAAO,MAAM;AAE3C,SAAI,KAAM;AAEV,SAAI,MAAM,MAAM;;AAGpB,QAAI,KAAK;WACL;AACJ,QAAI,KAAK;;;AAIjB,QAAM,QAAQ;;;AAMtB,MAAM,aAAa,SAAwC;CACvD,MAAM,MAA0B,KAAK;CACrC,MAAM,QAA8B,KAAK,IAAI,SAAS,EAAE;AAExD,QAAO;EACH,MAAM;EACN,OAAO;EACP,OAAO,QAAgC;AAuBnC,mCAAgB,QAtBc;IAC1B,OAAO;KACH,KAAK;KACL,eAAe,EACX,OAAO,KAAK,OACf;KACJ;IACD,QAAQ;KACJ,MAAM,IAAI;KACV,MAAM,IAAI;KACV,GAAI,MAAM,SAAS,KAAK,KAAK,MAAM,QAAQ,KAAK,IAC1C,EACI,OAAO;MACH,MAAM,MAAM;MACZ,KAAK,MAAM;MACX,YAAY,MAAM;MACrB,EACJ,GACD,EAAE;KACX;IACJ,CAEiC;;EAEtC,iBAAiB,OAAO,SAAuC;GAC3D,MAAM,iBACF,MAAM,KAAK,cAAc,KAAK,MAAM,EACtC;GAkBF,MAAM,aAAyB,iBAAiB;IAC5C;IACA,wBAlBwC;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"}
|
package/dist/vite/dev.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import { serve } from "srvx";
|
|
|
3
3
|
|
|
4
4
|
const createMiddleware = ({ vite, server }) => {
|
|
5
5
|
return async (req, res, _next) => {
|
|
6
|
-
const protocol = `http${vite.config.server.https !== void 0 ? "s" : ""}`;
|
|
6
|
+
const protocol = `http${vite.config.server.https?.cert !== void 0 && vite.config.server.https?.key !== void 0 ? "s" : ""}`;
|
|
7
7
|
const host = process.env.HOST ?? "localhost";
|
|
8
8
|
const port = vite.config.server.port;
|
|
9
9
|
const path = req.url ?? "";
|
|
@@ -55,11 +55,11 @@ const devPlugin = (opts) => {
|
|
|
55
55
|
server: {
|
|
56
56
|
host: dev.host,
|
|
57
57
|
port: dev.port,
|
|
58
|
-
https: {
|
|
58
|
+
...https.cert !== void 0 && https.key !== void 0 ? { https: {
|
|
59
59
|
cert: https.cert,
|
|
60
60
|
key: https.key,
|
|
61
61
|
passphrase: https.passphrase
|
|
62
|
-
}
|
|
62
|
+
} } : {}
|
|
63
63
|
}
|
|
64
64
|
});
|
|
65
65
|
},
|
package/dist/vite/dev.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dev.mjs","names":[],"sources":["../../src/vite/dev.ts"],"sourcesContent":["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
|
|
1
|
+
{"version":3,"file":"dev.mjs","names":[],"sources":["../../src/vite/dev.ts"],"sourcesContent":["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"],"mappings":";;;AAmBA,MAAM,oBAAoB,EAAE,MAAM,aAAsC;AACpE,QAAO,OACH,KACA,KACA,UACgB;EAKhB,MAAM,WAAmB,OAHrB,KAAK,OAAO,OAAO,OAAO,SAAS,KAAK,KACxC,KAAK,OAAO,OAAO,OAAO,QAAQ,KAAK,IAED,MAAM;EAEhD,MAAM,OAAe,QAAQ,IAAI,QAAQ;EAEzC,MAAM,OAAe,KAAK,OAAO,OAAO;EAExC,MAAM,OAAe,IAAI,OAAO;EAEhC,MAAM,MAAW,IAAI,IAAI,GAAG,SAAS,KAAK,KAAK,GAAG,OAAO,OAAO;EAEhE,MAAM,OACF,IAAI,WAAW,SAAS,IAAI,WAAW,SAAS,MAAM,KAAK;EAE/D,MAAM,UAAmB,IAAI,QAAQ,KAAK;GACtC,QAAQ,IAAI;GACZ,SAAS,IAAI;GACb;GACA,QAAQ;GACX,CAAgB;EAEjB,MAAM,WAAqB,MAAM,OAAO,MAAM,QAAQ;AAEtD,MAAI,aAAa,SAAS;AAE1B,WAAS,QAAQ,SAAS,OAAe,QAAsB;AAC3D,OAAI,UAAU,KAAK,MAAM;IAC3B;AAEF,MAAI,CAAC,SAAS,MAAM;AAChB,OAAI,KAAK;AACT;;EAGJ,MAAM,SACF,SAAS,KAAK,WAAW;EAE7B,MAAM,SAAS,YAA2B;AACtC,OAAI;AACA,WAAO,MAAM;KACT,MAAM,EAAE,MAAM,UAAU,MAAM,OAAO,MAAM;AAE3C,SAAI,KAAM;AAEV,SAAI,MAAM,MAAM;;AAGpB,QAAI,KAAK;WACL;AACJ,QAAI,KAAK;;;AAIjB,QAAM,QAAQ;;;AAMtB,MAAM,aAAa,SAAwC;CACvD,MAAM,MAA0B,KAAK;CACrC,MAAM,QAA8B,KAAK,IAAI,SAAS,EAAE;AAExD,QAAO;EACH,MAAM;EACN,OAAO;EACP,OAAO,QAAgC;AAuBnC,UAAO,SAAS,QAtBc;IAC1B,OAAO;KACH,KAAK;KACL,eAAe,EACX,OAAO,KAAK,OACf;KACJ;IACD,QAAQ;KACJ,MAAM,IAAI;KACV,MAAM,IAAI;KACV,GAAI,MAAM,SAAS,KAAK,KAAK,MAAM,QAAQ,KAAK,IAC1C,EACI,OAAO;MACH,MAAM,MAAM;MACZ,KAAK,MAAM;MACX,YAAY,MAAM;MACrB,EACJ,GACD,EAAE;KACX;IACJ,CAEiC;;EAEtC,iBAAiB,OAAO,SAAuC;GAC3D,MAAM,iBACF,MAAM,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"}
|
package/dist/vite/vitend.js
CHANGED
|
@@ -31,7 +31,7 @@ const vitend = (options) => {
|
|
|
31
31
|
return [
|
|
32
32
|
require_dev.devPlugin({ ...opts }),
|
|
33
33
|
require_build.buildPlugin({ ...opts }),
|
|
34
|
-
...build
|
|
34
|
+
...build.target === "default" && build.copyPublicDir ? [(0, rollup_plugin_copy.default)({
|
|
35
35
|
hook: "closeBundle",
|
|
36
36
|
targets: [{
|
|
37
37
|
src: node_path.resolve(build.publicDir, "**", "*"),
|
package/dist/vite/vitend.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vitend.js","names":["createOptions","devPlugin","buildPlugin","Path"],"sources":["../../src/vite/vitend.ts"],"sourcesContent":["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
|
|
1
|
+
{"version":3,"file":"vitend.js","names":["createOptions","devPlugin","buildPlugin","Path"],"sources":["../../src/vite/vitend.ts"],"sourcesContent":["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 ]\n : []),\n ];\n};\n\nexport { vitend };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCA,MAAM,UAAU,YAAsC;CAClD,MAAM,OAA8BA,8BAAc,QAAQ;CAE1D,MAAM,QAA8B,KAAK;AAEzC,QAAO;EACHC,sBAAU,EACN,GAAG,MACN,CAAC;EACFC,0BAAY,EACR,GAAG,MACN,CAAC;EACF,GAAI,MAAM,WAAW,aAAa,MAAM,gBAClC,iCACS;GACD,MAAM;GACN,SAAS,CACL;IACI,KAAKC,UAAK,QAAQ,MAAM,WAAW,MAAM,IAAI;IAC7C,MAAMA,UAAK,QACP,MAAM,WACN,MAAM,UACT;IACJ,CACJ;GACJ,CAAC,CACL,GACD,EAAE;EACX"}
|
package/dist/vite/vitend.mjs
CHANGED
|
@@ -28,7 +28,7 @@ const vitend = (options) => {
|
|
|
28
28
|
return [
|
|
29
29
|
devPlugin({ ...opts }),
|
|
30
30
|
buildPlugin({ ...opts }),
|
|
31
|
-
...build
|
|
31
|
+
...build.target === "default" && build.copyPublicDir ? [copy({
|
|
32
32
|
hook: "closeBundle",
|
|
33
33
|
targets: [{
|
|
34
34
|
src: Path.resolve(build.publicDir, "**", "*"),
|
package/dist/vite/vitend.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vitend.mjs","names":[],"sources":["../../src/vite/vitend.ts"],"sourcesContent":["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
|
|
1
|
+
{"version":3,"file":"vitend.mjs","names":[],"sources":["../../src/vite/vitend.ts"],"sourcesContent":["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 ]\n : []),\n ];\n};\n\nexport { vitend };\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAkCA,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,gBAClC,CACI,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"}
|