devtool icon indicating copy to clipboard operation
devtool copied to clipboard

Require hook for ts-node doesn't work

Open unlight opened this issue 9 years ago • 3 comments

[email protected]

 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 avatar Nov 12 '16 21:11 unlight

Mention mainterners of convert-source-map @thlorenz

unlight avatar Nov 12 '16 22:11 unlight

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

oztune avatar Dec 11 '16 20:12 oztune

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.

thlorenz avatar Dec 22 '16 16:12 thlorenz