@theholocron/vite-config 6.1.0 → 7.0.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.
@@ -0,0 +1,12 @@
1
+ import { readFileSync } from "node:fs";
2
+ import { resolve } from "node:path";
3
+ //#region presets/get-package-name.ts
4
+ function getPackageName() {
5
+ try {
6
+ return JSON.parse(readFileSync(resolve(process.cwd(), "package.json"), "utf-8")).name ?? "unknown";
7
+ } catch {
8
+ return "unknown";
9
+ }
10
+ }
11
+ //#endregion
12
+ export { getPackageName as t };
@@ -0,0 +1,4 @@
1
+ import { library } from "./presets/library.js";
2
+ import { reactApp } from "./presets/react-app.js";
3
+ import { nodeApp } from "./presets/node-app.js";
4
+ export { library, nodeApp, reactApp };
package/dist/index.js ADDED
@@ -0,0 +1,4 @@
1
+ import { library } from "./presets/library.js";
2
+ import { reactApp } from "./presets/react-app.js";
3
+ import { nodeApp } from "./presets/node-app.js";
4
+ export { library, nodeApp, reactApp };
@@ -0,0 +1,15 @@
1
+ import { UserConfig } from "vite";
2
+ //#region presets/library.d.ts
3
+ /**
4
+ * Vite preset for publishable libraries.
5
+ * Outputs ESM only; externalises React and react-dom by default.
6
+ * Uploads bundle stats to Codecov when CODECOV_TOKEN is set.
7
+ */
8
+ declare function library({ entry, name, external, overrides }?: {
9
+ entry?: string;
10
+ name?: string;
11
+ external?: string[];
12
+ overrides?: UserConfig;
13
+ }): Promise<UserConfig>;
14
+ //#endregion
15
+ export { library };
@@ -0,0 +1,44 @@
1
+ import { t as getPackageName } from "../get-package-name-D6LP2hiw.js";
2
+ import { mergeConfig } from "vite";
3
+ //#region presets/library.ts
4
+ /**
5
+ * Vite preset for publishable libraries.
6
+ * Outputs ESM only; externalises React and react-dom by default.
7
+ * Uploads bundle stats to Codecov when CODECOV_TOKEN is set.
8
+ */
9
+ async function library({ entry = "src/index.ts", name, external = [], overrides = {} } = {}) {
10
+ const plugins = [];
11
+ try {
12
+ const { codecovVitePlugin } = await import("@codecov/vite-plugin");
13
+ plugins.push(codecovVitePlugin({
14
+ enableBundleAnalysis: !!process.env.CODECOV_TOKEN,
15
+ bundleName: getPackageName(),
16
+ uploadToken: process.env.CODECOV_TOKEN
17
+ }));
18
+ } catch {}
19
+ return mergeConfig({
20
+ plugins,
21
+ build: {
22
+ lib: {
23
+ entry,
24
+ name,
25
+ formats: ["es"],
26
+ fileName: () => "index.mjs"
27
+ },
28
+ rollupOptions: {
29
+ external: [
30
+ "react",
31
+ "react-dom",
32
+ ...external
33
+ ],
34
+ output: { globals: {
35
+ react: "React",
36
+ "react-dom": "ReactDOM"
37
+ } }
38
+ },
39
+ sourcemap: true
40
+ }
41
+ }, overrides);
42
+ }
43
+ //#endregion
44
+ export { library };
@@ -0,0 +1,13 @@
1
+ import { UserConfig } from "vite";
2
+ //#region presets/node-app.d.ts
3
+ /**
4
+ * Vite preset for Node.js CLI tools and server apps.
5
+ * Targets Node 22, outputs a single ESM bundle, no browser polyfills.
6
+ * Uploads bundle stats to Codecov when CODECOV_TOKEN is set.
7
+ */
8
+ declare function nodeApp({ entry, overrides }?: {
9
+ entry?: string;
10
+ overrides?: UserConfig;
11
+ }): Promise<UserConfig>;
12
+ //#endregion
13
+ export { nodeApp };
@@ -0,0 +1,34 @@
1
+ import { t as getPackageName } from "../get-package-name-D6LP2hiw.js";
2
+ import { mergeConfig } from "vite";
3
+ //#region presets/node-app.ts
4
+ /**
5
+ * Vite preset for Node.js CLI tools and server apps.
6
+ * Targets Node 22, outputs a single ESM bundle, no browser polyfills.
7
+ * Uploads bundle stats to Codecov when CODECOV_TOKEN is set.
8
+ */
9
+ async function nodeApp({ entry = "src/index.ts", overrides = {} } = {}) {
10
+ const plugins = [];
11
+ try {
12
+ const { codecovVitePlugin } = await import("@codecov/vite-plugin");
13
+ plugins.push(codecovVitePlugin({
14
+ enableBundleAnalysis: !!process.env.CODECOV_TOKEN,
15
+ bundleName: getPackageName(),
16
+ uploadToken: process.env.CODECOV_TOKEN
17
+ }));
18
+ } catch {}
19
+ return mergeConfig({
20
+ plugins,
21
+ build: {
22
+ target: "node22",
23
+ lib: {
24
+ entry,
25
+ formats: ["es"],
26
+ fileName: () => "index.mjs"
27
+ },
28
+ sourcemap: true,
29
+ rollupOptions: { external: [/^node:/] }
30
+ }
31
+ }, overrides);
32
+ }
33
+ //#endregion
34
+ export { nodeApp };
@@ -0,0 +1,11 @@
1
+ import { UserConfig } from "vite";
2
+ //#region presets/react-app.d.ts
3
+ /**
4
+ * Vite preset for React single-page applications.
5
+ * Wires up @vitejs/plugin-react; accepts a vite-tsconfig-paths instance
6
+ * via options.plugins if tsconfig path aliases are needed.
7
+ * Uploads bundle stats to Codecov when CODECOV_TOKEN is set.
8
+ */
9
+ declare function reactApp(overrides?: UserConfig): Promise<UserConfig>;
10
+ //#endregion
11
+ export { reactApp };
@@ -0,0 +1,27 @@
1
+ import { t as getPackageName } from "../get-package-name-D6LP2hiw.js";
2
+ import { mergeConfig } from "vite";
3
+ //#region presets/react-app.ts
4
+ /**
5
+ * Vite preset for React single-page applications.
6
+ * Wires up @vitejs/plugin-react; accepts a vite-tsconfig-paths instance
7
+ * via options.plugins if tsconfig path aliases are needed.
8
+ * Uploads bundle stats to Codecov when CODECOV_TOKEN is set.
9
+ */
10
+ async function reactApp(overrides = {}) {
11
+ const { default: react } = await import("@vitejs/plugin-react");
12
+ const plugins = [react()];
13
+ try {
14
+ const { codecovVitePlugin } = await import("@codecov/vite-plugin");
15
+ plugins.push(codecovVitePlugin({
16
+ enableBundleAnalysis: !!process.env.CODECOV_TOKEN,
17
+ bundleName: getPackageName(),
18
+ uploadToken: process.env.CODECOV_TOKEN
19
+ }));
20
+ } catch {}
21
+ return mergeConfig({
22
+ plugins,
23
+ build: { sourcemap: true }
24
+ }, overrides);
25
+ }
26
+ //#endregion
27
+ export { reactApp };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theholocron/vite-config",
3
- "version": "6.1.0",
3
+ "version": "7.0.0",
4
4
  "description": "Vite configuration presets for libraries, React apps, and Node tools within the Galaxy.",
