diff --git a/docs/new-sdk-release-checklist.md b/docs/new-sdk-release-checklist.md index a6e0f60e8235..1292c5363fb0 100644 --- a/docs/new-sdk-release-checklist.md +++ b/docs/new-sdk-release-checklist.md @@ -29,22 +29,18 @@ differ slightly for other SDKs depending on how they are structured and how they - [ ] Make sure that the tarball (`yarn build:tarball`) has all the necessary contents - For basic SDKs, this means that the tarball has at least these files: + For basic SDKs, this means that the tarball has at least these files - you can configure what is included in the + tarball via the `files` field in `package.json`: - - [ ] `cjs/.js` - - [ ] `esm/.js` - - [ ] `types/` + - [ ] `build/cjs/.js` (or `build/npm/cjs/.js`) + - [ ] `build/esm/.js` (or `build/npm/esm/.js`) + - [ ] `build/types/` (or `build/npm/types/.js`) - [ ] `package.json` - [ ] Entry points registered in this file match the file structure above - [ ] `LICENSE` - [ ] `README.md` - - [ ] If your tarball should contain additional files outside `esm`, `cjs`, and `types` that are not listed above - (e.g. like Gatsby or Remix), be sure to add a package-specific `prepack.ts` script. In this script, you can copy - these additional files and make other adjustments.\ - Check out the - [Gatsby script](https://github.com/getsentry/sentry-javascript/blob/acd7fbb56ed1859ce48f06a76143075108631c25/packages/gatsby/scripts/prepack.ts#L1) - as an example.\ - It’s recommended to build and pack a tarball and then `yarn add path/to/tarball.tar.gz` it to your test app(s) + - [ ] Any additional files that should be part of the tarball + - [ ] It’s recommended to build and pack a tarball and then `yarn add path/to/tarball.tar.gz` it to your test app(s) to ensure that it has all the correct files. - [ ] Make sure `build.yml` CI script is correctly set up to cover tests for the new package diff --git a/packages/angular/ng-package.json b/packages/angular/ng-package.json index 64304f12de15..0bbbbdcdef14 100644 --- a/packages/angular/ng-package.json +++ b/packages/angular/ng-package.json @@ -5,5 +5,5 @@ "entryFile": "src/index.ts" }, "allowedNonPeerDependencies": ["@sentry/browser", "@sentry/core", "@sentry/utils", "@sentry/types", "tslib"], - "assets": ["README.md", "LICENSE"] + "assets": [] } diff --git a/packages/angular/package.json b/packages/angular/package.json index c1cd1d9e8a92..8a6453ca6cca 100644 --- a/packages/angular/package.json +++ b/packages/angular/package.json @@ -57,7 +57,7 @@ "test": "yarn test:unit", "test:unit": "vitest run", "test:unit:watch": "vitest --watch", - "yalc:publish": "yalc publish build --push --sig" + "yalc:publish": "yalc publish --push --sig" }, "volta": { "extends": "../../package.json" @@ -73,8 +73,8 @@ "outputs": [ "{projectRoot}/build/esm2015", "{projectRoot}/build/fesm2015", - "{projectRoot}/build/*.{md,json}", - "{projectRoot}/build/LICENCE" + "{projectRoot}/build/fesm2020", + "{projectRoot}/build/*.d.ts" ] } } diff --git a/packages/astro/package.json b/packages/astro/package.json index 32bdef57bdba..6c6edb7ea39f 100644 --- a/packages/astro/package.json +++ b/packages/astro/package.json @@ -18,12 +18,7 @@ }, "type": "module", "files": [ - "cjs", - "esm", - "types", - "types-ts3.8", - "import-hook.mjs", - "loader-hook.mjs" + "/build" ], "main": "build/cjs/index.client.js", "module": "build/esm/index.server.js", @@ -81,7 +76,7 @@ "build:dev:watch": "yarn build:watch", "build:transpile:watch": "rollup -c rollup.npm.config.mjs --watch", "build:types:watch": "tsc -p tsconfig.types.json --watch", - "build:tarball": "ts-node ../../scripts/prepack.ts && npm pack ./build", + "build:tarball": "npm pack", "circularDepCheck": "madge --circular src/index.client.ts && madge --circular src/index.server.ts && madge --circular src/index.types.ts", "clean": "rimraf build coverage sentry-astro-*.tgz", "fix": "eslint . --format stylish --fix", @@ -89,7 +84,7 @@ "test": "yarn test:unit", "test:unit": "vitest run", "test:watch": "vitest --watch", - "yalc:publish": "ts-node ../../scripts/prepack.ts && yalc publish build --push --sig" + "yalc:publish": "yalc publish --push --sig" }, "volta": { "extends": "../../package.json" diff --git a/packages/aws-serverless/package.json b/packages/aws-serverless/package.json index db5bf42fbd6b..4d864b0f6b54 100644 --- a/packages/aws-serverless/package.json +++ b/packages/aws-serverless/package.json @@ -10,12 +10,9 @@ "node": ">=14.18" }, "files": [ - "cjs", - "esm", - "types", - "types-ts3.8", - "import-hook.mjs", - "loader-hook.mjs" + "/build/npm", + "/build/import-hook.mjs", + "/build/loader-hook.mjs" ], "main": "build/npm/cjs/index.js", "types": "build/npm/types/index.d.ts", @@ -88,14 +85,14 @@ "build:dev:watch": "yarn build:watch", "build:transpile:watch": "rollup -c rollup.npm.config.mjs --watch", "build:types:watch": "tsc -p tsconfig.types.json --watch", - "build:tarball": "ts-node ../../scripts/prepack.ts --bundles && npm pack ./build/npm", + "build:tarball": "npm pack", "circularDepCheck": "madge --circular src/index.ts", "clean": "rimraf build dist-awslambda-layer coverage sentry-serverless-*.tgz", "fix": "eslint . --format stylish --fix", "lint": "eslint . --format stylish", "test": "jest", "test:watch": "jest --watch", - "yalc:publish": "ts-node ../../scripts/prepack.ts --bundles && yalc publish ./build/npm --push --sig" + "yalc:publish": "yalc publish --push --sig" }, "volta": { "extends": "../../package.json" diff --git a/packages/browser-utils/package.json b/packages/browser-utils/package.json index a73e87b2477d..53a5a765874c 100644 --- a/packages/browser-utils/package.json +++ b/packages/browser-utils/package.json @@ -10,10 +10,7 @@ "node": ">=14.18" }, "files": [ - "cjs", - "esm", - "types", - "types-ts3.8" + "/build" ], "main": "build/cjs/index.js", "module": "build/esm/index.js", @@ -57,14 +54,14 @@ "build:dev:watch": "run-p build:transpile:watch build:types:watch", "build:transpile:watch": "rollup -c rollup.npm.config.mjs --watch", "build:types:watch": "tsc -p tsconfig.types.json --watch", - "build:tarball": "ts-node ../../scripts/prepack.ts && npm pack ./build", + "build:tarball": "npm pack", "clean": "rimraf build coverage sentry-internal-browser-utils-*.tgz", "fix": "eslint . --format stylish --fix", "lint": "eslint . --format stylish", "test:unit": "jest", "test": "jest", "test:watch": "jest --watch", - "yalc:publish": "ts-node ../../scripts/prepack.ts && yalc publish build --push --sig" + "yalc:publish": "yalc publish --push --sig" }, "volta": { "extends": "../../package.json" diff --git a/packages/browser/package.json b/packages/browser/package.json index 55cc3144a723..0e5a21767baa 100644 --- a/packages/browser/package.json +++ b/packages/browser/package.json @@ -10,10 +10,7 @@ "node": ">=14.18" }, "files": [ - "cjs", - "esm", - "types", - "types-ts3.8" + "/build/npm" ], "main": "build/npm/cjs/index.js", "module": "build/npm/esm/index.js", @@ -68,7 +65,7 @@ "build:bundle:watch": "rollup -c rollup.bundle.config.mjs --watch", "build:transpile:watch": "rollup -c rollup.npm.config.mjs --watch", "build:types:watch": "tsc -p tsconfig.types.json --watch", - "build:tarball": "ts-node ../../scripts/prepack.ts --bundles && npm pack ./build/npm", + "build:tarball": "npm pack", "circularDepCheck": "madge --circular src/index.ts", "clean": "rimraf build coverage .rpt2_cache sentry-browser-*.tgz", "fix": "eslint . --format stylish --fix", @@ -78,7 +75,7 @@ "test:unit": "jest", "test:package": "node test/package/npm-build.js && rm test/package/tmp.js", "test:unit:watch": "jest --watch", - "yalc:publish": "ts-node ../../scripts/prepack.ts --bundles && yalc publish ./build/npm --push --sig" + "yalc:publish": "yalc publish --push --sig" }, "volta": { "extends": "../../package.json" diff --git a/packages/bun/package.json b/packages/bun/package.json index 295faadd6511..ba0e6205845c 100644 --- a/packages/bun/package.json +++ b/packages/bun/package.json @@ -10,10 +10,7 @@ "node": ">=14.18" }, "files": [ - "cjs", - "esm", - "types", - "types-ts3.8" + "/build" ], "main": "build/cjs/index.js", "module": "build/esm/index.js", @@ -62,7 +59,7 @@ "build:dev:watch": "yarn build:watch", "build:transpile:watch": "rollup -c rollup.npm.config.mjs --watch", "build:types:watch": "tsc -p tsconfig.types.json --watch", - "build:tarball": "ts-node ../../scripts/prepack.ts && npm pack ./build", + "build:tarball": "npm pack", "circularDepCheck": "madge --circular src/index.ts", "clean": "rimraf build coverage sentry-bun-*.tgz", "fix": "eslint . --format stylish --fix", @@ -71,7 +68,7 @@ "test": "run-s install:bun test:bun", "test:bun": "bun test", "test:watch": "bun test --watch", - "yalc:publish": "ts-node ../../scripts/prepack.ts && yalc publish build --push --sig" + "yalc:publish": "yalc publish --push --sig" }, "volta": { "extends": "../../package.json" diff --git a/packages/core/package.json b/packages/core/package.json index 432aaeb7b62d..f549088161b8 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -10,10 +10,7 @@ "node": ">=14.18" }, "files": [ - "cjs", - "esm", - "types", - "types-ts3.8" + "/build" ], "main": "build/cjs/index.js", "module": "build/esm/index.js", @@ -56,14 +53,14 @@ "build:dev:watch": "yarn build:watch", "build:transpile:watch": "rollup -c rollup.npm.config.mjs --watch", "build:types:watch": "tsc -p tsconfig.types.json --watch", - "build:tarball": "ts-node ../../scripts/prepack.ts && npm pack ./build", + "build:tarball": "npm pack", "circularDepCheck": "madge --circular src/index.ts", "clean": "rimraf build coverage sentry-core-*.tgz", "fix": "eslint . --format stylish --fix", "lint": "eslint . --format stylish", "test": "jest", "test:watch": "jest --watch", - "yalc:publish": "ts-node ../../scripts/prepack.ts && yalc publish build --push --sig" + "yalc:publish": "yalc publish --push --sig" }, "volta": { "extends": "../../package.json" diff --git a/packages/deno/package.json b/packages/deno/package.json index 111682c9925d..eefb8ea4d340 100644 --- a/packages/deno/package.json +++ b/packages/deno/package.json @@ -21,9 +21,7 @@ "access": "public" }, "files": [ - "index.mjs", - "index.mjs.map", - "index.d.ts" + "/build" ], "dependencies": { "@sentry/core": "8.12.0", @@ -43,7 +41,7 @@ "build:types": "run-s deno-types build:types:tsc build:types:bundle", "build:types:tsc": "tsc -p tsconfig.types.json", "build:types:bundle": "rollup -c rollup.types.config.mjs", - "build:tarball": "ts-node ../../scripts/prepack.ts && npm pack ./build", + "build:tarball": "npm pack", "circularDepCheck": "madge --circular src/index.ts", "clean": "rimraf build build-types build-test coverage", "prefix": "yarn deno-types", @@ -57,7 +55,7 @@ "test:types": "deno check ./build/index.mjs", "test:unit": "deno test --allow-read --allow-run", "test:unit:update": "deno test --allow-read --allow-write --allow-run -- --update", - "yalc:publish": "ts-node ../../scripts/prepack.ts && yalc publish build --push --sig" + "yalc:publish": "yalc publish --push --sig" }, "volta": { "extends": "../../package.json" diff --git a/packages/eslint-config-sdk/package.json b/packages/eslint-config-sdk/package.json index 180827521667..de7380692e5b 100644 --- a/packages/eslint-config-sdk/package.json +++ b/packages/eslint-config-sdk/package.json @@ -15,7 +15,7 @@ "node": ">=14.18" }, "files": [ - "src" + "/src" ], "main": "src/index.js", "publishConfig": { diff --git a/packages/eslint-plugin-sdk/package.json b/packages/eslint-plugin-sdk/package.json index a72a3c3a0d15..d96ece7a35b1 100644 --- a/packages/eslint-plugin-sdk/package.json +++ b/packages/eslint-plugin-sdk/package.json @@ -15,7 +15,7 @@ "node": ">=14.18" }, "files": [ - "src" + "/src" ], "main": "src/index.js", "publishConfig": { diff --git a/packages/feedback/package.json b/packages/feedback/package.json index 7f3898f59f99..bcd5b2a69cd8 100644 --- a/packages/feedback/package.json +++ b/packages/feedback/package.json @@ -10,10 +10,7 @@ "node": ">=14.18" }, "files": [ - "cjs", - "esm", - "types", - "types-ts3.8" + "/build/npm" ], "main": "build/npm/cjs/index.js", "module": "build/npm/esm/index.js", @@ -62,14 +59,14 @@ "build:transpile:watch": "yarn build:transpile --watch", "build:bundle:watch": "yarn build:bundle --watch", "build:types:watch": "tsc -p tsconfig.types.json --watch", - "build:tarball": "ts-node ../../scripts/prepack.ts --bundles && npm pack ./build/npm", + "build:tarball": "npm pack", "circularDepCheck": "madge --circular src/index.ts", "clean": "rimraf build sentry-internal-feedback-*.tgz", "fix": "eslint . --format stylish --fix", "lint": "eslint . --format stylish", "test": "jest", "test:watch": "jest --watch", - "yalc:publish": "ts-node ../../scripts/prepack.ts --bundles && yalc publish ./build/npm --push --sig" + "yalc:publish": "yalc publish --push --sig" }, "volta": { "extends": "../../package.json" diff --git a/packages/gatsby/package.json b/packages/gatsby/package.json index 446459d9a591..237397ed8eb6 100644 --- a/packages/gatsby/package.json +++ b/packages/gatsby/package.json @@ -14,10 +14,7 @@ "node": ">=14.18" }, "files": [ - "cjs", - "esm", - "types", - "types-ts3.8", + "/build", "gatsby-node.js", "gatsby-node.d.ts" ], @@ -75,14 +72,14 @@ "build:dev:watch": "yarn build:watch", "build:transpile:watch": "rollup -c rollup.npm.config.mjs --watch", "build:types:watch": "tsc -p tsconfig.types.json --watch", - "build:tarball": "ts-node ../../scripts/prepack.ts && npm pack ./build", + "build:tarball": "npm pack", "circularDepCheck": "madge --circular src/index.ts", "clean": "rimraf build coverage *.d.ts sentry-gatsby-*.tgz", "fix": "eslint . --format stylish --fix", "lint": "eslint . --format stylish", "test": "yarn ts-node scripts/pretest.ts && yarn jest", "test:watch": "yarn ts-node scripts/pretest.ts && yarn jest --watch", - "yalc:publish": "ts-node ../../scripts/prepack.ts && yalc publish build --push --sig" + "yalc:publish": "yalc publish --push --sig" }, "volta": { "extends": "../../package.json" diff --git a/packages/gatsby/scripts/prepack.ts b/packages/gatsby/scripts/prepack.ts deleted file mode 100644 index f6bf056fcfa3..000000000000 --- a/packages/gatsby/scripts/prepack.ts +++ /dev/null @@ -1,32 +0,0 @@ -/* eslint-disable no-console */ - -// DO NOT RUN this script yourself! -// This is invoked from the main `prepack.ts` script in `sentry-javascript/scripts/prepack.ts`. - -import * as fs from 'fs'; -import * as path from 'path'; - -const PACKAGE_ASSETS = ['gatsby-node.js', 'gatsby-node.d.ts']; - -export function prepack(buildDir: string): boolean { - // copy package-specific assets to build dir - return PACKAGE_ASSETS.every(asset => { - const assetPath = path.resolve(asset); - const destinationPath = path.resolve(buildDir, asset); - try { - if (!fs.existsSync(assetPath)) { - console.error(`\nERROR: Asset '${asset}' does not exist.`); - return false; - } - console.log(`Copying ${path.basename(asset)} to ${path.relative('../..', destinationPath)}.`); - fs.copyFileSync(assetPath, destinationPath); - } catch (error) { - console.error( - `\nERROR: Error while copying ${path.basename(asset)} to ${path.relative('../..', destinationPath)}:\n`, - error, - ); - return false; - } - return true; - }); -} diff --git a/packages/google-cloud-serverless/package.json b/packages/google-cloud-serverless/package.json index b0c2fab0ce82..9bb4376fd11b 100644 --- a/packages/google-cloud-serverless/package.json +++ b/packages/google-cloud-serverless/package.json @@ -10,12 +10,7 @@ "node": ">=14.18" }, "files": [ - "cjs", - "esm", - "types", - "types-ts3.8", - "import-hook.mjs", - "loader-hook.mjs" + "/build" ], "main": "build/cjs/index.js", "types": "build/types/index.d.ts", @@ -79,14 +74,14 @@ "build:dev:watch": "yarn build:watch", "build:transpile:watch": "rollup -c rollup.npm.config.mjs --watch", "build:types:watch": "tsc -p tsconfig.types.json --watch", - "build:tarball": "ts-node ../../scripts/prepack.ts && npm pack ./build", + "build:tarball": "npm pack", "circularDepCheck": "madge --circular src/index.ts", "clean": "rimraf build coverage sentry-google-cloud-*.tgz", "fix": "eslint . --format stylish --fix", "lint": "eslint . --format stylish", "test": "jest", "test:watch": "jest --watch", - "yalc:publish": "ts-node ../../scripts/prepack.ts && yalc publish build --push --sig" + "yalc:publish": "yalc publish --push --sig" }, "volta": { "extends": "../../package.json" diff --git a/packages/integration-shims/package.json b/packages/integration-shims/package.json index 00711c4a21bc..15024e78660e 100644 --- a/packages/integration-shims/package.json +++ b/packages/integration-shims/package.json @@ -5,6 +5,9 @@ "main": "build/cjs/index.js", "module": "build/esm/index.js", "types": "build/types/index.d.ts", + "files": [ + "/build" + ], "exports": { "./package.json": "./package.json", ".": { diff --git a/packages/nestjs/package.json b/packages/nestjs/package.json index c51263c1fc2a..50fc6b8180a3 100644 --- a/packages/nestjs/package.json +++ b/packages/nestjs/package.json @@ -10,9 +10,7 @@ "node": ">=16" }, "files": [ - "/build", - "LICENSE", - "README.md" + "/build" ], "main": "build/cjs/nestjs/index.js", "module": "build/esm/nestjs/index.js", diff --git a/packages/nextjs/package.json b/packages/nextjs/package.json index 4384a29c2c61..5a67fc8658fa 100644 --- a/packages/nextjs/package.json +++ b/packages/nextjs/package.json @@ -12,6 +12,9 @@ "main": "build/cjs/index.server.js", "module": "build/esm/index.server.js", "types": "build/types/index.types.d.ts", + "files": [ + "/build" + ], "exports": { "./package.json": "./package.json", ".": { @@ -106,7 +109,7 @@ "build:dev:watch": "yarn build:watch", "build:transpile:watch": "nodemon --ext ts --watch src scripts/buildRollup.ts", "build:types:watch": "tsc -p tsconfig.types.json --watch", - "build:tarball": "ts-node ../../scripts/prepack.ts && npm pack ./build", + "build:tarball": "npm pack", "circularDepCheck": "madge --circular src/index.client.ts && madge --circular src/edge/index.ts && madge --circular src/index.server.ts && madge --circular src/index.types.ts", "clean": "rimraf build coverage sentry-nextjs-*.tgz", "fix": "eslint . --format stylish --fix", @@ -122,7 +125,7 @@ "test:watch": "jest --watch", "vercel:branch": "source vercel/set-up-branch-for-test-app-use.sh", "vercel:project": "source vercel/make-project-use-current-branch.sh", - "yalc:publish": "ts-node ../../scripts/prepack.ts && yalc publish build --push --sig" + "yalc:publish": "yalc publish --push --sig" }, "volta": { "extends": "../../package.json" diff --git a/packages/node/package.json b/packages/node/package.json index c77ec40ff4f9..b576dd2b32e2 100644 --- a/packages/node/package.json +++ b/packages/node/package.json @@ -10,12 +10,7 @@ "node": ">=14.18" }, "files": [ - "cjs", - "esm", - "types", - "types-ts3.8", - "import-hook.mjs", - "loader-hook.mjs" + "/build" ], "main": "build/cjs/index.js", "module": "build/esm/index.js", @@ -115,7 +110,7 @@ "build:dev:watch": "yarn build:watch", "build:transpile:watch": "rollup -c rollup.npm.config.mjs --watch", "build:types:watch": "tsc -p tsconfig.types.json --watch", - "build:tarball": "ts-node ../../scripts/prepack.ts && npm pack ./build", + "build:tarball": "npm pack", "circularDepCheck": "madge --circular src/index.ts", "clean": "rimraf build coverage sentry-node-*.tgz", "fix": "eslint . --format stylish --fix", @@ -123,7 +118,7 @@ "test": "yarn test:jest", "test:jest": "jest", "test:watch": "jest --watch", - "yalc:publish": "ts-node ../../scripts/prepack.ts && yalc publish build --push --sig" + "yalc:publish": "yalc publish --push --sig" }, "volta": { "extends": "../../package.json" diff --git a/packages/node/src/proxy/base.ts b/packages/node/src/proxy/base.ts index 4787538c17bb..6e374160b16a 100644 --- a/packages/node/src/proxy/base.ts +++ b/packages/node/src/proxy/base.ts @@ -1,6 +1,6 @@ /** * This code was originally forked from https://github.com/TooTallNate/proxy-agents/tree/b133295fd16f6475578b6b15bd9b4e33ecb0d0b7 - * With the following licence: + * With the following LICENSE: * * (The MIT License) * diff --git a/packages/node/src/proxy/helpers.ts b/packages/node/src/proxy/helpers.ts index cb9a37b13305..4a131c47b4ac 100644 --- a/packages/node/src/proxy/helpers.ts +++ b/packages/node/src/proxy/helpers.ts @@ -1,6 +1,6 @@ /** * This code was originally forked from https://github.com/TooTallNate/proxy-agents/tree/b133295fd16f6475578b6b15bd9b4e33ecb0d0b7 - * With the following licence: + * With the following LICENSE: * * (The MIT License) * diff --git a/packages/node/src/proxy/index.ts b/packages/node/src/proxy/index.ts index 07674895379e..b5e289729607 100644 --- a/packages/node/src/proxy/index.ts +++ b/packages/node/src/proxy/index.ts @@ -1,6 +1,6 @@ /** * This code was originally forked from https://github.com/TooTallNate/proxy-agents/tree/b133295fd16f6475578b6b15bd9b4e33ecb0d0b7 - * With the following licence: + * With the following LICENSE: * * (The MIT License) * diff --git a/packages/node/src/proxy/parse-proxy-response.ts b/packages/node/src/proxy/parse-proxy-response.ts index da29fa52c747..f1878a4e377b 100644 --- a/packages/node/src/proxy/parse-proxy-response.ts +++ b/packages/node/src/proxy/parse-proxy-response.ts @@ -1,6 +1,6 @@ /** * This code was originally forked from https://github.com/TooTallNate/proxy-agents/tree/b133295fd16f6475578b6b15bd9b4e33ecb0d0b7 - * With the following licence: + * With the following LICENSE: * * (The MIT License) * diff --git a/packages/nuxt/package.json b/packages/nuxt/package.json index a381f22d1583..99dc76cd8f87 100644 --- a/packages/nuxt/package.json +++ b/packages/nuxt/package.json @@ -10,7 +10,7 @@ "node": ">=16" }, "files": [ - "build" + "/build" ], "main": "build/module.cjs", "module": "build/module.mjs", @@ -51,7 +51,7 @@ "build:dev:watch": "yarn build:watch", "build:transpile:watch": "nuxt-module-build build --outDir build --watch", "build:types:watch": "tsc -p tsconfig.types.json --watch", - "build:tarball": "ts-node ../../scripts/prepack.ts && npm pack ./build", + "build:tarball": "npm pack", "circularDepCheck": "madge --circular src/index.client.ts && madge --circular src/index.server.ts && madge --circular src/index.types.ts", "clean": "rimraf build coverage sentry-nuxt-*.tgz", "fix": "eslint . --format stylish --fix", @@ -59,7 +59,7 @@ "test": "yarn test:unit", "test:unit": "vitest run", "test:watch": "vitest --watch", - "yalc:publish": "ts-node ../../scripts/prepack.ts && yalc publish build --push --sig" + "yalc:publish": "yalc publish --push --sig" }, "volta": { "extends": "../../package.json" diff --git a/packages/opentelemetry/package.json b/packages/opentelemetry/package.json index 96649fe3a051..83fd1b81267d 100644 --- a/packages/opentelemetry/package.json +++ b/packages/opentelemetry/package.json @@ -10,10 +10,7 @@ "node": ">=14.18" }, "files": [ - "cjs", - "esm", - "types", - "types-ts3.8" + "/build" ], "main": "build/cjs/index.js", "module": "build/esm/index.js", @@ -71,7 +68,7 @@ "build:dev:watch": "yarn build:watch", "build:transpile:watch": "rollup -c rollup.npm.config.mjs --watch", "build:types:watch": "tsc -p tsconfig.types.json --watch", - "build:tarball": "ts-node ../../scripts/prepack.ts && npm pack ./build", + "build:tarball": "npm pack", "circularDepCheck": "madge --circular src/index.ts", "clean": "rimraf build coverage sentry-opentelemetry-*.tgz", "fix": "eslint . --format stylish --fix", @@ -79,7 +76,7 @@ "test": "yarn test:jest", "test:jest": "jest", "test:watch": "jest --watch", - "yalc:publish": "ts-node ../../scripts/prepack.ts && yalc publish build --push --sig" + "yalc:publish": "yalc publish --push --sig" }, "volta": { "extends": "../../package.json" diff --git a/packages/profiling-node/package.json b/packages/profiling-node/package.json index 5eebb18947e0..b24316abffb8 100644 --- a/packages/profiling-node/package.json +++ b/packages/profiling-node/package.json @@ -38,16 +38,14 @@ "access": "public" }, "files": [ - "lib", - "bindings", - "binding.gyp", - "LICENSE", - "README.md", + "/lib", + "/bindings", + "/binding.gyp", "package.json", - "scripts/binaries.js", - "scripts/check-build.js", - "scripts/copy-target.js", - "scripts/prune-profiler-binaries.js" + "/scripts/binaries.js", + "/scripts/check-build.js", + "/scripts/copy-target.js", + "/scripts/prune-profiler-binaries.js" ], "scripts": { "install": "node scripts/check-build.js", diff --git a/packages/react/package.json b/packages/react/package.json index ae39ffe95c10..14b0d5940b58 100644 --- a/packages/react/package.json +++ b/packages/react/package.json @@ -10,10 +10,7 @@ "node": ">=14.18" }, "files": [ - "cjs", - "esm", - "types", - "types-ts3.8" + "/build" ], "main": "build/cjs/index.js", "module": "build/esm/index.js", @@ -87,14 +84,14 @@ "build:dev:watch": "yarn build:watch", "build:transpile:watch": "rollup -c rollup.npm.config.mjs --watch", "build:types:watch": "tsc -p tsconfig.types.json --watch", - "build:tarball": "ts-node ../../scripts/prepack.ts && npm pack ./build", + "build:tarball": "npm pack", "circularDepCheck": "madge --circular src/index.ts", "clean": "rimraf build coverage sentry-react-*.tgz", "fix": "eslint . --format stylish --fix", "lint": "eslint . --format stylish", "test": "jest", "test:watch": "jest --watch", - "yalc:publish": "ts-node ../../scripts/prepack.ts && yalc publish build --push --sig" + "yalc:publish": "yalc publish --push --sig" }, "volta": { "extends": "../../package.json" diff --git a/packages/remix/package.json b/packages/remix/package.json index f824d622c984..5609be867958 100644 --- a/packages/remix/package.json +++ b/packages/remix/package.json @@ -13,13 +13,8 @@ "node": ">=14.18" }, "files": [ - "cjs", - "esm", - "types", - "types-ts3.8", - "scripts", - "import-hook.mjs", - "loader-hook.mjs" + "/build", + "/scripts" ], "main": "build/cjs/index.server.js", "module": "build/esm/index.server.js", @@ -93,7 +88,7 @@ "build:dev:watch": "yarn build:watch", "build:transpile:watch": "rollup -c rollup.npm.config.mjs --watch", "build:types:watch": "tsc -p tsconfig.types.json --watch", - "build:tarball": "ts-node ../../scripts/prepack.ts && npm pack ./build", + "build:tarball": "npm pack", "circularDepCheck": "madge --circular src/index.server.ts", "clean": "rimraf build coverage sentry-remix-*.tgz", "fix": "eslint . --format stylish --fix", @@ -112,7 +107,7 @@ "test:integration:server": "export NODE_OPTIONS='--stack-trace-limit=25' && vitest run", "test:unit": "jest", "test:watch": "jest --watch", - "yalc:publish": "ts-node ../../scripts/prepack.ts && yalc publish build --push --sig" + "yalc:publish": "yalc publish --push --sig" }, "volta": { "extends": "../../package.json" diff --git a/packages/remix/scripts/prepack.ts b/packages/remix/scripts/prepack.ts deleted file mode 100644 index bd32f6fe094e..000000000000 --- a/packages/remix/scripts/prepack.ts +++ /dev/null @@ -1,39 +0,0 @@ -/* eslint-disable no-console */ - -import * as fs from 'fs'; -import * as path from 'path'; - -const PACKAGE_ASSETS = [ - 'scripts/sentry-upload-sourcemaps.js', - 'scripts/createRelease.js', - 'scripts/deleteSourcemaps.js', - 'scripts/injectDebugId.js', -]; - -export function prepack(buildDir: string): boolean { - // copy package-specific assets to build dir - return PACKAGE_ASSETS.every(asset => { - const assetPath = path.resolve(asset); - const destinationPath = path.resolve(buildDir, asset); - try { - if (!fs.existsSync(assetPath)) { - console.error(`\nERROR: Asset '${asset}' does not exist.`); - return false; - } - const scriptsDir = path.resolve(buildDir, 'scripts'); - if (!fs.existsSync(scriptsDir)) { - console.log('Creating missing directory', scriptsDir); - fs.mkdirSync(scriptsDir); - } - console.log(`Copying ${path.basename(asset)} to ${path.relative('../..', destinationPath)}.`); - fs.copyFileSync(assetPath, destinationPath); - } catch (error) { - console.error( - `\nERROR: Error while copying ${path.basename(asset)} to ${path.relative('../..', destinationPath)}:\n`, - error, - ); - return false; - } - return true; - }); -} diff --git a/packages/replay-canvas/package.json b/packages/replay-canvas/package.json index 3cbe1f4c84cd..cc36812fdb84 100644 --- a/packages/replay-canvas/package.json +++ b/packages/replay-canvas/package.json @@ -26,10 +26,7 @@ } }, "files": [ - "cjs", - "esm", - "types", - "types-ts3.8" + "/build/npm" ], "sideEffects": false, "scripts": { @@ -45,14 +42,14 @@ "build:transpile:watch": "yarn build:transpile --watch", "build:bundle:watch": "yarn build:bundle --watch", "build:types:watch": "tsc -p tsconfig.types.json --watch", - "build:tarball": "ts-node ../../scripts/prepack.ts --bundles && npm pack ./build/npm", + "build:tarball": "npm pack", "circularDepCheck": "madge --circular src/index.ts", "clean": "rimraf build sentry-replay-*.tgz", "fix": "eslint . --format stylish --fix", "lint": "eslint . --format stylish", "test": "jest", "test:watch": "jest --watch", - "yalc:publish": "ts-node ../../scripts/prepack.ts --bundles && yalc publish ./build/npm --push --sig" + "yalc:publish": "yalc publish --push --sig" }, "publishConfig": { "access": "public" diff --git a/packages/replay-internal/package.json b/packages/replay-internal/package.json index eb00efc66b9b..fee3439777c5 100644 --- a/packages/replay-internal/package.json +++ b/packages/replay-internal/package.json @@ -26,10 +26,7 @@ } }, "files": [ - "cjs", - "esm", - "types", - "types-ts3.8" + "/build/npm" ], "sideEffects": false, "publishConfig": { @@ -48,7 +45,7 @@ "build:transpile:watch": "yarn build:transpile --watch", "build:bundle:watch": "yarn build:bundle --watch", "build:types:watch": "tsc -p tsconfig.types.json --watch", - "build:tarball": "ts-node ../../scripts/prepack.ts --bundles && npm pack ./build/npm", + "build:tarball": "npm pack", "circularDepCheck": "madge --circular src/index.ts", "clean": "rimraf build sentry-replay-*.tgz", "fix": "run-s fix:biome fix:eslint", @@ -57,7 +54,7 @@ "lint": "eslint . --format stylish", "test": "vitest", "test:watch": "vitest --watch", - "yalc:publish": "ts-node ../../scripts/prepack.ts --bundles && yalc publish ./build/npm --push --sig" + "yalc:publish": "yalc publish --push --sig" }, "repository": { "type": "git", diff --git a/packages/replay-worker/package.json b/packages/replay-worker/package.json index 755353814e2d..367d007dcd04 100644 --- a/packages/replay-worker/package.json +++ b/packages/replay-worker/package.json @@ -2,21 +2,18 @@ "name": "@sentry-internal/replay-worker", "version": "8.12.0", "description": "Worker for @sentry-internal/replay", - "main": "build/npm/esm/index.js", - "module": "build/npm/esm/index.js", - "types": "build/npm/types/index.d.ts", + "main": "build/esm/index.js", + "module": "build/esm/index.js", + "types": "build/types/index.d.ts", "typesVersions": { "<4.9": { - "build/npm/types/index.d.ts": [ - "build/npm/types-ts3.8/index.d.ts" + "build/types/index.d.ts": [ + "build/types-ts3.8/index.d.ts" ] } }, "files": [ - "cjs", - "esm", - "types", - "types-ts3.8" + "/build" ], "sideEffects": false, "private": true, @@ -26,7 +23,7 @@ "build:examples": "rollup -c rollup.examples.config.mjs", "build:types": "run-s build:types:core build:types:downlevel", "build:types:core": "tsc -p tsconfig.types.json", - "build:types:downlevel": "yarn downlevel-dts build/npm/types build/npm/types-ts3.8 --to ts3.8", + "build:types:downlevel": "yarn downlevel-dts build/types build/types-ts3.8 --to ts3.8", "build:dev": "yarn build", "build:watch": "run-p build:transpile:watch build:types:watch", "build:dev:watch": "yarn build:watch", diff --git a/packages/replay-worker/rollup.worker.config.mjs b/packages/replay-worker/rollup.worker.config.mjs index 48d3f5d41080..fd22c54298dc 100644 --- a/packages/replay-worker/rollup.worker.config.mjs +++ b/packages/replay-worker/rollup.worker.config.mjs @@ -11,7 +11,7 @@ const config = defineConfig([ input: ['./src/index.ts'], treeshake: 'smallest', output: { - dir: './build/npm/esm', + dir: './build/esm', format: 'esm', }, external: ['./worker'], @@ -27,7 +27,7 @@ const config = defineConfig([ { input: ['./src/_worker.ts'], output: { - file: './build/npm/esm/worker.ts', + file: './build/esm/worker.ts', format: 'esm', }, treeshake: 'smallest', diff --git a/packages/replay-worker/tsconfig.types.json b/packages/replay-worker/tsconfig.types.json index 58b6f60a32b1..1a83cadfebcd 100644 --- a/packages/replay-worker/tsconfig.types.json +++ b/packages/replay-worker/tsconfig.types.json @@ -5,6 +5,6 @@ "declaration": true, "declarationMap": true, "emitDeclarationOnly": true, - "outDir": "build/npm/types" + "outDir": "build/types" } } diff --git a/packages/solid/.eslintignore b/packages/solid/.eslintignore new file mode 100644 index 000000000000..3e89751310a5 --- /dev/null +++ b/packages/solid/.eslintignore @@ -0,0 +1,2 @@ +/*.d.ts +/*.d.ts.map diff --git a/packages/solid/.gitignore b/packages/solid/.gitignore new file mode 100644 index 000000000000..3e89751310a5 --- /dev/null +++ b/packages/solid/.gitignore @@ -0,0 +1,2 @@ +/*.d.ts +/*.d.ts.map diff --git a/packages/solid/package.json b/packages/solid/package.json index b7e713ce2c61..8822467e4fdf 100644 --- a/packages/solid/package.json +++ b/packages/solid/package.json @@ -10,35 +10,32 @@ "node": ">=14.18" }, "files": [ - "cjs", - "esm", - "index.d.ts", - "index.d.ts.map", - "solidrouter.d.ts", - "solidrouter.d.ts.map" + "/build", + "/*.d.ts", + "/*.d.ts.map" ], "main": "build/cjs/index.js", "module": "build/esm/index.js", - "types": "build/index.d.ts", + "types": "build/types/index.d.ts", "exports": { "./package.json": "./package.json", ".": { "import": { - "types": "./build/index.d.ts", + "types": "./build/types/index.d.ts", "default": "./build/esm/index.js" }, "require": { - "types": "./build/index.d.ts", + "types": "./build/types/index.d.ts", "default": "./build/cjs/index.js" } }, "./solidrouter": { "import": { - "types": "./build/solidrouter.d.ts", + "types": "./solidrouter.d.ts", "default": "./build/esm/solidrouter.js" }, "require": { - "types": "./build/solidrouter.d.ts", + "types": "./solidrouter.d.ts", "default": "./build/cjs/solidrouter.js" } } @@ -73,23 +70,35 @@ "build": "run-p build:transpile build:types", "build:dev": "yarn build", "build:transpile": "rollup -c rollup.npm.config.mjs", - "build:types": "run-s build:types:core", + "build:types": "run-s build:types:core build:types:solidrouter", "build:types:core": "tsc -p tsconfig.types.json", + "build:types:solidrouter": "tsc -p tsconfig.solidrouter-types.json", "build:watch": "run-p build:transpile:watch build:types:watch", "build:dev:watch": "yarn build:watch", "build:transpile:watch": "rollup -c rollup.npm.config.mjs --watch", "build:types:watch": "tsc -p tsconfig.types.json --watch", - "build:tarball": "ts-node ../../scripts/prepack.ts && npm pack ./build", + "build:tarball": "npm pack", "circularDepCheck": "madge --circular src/index.ts", - "clean": "rimraf build coverage sentry-solid-*.tgz", + "clean": "rimraf build coverage sentry-solid-*.tgz ./*.d.ts ./*.d.ts.map", "fix": "eslint . --format stylish --fix", "lint": "eslint . --format stylish", "test": "vitest run", "test:watch": "vitest --watch", - "yalc:publish": "ts-node ../../scripts/prepack.ts && yalc publish build --push --sig" + "yalc:publish": "yalc publish --push --sig" }, "volta": { "extends": "../../package.json" }, + "nx": { + "targets": { + "build:types": { + "outputs": [ + "{projectRoot}/build/types", + "{projectRoot}/*.d.ts", + "{projectRoot}/*.d.ts.map" + ] + } + } + }, "sideEffects": false } diff --git a/packages/solid/tsconfig.solidrouter-types.json b/packages/solid/tsconfig.solidrouter-types.json new file mode 100644 index 000000000000..055ad82a187a --- /dev/null +++ b/packages/solid/tsconfig.solidrouter-types.json @@ -0,0 +1,15 @@ +{ + "extends": "./tsconfig.json", + + "compilerOptions": { + "declaration": true, + "declarationMap": true, + "emitDeclarationOnly": true, + "outDir": "./" + }, + + "//": "This type is built separately because it is for a subpath export, which has problems if it is not in the root", + "include": ["src/solidrouter.ts"], + "//": "Without this, we cannot output into the root dir", + "exclude": [] +} diff --git a/packages/solid/tsconfig.types.json b/packages/solid/tsconfig.types.json index 49a8c984fcc6..fa96a3ccc08b 100644 --- a/packages/solid/tsconfig.types.json +++ b/packages/solid/tsconfig.types.json @@ -5,6 +5,9 @@ "declaration": true, "declarationMap": true, "emitDeclarationOnly": true, - "outDir": "build" - } + "outDir": "build/types" + }, + + "//": "This is built separately in tsconfig.solidrouter-types.json", + "exclude": ["src/solidrouter.ts"] } diff --git a/packages/svelte/package.json b/packages/svelte/package.json index fa1cb9eefcab..2a1161f1d26d 100644 --- a/packages/svelte/package.json +++ b/packages/svelte/package.json @@ -10,10 +10,7 @@ "node": ">=14.18" }, "files": [ - "cjs", - "esm", - "types", - "types-ts3.8" + "/build" ], "main": "build/cjs/index.js", "module": "build/esm/index.js", @@ -67,14 +64,14 @@ "build:dev:watch": "yarn build:watch", "build:transpile:watch": "rollup -c rollup.npm.config.mjs --watch", "build:types:watch": "tsc -p tsconfig.types.json --watch", - "build:tarball": "ts-node ../../scripts/prepack.ts && npm pack ./build", + "build:tarball": "npm pack", "circularDepCheck": "madge --circular src/index.ts", "clean": "rimraf build coverage sentry-svelte-*.tgz", "fix": "eslint . --format stylish --fix", "lint": "eslint . --format stylish", "test": "vitest run", "test:watch": "vitest --watch", - "yalc:publish": "ts-node ../../scripts/prepack.ts && yalc publish build --push --sig" + "yalc:publish": "yalc publish --push --sig" }, "volta": { "extends": "../../package.json" diff --git a/packages/sveltekit/package.json b/packages/sveltekit/package.json index 314fd42c1f0d..1762d059ef6a 100644 --- a/packages/sveltekit/package.json +++ b/packages/sveltekit/package.json @@ -10,10 +10,7 @@ "node": ">=16" }, "files": [ - "cjs", - "esm", - "types", - "types-ts3.8" + "/build" ], "main": "build/cjs/index.server.js", "module": "build/esm/index.server.js", @@ -63,7 +60,7 @@ "build:dev:watch": "yarn build:watch", "build:transpile:watch": "rollup -c rollup.npm.config.mjs --watch", "build:types:watch": "tsc -p tsconfig.types.json --watch", - "build:tarball": "ts-node ../../scripts/prepack.ts && npm pack ./build", + "build:tarball": "npm pack", "circularDepCheck": "madge --circular src/index.client.ts && madge --circular src/index.server.ts && madge --circular src/index.types.ts", "clean": "rimraf build coverage sentry-sveltekit-*.tgz", "fix": "eslint . --format stylish --fix", @@ -71,7 +68,7 @@ "test": "yarn test:unit", "test:unit": "vitest run", "test:watch": "vitest --watch", - "yalc:publish": "ts-node ../../scripts/prepack.ts && yalc publish build --push --sig" + "yalc:publish": "yalc publish --push --sig" }, "volta": { "extends": "../../package.json" diff --git a/packages/types/package.json b/packages/types/package.json index 71040ddc47e6..7e820b2b9fa6 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -10,10 +10,7 @@ "node": ">=14.18" }, "files": [ - "cjs", - "esm", - "types", - "types-ts3.8" + "/build" ], "main": "build/cjs/index.js", "module": "build/esm/index.js", @@ -52,11 +49,11 @@ "build:dev:watch": "yarn build:watch", "build:transpile:watch": "rollup -c rollup.npm.config.mjs --watch", "build:types:watch": "tsc -p tsconfig.types.json --watch", - "build:tarball": "ts-node ../../scripts/prepack.ts && npm pack ./build", + "build:tarball": "npm pack", "clean": "rimraf build sentry-types-*.tgz", "lint": "eslint . --format stylish", "fix": "eslint . --format stylish --fix", - "yalc:publish": "ts-node ../../scripts/prepack.ts && yalc publish build --push --sig" + "yalc:publish": "yalc publish --push --sig" }, "volta": { "extends": "../../package.json" diff --git a/packages/utils/package.json b/packages/utils/package.json index 0088c13d3167..7cbf46ffc3a1 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -10,10 +10,7 @@ "node": ">=14.18" }, "files": [ - "cjs", - "esm", - "types", - "types-ts3.8" + "/build" ], "main": "build/cjs/index.js", "module": "build/esm/index.js", @@ -59,7 +56,7 @@ "build:dev:watch": "yarn build:watch", "build:transpile:watch": "rollup -c rollup.npm.config.mjs --watch", "build:types:watch": "tsc -p tsconfig.types.json --watch", - "build:tarball": "ts-node ../../scripts/prepack.ts && npm pack ./build", + "build:tarball": "npm pack", "circularDepCheck": "madge --circular src/index.ts", "clean": "rimraf build coverage cjs esm sentry-utils-*.tgz", "fix": "eslint . --format stylish --fix", @@ -68,7 +65,7 @@ "test:watch": "jest --watch", "test:package": "node test/types/index.js", "version": "node ../../scripts/versionbump.js src/version.ts", - "yalc:publish": "ts-node ../../scripts/prepack.ts && yalc publish build --push --sig" + "yalc:publish": "yalc publish --push --sig" }, "volta": { "extends": "../../package.json" diff --git a/packages/vercel-edge/package.json b/packages/vercel-edge/package.json index 26393f35e4f5..e91d65abace4 100644 --- a/packages/vercel-edge/package.json +++ b/packages/vercel-edge/package.json @@ -10,10 +10,7 @@ "node": ">=14.18" }, "files": [ - "cjs", - "esm", - "types", - "types-ts3.8" + "/build" ], "main": "build/cjs/index.js", "module": "build/esm/index.js", @@ -61,14 +58,14 @@ "build:dev:watch": "yarn build:watch", "build:transpile:watch": "rollup -c rollup.npm.config.mjs --watch", "build:types:watch": "tsc -p tsconfig.types.json --watch", - "build:tarball": "ts-node ../../scripts/prepack.ts && npm pack ./build", + "build:tarball": "npm pack", "circularDepCheck": "madge --circular src/index.ts", "clean": "rimraf build coverage sentry-vercel-edge-*.tgz", "fix": "eslint . --format stylish --fix", "lint": "eslint . --format stylish", "test": "jest", "test:watch": "jest --watch", - "yalc:publish": "ts-node ../../scripts/prepack.ts && yalc publish build --push --sig" + "yalc:publish": "yalc publish --push --sig" }, "volta": { "extends": "../../package.json" diff --git a/packages/vue/package.json b/packages/vue/package.json index f11a77677f81..b70ee8d8e100 100644 --- a/packages/vue/package.json +++ b/packages/vue/package.json @@ -10,10 +10,7 @@ "node": ">=14.18" }, "files": [ - "cjs", - "esm", - "types", - "types-ts3.8" + "/build" ], "main": "build/cjs/index.js", "module": "build/esm/index.js", @@ -64,14 +61,14 @@ "build:dev:watch": "run-p build:transpile:watch build:types:watch", "build:transpile:watch": "rollup -c rollup.npm.config.mjs --watch", "build:types:watch": "tsc -p tsconfig.types.json --watch", - "build:tarball": "ts-node ../../scripts/prepack.ts && npm pack ./build", + "build:tarball": "npm pack", "circularDepCheck": "madge --circular src/index.ts", "clean": "rimraf build coverage sentry-vue-*.tgz", "fix": "eslint . --format stylish --fix", "lint": "eslint . --format stylish", "test": "jest", "test:watch": "jest --watch", - "yalc:publish": "ts-node ../../scripts/prepack.ts && yalc publish build --push --sig" + "yalc:publish": "yalc publish --push --sig" }, "volta": { "extends": "../../package.json" diff --git a/packages/wasm/package.json b/packages/wasm/package.json index ef004b28c9a1..b1b86738cd45 100644 --- a/packages/wasm/package.json +++ b/packages/wasm/package.json @@ -10,10 +10,7 @@ "node": ">=14.18" }, "files": [ - "cjs", - "esm", - "types", - "types-ts3.8" + "/build/npm" ], "main": "build/npm/cjs/index.js", "module": "build/npm/esm/index.js", @@ -60,12 +57,12 @@ "build:dev:watch": "run-p build:transpile:watch build:types:watch", "build:transpile:watch": "rollup -c rollup.npm.config.mjs --watch", "build:types:watch": "tsc -p tsconfig.types.json --watch", - "build:tarball": "ts-node ../../scripts/prepack.ts --bundles && npm pack ./build/npm", + "build:tarball": "npm pack", "circularDepCheck": "madge --circular src/index.ts", "clean": "rimraf build coverage sentry-wasm-*.tgz", "fix": "eslint . --format stylish --fix", "lint": "eslint . --format stylish", - "yalc:publish": "ts-node ../../scripts/prepack.ts --bundles && yalc publish ./build/npm --push --sig" + "yalc:publish": "yalc publish --push --sig" }, "volta": { "extends": "../../package.json" diff --git a/scripts/prepack.ts b/scripts/prepack.ts deleted file mode 100644 index fd3d12e52d60..000000000000 --- a/scripts/prepack.ts +++ /dev/null @@ -1,157 +0,0 @@ -/* eslint-disable no-console */ -/* - This script prepares the central `build` directory for NPM package creation. - It first copies all non-code files into the `build` directory, including `package.json`, which - is edited to adjust entry point paths. These corrections are performed so that the paths align with - the directory structure inside `build`. -*/ - -import * as fs from 'fs'; -import * as path from 'path'; - -const NPM_BUILD_DIR = 'build/npm'; -const BUILD_DIR = 'build'; - -const ASSETS = ['README.md', 'LICENSE', 'package.json', '.npmignore']; - -const ENTRY_POINTS = ['main', 'module', 'types', 'browser'] as const; -const CONDITIONAL_EXPORT_ENTRY_POINTS = ['import', 'require', ...ENTRY_POINTS] as const; -const EXPORT_MAP_ENTRY_POINT = 'exports'; -const TYPES_VERSIONS_ENTRY_POINT = 'typesVersions'; - -const packageWithBundles = process.argv.includes('--bundles'); -const buildDir = packageWithBundles ? NPM_BUILD_DIR : BUILD_DIR; - -type PackageJsonEntryPoints = Record<(typeof ENTRY_POINTS)[number], string>; -type ConditionalExportEntryPoints = Record<(typeof CONDITIONAL_EXPORT_ENTRY_POINTS)[number], string>; - -interface TypeVersions { - [key: string]: { - [key: string]: string[]; - }; -} - -type PackageJsonExports = Partial & { - [key: string]: Partial; -}; - -interface PackageJson extends Record, PackageJsonEntryPoints { - [EXPORT_MAP_ENTRY_POINT]: PackageJsonExports; - [TYPES_VERSIONS_ENTRY_POINT]: TypeVersions; -} - -// eslint-disable-next-line @typescript-eslint/no-var-requires -const pkgJson: PackageJson = require(path.resolve('package.json')); - -// check if build dir exists -if (!fs.existsSync(path.resolve(buildDir))) { - console.error(`\nERROR: Directory '${buildDir}' does not exist in ${pkgJson.name}.`); - console.error("This script should only be executed after you've run `yarn build`."); - process.exit(1); -} - -// copy non-code assets to build dir -ASSETS.forEach(asset => { - const assetPath = path.resolve(asset); - if (fs.existsSync(assetPath)) { - const destinationPath = path.resolve(buildDir, path.basename(asset)); - console.log(`Copying ${path.basename(asset)} to ${path.relative('../..', destinationPath)}.`); - fs.copyFileSync(assetPath, destinationPath); - } -}); - -// package.json modifications -const newPackageJsonPath = path.resolve(buildDir, 'package.json'); -// eslint-disable-next-line @typescript-eslint/no-var-requires -const newPkgJson: PackageJson = require(newPackageJsonPath); - -// modify entry points to point to correct paths (i.e. strip out the build directory) -ENTRY_POINTS.filter(entryPoint => newPkgJson[entryPoint]).forEach(entryPoint => { - newPkgJson[entryPoint] = newPkgJson[entryPoint].replace(`${buildDir}/`, ''); -}); - -/** - * Recursively traverses the exports object and rewrites all string values to remove the build directory. - */ -function rewriteConditionalExportEntryPoint( - exportsObject: Record>, - key: string, -): void { - const exportsField = exportsObject[key]; - if (!exportsField) { - return; - } - - if (typeof exportsField === 'string') { - exportsObject[key] = exportsField.replace(`${buildDir}/`, ''); - return; - } - Object.keys(exportsField).forEach(subfieldKey => { - rewriteConditionalExportEntryPoint(exportsField, subfieldKey); - }); -} - -if (newPkgJson[EXPORT_MAP_ENTRY_POINT]) { - Object.keys(newPkgJson[EXPORT_MAP_ENTRY_POINT]).forEach(key => { - rewriteConditionalExportEntryPoint(newPkgJson[EXPORT_MAP_ENTRY_POINT], key); - }); -} - -if (newPkgJson[TYPES_VERSIONS_ENTRY_POINT]) { - Object.entries(newPkgJson[TYPES_VERSIONS_ENTRY_POINT]).forEach(([key, val]) => { - newPkgJson[TYPES_VERSIONS_ENTRY_POINT][key] = Object.entries(val).reduce( - (acc, [key, val]) => { - const newKey = key.replace(`${buildDir}/`, ''); - acc[newKey] = val.map(v => v.replace(`${buildDir}/`, '')); - return acc; - }, - {} as Record, - ); - }); -} - -delete newPkgJson.scripts; -delete newPkgJson.volta; -delete newPkgJson.jest; - -// write modified package.json to file (pretty-printed with 2 spaces) -try { - fs.writeFileSync(newPackageJsonPath, JSON.stringify(newPkgJson, null, 2)); -} catch (error) { - console.error(`\nERROR: Error while writing modified 'package.json' to disk in ${pkgJson.name}:\n`, error); - process.exit(1); -} - -async function runPackagePrepack(packagePrepackPath: string): Promise { - const { prepack } = await import(packagePrepackPath); - if (prepack && typeof prepack === 'function') { - const isSuccess = prepack(buildDir); - if (!isSuccess) { - process.exit(1); - } - } else { - console.error(`\nERROR: Could not find a \`prepack\` function in './scripts/prepack.ts' in ${pkgJson.name}.`); - console.error( - 'Make sure your package-specific prepack script exports `function prepack(buildDir: string): boolean`.', - ); - process.exit(1); - } -} - -// execute package specific settings -// 1. check if a script called `/scripts/prepack.ts` exists -// if yes, 2.) execute that script for things that are package-specific -async function runPackageSpecificScripts(): Promise { - const packagePrepackPath = path.resolve('scripts', 'prepack.ts'); - try { - if (fs.existsSync(packagePrepackPath)) { - await runPackagePrepack(packagePrepackPath); - } - } catch (error) { - console.error(`\nERROR: Error while trying to load and run ./scripts/prepack.ts in ${pkgJson.name}:\n`, error); - process.exit(1); - } - console.log(`\nSuccessfully finished prepack commands for ${pkgJson.name}\n`); -} - -void runPackageSpecificScripts();