Skip to content

Commit a55c974

Browse files
committed
added support for deep crawls over ES7 exported namespaces
1 parent b73420c commit a55c974

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

src/core/getExports.js

+2
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,8 @@ export default class ExportMap {
149149
} else if (s.type === 'ExportSpecifier' && namespaces.has(s.local.name)){
150150
let namespace = m.resolveReExport(namespaces.get(s.local.name), path)
151151
if (namespace) exportMeta.namespace = namespace.named
152+
} else if (s.type === 'ExportNamespaceSpecifier') {
153+
exportMeta.namespace = remoteMap.named
152154
}
153155

154156
// todo: JSDoc

tests/src/core/getExports.js

+19
Original file line numberDiff line numberDiff line change
@@ -195,4 +195,23 @@ describe('getExports', function () {
195195
})
196196
})
197197

198+
context('exported static namespaces', function () {
199+
const espreeContext = { parserPath: 'espree', parserOptions: { sourceType: 'module' }, settings: {} }
200+
const babelContext = { parserPath: 'babel-eslint', parserOptions: { sourceType: 'module' }, settings: {} }
201+
202+
it('works with espree & traditional namespace exports', function () {
203+
const a = ExportMap.parse(getFilename('deep/a.js'), espreeContext)
204+
expect(a.errors).to.be.empty
205+
expect(a.named.get('b').namespace).to.exist
206+
expect(a.named.get('b').namespace.has('c')).to.be.true
207+
})
208+
209+
it('works with babel-eslint & ES7 namespace exports', function () {
210+
const a = ExportMap.parse(getFilename('deep-es7/a.js'), babelContext)
211+
expect(a.errors).to.be.empty
212+
expect(a.named.get('b').namespace).to.exist
213+
expect(a.named.get('b').namespace.has('c')).to.be.true
214+
})
215+
})
216+
198217
})

0 commit comments

Comments
 (0)