Invalid source map if using prepreprocessors
See original GitHub issueHello,
I use esbuild with this plugin and I have found the following problem if I enable source map generation with css
set to false
in compileOptions
const esbuild_svelte = require("esbuild-svelte/configurable")({
compileOptions: { css: false, hydratable: true },
preprocessor: svelteConfig.preprocess,
}
I think the source of the problem is in your code at configurable/index.js
line 44:
//if svelte emits css seperately, then store it in a map and import it from the js
if (!compileOptions.css && css.code) {
let cssPath = args.path.replace(".svelte", ".esbuild-svelte-fake-css").replace(/\\/g, "/");
cssCode.set(cssPath, css.code + `/*# sourceMappingURL=${css.map.toUrl()}*/`);
contents = `import "${cssPath}";\n` + contents;
}
If I remove the \n
the source map line is ok:
...
contents = `import "${cssPath}";` + contents;
...
I donβt know if this will fix the problem completely. Possibly there is another way in esbuild to inject the css without modifying the contents.
Issue Analytics
- State:
- Created 3 years ago
- Comments:16 (11 by maintainers)
Top Results From Across the Web
Invalid source maps when building with optimization #7039
All files must generate sourceMap when optimization is true. Steps to Reproduce. Setup a new workspace with npx create-nx-workspace --preset=Β ...
Read more >Why is the sourcemap invalid when is use UglifyJs?
When I run npm run build in my react app I get the following warning: static/js/widget.js contains invalid source map .
Read more >Source map errors β Firefox Source Docs documentation
Invalid source mapΒΆ. The source map data can be invalid β either not a JSON file at all, or with an incorrect structure....
Read more >Sourcemap was invalid or not parseable - Feedback - #sentry
I am facing strange behavior from sentry. I use sentry-webpack-plugin to upload my sourcemaps to remote company sentry server.
Read more >Map Preprocessed Code to Source Code - Chrome Developers
You can then read and debug compiled code in its original source. Only use preprocessors capable of producing Source Maps. Verify that your...
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 FreeTop 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
Top GitHub Comments
Currently I use:
I can use the current version of esbuild-svelte 0.5.4 without warnings or errors in my test project. I donβt know in which version it fixed my problem because I used an old version of esbuild-svelte in my other project. Now the only problem is still the referenced source in browser is after preprocessing.
See following test project:
Original:
Console.log says:
and is referencing in browser to:
I tested with the branch
preprocessor-sourcemaps
and there are the same errors. Not everyjs.map.sources
has 2 items, but most of them.Here ist my
yarn list | egrep "svelte|esbuild"
afteryarn upgrade
:Later I will try it with a new project. Now I see no relation between the import statement and the output of one or two items in the
js.map.sources
array.I think my current project is too complex for tests. Starting with a new small project hopefully I can discover when the duplication of files happen.