File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -17,3 +17,19 @@ export default {
17
17
};;` ,
18
18
'transform global component registration'
19
19
)
20
+
21
+ defineInlineTest (
22
+ transform ,
23
+ { } ,
24
+ `import Vue from 'vue'
25
+ import App from './App.vue'
26
+ import MyComponent from './MyComponent'
27
+ Vue.component('my-component', MyComponent)
28
+ new Vue(App).$mount('app')` ,
29
+ `import Vue from 'vue'
30
+ import App from './App.vue'
31
+ import MyComponent from './MyComponent'
32
+ Vue.component('my-component', MyComponent)
33
+ new Vue(App).$mount('app')` ,
34
+ `don't transform global component api when there are other expression statements`
35
+ )
Original file line number Diff line number Diff line change @@ -6,6 +6,12 @@ import * as _ from 'lodash'
6
6
7
7
export const transformAST : ASTTransformation = context => {
8
8
const { root, j, filename } = context
9
+ const rootExpressionStatement = root
10
+ . find ( j . ExpressionStatement )
11
+ . filter ( path => path . parent . value . type === 'Program' )
12
+ if ( rootExpressionStatement . length > 1 ) {
13
+ return
14
+ }
9
15
// find Vue.component
10
16
const componentRegistration = root
11
17
. find ( j . CallExpression , {
You can’t perform that action at this time.
0 commit comments