Skip to content

Commit

Permalink
refactor(transformer): isNormal 变为可选参数
Browse files Browse the repository at this point in the history
  • Loading branch information
yuche authored and luckyadam committed Jan 7, 2020
1 parent 8c80418 commit 1113508
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
15 changes: 15 additions & 0 deletions packages/taro-transformer-wx/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,21 @@ export default function transform (options: TransformOptions): TransformResult {
// 原因大概是 babylon.parse 没有生成 File 实例导致 scope 和 path 原型上都没有 `file`
// 将来升级到 babel@7 可以直接用 parse 而不是 transform
const ast = parse(code, buildBabelTransformOptions()).ast as t.File
// traverse(ast, {
// JSXElement (p) {
// setIsNormal(false)
// p.stop()
// },
// ImportDeclaration (path) {
// const { source, specifiers } = path.node
// if (source.value === TARO_PACKAGE_NAME) {
// if (specifiers.some(s => s.local.name === 'Component')) {
// setIsNormal(false)
// path.stop()
// }
// }
// }
// })
if (options.isNormal) {
if (options.isTyped) {
const mainClassNode = ast.program.body.find(v => {
Expand Down
2 changes: 1 addition & 1 deletion packages/taro-transformer-wx/src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export interface Options {
code: string,
isTyped: boolean,
isNormal?: boolean,
env?: object,
env?: Object,
adapter?: Adapters,
jsxAttributeNameReplace?: Object,
rootProps?: object
Expand Down

0 comments on commit 1113508

Please sign in to comment.