-
-
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
feat: allow snippets to be exported from module scripts #14315
base: main
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: 811843b 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 |
preview: https://svelte-dev-git-preview-svelte-14315-svelte.vercel.app/ this is an automated message |
|
If we're going to do the Acorn hack (and I can't think of a better alternative; this seems like the smartest approach as long as we're reasonably confident that the API won't change outside a major version change) then we're going to need to throw our own compile errors |
This would be huge for Storybook's Svelte language integration, where we currently have this ugly API for setting a global snippet as the render target. This change would allow us to get the Svelte integration closer to the rest of the Storybook API, which would be great for knowledge transferability. For us, it's really only about having the snippet variable available in the module context, and not about exporting it at all, but I see in the playground output that that is indeed what's happening, so that's great. |
Should we be concerned about what's required in other dev-time tooling to support exporting something that doesn't look like it's declared? Or does other tooling tend to parse this more laxly than what's happening in Acorn? |
Errr good question. I think it's probably fine, but do you have anything specific in mind? |
Not anything in particular, just: is this going to freak out language tools / intellisense? is this going to freak out Prettier? is this going to freak out ESLint? |
yes this needs adjustment in language-tools. will work on this soon. |
Closes #10350. Had to add a hacky bit of logic to prevent Acorn from complaining about bad identifiers being in the script
exports
.