rollup-plugin-flow icon indicating copy to clipboard operation
rollup-plugin-flow copied to clipboard

Incorrect source map generation

Open swansontec opened this issue 7 years ago • 4 comments

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

swansontec avatar Aug 28 '17 08:08 swansontec

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

Luobata avatar Dec 07 '17 03:12 Luobata

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

code4cake avatar Dec 18 '17 14:12 code4cake

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

anandthakker avatar Feb 22 '18 03:02 anandthakker

Thanks to @kepta for showing how to fix this!

taoeffect avatar Jun 29 '19 04:06 taoeffect