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

Svelte 5: Throw an error when importing svelte/internal/* #11622

Closed
dummdidumm opened this issue May 14, 2024 · 5 comments · Fixed by #11632
Closed

Svelte 5: Throw an error when importing svelte/internal/* #11622

dummdidumm opened this issue May 14, 2024 · 5 comments · Fixed by #11632
Milestone

Comments

@dummdidumm
Copy link
Member

Describe the problem

People have reached into svelte/internal too much in the past. We should discourage it as much as possible and throw a compiler error when someone imports from it. People who reaaaally wanna do it can hide it by importing it from a regular JS file and reexport it.

Describe the proposed solution

Error on svelte/internal/client and svelte/internal/server

Importance

nice to have

@dummdidumm dummdidumm added this to the 5.0 milestone May 14, 2024
@dominikg
Copy link
Member

warn in non-runes mode, error in runes mode 👍

The svelte compiler can only do this in .svelte and .svelte.js files, technically someone could be doing it in regular js files and reexport to fool it. There is an issue on v-p-s to do it on the resolve level sveltejs/vite-plugin-svelte#861

and iirc eslint-plugin-svelte also added a warning for this recently.

@trueadm
Copy link
Contributor

trueadm commented May 14, 2024

I think we should error.

@paoloricciuti
Copy link
Member

As a side note tho might be worth checking what they were using internals for? If we notice a pattern that is very useful for library authors might be worth exporting it for real?

Rich-Harris pushed a commit that referenced this issue May 15, 2024
* feat: error on imports to `svelte/internal/*`

closes #11622

* regenerate

* also error on svelte/internal
@JLarky

This comment was marked as off-topic.

@dominikg
Copy link
Member

dominikg commented Jan 5, 2025

@JLarky please don't give people ideas. As the name says and our documentation and errors show, svelte/internal is for internal use only. You must not use it or provide guidance on how to do so. There are no guarantees whatsoever that these interfaces are stable or change at any point in time without notice. Your app or the apps of users using your library that contains this code are going to break and it will be all your fault.

TL;DR: don't use svelte/internal, period.

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

Successfully merging a pull request may close this issue.

5 participants