@theholocron/vite-config 7.9.1 → 7.11.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 +2 -1
- package/dist/index.js +2 -1
- package/dist/presets/react-library.d.ts +16 -0
- package/dist/presets/react-library.js +48 -0
- package/package.json +8 -3
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,48 @@
|
|
|
1
|
+
import { t as getPackageName } from "../get-package-name-D6LP2hiw.js";
|
|
2
|
+
import { mergeConfig } from "vite";
|
|
3
|
+
import { resolve } from "node:path";
|
|
4
|
+
//#region presets/react-library.ts
|
|
5
|
+
/**
|
|
6
|
+
* Vite preset for publishable React component libraries.
|
|
7
|
+
* Outputs ESM + CJS; externalises React and react-dom; wires up
|
|
8
|
+
* @vitejs/plugin-react and optional Codecov bundle analysis.
|
|
9
|
+
*/
|
|
10
|
+
async function reactLibrary({ entry = "src/index.ts", name, formats = ["es", "cjs"], external = [], overrides = {} } = {}) {
|
|
11
|
+
const resolvedName = name ?? getPackageName();
|
|
12
|
+
const { default: react } = await import("@vitejs/plugin-react");
|
|
13
|
+
const plugins = [react()];
|
|
14
|
+
try {
|
|
15
|
+
const { codecovVitePlugin } = await import("@codecov/vite-plugin");
|
|
16
|
+
plugins.push(codecovVitePlugin({
|
|
17
|
+
enableBundleAnalysis: !!process.env.CODECOV_TOKEN,
|
|
18
|
+
bundleName: resolvedName,
|
|
19
|
+
uploadToken: process.env.CODECOV_TOKEN
|
|
20
|
+
}));
|
|
21
|
+
} catch {}
|
|
22
|
+
return mergeConfig({
|
|
23
|
+
plugins,
|
|
24
|
+
build: {
|
|
25
|
+
lib: {
|
|
26
|
+
entry,
|
|
27
|
+
name: resolvedName,
|
|
28
|
+
formats,
|
|
29
|
+
fileName: (format) => `${resolvedName}.${format}.js`
|
|
30
|
+
},
|
|
31
|
+
rollupOptions: {
|
|
32
|
+
external: [
|
|
33
|
+
"react",
|
|
34
|
+
"react-dom",
|
|
35
|
+
...external
|
|
36
|
+
],
|
|
37
|
+
output: { globals: {
|
|
38
|
+
react: "React",
|
|
39
|
+
"react-dom": "ReactDOM"
|
|
40
|
+
} }
|
|
41
|
+
},
|
|
42
|
+
sourcemap: true
|
|
43
|
+
},
|
|
44
|
+
resolve: { alias: { "@": resolve(process.cwd(), "src") } }
|
|
45
|
+
}, overrides);
|
|
46
|
+
}
|
|
47
|
+
//#endregion
|
|
48
|
+
export { reactLibrary };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theholocron/vite-config",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.11.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.
|
|
30
|
-
"@theholocron/vitest-config": "7.
|
|
29
|
+
"@theholocron/tsconfig": "7.11.0",
|
|
30
|
+
"@theholocron/vitest-config": "7.11.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",
|