-
-
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
breaking: deprecate context="module"
in favor of module
#12948
Conversation
Also reserve a few attributes, which we may or may not use in the future closes #12637
🦋 Changeset detectedLatest commit: 9e62141 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
How are we deciding which other attribute names to reserve? Where was that discussed? |
I think it's just the stuff that was mentioned in #12637. Are there others you have in mind, or are you thinking we need to hold off on this until it's percolated a bit more? |
I don't know. I know you hated using |
My basic position is this — #12637 (comment) — that we haven't worried about this in the past when we've added One thing we could do is refuse to accept any attribute that we didn't define — in that case, if someone does add something like |
are preprocessors able to remove attributes? we had issues with that in the past iirc. if we are really going to phase out/redesign preprocessing sooner rather than later a generic "don't use common names, ideally prefix with your preprocessor name" should be enough, doesn't have to be hardcoded/validated |
AFK so can't check but I thought we explicitly added this ability so that (for example) TS code wasn't transpiled twice if you were (e.g.) packaging a component - the consumer of the packaged/transpiled version shouldn't see |
It should work. The docs say it does.
Saying that unknown attributes are disallowed and that it's a preprocessor's job to remove them makes me a lot more comfortable, if we think people will be okay with that. |
For me this is a case of being strict for strictness sake - as Rich said, we didn't worry about it in the past and there have been no known issues with that. It's not like we add these things every day. |
So do we make unknown attributes an error or just a warning? An error would make us bulletproof from a breaking change perspective, but might be annoying in the short term until preprocessors can be updated. |
Personally I just would merge this, i.e. not warn not error 😅 if everyone else wants to future proof this more, then a warning |
I'd have more peace of mind with a warning honestly — updated the PR |
I still see the use of a list of reserved attributes - is the idea that those would still be an error, but other unknown ones would just be a warning? A warning sounds like a good compromise. I'm not going to die on the hill of demanding that this is always a compiler error. |
|
||
if (attribute.name === 'context') { | ||
if (attribute.value === true || !is_text_attribute(attribute)) { | ||
throw new Error('TODO'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wasn't this supposed to be e.script_invalid_context(attribute);
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes! good spot, thanks — #12973
Cannot
at the same time |
Please provide a reproduction |
<script lang="ts" module>
export function myFn(param: string) {
return param + "pam" + "pam"
}
</script> then import { myFn } from '$components/Component.svelte' |
This looks like a language-tools issue @dummdidumm — it works, but VS Code doesn't know that it works Opened an issue over there sveltejs/language-tools#2472 |
|
Also reserve a few attributes, which we may or may not use in the future
closes #12637
Making this change revealed that we're currently adding another copy of Svelte 5 to our root node_modules, because the eslint and prettier plugin depend on it, don't find a dependency and then presumably have installed it. By adding an explicit dependency on our workspace version of Svelte to the root this is resolved.
Before submitting the PR, please make sure you do the following
feat:
,fix:
,chore:
, ordocs:
.Tests and linting
pnpm test
and lint the project withpnpm lint