Skip to content

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

Closed
bryanmylee wants to merge 5 commits intosveltejs:masterfrom
bryanmylee:package/copy-package-json
Closed

@sveltejs/package Allow disabling the default behavior of copying package.json to the output directory when packaging a Svelte library#6825
bryanmylee wants to merge 5 commits intosveltejs:masterfrom
bryanmylee:package/copy-package-json

Conversation

@bryanmylee
Copy link
Copy Markdown

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 copyPackageJson option to allow disabling the copy feature.

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

changeset-bot Bot commented Sep 15, 2022

🦋 Changeset detected

Latest commit: bdbbb6e

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 Patch

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/copy package json @sveltejs/package Allow disabling the default behavior of copying package.json to the output directory when packaging a Svelte library Sep 15, 2022
@david-plugge
Copy link
Copy Markdown
Contributor

The package command also copied the readme and changelog. What about a more general solution like an array of files and folders to copy or a filter function?

@dummdidumm
Copy link
Copy Markdown
Member

dummdidumm commented Sep 15, 2022

Yes that could be a more general solution. I'm tempted to put this into files but that's currently used for project files only, not sure if that breaking change is worth it (especially since it's not easy to detect) and if that even would be a good API.

@bryanmylee
Copy link
Copy Markdown
Author

I didn't notice the README or changelog because it wasn't affecting the monorepo, but perhaps a more general metadata field would be better?

We can make its API similar to files, except we make the distinction that files only relates to project code, while metadata refers to the extra things like README, package.json, and the changelog.

@bryanmylee bryanmylee closed this Sep 17, 2022
@bryanmylee bryanmylee deleted the package/copy-package-json branch September 17, 2022 14:05
@bryanmylee bryanmylee restored the package/copy-package-json branch September 17, 2022 14:07
@bryanmylee
Copy link
Copy Markdown
Author

Closed this in favor of #6864.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

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

3 participants