diff --git a/src/analyze.ts b/src/analyze.ts index 0a6217f..e27417b 100644 --- a/src/analyze.ts +++ b/src/analyze.ts @@ -102,7 +102,7 @@ export function findExports (code: string): ESMExport[] { // Find named exports const namedExports: NamedExport[] = matchAll(EXPORT_NAMED_RE, code, { type: 'named' }) for (const namedExport of namedExports) { - namedExport.names = namedExport.exports.split(/\s*,\s*/g).map(name => name.replace(/^.*?\sas\s/, '').trim()) + namedExport.names = namedExport.exports.replace(/^\r?\n?/, '').split(/\s*,\s*/g).map(name => name.replace(/^.*?\sas\s/, '').trim()) } // Find export default diff --git a/test/exports.test.ts b/test/exports.test.ts index 6fb3dd1..a073320 100644 --- a/test/exports.test.ts +++ b/test/exports.test.ts @@ -119,6 +119,17 @@ describe('findExports', () => { const matches = findExports(code) expect(matches).to.have.lengthOf(2) }) + + it('works with line feed named exports', () => { + const code = ` + export { + _foo as foo, + bar, + }; + ` + const matches = findExports(code) + expect(matches[0].names).toEqual(['foo', 'bar']) + }) }) describe('fineExportNames', () => {