Experience-Monks / Experience-Monks/devtool
Require hook for ts-node doesn't work
- Dominant language
- JavaScript
- Stars
- 3.7k
- Forks
- 147
- PR merge metrics
- No merged PRs in 30d
Description
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`
Contributor guide
Assessment
This issue has not been assessed yet.