Skip to content

Commit 0ff1e49

Browse files
committed
feat(alita): support export from 语法
1 parent 0d623e4 commit 0ff1e49

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/basetran/handleModules.js

+12-3
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,21 @@ export default function (ast, info) {
103103
}
104104
}
105105

106-
// import 其他 配置在dependenciesMap的npm包
106+
// import 配置在dependenciesMap的npm包
107107
if (path.type === 'ImportDeclaration' && getWxNpmPackageName(path.node.source.value)) {
108108
const newV = getWxNpmPackageName(path.node.source.value)
109109
path.node.source.value = newV
110110
return
111111
}
112112

113+
// export {x} from 'xxx'
114+
if (path.type === 'ExportNamedDeclaration' && path.node.source && getWxNpmPackageName(path.node.source.value)) {
115+
const newV = getWxNpmPackageName(path.node.source.value)
116+
path.node.source.value = newV
117+
return
118+
}
119+
120+
113121
// require 其他 配置在dependenciesMap的npm包
114122
if (path.type === 'CallExpression'
115123
&& path.node.callee.name === 'require'
@@ -171,8 +179,9 @@ export default function (ast, info) {
171179
}
172180

173181

174-
// import 目录, 小程序不支持需要处理
175-
if (path.type === 'ImportDeclaration') {
182+
// 1. import 目录, 小程序不支持需要处理
183+
// 2. export {x} from './xxx' 这种情况
184+
if (path.type === 'ImportDeclaration' || (path.type === 'ExportNamedDeclaration' && path.node.source)) {
176185
const source = path.node.source.value
177186
const rs = getRealSource(source, filepath)
178187
path.node.source.value = rs

0 commit comments

Comments
 (0)