Skip to content

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

Closed
bryanmylee wants to merge 8 commits into
sveltejs:masterfrom
bryanmylee:package/metadata
Closed

bryanmylee wants to merge 8 commits into
sveltejs:masterfrom
bryanmylee:package/metadata

Conversation

@bryanmylee

Copy link
Copy Markdown

Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

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

changeset-bot Bot commented Sep 17, 2022 •

Copy link
Copy Markdown

🦋 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
@ghost

ghost commented Sep 17, 2022

Copy link
Copy Markdown

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

@dummdidumm

Copy link
Copy Markdown
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
Copy Markdown
Author

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

@vercel

vercel Bot commented Dec 14, 2022

Copy link
Copy Markdown
Contributor

@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
Copy Markdown
Author

The failing test seems to be unrelated to svelte-package

@dummdidumm dummdidumm mentioned this pull request Feb 7, 2023
9 of 10 tasks
@Rich-Harris

Copy link
Copy Markdown
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

This branch was successfully deployed

1 active deployment
Preview – kit — 2e086685 Deployed Dec 23, 2022 by vercel[bot]
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

Development

Successfully merging this pull request may close these issues.

@sveltejs/package Allow disabling the default behavior of copying package.json to the output directory when packaging a Svelte library

4 participants