sveltejs / svelte-loader

Webpack loader for svelte components.
MIT License
594 stars 73 forks source link

fix: loader errors when sourcemaps are disabled in svelte #236

Closed wabain closed 1 month ago

wabain commented 8 months ago

This pull request fixes a couple errors I hit when setting { compilerOptions: { enableSourcemap: false } }. At different places, the loader code assumes that each of js.map and css.map are non-null. Both errors are triggered in the added tests.

(I assume that disabling sourcemaps at the Svelte level rather than through the webpack config is uncommon. In my case, I was disabling CSS sourcemaps for Svelte specifically in order to work around some issues with preprocessor map handling. I found the JS sourcemap error in the course of fixing the CSS error.)