Require hook for ts-node doesn't work
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
Mention mainterners of convert-source-map @thlorenz
Same issue here. @unlight did you find a workaround?
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.