Simplify auto preprocessing #424
kaisermann
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Currently, the
auto
mode is a single preprocessor that calls the necessary transformers given a certain svelte file. I've been wanting to refactor it for quite some time; the code feels convoluted, there are some hacky workarounds for handling options overrides, for enqueueing more than one transformer and for much more. Scenarios wherebabel
orpostcss
are needed alongside some other language, like TS or SCSS, are basically hard-coded. My initial thoughts were to implement some kind of "queue" mechanism, so we could streamline the code a bit.However, that brings me to my current way of thinking that is: we already have a queue mechanism, the one the
svelte.preprocess
API provides. The core ofsvelte-preprocess
was born in 2018 when Svelte didn't have support for a queue of preprocessors yet (I may be wrong here 😅). Since we already have each transformer as a standalone preprocessor (src/processors
), we could enqueue all of them in the appropriate order (babel
andpostcss
at the end i.e). This would left theauto
mode only responsible for setting default options, turning on/off settings etc.If I'm not forgetting something and we move forward with this idea, this can be implemented in three ways:
sveltePreprocess()
returns the array of preprocessors with the appropriate options set. This is a breaking change for people who usesvelte-preprocess
inside an array of preprocessors already.However, for the common use-case this shouldn't require any refactor:
sveltePreprocess()
will executesvelte.preprocess
inside of itself. This isn't a breaking-change and not completely novel, but it's strange nevertheless.Wait for the Preprocess API RFC to go through and see what we can do after that.
Beta Was this translation helpful? Give feedback.
All reactions