Skip to content

Commit 4b3737e

Browse files
vwxyutarooogregberge
authored andcommitted
fix(rollup): fix to work with rollup-plugin-typescript2 (#147)
Do not provide AST if parsed using Babel.
1 parent c7ab92b commit 4b3737e

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

packages/rollup/src/index.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ function svgrPlugin(options = {}) {
88
const { babel = true } = options
99

1010
return {
11+
name: 'svgr',
1112
async transform(data, id) {
1213
if (!filter(id)) return null
1314
if (id.slice(-4) !== '.svg') return null
@@ -54,9 +55,13 @@ function svgrPlugin(options = {}) {
5455
)
5556
})
5657

57-
const code = babel ? await pBabelTransform(jsCode) : jsCode
58+
if (babel) {
59+
const code = await pBabelTransform(jsCode);
5860

59-
return { ast, code, map: { mappings: '' } }
61+
return { code, map: { mappings: '' } }
62+
}
63+
64+
return { ast, code: jsCode, map: { mappings: '' } }
6065
},
6166
}
6267
}

0 commit comments

Comments
 (0)