rollup-plugin-flow
rollup-plugin-flow copied to clipboard
Incorrect source map generation
I recently added rollup-plugin-flow
to my build flow. Unfortunately, my source maps come out with useless content now:
{
"version": 3,
"file": "index.cjs.js",
"sources": [],
"sourcesContent": [],
"names": [],
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;[...]"
}
I've trimmed a few thousand semicolons for brevity, but you get the idea. When I remove rollup-plugin-flow
, the source maps come out correctly again. Here is my rollup.config.js
:
import buble from 'rollup-plugin-buble'
import flow from 'rollup-plugin-flow'
import commonjs from 'rollup-plugin-commonjs'
import packageJson from './package.json'
export default {
entry: 'src/index.js',
external: Object.keys(packageJson.dependencies),
plugins: [
flow(),
buble({
objectAssign: 'Object.assign',
transforms: {
dangerousForOf: true
}
}),
commonjs({
include: 'build/crypto-bundle.js'
})
],
targets: [
{
dest: packageJson.main,
format: 'cjs',
sourceMap: true
},
{
dest: packageJson.module,
format: 'es',
sourceMap: true
}
]
}
Versions are:
- rollup: 0.46.2
- rollup-plugin-buble: 0.15.0
- rollup-plugin-commonjs: 8.1.0
- rollup-plugin-flow: 1.1.1
I have the same problem when add the rollup-plugin-flow
;
@Luobata & @swansontec have you guys found a solution for this ? thanks
The Rollup plugin docs here suggest that the sourcemap should be null
if the transform doesn't change the source, versus {mappings: ''}
if "it doesn't make sense to generate a sourcemap". So unless {pretty: true}
, I think the former is the case, but it looks like flow-remove-types returns a sourcemap with mappings: ''
Thanks to @kepta for showing how to fix this!