Babel parses and removes sourceMappingURL from input
See original GitHub issueBug Report
Current Behavior
I have some code that generates JavaScript files and includes the string //# sourceMappingURL=
. Babel appears to remove this string and the remainder of the line before parsing.
Input Code
const comment = `//# sourceMappingURL=${path.basename(
sourceMapFilename
)}`
Output Code
const comment = `
sourceMapFilename
)}`;
Expected behavior/code
//# sourceMappingURL=
should not have special meaning inside of a template literal, and should be included in the generated output
const comment = `//# sourceMappingURL=${path.basename(sourceMapFilename)}`;
Babel Configuration (.babelrc, package.json, cli command)
None, see REPL link.
Environment
- Babel version(s): v7.4.2
- How you are using Babel: repl
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Options - Babel.js
Babel's default is to generate a string and a sourcemap, but in some ... false can improve parsing performance if the input AST...
Read more >Webpack Module Warning: Failed to parse source map from ...
As a sort of fix I removed the source-map-parser and the warning disappeared. Is it possible this issue happened because a webpack watch...
Read more >source-map-loader - webpack
Allows you to specify the behavior of the loader for SourceMappingURL comment. ... true or 'consume' - consume the source map and remove...
Read more >How to use the rollup-plugin-sourcemaps function in ... - Snyk
To help you get started, we've selected a few rollup-plugin-sourcemaps examples, based on popular ways it is used in public projects.
Read more >@babel/preset-react | Yarn - Package Manager
Important: This documentation covers modern versions of Yarn. For 1.x docs, see classic.yarnpkg.com. Yarn.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@nicolo-ribaudo I think you misread this one. We’re removing the comment-like content of a JS string, which is not right.
The logic for stripping
sourceMappingURL
must not verify that it’s in a file-end comment token, and instead just look for the string itself.@also Seems reasonable for us to fix this. For now I’d split the string into two pieces and concatenate with
+
so we don’t match the comment string, e.g.It needs to be fixed in the
convert-source-map
package.