From 7cfd81377f9f370e479212e935e995301884c8a3 Mon Sep 17 00:00:00 2001 From: Edoardo Ranghieri Date: Sun, 23 Apr 2023 11:01:43 +0200 Subject: [PATCH] build: use dist/ as package root folder --- copy-package-files.js | 23 +++++++++++++++++++++++ package.json | 43 ++++++++++++++----------------------------- 2 files changed, 37 insertions(+), 29 deletions(-) create mode 100644 copy-package-files.js diff --git a/copy-package-files.js b/copy-package-files.js new file mode 100644 index 00000000..79e6bf4b --- /dev/null +++ b/copy-package-files.js @@ -0,0 +1,23 @@ +// This is used to copy package.json and LICENSE files into dist/ folder, for +// publish. + +const { copyFileSync } = require("fs"); +const { join } = require("path"); + +const distDir = join(__dirname, "dist"); + +const main = () => { + const copyFile = (file) => { + const from = join(__dirname, file); + const to = join(__dirname, "dist", file); + + copyFileSync(from, to); + console.log("Copied", file, "to dist/ folder"); + }; + + copyFile("package.json"); + copyFile("LICENSE"); + copyFile("README.md"); +}; + +main(); diff --git a/package.json b/package.json index 26a0c146..b8a5646d 100644 --- a/package.json +++ b/package.json @@ -3,37 +3,13 @@ "version": "0.0.0-development", "private": false, "description": "A typesafe mutation implementation for Next.js with RSC.", - "main": "dist/index.js", - "module": "dist/index.mjs", - "types": "dist/index.d.ts", - "files": [ - "dist/**", - "package.json" - ], - "exports": { - ".": { - "import": "./dist/index.mjs", - "types": "./dist/index.d.ts" - }, - "./hook": { - "import": "./dist/hook/index.mjs", - "types": "./dist/hook/index.d.ts" - } - }, - "typesVersions": { - "*": { - ".": [ - "dist/index.d.ts" - ], - "hook": [ - "dist/hook/index.d.ts" - ] - } - }, + "main": "index.js", + "module": "index.mjs", + "types": "index.d.ts", "scripts": { "prepare": "is-ci || husky install", "lint": "tsc && eslint --ext ts .", - "build": "tsup", + "build": "tsup; node copy-package-files", "semantic-release": "semantic-release --branches main" }, "keywords": [ @@ -114,6 +90,10 @@ "type": "perf", "release": "patch" }, + { + "type": "build", + "release": "patch" + }, { "type": "docs", "scope": "readme", @@ -131,7 +111,12 @@ } ], "@semantic-release/release-notes-generator", - "@semantic-release/npm", + [ + "@semantic-release/npm", + { + "pkgRoot": "./dist" + } + ], "@semantic-release/github" ] }