Skip to content

Commit

Permalink
feat(alita): support export from 语法
Browse files Browse the repository at this point in the history
  • Loading branch information
ykforerlang committed Nov 2, 2019
1 parent 0d623e4 commit 0ff1e49
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/basetran/handleModules.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,21 @@ export default function (ast, info) {
}
}

// import 其他 配置在dependenciesMap的npm包
// import 配置在dependenciesMap的npm包
if (path.type === 'ImportDeclaration' && getWxNpmPackageName(path.node.source.value)) {
const newV = getWxNpmPackageName(path.node.source.value)
path.node.source.value = newV
return
}

// export {x} from 'xxx'
if (path.type === 'ExportNamedDeclaration' && path.node.source && getWxNpmPackageName(path.node.source.value)) {
const newV = getWxNpmPackageName(path.node.source.value)
path.node.source.value = newV
return
}


// require 其他 配置在dependenciesMap的npm包
if (path.type === 'CallExpression'
&& path.node.callee.name === 'require'
Expand Down Expand Up @@ -171,8 +179,9 @@ export default function (ast, info) {
}


// import 目录, 小程序不支持需要处理
if (path.type === 'ImportDeclaration') {
// 1. import 目录, 小程序不支持需要处理
// 2. export {x} from './xxx' 这种情况
if (path.type === 'ImportDeclaration' || (path.type === 'ExportNamedDeclaration' && path.node.source)) {
const source = path.node.source.value
const rs = getRealSource(source, filepath)
path.node.source.value = rs
Expand Down

0 comments on commit 0ff1e49

Please sign in to comment.