Skip to content

Commit bb36a41

Browse files
fix: move mount function to the next line of createApp (#80)
1 parent f15a51f commit bb36a41

File tree

2 files changed

+3
-27
lines changed

2 files changed

+3
-27
lines changed

transformations/__tests__/const-app.spec.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,11 @@ defineInlineTest(
99
`Vue.createApp(App).use(button_counter).use(router).use(store).mount("#app");
1010
Vue.directive('demo', {})
1111
Vue.component('myComponent',{})
12-
1312
`,
1413
`const app = Vue.createApp(App).use(button_counter).use(router).use(store);
14+
app.mount("#app");
1515
app.directive('demo', {})
16-
app.component('myComponent',{})
17-
18-
app.mount("#app");`,
19-
16+
app.component('myComponent',{})`,
2017
'add const app and transform Vue to app in main.js'
2118
)
2219

@@ -26,12 +23,10 @@ defineInlineTest(
2623
`const app = Vue.createApp(App).use(button_counter).use(router).use(store);
2724
Vue.directive('demo', {})
2825
Vue.component('myComponent',{})
29-
3026
app.mount("#app");`,
3127
`const app = Vue.createApp(App).use(button_counter).use(router).use(store);
3228
app.directive('demo', {})
3329
app.component('myComponent',{})
34-
3530
app.mount("#app");`,
3631

3732
'do not add const app when app.mount() is already exist '

transformations/const-app.ts

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -71,26 +71,7 @@ export const transformAST: ASTTransformation = ({ root, j }) => {
7171
])
7272
)
7373

74-
let end = 0
75-
let lastNode = createAppParent.get()
76-
root.find(j.VariableDeclaration).forEach(node => {
77-
// @ts-ignore
78-
if (node.value.end > end) {
79-
// @ts-ignore
80-
end = node.value.end
81-
lastNode = node
82-
}
83-
})
84-
root.find(j.ExpressionStatement).forEach(node => {
85-
// @ts-ignore
86-
if (node.value.end > end) {
87-
// @ts-ignore
88-
end = node.value.end
89-
lastNode = node
90-
}
91-
})
92-
93-
j(lastNode).insertAfter(
74+
createAppParent.insertAfter(
9475
j.expressionStatement(
9576
j.callExpression(
9677
j.memberExpression(j.identifier('app'), j.identifier('mount')),

0 commit comments

Comments
 (0)