Skip to content

Commit

Permalink
fix(rollup): fix to work with rollup-plugin-typescript2 (#147)
Browse files Browse the repository at this point in the history
Do not provide AST if parsed using Babel.
  • Loading branch information
vwxyutarooo authored and gregberge committed Aug 16, 2018
1 parent c7ab92b commit 4b3737e
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions packages/rollup/src/index.js
Expand Up @@ -8,6 +8,7 @@ function svgrPlugin(options = {}) {
const { babel = true } = options

return {
name: 'svgr',
async transform(data, id) {
if (!filter(id)) return null
if (id.slice(-4) !== '.svg') return null
Expand Down Expand Up @@ -54,9 +55,13 @@ function svgrPlugin(options = {}) {
)
})

const code = babel ? await pBabelTransform(jsCode) : jsCode
if (babel) {
const code = await pBabelTransform(jsCode);

return { ast, code, map: { mappings: '' } }
return { code, map: { mappings: '' } }
}

return { ast, code: jsCode, map: { mappings: '' } }
},
}
}
Expand Down

0 comments on commit 4b3737e

Please sign in to comment.