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

@sveltejs/package Customize behavior of copying package.json and other essential files to the output directory when packaging a Svelte library #6864

Closed
wants to merge 8 commits into from

Conversation

bryanmylee
Copy link

Please don't delete this checklist! 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
  • This message body should clearly illustrate what problems it solves.
  • 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

  • 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

  • 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

@changeset-bot
Copy link

changeset-bot bot commented Sep 17, 2022

🦋 Changeset detected

Latest commit: 2e08668

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

@bryanmylee bryanmylee changed the title Package/metadata @sveltejs/package Customize behavior of copying package.json and other essential files to the output directory when packaging a Svelte library Sep 17, 2022
@benmccann benmccann added the pkg:svelte-package Issues related to svelte-package label Sep 17, 2022
@dominikg
Copy link
Member

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

@dummdidumm
Copy link
Member

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.

@bryanmylee
Copy link
Author

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

@vercel
Copy link

vercel bot commented Dec 14, 2022

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

A member of the Team first needs to authorize it.

@bryanmylee
Copy link
Author

The failing test seems to be unrelated to svelte-package

@dummdidumm dummdidumm mentioned this pull request Feb 7, 2023
10 tasks
@Rich-Harris
Copy link
Member

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

@Rich-Harris Rich-Harris closed this Feb 8, 2023
@bryanmylee bryanmylee deleted the package/metadata branch February 9, 2023 01:37
@bryanmylee bryanmylee restored the package/metadata branch February 9, 2023 01:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg:svelte-package Issues related to svelte-package
Projects
None yet
5 participants