parcel-plugin-svelte icon indicating copy to clipboard operation
parcel-plugin-svelte copied to clipboard

CSS Compiler Option Can Never Be Set to `true`

Open bdoms opened this issue 3 years ago • 1 comments

🐛 Bug Report

🎛 Configuration (.svelterc, package.json, cli command)

I have different config options for active development vs bundling for production in a svelte.config.js file that looks like this:

var prod = {
    compilerOptions: {css: false}
};

var dev = {
    compilerOptions: {css: true}
};

module.exports = process.env.NODE_ENV === 'production' ? prod : dev;

Everything was working fine until I upgraded parcel-plugin-svelte to version 4.0.8. Now, the the css option never gets set to true anywhere. This means that my ability to run a hot reload server over a websocket with something like parcel app.js works for JavaScript, but the CSS is totally broken.

💻 Code Sample

The cause appears to be this commit: https://github.com/DeMoorJasper/parcel-plugin-svelte/commit/e14cf22d115d5d3494c9e7e812cf349cfd00d5ec

Because css is hardcoded to false there and a few lines below that the parcel config OVERRIDES any custom config, it means my config is effectively ignored and there is no way for someone using this plugin to set "css": true: https://github.com/DeMoorJasper/parcel-plugin-svelte/blob/master/packages/parcel-plugin-svelte/lib/svelte-asset.js#L27

I'm not sure what the best solution is given that others were having a problem before (but also why didn't they just set "css": false in their own config, rather than opening a pull request to force it that one way for everyone all the time here?), but hardcoding a config option seems like a bad idea to me in general. In this case it has broken parcel development for me and my team.

I believe the only reason you haven't been swamped with bug reports yet is that the published version is still 4.0.6, which does not contain this bug. I strongly suggest reversing the responsible commit. As soon as 4.0.8 gets published it's going to cause a lot more problems than it solves. And then anyone with similar issues to https://github.com/DeMoorJasper/parcel-plugin-svelte/issues/138 can always set their own config option themselves, which was working perfectly fine before this anyway.

🌍 Your Environment

"parcel-plugin-svelte": "4.0.8", "svelte": "3.31.2"

bdoms avatar Jan 12 '21 21:01 bdoms

I did some more research, and it's worth noting that the other project that got the same report and pull request - https://github.com/orlov-vo/parcel-transformer-svelte - did not end up merging the commit that hard codes css: false. I'd say that's further evidence it's not a good idea.

bdoms avatar Jan 14 '21 18:01 bdoms