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 Pre-release Compatibility #235

Open
EMH333 opened this issue May 21, 2024 · 6 comments
Open

Svelte 5 Pre-release Compatibility #235

EMH333 opened this issue May 21, 2024 · 6 comments

Comments

@EMH333
Copy link
Owner

EMH333 commented May 21, 2024

This is different than #234 since npm does some funny things with version locks and the prerelease versions may have subtle changes compared to the actual release.

This is a good time to clarify my commitment to prerelease support:

  1. I promise that esbuild-svelte will have an installable version compatible with Svelte 5 the day it is released. It may not support all the new features, but it will at least let projects compile with Svelte 5. Worth noting that I am intending v0.8.1 to be that version, but won't hesitate to make changes as required.
  2. Support for prereleases is best effort only and will stop immediately (and retroactively) once a production version of Svelte 5 is released.
  3. The usual DX does not exist for prerelease versions (see below) since they are, well, prerelease. Hacky workarounds may be required, with the expectation that they go away on the release of Svelte 5.
@EMH333
Copy link
Owner Author

EMH333 commented May 21, 2024

I'm not sure if I'm doing something wrong, but I'm seeing this when I run npm install.

$ npm install
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: project@undefined
npm ERR! Found: svelte@5.0.0-next.136
npm ERR! node_modules/svelte
npm ERR!   dev svelte@"^5.0.0-next.136" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer svelte@">=3.43.0 <6" from esbuild-svelte@0.8.1
npm ERR! node_modules/esbuild-svelte
npm ERR!   dev esbuild-svelte@"^0.8.1" from the root project

My package.json looks like this.

{
  "name": "project",
  "devDependencies": {
    "esbuild": "^0.21.0",
    "esbuild-svelte": "^0.8.1",
    "svelte": "^5.0.0-next.136"
  }
}

I updated to the latest esbuild-svelte and installed svelte@next.

@EMH333
Copy link
Owner Author

EMH333 commented May 21, 2024

TL;DR: Use --force or --legacy-peer-deps for the prereleases since there isn't a great way to allow peer dependencies of all prerelease versions of a package.

Essentially, semver doesn't consider prereleases of v5 to be <6. As a result, even though the human-readable version number of 5.0.0-next.1 is clearly less than v6, semver doesn't consider that to be the case (try it out with https://semver.npmjs.com/). This means that dependency graph solving fails.

There are numerous issues about this (npm/cli#2087 as an example) and an active RFC on how to resolve this npm/rfcs#397.

But I don't think there is a clear/easy way to fix this for the prerelease versions. This won't be an issue once Svelte 5 is officially released.

@tgf9
Copy link

tgf9 commented May 21, 2024

Excellent! Thanks for the detailed answer! I didn't realize this was a known behavior with npm. Good to know. Adding --force worked! Project builds and runs fine now.

@tgf9
Copy link

tgf9 commented Jun 5, 2024

Would it make sense to change esbuild-svelte's package.json to this?

  "peerDependencies": {
    "esbuild": ">=0.9.6",
-    "svelte": ">=3.43.0 <6"
+    "svelte": ">=3.43.0 <5 || ^5.0.0-next.0"
  },

Then later, when Svelte 5 officially releases, maybe you could do this?

  "peerDependencies": {
    "esbuild": ">=0.9.6",
-    "svelte": ">=3.43.0 <5 || ^5.0.0-next.0"
+    "svelte": ">=3.43.0 <5 || ^5.0.0-next.0 || ^5.0.0"
  },

I think this could improve the DX by not requiring that users pass --force to npm install. Also, this is how svelte-check does it.

@EMH333
Copy link
Owner Author

EMH333 commented Aug 6, 2024

Interesting! Let me play around with that and see what I can do

@EMH333
Copy link
Owner Author

EMH333 commented Sep 14, 2024

The change to allow Svelte 5 pre-releases as a peer dependency has been released as v0.8.2. Sorry for the delay!

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

No branches or pull requests

2 participants