File tree Expand file tree Collapse file tree 4 files changed +426
-3
lines changed Expand file tree Collapse file tree 4 files changed +426
-3
lines changed Original file line number Diff line number Diff line change 28
28
run : yarn build
29
29
- name : Check for SSR compat
30
30
run : node dist/index.cjs && node dist/index.js
31
+ - name : Check tree-shaking
32
+ run : npx agadoo@latest dist/index.js
31
33
- name : Check NPM config
32
34
run : npx publint@latest dist
33
35
release :
Original file line number Diff line number Diff line change 36
36
},
37
37
"sideEffects" : false ,
38
38
"devDependencies" : {
39
+ "@babel/core" : " ^7.22.20" ,
40
+ "@types/babel__core" : " ^7.20.2" ,
39
41
"@types/node" : " ^20.6.3" ,
40
42
"@types/three" : " ^0.128.0" ,
41
43
"copyfiles" : " ^2.4.1" ,
Original file line number Diff line number Diff line change 1
1
import * as path from 'node:path'
2
+ import * as babel from '@babel/core'
2
3
import { defineConfig } from 'vite'
3
4
4
5
export default defineConfig ( {
@@ -13,9 +14,33 @@ export default defineConfig({
13
14
} ,
14
15
rollupOptions : {
15
16
external : ( id : string ) => ! id . startsWith ( '.' ) && ! path . isAbsolute ( id ) ,
16
- output : {
17
- preserveModules : true ,
18
- } ,
19
17
} ,
20
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
+ } ,
43
+ } ,
44
+ } ,
45
+ ] ,
21
46
} )
You can’t perform that action at this time.
0 commit comments