plugin-svelte sets compiler options incorrectly, leading to broken sourcemaps #1941
Replies: 2 comments 6 replies
-
...though it did just occur to me that a plugin could theoretically need to control the |
Beta Was this translation helpful? Give feedback.
-
This makes sense, and I'm on board with passing the output file location data to the load plugin hook. One question: What should this value be in dev, when there is no build location on disk? During dev we only know the URL that requested the file. We could pass undefined, or we could just fake it and pass the plugin the would-be build location as if it were running build. But I'm not really sure what's closer to expected behavior. |
Beta Was this translation helpful? Give feedback.
-
The Svelte plugin has code like this:
filePath
is the full path to the .svelte file, and is the correct setting for thefilename
compiler option. ButoutputFilename
should not befilePath
, it should be the name of the file that gets written to disk (i.e./path/to/build/directory/Component.js
) and there should be a correspondingcssOutputFilename
like/path/to/build/directory/Component.css
.The
filename
,outputFilename
andcssOutputFilename
options are used together to populate thesources
property of the generated sourcemap, which should typically look something like this:Instead, because
filePath
is used foroutputFilename
andcssOutputFilename
, the `sources array looks like this:This makes it impossible to reliably locate the source of errors.
One option here would be for plugin
load
hooks to be passed information about where the output was going to be written to. That would allow the Svelte plugin to set the compiler options correctly.Another possibility is for Snowpack to automatically set both
sources
andsourcesContent
automatically after invokingload
, overriding whatever was returned by the plugin:That would alleviate the burden on plugin authors to figure this stuff out.
Beta Was this translation helpful? Give feedback.
All reactions