-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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-kit package should automatically include Svelte as a peerDependency #3023
Comments
I tend to agree, although it's prefectly valid to create packages that don't depend on Svelte directly, for example packages that only provide actions ( |
An action can't be assumed to work correctly on different major versions of Svelte, because the syntax or even some assumptions on components lifecycle could change in the future. So I don't think it would be a false positive and Svelte should still appear as a peerDep, even if the Svelte runtime libs are not used in the code. I get your point about the version that should be specified. Using the same version as the devDeps is a possibility and should guarantee compatibility, but at the same time this could be problematic for adoption, because a new library would naturally use the latest version of Svelte while a lot of already existing projects would not, thus resulting in a lot of peerDep warnings from I have to strategies in mind:
These two strategies would only be used if Svelte isn't already a peerDep. I tend to think that the first strategy is better, because it forces the developer to make a conscious decision. |
I agree with @dummdidumm. The svelte peer dep isn't necessary for actions library, they can be used generically and are not bound to Svelte. So I don't think adding svelte peer dep automatically is ideal here. Relying on dev dep version would be a bit fragile too. Suppose you want to test your library with the latest svelte version, but still supporting an older svelte version, the peer dep and dev dep version would be different. Bumping svelte peer dep version is also a major change in semver, so it would be rare if someone wants to do it. I think @dummdidumm's suggestion of doing that during setup would be the best way. That should prompt the developer to be aware of the peer dep and manage it. |
Do keep in mind that |
@ignatiusmb you made a good point about making non-Svelte libraries. Could we create an FAQ section related to libraries made using sveltekit and display the link to the developer during init, so that they are aware of this, even if it's their first library? $ npm init svelte@next my-app
...questions
Done. Next steps
cd my-app
npm install
Are you building a library? You can read the FAQs here: https://www.example.com/sveltekit-lib-faqs.html The FAQs could then point out the different approaches to peerDeps (actions vs runtime vs etc) among other useful distilled information |
Where do we draw the line between SvelteKit packaging and npm's packaging/publishing? I don't think it is in our scope to explain how npm works. There would be a lot of follow-up questions if we do put them in the FAQ, and it would become a docs on its own by that point. |
It's seems to me that the moment a command like svelte-kit package exists its behaviour should be thoroughly explained, even considering the fact that this command is mangling the original package.json, automating stuff like the "exports" field. I don't think it's a problem to have a somewhat redundant documentation that could be found elsewhere on the web about how npm packaging works, considering that svelte kit is using a subset of all the available functionalities. It could also be a great way to introduce new developers to the fragmented world of JavaScript libraries/bundlers etc. |
Sounds like something for the documentation rework we will be doing at some point. If we decide to go multi-page, we will have enough space for more in-depth explanations. |
I think an alternative approach would be to allow the lib folder to contain a |
I'm going to consider this closed by #7685 |
Describe the bug
I used
svelte-kit package
/npm run package
to create a simple library that provides some Svelte stores.The
package
command prepared a folder containing all the library files, but the generated package.json did not include Svelte as a peerDependency, even thought the library code depends on the Svelte runtime environment (in my case the generated bundle contains import statements targeting 'svelte/store').The generated library only works in an environment where Svelte has already been installed and won't warn the user in case of breaking changes to the runtime. For example, suppose that a year from now Svelte 4 were to be released, all libraries that don't include "svelte": "^3.44.0" as a peerDependency may silently break without the usual warning from
npm
.Reproduction
One can reproduce the issue using the default demo project:
The package/package.json file contains Svelte as a devDependency, thus resulting in an untracked dependency on the users' side.
Logs
No response
System Info
Severity
annoyance
Additional Information
No response
The text was updated successfully, but these errors were encountered: