Skip to content
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

Closed
MaartenX opened this issue May 27, 2020 · 4 comments
Closed

Add a markup parameter to the script and style preprocessors. #4912

MaartenX opened this issue May 27, 2020 · 4 comments

Comments

@MaartenX
Copy link

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.

MaartenX pushed a commit to MaartenX/svelte that referenced this issue May 27, 2020
This parameter will hold the entire processed source file up until the
current preprocessor.

Fixes sveltejs#4912
MaartenX pushed a commit to MaartenX/svelte that referenced this issue May 27, 2020
This parameter will hold the entire processed source file up until the
current preprocessor.

Fixes sveltejs#4912
MaartenX pushed a commit to MaartenX/svelte that referenced this issue May 27, 2020
This parameter will hold the entire processed source file up until the
current preprocessor.

Fixes sveltejs#4912
@pngwn
Copy link
Member

pngwn commented May 27, 2020

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.

@Conduitry
Copy link
Member

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.

@MaartenX
Copy link
Author

Agreed, I would really like to be involved in the discussion about preprocessors, if that's possible.

@swyxio
Copy link
Contributor

swyxio commented Jun 4, 2020

I don't think that tacking on additional options without looking at the whole situation is the right way forward.

great call

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants