From afb96af46989cc990c90329e254432a75fdbc255 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Boye=20Borg=20Nyg=C3=A5rd?= <6630430+boyeborg@users.noreply.github.com> Date: Mon, 8 Aug 2022 09:07:45 +0200 Subject: [PATCH 1/5] remove (if it exists) from generated package.json --- packages/kit/src/packaging/utils.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/kit/src/packaging/utils.js b/packages/kit/src/packaging/utils.js index eb65b788f60b..5d0be1c552be 100644 --- a/packages/kit/src/packaging/utils.js +++ b/packages/kit/src/packaging/utils.js @@ -103,6 +103,7 @@ export function analyze(config, file) { export function generate_pkg(cwd, files) { const pkg = JSON.parse(fs.readFileSync(path.join(cwd, 'package.json'), 'utf8')); + delete pkg.publishConfig?.directory; delete pkg.scripts; pkg.type = 'module'; From 9826af7140603a14b8b026e59fd855d1191d5026 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Boye=20Borg=20Nyg=C3=A5rd?= <6630430+boyeborg@users.noreply.github.com> Date: Mon, 8 Aug 2022 09:42:09 +0200 Subject: [PATCH 2/5] provide changeset --- .changeset/stale-apples-cry.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/stale-apples-cry.md diff --git a/.changeset/stale-apples-cry.md b/.changeset/stale-apples-cry.md new file mode 100644 index 000000000000..ba5669e244e2 --- /dev/null +++ b/.changeset/stale-apples-cry.md @@ -0,0 +1,5 @@ +--- +'@sveltejs/kit': patch +--- + +Make package command remove `publishConfig.directory` from generated package.json From ca0a1af2def720f617271cd7e0d0417c26a92362 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Boye=20Borg=20Nyg=C3=A5rd?= <6630430+boyeborg@users.noreply.github.com> Date: Tue, 9 Aug 2022 08:53:08 +0200 Subject: [PATCH 3/5] also remove linkDirectory --- packages/kit/src/packaging/utils.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/kit/src/packaging/utils.js b/packages/kit/src/packaging/utils.js index 5d0be1c552be..04667cd23635 100644 --- a/packages/kit/src/packaging/utils.js +++ b/packages/kit/src/packaging/utils.js @@ -103,7 +103,11 @@ 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's 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'; From 1fe970ec1943fcd092cc2d3733224f15aaeadb20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Boye=20Borg=20Nyg=C3=A5rd?= <6630430+boyeborg@users.noreply.github.com> Date: Tue, 9 Aug 2022 08:56:20 +0200 Subject: [PATCH 4/5] add docs --- documentation/docs/13-packaging.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/documentation/docs/13-packaging.md b/documentation/docs/13-packaging.md index 2a9ae698c7d1..0dab6c4918f6 100644 --- a/documentation/docs/13-packaging.md +++ b/documentation/docs/13-packaging.md @@ -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. From cf0271ed1fbb9a77e9653d8b8ff4bc24738aa822 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Mon, 15 Aug 2022 18:31:51 -0400 Subject: [PATCH 5/5] tweak --- packages/kit/src/packaging/utils.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/kit/src/packaging/utils.js b/packages/kit/src/packaging/utils.js index 04667cd23635..c944beff5764 100644 --- a/packages/kit/src/packaging/utils.js +++ b/packages/kit/src/packaging/utils.js @@ -103,12 +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's specific to the original package.json + // 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 = {