DevTools failed to load SourceMap
Closed this issue · 6 comments
Describe the bug
DevTools can't parse generated source maps.
How it happened?
The error is pretty much trivial and happens because of the path replacements (probably only for Windows).
It's easy to identify the reason just looking at the console log.
DevTools error message:
Unexpected token s in JSON at position 86
Now, let's take a look at the generated source map file.
The source map JSON:
{"version":3,"sources":[],"names":[],"mappings":"","file":"main.css","sourceRoot":"..\src"}
See, the sourceRoot
value contains a non-escaped string. Should be "..\\src"
;
Desktop (please complete the following information):
- OS: Windows 10 Pro
- Parcel version: 1.12.4
- Plugin version: 1.1.14
Plugin configuration object:
"customDistStructure": {
"config": {
"css": [
".css",
".css.map"
],
"js": [
".js",
".js.map"
]
},
"options": {
"development": true
}
}
Hi @jhess666. Thank you for reporting this issue.
Do you, by any chance use WSL?
Nope. It's a pure Windows environment.
Hi @jhess666.
I have a Windows 7 in VM and I am unable to reproduce the issue. Could you set up an example repo which reproduces this issue? Thanks.
In my tests I have found where the issue is being originated (at least for me):
// File: "./lib/Utils.js"
// ...
exports.replaceInFileSync = (files, stringToReplace, newString) => {
const regexPattern = escapeRegex(stringToReplace);
const result = replaceInFile.sync({
files,
from: new RegExp(regexPattern, 'g'),
to: newString // <-- here, it should be escaped
});
return result;
};
// ...
@jhess666 Could you please set up an example repo that reproduces this issue? Thanks.
Closing this since I was unable to reproduce the issue. Feel free to comment here and we'll reopen this if it happens again.