-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a markup parameter to the script and style preprocessors. #4912
Comments
This parameter will hold the entire processed source file up until the current preprocessor. Fixes sveltejs#4912
This parameter will hold the entire processed source file up until the current preprocessor. Fixes sveltejs#4912
This parameter will hold the entire processed source file up until the current preprocessor. Fixes sveltejs#4912
The markup preprocessor already has all of this information, why not just use that for everything? The script and style preprocessors can just be seen as sugar over the markup preprocessor. |
I think things like #4141 and #4701 indicate that we need to re-think how we're dealing with preprocessors. I want to at some point spend some time thinking about how the ideal preprocessor API would look if we were designing it from scratch today, and then think about what we can actually do to make this not a breaking change. I don't think that tacking on additional options without looking at the whole situation is the right way forward. |
Agreed, I would really like to be involved in the discussion about preprocessors, if that's possible. |
great call |
Is your feature request related to a problem? Please describe.
Since a Svelte component is a whole, the preprocessors and scripts should be able to read the markup. For example, a TypeScript plugin should be able to warn if some imported types are not used in the markup.
Describe the solution you'd like
I propose to add an extra parameter to a Preprocessor, named markup, which will hold the contents of the entire file.
Describe alternatives you've considered
Currently, I implement both the markup and script preprocessors, and hold a cache of markup per filename. This works, but it depends on the fact that first the markup preprocessor is called and then the script one.
Also, this data is readily available in the compiler, and needs to be cached on the preprocessor side.
How important is this feature to you?
I think as the preprocessor ecosystem grows larger, this will be needed more. This is not a high prio feature, but easy to implement, and it would make my preprocessor simpler.
Additional context
I'll add a pull request to implement this.
The text was updated successfully, but these errors were encountered: