Skip to content

Commit 693f5e0

Browse files
authored
Merge pull request #216 from CodyJasonBennett/fix/bundle-transpile-n8ao
fix: bundle & transpile n8ao for compat
2 parents 1ff8066 + cd69680 commit 693f5e0

File tree

4 files changed

+310
-408
lines changed

4 files changed

+310
-408
lines changed

package.json

+4-10
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,13 @@
3434
]
3535
},
3636
"scripts": {
37-
"prebuild": "rimraf dist && yarn typegen",
38-
"build": "rollup -c",
37+
"prebuild": "rimraf dist",
38+
"build": "vite build && tsc --emitDeclarationOnly",
3939
"prepare": "yarn build",
4040
"eslint": "eslint . --fix --ext=js,ts,jsx,tsx",
4141
"eslint:ci": "eslint . --ext=js,ts,jsx,tsx",
4242
"test": "echo no tests yet",
43-
"typecheck": "tsc --noEmit --emitDeclarationOnly false --strict --jsx react",
44-
"typegen": "tsc --emitDeclarationOnly || true",
43+
"typecheck": "tsc --noEmit false --strict --jsx react",
4544
"release": "semantic-release",
4645
"storybook": "storybook dev -p 6006",
4746
"build-storybook": "storybook build"
@@ -51,14 +50,11 @@
5150
"n8ao": "^1.4.2",
5251
"postprocessing": "^6.31.0",
5352
"screen-space-reflections": "2.5.0",
54-
"three-stdlib": "^2.21.10"
53+
"three-stdlib": "^2.23.4"
5554
},
5655
"devDependencies": {
5756
"@react-three/drei": "^9.68.2",
5857
"@react-three/fiber": "^8.13.0",
59-
"@rollup/plugin-commonjs": "^24.1.0",
60-
"@rollup/plugin-node-resolve": "^15.0.2",
61-
"@rollup/plugin-typescript": "^11.1.0",
6258
"@storybook/addon-essentials": "^7.0.10",
6359
"@storybook/addon-interactions": "^7.0.10",
6460
"@storybook/addon-links": "^7.0.10",
@@ -85,8 +81,6 @@
8581
"react": "^18.2.0",
8682
"react-dom": "^18.2.0",
8783
"rimraf": "^5.0.0",
88-
"rollup": "^3.21.0",
89-
"rollup-plugin-filesize": "^10.0.0",
9084
"semantic-release": "^21.0.2",
9185
"storybook": "^7.0.10",
9286
"three": "^0.151.3",

rollup.config.js

-23
This file was deleted.

vite.config.ts

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import * as path from 'node:path'
2+
import { defineConfig } from 'vite'
3+
4+
const inline: string[] = ['n8ao']
5+
6+
export default defineConfig({
7+
build: {
8+
minify: false,
9+
target: 'es2018',
10+
sourcemap: true,
11+
lib: {
12+
formats: ['es', 'cjs'],
13+
entry: 'src/index.tsx',
14+
fileName: '[name]',
15+
},
16+
rollupOptions: {
17+
external: (id: string) => !id.startsWith('.') && !path.isAbsolute(id) && !inline.includes(id),
18+
},
19+
},
20+
plugins: [
21+
{
22+
name: 'n8ao-fix',
23+
generateBundle(_, bundle) {
24+
for (const id in bundle) {
25+
const asset = bundle[id]
26+
if ('code' in asset) {
27+
asset.code = asset.code.replace(/three\/(addons|examples)[^'"`]+/g, 'three-stdlib')
28+
}
29+
}
30+
},
31+
},
32+
],
33+
})

0 commit comments

Comments
 (0)