kit icon indicating copy to clipboard operation
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

Open bryanmylee opened this issue 1 year ago • 6 comments

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 with pnpm lint and pnpm 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 be patch until SvelteKit 1.0

bryanmylee avatar Sep 17 '22 14:09 bryanmylee

🦋 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

changeset-bot[bot] avatar Sep 17 '22 14:09 changeset-bot[bot]

fyi: the test fail in create-svelte is unrelated to this issue and a fix for that is pending in #6866

dominikg avatar Sep 17 '22 20:09 dominikg

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.

dummdidumm avatar Sep 19 '22 07:09 dummdidumm

Any updates on this? I would love to have this merged into the package itself.

bryanmylee avatar Nov 30 '22 03:11 bryanmylee

@dummdidumm is attempting to deploy a commit to the Svelte Team on Vercel.

A member of the Team first needs to authorize it.

vercel[bot] avatar Dec 14 '22 14:12 vercel[bot]

The failing test seems to be unrelated to svelte-package

bryanmylee avatar Dec 23 '22 07:12 bryanmylee

Thank you for the PR. We ended up going in a different direction (#8825) — closing in favour of #8922

Rich-Harris avatar Feb 08 '23 21:02 Rich-Harris