leebyron / rollup-plugin-flow

Rollup plugin for removing Flow type annotations.
Other
80 stars 11 forks source link

Incorrect source map generation #5

Open swansontec opened 7 years ago

swansontec commented 7 years ago

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:

Luobata commented 6 years ago

I have the same problem when add the rollup-plugin-flow;

code4cake commented 6 years ago

@Luobata & @swansontec have you guys found a solution for this ? thanks

anandthakker commented 6 years ago

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: ''

taoeffect commented 5 years ago

Thanks to @kepta for showing how to fix this!