From 0945248e2faf2a2d0f7fcf5f0e52473c85c5d073 Mon Sep 17 00:00:00 2001 From: yuche Date: Tue, 9 Jul 2019 21:35:41 +0800 Subject: [PATCH] =?UTF-8?q?fix(transformer):=20opt.isNormal=20=E4=B8=8D?= =?UTF-8?q?=E9=9C=80=E8=A6=81=E8=B5=B0=E8=87=AA=E5=AE=9A=E4=B9=89=20babel?= =?UTF-8?q?=20=E6=8F=92=E4=BB=B6=20close=20#3731?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/taro-transformer-wx/src/options.ts | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/packages/taro-transformer-wx/src/options.ts b/packages/taro-transformer-wx/src/options.ts index bc1a7b705ba4..a5fdee9f9c79 100644 --- a/packages/taro-transformer-wx/src/options.ts +++ b/packages/taro-transformer-wx/src/options.ts @@ -32,6 +32,17 @@ export const setTransformOptions = (options: Options) => { export const buildBabelTransformOptions: () => TransformOptions = () => { Status.isSFC = false + let plugins = [ + require('babel-plugin-transform-do-expressions'), + require('babel-plugin-transform-export-extensions'), + require('babel-plugin-transform-flow-strip-types'), + buildVistor(), + functionalComponent, + [require('babel-plugin-transform-define').default, transformOptions.env] + ] + if (!transformOptions.isNormal) { + plugins.push(buildVistor(), functionalComponent) + } return { parserOpts: { sourceType: 'module', @@ -51,14 +62,7 @@ export const buildBabelTransformOptions: () => TransformOptions = () => { 'exportExtensions' ] as any[] }, - plugins: [ - require('babel-plugin-transform-do-expressions'), - require('babel-plugin-transform-export-extensions'), - require('babel-plugin-transform-flow-strip-types'), - buildVistor(), - functionalComponent, - [require('babel-plugin-transform-define').default, transformOptions.env] - ].concat(process.env.ESLINT === 'false' || transformOptions.isNormal || transformOptions.isTyped ? [] : eslintValidation) + plugins: plugins.concat(process.env.ESLINT === 'false' || transformOptions.isNormal || transformOptions.isTyped ? [] : eslintValidation) .concat((isTestEnv) ? [] : require('babel-plugin-remove-dead-code').default) } }