Experience-Monks / devtool

[OBSOLETE] runs Node.js programs through Chromium DevTools

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Broken with babel-register source mapping

samdj opened this issue · comments

commented

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

├─┬ babel-preset-es2015@6.9.0
│ └─┬ babel-plugin-transform-regenerator@6.9.0
│   └─┬ babel-core@6.10.4
│     └── babel-register@6.9.0 
└── babel-register@6.8.0 

Any ideas?

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. 👍

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).
commented

Interesting @aleclarson, that is quite a hacky fix.

@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 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.

Seems to only be a problem when devtool is global

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.