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

Allow package.json customisation when using svelte-package #7258

Closed
tkvw opened this issue Oct 13, 2022 · 2 comments · Fixed by #8922
Closed

Allow package.json customisation when using svelte-package #7258

tkvw opened this issue Oct 13, 2022 · 2 comments · Fixed by #8922
Labels
feature request New feature or request pkg:svelte-package Issues related to svelte-package
Milestone

Comments

@tkvw
Copy link

tkvw commented Oct 13, 2022

Describe the problem

I'm always frustrated when svelte-package creates a package.json not to my liking.
In a monorepo I have specified the following two entries in the original package.json to allow a component library to work with the svelte-kit generated website:

  "svelte": "src/lib/index.ts",
  "types": "src/lib/index.ts",

This is shamefully copied by the svelte-package library.

Describe the proposed solution

Allow packageJson generation to be overwritten in the package config section of svelte.config.js.

/** @type {import('@sveltejs/kit').Config} */
const config = {
  preprocess: preprocess(),
  kit: {
    adapter: adapter()	
  },
  package: {
	mergePackageJson: (original,proposed) => proposed // default = proposed, false = skip 
  }
};

Alternatives considered

Post edit the generated package.json

Importance

would make my life easier

Additional Information

No response

@dummdidumm dummdidumm added feature request New feature or request pkg:svelte-package Issues related to svelte-package labels Oct 13, 2022
@dummdidumm
Copy link
Member

Somewhat related to #6824

@dummdidumm dummdidumm added this to the whenever milestone Oct 13, 2022
@tkvw
Copy link
Author

tkvw commented Oct 14, 2022

FWIW I create a svelte-package-unpack gist which will copy the package content to the root folder and creates appropriate package.json files in subfolders. This allows typescript to find the correct typings and use the package in place (for use in a monorepo).

Make sure to add the generated folders to the .gitignore
The gist can simply be run by npx after build:

// package.json
"scripts": {
   "build": "svelte-kit sync && svelte-package && npx --yes https://gist.github.com/tkvw/ade8c42068fab1610bcad241649fd745/dfb552d06cea7ae9821456d9ac0678bc428f1e9b",
}

I think having the transpiled javascript in the root package with an appropriate .gitignore is best solution.

dummdidumm added a commit that referenced this issue Jan 31, 2023
- closes #7258
- closes #6824
- closes #4828
- part of #2242
- better message for #2884
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request pkg:svelte-package Issues related to svelte-package
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants