Skip to content

Commit fed1f63

Browse files
Add support for building as an ES lib
1 parent c57c4b1 commit fed1f63

File tree

4 files changed

+27
-0
lines changed

4 files changed

+27
-0
lines changed

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
},
1616
"devDependencies": {
1717
"@eslint/js": "^9.9.0",
18+
"@types/node": "22.3.0",
1819
"@types/react": "^18.3.3",
1920
"@types/react-dom": "^18.3.0",
2021
"@vitejs/plugin-react": "^4.3.1",

tsconfig.node.json

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
{
22
"compilerOptions": {
3+
"types": ["node"],
4+
35
"target": "ES2022",
46
"lib": ["ES2023"],
57
"module": "ESNext",

vite.config.ts

+12
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,19 @@
1+
import { resolve } from 'path'
12
import { defineConfig } from 'vite'
23
import react from '@vitejs/plugin-react'
34

45
// https://vitejs.dev/config/
56
export default defineConfig({
67
plugins: [react()],
8+
build: {
9+
lib: {
10+
// Could also be a dictionary or array of multiple entry points
11+
entry: resolve(__dirname, 'src/App.tsx'),
12+
formats: ['es', ],
13+
},
14+
rollupOptions: {
15+
external: ['react', 'react/jsx-runtime', 'react-dom'],
16+
},
17+
},
18+
719
})

yarn.lock

+12
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,13 @@
523523
resolved "https://registry.yarnpkg.com/@types/estree/-/estree-1.0.5.tgz#a6ce3e556e00fd9895dd872dd172ad0d4bd687f4"
524524
integrity sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==
525525

526+
527+
version "22.3.0"
528+
resolved "https://registry.yarnpkg.com/@types/node/-/node-22.3.0.tgz#7f8da0e2b72c27c4f9bd3cb5ef805209d04d4f9e"
529+
integrity sha512-nrWpWVaDZuaVc5X84xJ0vNrLvomM205oQyLsRt7OHNZbSHslcWsvgFR7O7hire2ZonjLrWBbedmotmIlJDVd6g==
530+
dependencies:
531+
undici-types "~6.18.2"
532+
526533
"@types/prop-types@*":
527534
version "15.7.12"
528535
resolved "https://registry.yarnpkg.com/@types/prop-types/-/prop-types-15.7.12.tgz#12bb1e2be27293c1406acb6af1c3f3a1481d98c6"
@@ -1521,6 +1528,11 @@ typescript@^5.5.3:
15211528
resolved "https://registry.yarnpkg.com/typescript/-/typescript-5.5.4.tgz#d9852d6c82bad2d2eda4fd74a5762a8f5909e9ba"
15221529
integrity sha512-Mtq29sKDAEYP7aljRgtPOpTvOfbwRWlS6dPRzwjdE+C0R4brX/GUyhHSecbHMFLNBLcJIPt9nl9yG5TZ1weH+Q==
15231530

1531+
undici-types@~6.18.2:
1532+
version "6.18.2"
1533+
resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-6.18.2.tgz#8b678cf939d4fc9ec56be3c68ed69c619dee28b0"
1534+
integrity sha512-5ruQbENj95yDYJNS3TvcaxPMshV7aizdv/hWYjGIKoANWKjhWNBsr2YEuYZKodQulB1b8l7ILOuDQep3afowQQ==
1535+
15241536
update-browserslist-db@^1.1.0:
15251537
version "1.1.0"
15261538
resolved "https://registry.yarnpkg.com/update-browserslist-db/-/update-browserslist-db-1.1.0.tgz#7ca61c0d8650766090728046e416a8cde682859e"

0 commit comments

Comments
 (0)