Skip to content

Commit 5382719

Browse files
fix: preserve modules (pmndrs#306)
1 parent 8119d7d commit 5382719

File tree

4 files changed

+3
-426
lines changed

4 files changed

+3
-426
lines changed

.github/workflows/main.yml

-2
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ jobs:
2828
run: yarn build
2929
- name: Check for SSR compat
3030
run: node dist/index.cjs && node dist/index.js
31-
- name: Check tree-shaking
32-
run: npx agadoo@latest dist/index.js
3331
- name: Check NPM config
3432
run: npx publint@latest dist
3533
release:

package.json

-2
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@
3636
},
3737
"sideEffects": false,
3838
"devDependencies": {
39-
"@babel/core": "^7.22.20",
40-
"@types/babel__core": "^7.20.2",
4139
"@types/node": "^20.6.3",
4240
"@types/three": "^0.128.0",
4341
"copyfiles": "^2.4.1",

vite.config.ts

+3-28
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import * as path from 'node:path'
2-
import * as babel from '@babel/core'
32
import { defineConfig } from 'vite'
43

54
export default defineConfig({
@@ -14,33 +13,9 @@ export default defineConfig({
1413
},
1514
rollupOptions: {
1615
external: (id: string) => !id.startsWith('.') && !path.isAbsolute(id),
17-
},
18-
},
19-
plugins: [
20-
{
21-
name: 'vite-tree-shake',
22-
renderChunk: {
23-
order: 'post',
24-
async handler(code) {
25-
function annotate(path: babel.NodePath): void {
26-
if (!path.getFunctionParent()) {
27-
path.addComment('leading', '@__PURE__')
28-
}
29-
}
30-
31-
return babel.transform(code, {
32-
sourceMaps: true,
33-
plugins: [
34-
{
35-
visitor: {
36-
CallExpression: annotate,
37-
NewExpression: annotate,
38-
},
39-
},
40-
],
41-
}) as any
42-
},
16+
output: {
17+
preserveModules: true,
4318
},
4419
},
45-
],
20+
},
4621
})

0 commit comments

Comments
 (0)