kit
kit copied to clipboard
`@sveltejs/package` Customize behavior of copying `package.json` and other essential files to the output directory when packaging a Svelte library
Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
- [x] 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
- [x] This message body should clearly illustrate what problems it solves.
- [x] Ideally, include a test that fails without this PR but passes with it.
This resolves #6824.
For context, I'm building a cross-framework component library so I've set up a standard package structure for each framework in my monorepo with npm workspaces.
I'm using Vite with @sveltejs/package
to develop and build my components. However, @sveltejs/package
breaks my toolchain because it creates a copy of package.json
in my dist
folder.
npm workspaces picks up both the original package.json
and dist/package.json
, causing other dependent packages to break due to the duplication.
This PR adds a metadata
filter function to allow disabling the copy feature for metadata files like package.json
and other whitelisted essential files.
Tests
- [x] Run the tests with
pnpm test
and lint the project withpnpm lint
andpnpm check
All existing tests for @sveltejs/package
pass and I added a test for the new config option.
Changesets
- [x] If your PR makes a change that should be noted in one or more packages' changelogs, generate a changeset by running
pnpm changeset
and following the prompts. All changesets should bepatch
until SvelteKit 1.0
🦋 Changeset detected
Latest commit: 2e086685adac0c6aa6bc4225f74a4c671cc3b2a1
The changes in this PR will be included in the next version bump.
This PR includes changesets to release 1 package
Name | Type |
---|---|
@sveltejs/package | Minor |
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
fyi: the test fail in create-svelte is unrelated to this issue and a fix for that is pending in #6866
Not 100% sure about the API yet but it's definitely going in the right direction. In the meantime, could you remove some of the unnecessary files from the tests? We don't need to have multiple Svelte files in there, copying them over and generating types for them is already checked in other tests. It should be enough to just have one index.js
file.
Any updates on this? I would love to have this merged into the package itself.
@dummdidumm is attempting to deploy a commit to the Svelte Team on Vercel.
A member of the Team first needs to authorize it.
The failing test seems to be unrelated to svelte-package
Thank you for the PR. We ended up going in a different direction (#8825) — closing in favour of #8922