omip - fix build error

This commit is contained in:
dntzhang 2019-02-26 11:59:39 +08:00
parent b803b5f074
commit ff8f1c9ff6
4 changed files with 18 additions and 8 deletions

View File

@ -1,6 +1,6 @@
button {
width: 200px;
height: 80px;
line-height: 80px;
width: 100px;
height: 40px;
line-height: 40px;
display: inline-block;
}

View File

@ -1,6 +1,6 @@
import { WeElement, define } from 'omi'
//import '../my-element'
import '../my-element'
//兼容 omi 下划线?
import './index.css'
@ -30,7 +30,7 @@ define('my-counter', class extends WeElement {
<button onClick={this.sub}>-</button>
<text>{this.data.count}</text>
<button onClick={this.add}>+</button>
{/* <my-element msg='omi'></my-element> */}
<my-element msg='omi'></my-element>
</view>
)
}

View File

@ -22,10 +22,10 @@ export function define(name, ctor) {
}
config.$usedState && config.$usedState.forEach(prop => {
if(config.data && !config.data.hasOwnProperty(prop)){
if(!config.data || (config.data && !config.data.hasOwnProperty(prop))){
config.properties[prop] = null
}
})
Component(config)
}

View File

@ -768,7 +768,7 @@ function parseAst (type, ast, depComponents, sourceFilePath, filePath, npmSkip =
//node.body.push(template(`Taro.initPxTransform(${JSON.stringify(pxTransformConfig)})`, babylonConfig)())
//@fix Please do not call Page constructor in files that not listed in "pages" section of app.json or plugin.json
node.body.forEach((item, index) => {
if (item.type === 'ImportDeclaration' && item.source.value.indexOf('./pages/') === 0) {
if (item.type === 'ImportDeclaration' && item.source.value.indexOf('./pages/') === 0 && node.body[index].specifiers.length === 0) {
node.body[index] = null
}
})
@ -790,6 +790,16 @@ function parseAst (type, ast, depComponents, sourceFilePath, filePath, npmSkip =
}
break
case PARSE_AST_TYPE.COMPONENT:
node.body.forEach((item, index) => {
if (item.type === 'ImportDeclaration') {
const v = node.body[index].source.value
if (v.indexOf('libs/taro/') === -1 && v.indexOf('libs/omip/') === -1 && node.body[index].specifiers.length === 0) {
node.body[index] = null
}
}
})
//@fix 注释掉用来解决小程序报错
//node.body.push(template(`Component(require('${taroMiniAppFrameworkPath}').default.createComponent(${exportVariableName}))`, babylonConfig)())
break