Skip to content

Commit

Permalink
fix(cli): 修复 H5 及 RN 环境变量替换
Browse files Browse the repository at this point in the history
  • Loading branch information
luckyadam committed Nov 14, 2018
1 parent 523dcc0 commit 0f26bb8
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 10 deletions.
8 changes: 2 additions & 6 deletions packages/taro-cli/src/h5.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,7 @@ function processEntry (code, filePath) {
sourcePath: filePath,
isNormal: true,
isTyped: Util.REG_TYPESCRIPT.test(filePath),
env: {
TARO_ENV: Util.BUILD_TYPES.H5
}
adapter: 'h5'
}).ast
let taroImportDefaultName
let providorImportName
Expand Down Expand Up @@ -475,9 +473,7 @@ function processOthers (code, filePath) {
sourcePath: filePath,
isNormal: true,
isTyped: Util.REG_TYPESCRIPT.test(filePath),
env: {
TARO_ENV: Util.BUILD_TYPES.H5
}
adapter: 'h5'
}).ast
let taroImportDefaultName
let hasAddNervJsImportDefaultName = false
Expand Down
4 changes: 1 addition & 3 deletions packages/taro-cli/src/rn/transformJS.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,7 @@ function getJSAst (code, filePath) {
sourcePath: filePath,
isNormal: true,
isTyped: Util.REG_TYPESCRIPT.test(filePath),
env: {
TARO_ENV: Util.BUILD_TYPES.RN
}
adapter: 'rn'
}).ast
}

Expand Down
2 changes: 1 addition & 1 deletion packages/taro-transformer-wx/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ export default function transform (options: Options): TransformResult {
noEmitHelpers: true
})
: options.code
options.env = Object.assign({ TARO_ENV: options.adapter || 'weapp' }, options.env || {})
options.env = Object.assign({ 'process.env.TARO_ENV': options.adapter || 'weapp' }, options.env || {})
setting.sourceCode = code
// babel-traverse 无法生成 Hub
// 导致 Path#getSource|buildCodeFrameError 都无法直接使用
Expand Down

0 comments on commit 0f26bb8

Please sign in to comment.