devtool icon indicating copy to clipboard operation
devtool copied to clipboard

Broken with babel-register source mapping

Open samdj opened this issue 9 years ago • 6 comments

I'm trying to run something like so:

require('babel-register')
// Do stuff

It only works with --no-source-maps. I'm getting this error:

/home/dev/W/app/index.js
/home/dev/W/app/node_modules/babel-register/lib/node.js
/home/dev/W/app/node_modules/babel-core/index.js
/home/dev/W/app/node_modules/babel-core/lib/api/node.js
/home/dev/W/app/node_modules/babel-core/lib/transformation/file/index.js
/home/dev/W/app/node_modules/convert-source-map/index.js
An error occurred while trying to read the map file at node_modules/convert-source-map/foo.js.map
Error: ENOENT: no such file or directory, open 'node_modules/convert-source-map/foo.js.map'

Using this babelrc:

{
    "presets": ["es2015-node5"],
    "plugins": [
        "transform-object-rest-spread",
        "transform-class-properties",
        "add-module-exports",
        [
            "transform-async-to-module-method",
            { "module": "bluebird", "method": "coroutine" }
        ]
    ]
}

Using node v5.12

├─┬ [email protected]
│ └─┬ [email protected]
│   └─┬ [email protected]
│     └── [email protected] 
└── [email protected] 

Any ideas?

samdj avatar Jun 29 '16 04:06 samdj

This is an issue with thlorenz/convert-source-map.

What's happening is that both devtool and babel-core depend on convert-source-map. This causes the source map converter to parse itself. This shouldn't be a problem, except there is a comment in convert-source-map/index.js that has a fake sourceMappingURL.

Just remove this line to fix it. :+1:

There are 3 ways to go about this:

  • Remove the comment in both babel-core/node_modules/convert-source-map and devtool/node_modules/convert-source-map. NOTE: This will be overwritten if you reinstall either package.
  • Fork convert-source-map, remove the comment, fork babel-core and devtool and make them depend on your fork of convert-source-map. 😢
  • Wait for @thlorenz to remove the comment in the original repo (or at least in the NPM package that is downloaded by babel-core and devtool).

aleclarson avatar Jul 07 '16 18:07 aleclarson

Interesting @aleclarson, that is quite a hacky fix.

samdj avatar Jul 09 '16 06:07 samdj

@aleclarson looks like I'm getting this error when just trying to run gulp without babel

devtool `which gulp`
screen shot 2016-09-04 at 3 48 54 pm

dtothefp avatar Sep 04 '16 19:09 dtothefp

@dtothefp Looks like you have convert-source-map installed in your devtool-test package? And devtool/node_modules/convert-source-map/index.js is parsing the example.

aleclarson avatar Sep 04 '16 20:09 aleclarson

Seems to only be a problem when devtool is global

pennyandsean avatar Sep 07 '16 11:09 pennyandsean

Aw damn it :( just found this tool and this caught me right off the bat. I need sourcemaps to be there, can't really do without them. Hopefully the source map folks get time to make a fix.

MiracleBlue avatar Oct 09 '16 01:10 MiracleBlue