Skip to content

Commit

Permalink
build hooks package with vite and stop bundling react
Browse files Browse the repository at this point in the history
  • Loading branch information
kid-icarus committed Dec 3, 2023
1 parent d73e715 commit d2ec026
Show file tree
Hide file tree
Showing 5 changed files with 350 additions and 18 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ build
.idea
vite.config.ts.timestamp-*
coverage
docs
docs
stats.html
yarn-error.log
13 changes: 10 additions & 3 deletions packages/automerge-repo-react-hooks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@
"type": "module",
"main": "dist/index.js",
"scripts": {
"build": "tsc",
"build": "tsc --noEmit && vite build",
"test": "vitest run",
"watch": "npm-watch"
"watch": "npm-watch",
"visualize": "VISUALIZE=true vite build"
},
"dependencies": {
"@automerge/automerge": "^2.1.8-alpha.1",
Expand All @@ -22,7 +23,13 @@
},
"devDependencies": {
"@testing-library/react": "^14.0.0",
"jsdom": "^22.1.0"
"jsdom": "^22.1.0",
"rollup-plugin-visualizer": "^5.9.3",
"vite-plugin-dts": "^3.6.4"
},
"peerDependencies": {
"react": ">16.8.0",
"react-dom": ">16.8.0"
},
"watch": {
"build": {
Expand Down
32 changes: 30 additions & 2 deletions packages/automerge-repo-react-hooks/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,39 @@
import { defineConfig } from "vitest/config"
import react from "@vitejs/plugin-react"
import { resolve } from "path"
import dts from "vite-plugin-dts"
import wasm from "vite-plugin-wasm"
import topLevelAwait from "vite-plugin-top-level-await"
import { visualizer } from "rollup-plugin-visualizer"

export default defineConfig({
plugins: [react(), wasm(), topLevelAwait()],
plugins: [
react(),
wasm(),
topLevelAwait(),
dts({
insertTypesEntry: true,
}),
process.env.VISUALIZE && visualizer(),
],
build: {
lib: {
entry: resolve(__dirname, 'src/index.ts'),
formats: ['es'],
fileName: 'index',
},
rollupOptions: {
external: ['react', 'react/jsx-runtime', 'react-dom', 'tailwindcss'],
output: {
globals: {
react: 'React',
'react/jsx-runtime': 'react/jsx-runtime',
'react-dom': 'ReactDOM',
}
}
},
},
worker: {
plugins: [wasm(), topLevelAwait()],
},
}
})
3 changes: 2 additions & 1 deletion packages/automerge-repo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
"crypto": false
},
"devDependencies": {
"http-server": "^14.1.0"
"http-server": "^14.1.0",
"vite": "^4.4.11"
},
"dependencies": {
"@automerge/automerge": "^2.1.8-alpha.1",
Expand Down
Loading

0 comments on commit d2ec026

Please sign in to comment.