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

feat: expose 'svelte/internal' #10987

Merged
merged 2 commits into from
Mar 29, 2024
Merged

feat: expose 'svelte/internal' #10987

merged 2 commits into from
Mar 29, 2024

Conversation

Rich-Harris
Copy link
Member

Fixes #10979 and sveltejs/kit#12056

Before submitting the PR, please make sure you do the following

  • It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
  • Prefix your PR title with feat:, fix:, chore:, or docs:.
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.

Tests and linting

  • Run the tests with pnpm test and lint the project with pnpm lint

Copy link

changeset-bot bot commented Mar 29, 2024

🦋 Changeset detected

Latest commit: 8311e9c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
svelte Patch

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

@@ -0,0 +1,5 @@
// TODO we may, on a best-effort basis, reimplement some of the legacy private APIs here so that certain libraries continue to work. Those APIs will be marked as deprecated (and should noisily warn the user) and will be removed in a future version of Svelte.

throw new Error(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I vaguely remember @dominikg / @bluwy trying this approach to throw an error for better visibility what's happening, but IIRC the node/bundlers/whatever swallow the error and show something opaque instead.

In general I would prefer if we instead would keep svelte/internal and expose a browser+default condition for the client/server entry points

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue people are facing isn't that they're importing this module and it's failing, it's that Vite is attempting to preoptimize stuff based on what vite-plugin-svelte tells it. So there are two possible solutions:

  • this one
  • vite-plugin-svelte dynamic generates the list of Svelte subpackages from the package.json it finds

Ultimately we need both, but this is what will fix the errors for the largest number of people most quickly

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general I would prefer if we instead would keep svelte/internal and expose a browser+default condition for the client/server entry points

I really don't think that's the right approach — having different export conditions is a good way to expose a common API across different environments (such as onMount being a no-op in SSR, but still existing), but using it to have the same module specifier mean two completely different modules feels like a recipe for confusion

Copy link
Member

@dummdidumm dummdidumm Mar 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Who would be confused by that? It's an internal implementation detail that only concerns us. And doing it this way would mean less configs in the wild that need to be adjusted, which I value way higher.

For a quick fix I agree that this is the best option for now

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 this pull request may close these issues.

Svelte 5: Missing "./internal" specifier in "svelte" package
2 participants