Skip to content

Commit 2e702b5

Browse files
author
xutao15
committed
parser comment
1 parent 6e14208 commit 2e702b5

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

lib/mp-compiler/parse.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ function parseConfig (babel) {
7171
function createMPParser () {
7272
return {
7373
visitor: {
74+
// 将import Vue from 'vue' 替换为 import {Vue, createMP} from 'vue'
7475
ImportDeclaration: function (path) {
7576
if (path.node.specifiers && path.node.source && path.node.source.value === 'vue') {
7677
const specifiersValue = path.node.specifiers[0].local.name
@@ -80,6 +81,13 @@ function createMPParser () {
8081
]
8182
}
8283
},
84+
// 处理const app = new Vue
85+
// 构造为 createMp({
86+
// mpType: App.mpType,
87+
// init(){
88+
// return new Vue(App)
89+
// }
90+
// })
8391
VariableDeclaration: function (path) {
8492
if (path.node.declarations &&
8593
t.isVariableDeclarator(path.node.declarations[0]) &&
@@ -126,6 +134,7 @@ function createMPParser () {
126134
))
127135
}
128136
},
137+
// main.js中app.$mount()移除掉
129138
ExpressionStatement: function (path) {
130139
if (
131140
path.parentPath.node.type === 'Program' &&

0 commit comments

Comments
 (0)