5
5
  "homepage": "https://github.com/theholocron/configs/tree/main/packages/vite-config#readme",
6
6
  "bugs": "https://github.com/theholocron/configs/issues",
@@ -11,28 +11,36 @@
11
11
  "license": "GPL-3.0",
12
12
  "author": "Newton Koumantzelis",
13
13
  "type": "module",
14
+ "devDependencies": {
15
+ "tsdown": "^0.22.8",
16
+ "typescript": "^5.9.3",
17
+ "@theholocron/tsconfig": "7.0.0"
18
+ },
14
19
  "exports": {
15
20
  ".": {
16
- "import": "./index.js",
17
- "default": "./index.js"
21
+ "types": "./dist/index.d.ts",
22
+ "import": "./dist/index.js",
23
+ "default": "./dist/index.js"
18
24
  },
19
25
  "./library": {
20
- "import": "./presets/library.js",
21
- "default": "./presets/library.js"
26
+ "types": "./dist/presets/library.d.ts",
27
+ "import": "./dist/presets/library.js",
28
+ "default": "./dist/presets/library.js"
22
29
  },
23
30
  "./react-app": {
24
- "import": "./presets/react-app.js",
25
- "default": "./presets/react-app.js"
31
+ "types": "./dist/presets/react-app.d.ts",
32
+ "import": "./dist/presets/react-app.js",
33
+ "default": "./dist/presets/react-app.js"
26
34
  },
27
35
  "./node-app": {
28
- "import": "./presets/node-app.js",
29
- "default": "./presets/node-app.js"
36
+ "types": "./dist/presets/node-app.d.ts",
37
+ "import": "./dist/presets/node-app.js",
38
+ "default": "./dist/presets/node-app.js"
30
39
  },
31
40
  "./package.json": "./package.json"
32
41
  },
33
42
  "files": [
34
- "index.js",
35
- "presets/"
43
+ "dist/"
36
44
  ],
37
45
  "peerDependencies": {
38
46
  "vite": "^6",
@@ -55,5 +63,8 @@
55
63
  "access": "public"
56
64
  },
57
65
  "releases": "https://github.com/theholocron/configs/releases",
58
- "wiki": "https://github.com/theholocron/configs/wiki"
66
+ "wiki": "https://github.com/theholocron/configs/wiki",
67
+ "scripts": {
68
+ "build": "tsdown"
69
+ }
59
70
  }
package/index.js DELETED
@@ -1,3 +0,0 @@
1
- export { library } from "./presets/library.js";
2
- export { reactApp } from "./presets/react-app.js";
3
- export { nodeApp } from "./presets/node-app.js";
@@ -1,14 +0,0 @@
1
- import { readFileSync } from "node:fs";
2
- import { resolve } from "node:path";
3
-
4
- export function getPackageName() {
5
- try {
6
- return (
7
- JSON.parse(
8
- readFileSync(resolve(process.cwd(), "package.json"), "utf-8"),
9
- ).name ?? "unknown"
10
- );
11
- } catch {
12
- return "unknown";
13
- }
14
- }
@@ -1,60 +0,0 @@
1
- import { mergeConfig } from "vite";
2
- import { getPackageName } from "./get-package-name.js";
3
-
4
- /**
5
- * Vite preset for publishable libraries.
6
- * Outputs ESM only; externalises React and react-dom by default.
7
- * Uploads bundle stats to Codecov when CODECOV_TOKEN is set.
8
- *
9
- * @param {object} options
10
- * @param {string} [options.entry='src/index.ts'] Library entry point
11
- * @param {string} [options.name] UMD global name (required for UMD builds)
12
- * @param {string[]} [options.external=[]] Additional peer deps to externalise
13
- * @param {import('vite').UserConfig} [options.overrides={}] Merged last
14
- * @returns {Promise<import('vite').UserConfig>}
15
- */
16
- export async function library({
17
- entry = "src/index.ts",
18
- name,
19
- external = [],
20
- overrides = {},
21
- } = {}) {
22
- const plugins = [];
23
- try {
24
- const { codecovVitePlugin } = await import("@codecov/vite-plugin");
25
- plugins.push(
26
- codecovVitePlugin({
27
- enableBundleAnalysis: !!process.env.CODECOV_TOKEN,
28
- bundleName: getPackageName(),
29
- uploadToken: process.env.CODECOV_TOKEN,
30
- }),
31
- );
32
- } catch {
33
- // @codecov/vite-plugin not installed — bundle analysis skipped
34
- }
35
-
36
- return mergeConfig(
37
- {
38
- plugins,
39
- build: {
40
- lib: {
41
- entry,
42
- name,
43
- formats: ["es"],
44
- fileName: () => "index.mjs",
45
- },
46
- rollupOptions: {
47
- external: ["react", "react-dom", ...external],
48
- output: {
49
- globals: {
50
- react: "React",
51
- "react-dom": "ReactDOM",
52
- },
53
- },
54
- },
55
- sourcemap: true,
56
- },
57
- },
58
- overrides,
59
- );
60
- }
@@ -1,47 +0,0 @@
1
- import { mergeConfig } from "vite";
2
- import { getPackageName } from "./get-package-name.js";
3
-
4
- /**
5
- * Vite preset for Node.js CLI tools and server apps.
6
- * Targets Node 22, outputs a single ESM bundle, no browser polyfills.
7
- * Uploads bundle stats to Codecov when CODECOV_TOKEN is set.
8
- *
9
- * @param {object} options
10
- * @param {string} [options.entry='src/index.ts'] Application entry point
11
- * @param {import('vite').UserConfig} [options.overrides={}] Merged last
12
- * @returns {Promise<import('vite').UserConfig>}
13
- */
14
- export async function nodeApp({ entry = "src/index.ts", overrides = {} } = {}) {
15
- const plugins = [];
16
- try {
17
- const { codecovVitePlugin } = await import("@codecov/vite-plugin");
18
- plugins.push(
19
- codecovVitePlugin({
20
- enableBundleAnalysis: !!process.env.CODECOV_TOKEN,
21
- bundleName: getPackageName(),
22
- uploadToken: process.env.CODECOV_TOKEN,
23
- }),
24
- );
25
- } catch {
26
- // @codecov/vite-plugin not installed — bundle analysis skipped
27
- }
28
-
29
- return mergeConfig(
30
- {
31
- plugins,
32
- build: {
33
- target: "node22",
34
- lib: {
35
- entry,
36
- formats: ["es"],
37
- fileName: () => "index.mjs",
38
- },
39
- sourcemap: true,
40
- rollupOptions: {
41
- external: [/^node:/],
42
- },
43
- },
44
- },
45
- overrides,
46
- );
47
- }
@@ -1,39 +0,0 @@
1
- import { mergeConfig } from "vite";
2
- import { getPackageName } from "./get-package-name.js";
3
-
4
- /**
5
- * Vite preset for React single-page applications.
6
- * Wires up @vitejs/plugin-react; accepts a vite-tsconfig-paths instance
7
- * via options.plugins if tsconfig path aliases are needed.
8
- * Uploads bundle stats to Codecov when CODECOV_TOKEN is set.
9
- *
10
- * @param {import('vite').UserConfig} [overrides={}]
11
- * @returns {Promise<import('vite').UserConfig>}
12
- */
13
- export async function reactApp(overrides = {}) {
14
- const { default: react } = await import("@vitejs/plugin-react");
15
-
16
- const plugins = [react()];
17
- try {
18
- const { codecovVitePlugin } = await import("@codecov/vite-plugin");
19
- plugins.push(
20
- codecovVitePlugin({
21
- enableBundleAnalysis: !!process.env.CODECOV_TOKEN,
22
- bundleName: getPackageName(),
23
- uploadToken: process.env.CODECOV_TOKEN,
24
- }),
25
- );
26
- } catch {
27
- // @codecov/vite-plugin not installed — bundle analysis skipped
28
- }
29
-
30
- return mergeConfig(
31
- {
32
- plugins,
33
- build: {
34
- sourcemap: true,
35
- },
36
- },
37
- overrides,
38
- );
39
- }