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

<script context="module"> -> <script module> #12637

Closed
Rich-Harris opened this issue Jul 28, 2024 · 11 comments · Fixed by #12948
Closed

<script context="module"> -> <script module> #12637

Rich-Harris opened this issue Jul 28, 2024 · 11 comments · Fixed by #12948
Milestone

Comments

@Rich-Harris
Copy link
Member

Describe the problem

We've been meaning to make this change for a while, we should make sure it happens for 5.0

Describe the proposed solution

Deprecate the old syntax, introduce the new, and update the migration script

Importance

nice to have

@Rich-Harris Rich-Harris added this to the 5.0 milestone Jul 28, 2024
@dominikg
Copy link
Member

are we going to reserve more attribute names on script or style tags? preprocessors can technically use them so defining new ones could be a breaking change.

@Rich-Harris
Copy link
Member Author

Good point. Without making any commitment to use any of these in future, we could reserve client, server, test... any others?

@trueadm
Copy link
Contributor

trueadm commented Jul 28, 2024

worker might be another one.

@dominikg
Copy link
Member

another option could be to claim all attributes that are not using an xmlns namespace id to show which third party tool/package they originate from.

The only current use that comes to my head is svelte-preprocess using src to allow multi-file svelte components 🙈

@Inqnuam
Copy link

Inqnuam commented Jul 29, 2024

@dominikg I'm developing a meta-framework based on Svelte, where pathname attribute is used in pre-processor:

<script context="module" pathname="/home">
</script>

I hope this will still be possible in Svelte 5

@Conduitry
Copy link
Member

Is <script $module> too ugly to consider? Could we just reserve everything with a given prefix?

@Rich-Harris
Copy link
Member Author

oof, I think I'd rather keep context than do that tbh

@jackvanderbilt-visma
Copy link

The nomodule attribute is already a thing. This one and other one's you guys are suggesting to already reserve might collide with the spec someday... maybe? who knows...

@7nik
Copy link

7nik commented Jul 31, 2024

The nomodule attribute is already a thing. This one and other one's you guys are suggesting to already reserve might collide with the spec someday... maybe? who knows...

Technically, the HTML's script and Svelte's top-level scripts are different things with unrelated sets of attributes. So it's not a problem at all.

@Rich-Harris
Copy link
Member Author

Yeah, the only breakage we potentially need to worry about is people using their own attributes, like the pathname example above. But by that reasoning we wouldn't be able to introduce any new attribute (like lang="ts" or generics="T") outside a major release, and I don't know that we'd be willing to accept that. To me this falls into a bit of a semver grey area, and I think the likelihood of collisions (outside reserved attributes that we anticipate) is low enough that we can just say 'adding your own attributes to <script> is not supported and prone to breakage, but on your own head be it' and look the other way.

@Autumnlight02
Copy link

Could this not be solvable with an additional plugin to convert that before the svelte compiler get's his hands on it? only issue with that would be the language server.

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.

8 participants