Experience-Monks / devtool

[OBSOLETE] runs Node.js programs through Chromium DevTools
MIT License
3.76k stars 148 forks source link

Require hook for ts-node doesn't work #104

Open unlight opened 7 years ago

unlight commented 7 years ago

devtool@2.3.0

 devtool -r ts-node/register server.ts

Fails with error:

...\node_modules\ts-node\register.js
...\node_modules\ts-node\dist\index.js
...\node_modules\source-map-support\source-map-support.js
An error occurred while trying to read the map file at ...\node_modules\source-map-support\foo.js.map
Error: ENOENT: no such file or directory, open '...\node_modules\source-map-support\foo.js.map'

Some research:

    var hasComment = convertSourceMap.commentRegex.test(script);
    var hasMapFile = convertSourceMap.mapFileCommentRegex.test(script);
    // if we have a map pointing to a file, inline it as base64
    if (!hasComment && hasMapFile) {
      var sm = convertSourceMap.fromMapFileSource(original, sourceFileDir);  // <--- ERROR

mapFileCommentRegex = /(?:\/\/[@#][ \t]+sourceMappingURL=([^\s'"]+?)[ \t]*$)|(?:\/\*[@#][ \t]+sourceMappingURL=([^\*]+?)[ \t]*(?:\*\/){1}[ \t]*$)/mg is incorrect. It detect regexp in the middle contents of the file (I suppose it should match only last line).

It detects comment sourceMappingURL=foo.js.map from source-map-support/source-map-support.js

unlight commented 7 years ago

Mention mainterners of convert-source-map @thlorenz

oztune commented 7 years ago

Same issue here. @unlight did you find a workaround?

thlorenz commented 7 years ago

I don't know what exactly trips up devtool, but convert-source-map just contains a valid JS comment. If devtool gets confused with JS comments then it needs to be fixed here instead of trying to fix the symptom cases that causes it to trip.