From cfd1d0592ea6b704470e7969d72f9b51d8a1f5a5 Mon Sep 17 00:00:00 2001 From: Arnoud de Vries <6420061+arnoud-dv@users.noreply.github.com> Date: Sat, 21 Jun 2025 15:40:24 +0200 Subject: [PATCH] fix(angular-query): fix package publishing --- knip.json | 3 +++ .../angular-query-experimental/package.json | 18 ++++++++++--- .../scripts/prepack.js | 2 ++ .../scripts/prepare-package.js | 26 +++++++++++++++++++ 4 files changed, 45 insertions(+), 4 deletions(-) create mode 100644 packages/angular-query-experimental/scripts/prepare-package.js diff --git a/knip.json b/knip.json index 490e31c190..c1e8be98bb 100644 --- a/knip.json +++ b/knip.json @@ -22,6 +22,9 @@ "packages/vue-query": { "ignore": ["**/__mocks__/**"], "ignoreDependencies": ["vue2", "vue2.7"] + }, + "packages/angular-query-experimental": { + "ignore": ["scripts/prepack.js"] } } } diff --git a/packages/angular-query-experimental/package.json b/packages/angular-query-experimental/package.json index cf0442eb82..55cd169530 100644 --- a/packages/angular-query-experimental/package.json +++ b/packages/angular-query-experimental/package.json @@ -43,8 +43,8 @@ "test:lib": "vitest", "test:lib:dev": "pnpm run test:lib --watch", "test:build": "pnpm pack && publint ./dist/*.tgz --strict && attw ./dist/*.tgz; premove ./dist/*.tgz", - "build": "vite build && pnpm run prepack", - "prepack": "node ./scripts/prepack.js" + "build": "vite build && pnpm run prepare-package", + "prepare-package": "node ./scripts/prepare-package.js" }, "type": "module", "types": "dist/index.d.ts", @@ -60,7 +60,8 @@ "sideEffects": false, "files": [ "**/*.d.ts", - "**/*.mjs.*" + "**/*.mjs", + "**/*.mjs.map" ], "dependencies": { "@tanstack/query-core": "workspace:*", @@ -84,6 +85,15 @@ }, "publishConfig": { "directory": "dist", - "linkDirectory": false + "linkDirectory": false, + "types": "index.d.ts", + "module": "index.mjs", + "exports": { + ".": { + "types": "./index.d.ts", + "default": "./index.mjs" + }, + "./package.json": "./package.json" + } } } diff --git a/packages/angular-query-experimental/scripts/prepack.js b/packages/angular-query-experimental/scripts/prepack.js index 32593d1d2e..9b6f734a74 100644 --- a/packages/angular-query-experimental/scripts/prepack.js +++ b/packages/angular-query-experimental/scripts/prepack.js @@ -1,6 +1,8 @@ import fs from 'node:fs' import path from 'node:path' +// Currently unused as life-cycle scripts do not run on CI + console.log('Running prepack script') /** diff --git a/packages/angular-query-experimental/scripts/prepare-package.js b/packages/angular-query-experimental/scripts/prepare-package.js new file mode 100644 index 0000000000..2d97c08eb1 --- /dev/null +++ b/packages/angular-query-experimental/scripts/prepare-package.js @@ -0,0 +1,26 @@ +import fs from 'node:fs' +import path from 'node:path' + +console.log('Running prepare package script') + +/** + * Files to link from the dist directory + * @type {string[]} + */ +const FILES_TO_LINK = ['README.md', 'package.json'] + +if (!fs.existsSync('dist')) { + fs.mkdirSync('dist', { recursive: true }) +} + +console.log('Linking files') +for (const fileName of FILES_TO_LINK) { + if (fs.existsSync(fileName)) { + fs.linkSync(fileName, path.join('dist', fileName)) + console.log(`${fileName}`) + } else { + console.log(`${fileName} not found, skipping`) + } +} + +console.log('prepare package complete')