Skip to content

Commit

Permalink
fix(transformer): 当继承基类组件没有 render 函数时不报错, close #1370
Browse files Browse the repository at this point in the history
  • Loading branch information
yuche committed Jan 7, 2019
1 parent fddff16 commit 4b43f24
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
2 changes: 0 additions & 2 deletions packages/taro-transformer-wx/src/class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -654,8 +654,6 @@ class Transformer {
this.componentProperies,
this.loopRefs
).outputTemplate
} else {
throw codeFrameError(this.classPath.node.loc, '没有定义 render 方法')
}
}

Expand Down
4 changes: 2 additions & 2 deletions packages/taro-transformer-wx/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { prettyPrint } from 'html'
import { transform as parse } from 'babel-core'
import * as ts from 'typescript'
import { Transformer } from './class'
import { setting, findFirstIdentifierFromMemberExpression, isContainJSXElement, codeFrameError, isArrayMapCallExpression } from './utils'
import { setting, findFirstIdentifierFromMemberExpression, isContainJSXElement, codeFrameError, isArrayMapCallExpression, pathResolver } from './utils'
import * as t from 'babel-types'
import { DEFAULT_Component_SET, INTERNAL_SAFE_GET, TARO_PACKAGE_NAME, REDUX_PACKAGE_NAME, MOBX_PACKAGE_NAME, IMAGE_COMPONENTS, INTERNAL_INLINE_STYLE, THIRD_PARTY_COMPONENTS, INTERNAL_GET_ORIGNAL, setLoopOriginal, GEL_ELEMENT_BY_ID } from './constant'
import { Adapters, setAdapter, Adapter } from './adapter'
Expand Down Expand Up @@ -241,7 +241,7 @@ export default function transform (options: Options): TransformResult {
if (bindingPath.isImportDeclaration()) {
const source = bindingPath.node.source
try {
const p = fs.existsSync(source.value + '.js') ? source.value + '.js' : source.value + '.tsx'
const p = pathResolver(source.value, options.sourcePath) + (options.isTyped ? '.js' : '.js')
const code = fs.readFileSync(p, 'utf8')
componentProperies = transform({
isRoot: false,
Expand Down

0 comments on commit 4b43f24

Please sign in to comment.