File tree Expand file tree Collapse file tree 2 files changed +21
-9
lines changed Expand file tree Collapse file tree 2 files changed +21
-9
lines changed Original file line number Diff line number Diff line change @@ -38,3 +38,13 @@ defineInlineTest(
38
38
`app.use(router);` ,
39
39
`don't remove app.use`
40
40
)
41
+
42
+ defineInlineTest (
43
+ transform ,
44
+ {
45
+ removablePlugins : [ 'VueRouter' ] ,
46
+ } ,
47
+ `process.env.NODE_ENV === 'development' ? Vue.use(VueRouter) : null` ,
48
+ `process.env.NODE_ENV === 'development' ? Vue.use(VueRouter) : null` ,
49
+ `don't remove Vue.use in other expression`
50
+ )
Original file line number Diff line number Diff line change @@ -33,17 +33,19 @@ export const transformAST: ASTTransformation<Params> = (
33
33
} )
34
34
35
35
const removedPlugins : string [ ] = [ ]
36
- const removableUseCalls = vueUseCalls . filter ( ( { node } ) => {
37
- if ( j . Identifier . check ( node . arguments [ 0 ] ) ) {
38
- const plugin = node . arguments [ 0 ] . name
39
- if ( removablePlugins ?. includes ( plugin ) ) {
40
- removedPlugins . push ( plugin )
41
- return true
36
+ const removableUseCalls = vueUseCalls
37
+ . filter ( path => path . parent . parent . value . type === 'Program' )
38
+ . filter ( ( { node } ) => {
39
+ if ( j . Identifier . check ( node . arguments [ 0 ] ) ) {
40
+ const plugin = node . arguments [ 0 ] . name
41
+ if ( removablePlugins ?. includes ( plugin ) ) {
42
+ removedPlugins . push ( plugin )
43
+ return true
44
+ }
42
45
}
43
- }
44
46
45
- return false
46
- } )
47
+ return false
48
+ } )
47
49
48
50
removableUseCalls . remove ( )
49
51
You can’t perform that action at this time.
0 commit comments