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

[package] remove tooling specific settings in publishConfig from generated package.json #5848

Merged
merged 6 commits into from Aug 15, 2022
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/stale-apples-cry.md
@@ -0,0 +1,5 @@
---
'@sveltejs/kit': patch
---

Make package command remove `publishConfig.directory` from generated package.json
2 changes: 1 addition & 1 deletion documentation/docs/13-packaging.md
Expand Up @@ -14,7 +14,7 @@ Running `svelte-kit package` will take the contents of `src/lib` and generate a

- All the files in `src/lib`, unless you [configure](/docs/configuration#package) custom `include`/`exclude` options. Svelte components will be preprocessed, TypeScript files will be transpiled to JavaScript.
- Type definitions (`d.ts` files) which are generated for Svelte, JavaScript and TypeScript files. You need to install `typescript >= 4.0.0` and `svelte2tsx >= 0.4.1` for this. Type definitions are placed next to their implementation, hand-written `d.ts` files are copied over as is. You can [disable generation](/docs/configuration#package), but we strongly recommend against it.
- A `package.json` copied from the project root with all fields but the `"scripts"` field. The `"dependencies"` field is included, which means you should add packages that you only need for your documentation or demo site to `"devDependencies"`. A `"type": "module"` and an `"exports"` field will be added if it's not defined in the original file.
- A `package.json` copied from the project root with all fields except `"scripts"`, `"publishConfig.directory"` and `"publishConfig.linkDirectory"`. The `"dependencies"` field is included, which means you should add packages that you only need for your documentation or demo site to `"devDependencies"`. A `"type": "module"` and an `"exports"` field will be added if it's not defined in the original file.

The `"exports"` field contains the package's entry points. By default, all files in `src/lib` will be treated as an entry point unless they start with (or live in a directory that starts with) an underscore, but you can [configure](/docs/configuration#package) this behaviour. If you have a `src/lib/index.js` or `src/lib/index.svelte` file, it will be treated as the package root.

Expand Down
5 changes: 5 additions & 0 deletions packages/kit/src/packaging/utils.js
Expand Up @@ -103,7 +103,12 @@ export function analyze(config, file) {
export function generate_pkg(cwd, files) {
const pkg = JSON.parse(fs.readFileSync(path.join(cwd, 'package.json'), 'utf8'));

// Remove fields that are specific to the original package.json
// See: https://pnpm.io/package_json#publishconfigdirectory
delete pkg.publishConfig?.directory;
delete pkg.linkDirectory?.directory;
delete pkg.scripts;

pkg.type = 'module';

pkg.exports = {
Expand Down