@theholocron/vite-config 7.9.1 → 7.10.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/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { library } from "./presets/library.js";
2
2
  import { reactApp } from "./presets/react-app.js";
3
+ import { reactLibrary } from "./presets/react-library.js";
3
4
  import { nodeApp } from "./presets/node-app.js";
4
- export { library, nodeApp, reactApp };
5
+ export { library, nodeApp, reactApp, reactLibrary };
package/dist/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { library } from "./presets/library.js";
2
2
  import { reactApp } from "./presets/react-app.js";
3
+ import { reactLibrary } from "./presets/react-library.js";
3
4
  import { nodeApp } from "./presets/node-app.js";
4
- export { library, nodeApp, reactApp };
5
+ export { library, nodeApp, reactApp, reactLibrary };
@@ -0,0 +1,16 @@
1
+ import { UserConfig } from "vite";
2
+ //#region presets/react-library.d.ts
3
+ /**
4
+ * Vite preset for publishable React component libraries.
5
+ * Outputs ESM + CJS; externalises React and react-dom; wires up
6
+ * @vitejs/plugin-react and optional Codecov bundle analysis.
7
+ */
8
+ declare function reactLibrary({ entry, name, formats, external, overrides }?: {
9
+ entry?: string;
10
+ name?: string;
11
+ formats?: ("es" | "cjs" | "umd" | "iife")[];
12
+ external?: string[];
13
+ overrides?: UserConfig;
14
+ }): Promise<UserConfig>;
15
+ //#endregion
16
+ export { reactLibrary };
@@ -0,0 +1,46 @@
1
+ import { t as getPackageName } from "../get-package-name-D6LP2hiw.js";
2
+ import { mergeConfig } from "vite";
3
+ //#region presets/react-library.ts
4
+ /**
5
+ * Vite preset for publishable React component libraries.
6
+ * Outputs ESM + CJS; externalises React and react-dom; wires up
7
+ * @vitejs/plugin-react and optional Codecov bundle analysis.
8
+ */
9
+ async function reactLibrary({ entry = "src/index.ts", name, formats = ["es", "cjs"], external = [], overrides = {} } = {}) {
10
+ const resolvedName = name ?? getPackageName();
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: resolvedName,
18
+ uploadToken: process.env.CODECOV_TOKEN
19
+ }));
20
+ } catch {}
21
+ return mergeConfig({
22
+ plugins,
23
+ build: {
24
+ lib: {
25
+ entry,
26
+ name: resolvedName,
27
+ formats,
28
+ fileName: (format) => `${resolvedName}.${format}.js`
29
+ },
30
+ rollupOptions: {
31
+ external: [
32
+ "react",
33
+ "react-dom",
34
+ ...external
35
+ ],
36
+ output: { globals: {
37
+ react: "React",
38
+ "react-dom": "ReactDOM"
39
+ } }
40
+ },
41
+ sourcemap: true
42
+ }
43
+ }, overrides);
44
+ }
45
+ //#endregion
46
+ export { reactLibrary };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theholocron/vite-config",
3
- "version": "7.9.1",
3
+ "version": "7.10.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",
@@ -26,8 +26,8 @@
26
26
  "@vitest/coverage-v8": "^4.1.10",
27
27
  "vite": "^8.2.0",
28
28
  "@codecov/vite-plugin": "^2.0.0",
29
- "@theholocron/tsconfig": "7.9.1",
30
- "@theholocron/vitest-config": "7.9.1"
29
+ "@theholocron/tsconfig": "7.10.0",
30
+ "@theholocron/vitest-config": "7.10.0"
31
31
  },
32
32
  "exports": {
33
33
  ".": {
@@ -45,6 +45,11 @@
45
45
  "import": "./dist/presets/react-app.js",
46
46
  "default": "./dist/presets/react-app.js"
47
47
  },
48
+ "./react-library": {
49
+ "types": "./dist/presets/react-library.d.ts",
50
+ "import": "./dist/presets/react-library.js",
51
+ "default": "./dist/presets/react-library.js"
52
+ },
48
53
  "./node-app": {
49
54
  "types": "./dist/presets/node-app.d.ts",
50
55
  "import": "./dist/presets/node-app.js",