From ff95fd5367d0a9fffba129d753911cbe73255ea2 Mon Sep 17 00:00:00 2001 From: Luca Forstner Date: Tue, 2 Jan 2024 13:15:02 +0100 Subject: [PATCH] build: Switch from npmignore to files field (#9991) --- .npmignore | 9 --------- packages/angular/.npmignore | 4 ---- packages/astro/.npmignore | 10 ---------- packages/astro/package.json | 6 ++++++ packages/browser/package.json | 6 ++++++ packages/bun/package.json | 6 ++++++ packages/core/package.json | 6 ++++++ packages/ember/.npmignore | 3 --- packages/eslint-config-sdk/.npmignore | 2 -- packages/eslint-config-sdk/package.json | 3 +++ packages/eslint-plugin-sdk/.npmignore | 2 -- packages/eslint-plugin-sdk/package.json | 1 + packages/feedback/package.json | 6 ++++++ packages/gatsby/.npmignore | 15 -------------- packages/gatsby/package.json | 10 ++++++++++ packages/hub/package.json | 6 ++++++ packages/integrations/package.json | 6 ++++++ packages/node-experimental/package.json | 6 ++++++ packages/node/package.json | 6 ++++++ packages/opentelemetry-node/package.json | 6 ++++++ packages/opentelemetry/package.json | 6 ++++++ packages/react/package.json | 6 ++++++ packages/remix/.npmignore | 4 ---- packages/remix/package.json | 7 +++++++ packages/replay-worker/package.json | 6 ++++++ packages/replay/package.json | 6 ++++++ packages/serverless/package.json | 6 ++++++ packages/svelte/package.json | 6 ++++++ packages/sveltekit/package.json | 6 ++++++ packages/tracing-internal/package.json | 6 ++++++ packages/tracing/package.json | 6 ++++++ packages/types/package.json | 6 ++++++ packages/typescript/.npmignore | 2 -- packages/typescript/package.json | 3 +++ packages/utils/package.json | 6 ++++++ packages/vercel-edge/package.json | 6 ++++++ packages/vue/package.json | 6 ++++++ packages/wasm/package.json | 6 ++++++ scripts/prepack.ts | 14 ++++++------- scripts/tarball-checksums.sh | 25 ------------------------ 40 files changed, 174 insertions(+), 84 deletions(-) delete mode 100644 .npmignore delete mode 100644 packages/angular/.npmignore delete mode 100644 packages/astro/.npmignore delete mode 100644 packages/eslint-config-sdk/.npmignore delete mode 100644 packages/eslint-plugin-sdk/.npmignore delete mode 100644 packages/gatsby/.npmignore delete mode 100644 packages/remix/.npmignore delete mode 100644 packages/typescript/.npmignore delete mode 100644 scripts/tarball-checksums.sh diff --git a/.npmignore b/.npmignore deleted file mode 100644 index 6cf3cd53d7e6..000000000000 --- a/.npmignore +++ /dev/null @@ -1,9 +0,0 @@ -# The paths in this file are specified so that they align with the file structure in `./build` after this file is copied -# into it by the prepack script `scripts/prepack.ts`. - -* - -!/cjs/**/* -!/esm/**/* -!/types/**/* -!/types-ts3.8/**/* diff --git a/packages/angular/.npmignore b/packages/angular/.npmignore deleted file mode 100644 index 75ee79933841..000000000000 --- a/packages/angular/.npmignore +++ /dev/null @@ -1,4 +0,0 @@ -* -!/cjs/**/* -!/esm/**/* -!/build/types/**/* diff --git a/packages/astro/.npmignore b/packages/astro/.npmignore deleted file mode 100644 index ded80d725803..000000000000 --- a/packages/astro/.npmignore +++ /dev/null @@ -1,10 +0,0 @@ -# The paths in this file are specified so that they align with the file structure in `./build` after this file is copied -# into it by the prepack script `scripts/prepack.ts`. - -* - -!/cjs/**/* -!/esm/**/* -!/types/**/* -!/types-ts3.8/**/* -!/integration/**/* diff --git a/packages/astro/package.json b/packages/astro/package.json index a8b18e17611b..061b6bbdcac5 100644 --- a/packages/astro/package.json +++ b/packages/astro/package.json @@ -17,6 +17,12 @@ "node": ">=18.14.1" }, "type": "module", + "files": [ + "cjs", + "esm", + "types", + "types-ts3.8" + ], "main": "build/cjs/index.client.js", "module": "build/esm/index.server.js", "browser": "build/esm/index.client.js", diff --git a/packages/browser/package.json b/packages/browser/package.json index 4acdb3713178..de646549de4d 100644 --- a/packages/browser/package.json +++ b/packages/browser/package.json @@ -9,6 +9,12 @@ "engines": { "node": ">=8" }, + "files": [ + "cjs", + "esm", + "types", + "types-ts3.8" + ], "main": "build/npm/cjs/index.js", "module": "build/npm/esm/index.js", "types": "build/npm/types/index.d.ts", diff --git a/packages/bun/package.json b/packages/bun/package.json index 4ef078a0b26d..70a3ee56e4b8 100644 --- a/packages/bun/package.json +++ b/packages/bun/package.json @@ -9,6 +9,12 @@ "engines": { "node": ">=8" }, + "files": [ + "cjs", + "esm", + "types", + "types-ts3.8" + ], "main": "build/esm/index.js", "module": "build/esm/index.js", "types": "build/types/index.d.ts", diff --git a/packages/core/package.json b/packages/core/package.json index 5462b3b1d301..14d7ab9f67fa 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -9,6 +9,12 @@ "engines": { "node": ">=8" }, + "files": [ + "cjs", + "esm", + "types", + "types-ts3.8" + ], "main": "build/cjs/index.js", "module": "build/esm/index.js", "types": "build/types/index.d.ts", diff --git a/packages/ember/.npmignore b/packages/ember/.npmignore index ff9862207d8e..a41abd750def 100644 --- a/packages/ember/.npmignore +++ b/packages/ember/.npmignore @@ -1,6 +1,3 @@ -# Disable rules of .npmignore in workspace root for this package -!* - # compiled output /dist/ /tmp/ diff --git a/packages/eslint-config-sdk/.npmignore b/packages/eslint-config-sdk/.npmignore deleted file mode 100644 index 8f4f62a06989..000000000000 --- a/packages/eslint-config-sdk/.npmignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!/src/**/* diff --git a/packages/eslint-config-sdk/package.json b/packages/eslint-config-sdk/package.json index 952da9e2db44..03c3ddcd2209 100644 --- a/packages/eslint-config-sdk/package.json +++ b/packages/eslint-config-sdk/package.json @@ -14,6 +14,9 @@ "engines": { "node": ">=8" }, + "files": [ + "src" + ], "main": "src/index.js", "publishConfig": { "access": "public" diff --git a/packages/eslint-plugin-sdk/.npmignore b/packages/eslint-plugin-sdk/.npmignore deleted file mode 100644 index 8f4f62a06989..000000000000 --- a/packages/eslint-plugin-sdk/.npmignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!/src/**/* diff --git a/packages/eslint-plugin-sdk/package.json b/packages/eslint-plugin-sdk/package.json index 155468970e33..cf3a96163edb 100644 --- a/packages/eslint-plugin-sdk/package.json +++ b/packages/eslint-plugin-sdk/package.json @@ -14,6 +14,7 @@ "engines": { "node": ">=8" }, + "files": ["src"], "main": "src/index.js", "publishConfig": { "access": "public" diff --git a/packages/feedback/package.json b/packages/feedback/package.json index 5e50194d340f..39e4fc7330ee 100644 --- a/packages/feedback/package.json +++ b/packages/feedback/package.json @@ -9,6 +9,12 @@ "engines": { "node": ">=12" }, + "files": [ + "cjs", + "esm", + "types", + "types-ts3.8" + ], "main": "build/npm/cjs/index.js", "module": "build/npm/esm/index.js", "types": "build/npm/types/index.d.ts", diff --git a/packages/gatsby/.npmignore b/packages/gatsby/.npmignore deleted file mode 100644 index 05a81b2542dd..000000000000 --- a/packages/gatsby/.npmignore +++ /dev/null @@ -1,15 +0,0 @@ -# The paths in this file are specified so that they align with the file structure in `./build` after this file is copied -# into it by the prepack script `scripts/prepack.ts`. - -* - -!/cjs/**/* -!/esm/**/* -!/types/**/* -!/types-ts3.8/**/* - -# Gatsby specific -!gatsby-browser.js -!gatsby-node.js -!gatsby-browser.d.ts -!gatsby-node.d.ts diff --git a/packages/gatsby/package.json b/packages/gatsby/package.json index 33fdb7406da3..0e5c74d642bc 100644 --- a/packages/gatsby/package.json +++ b/packages/gatsby/package.json @@ -13,6 +13,16 @@ "engines": { "node": ">=8" }, + "files": [ + "cjs", + "esm", + "types", + "types-ts3.8", + "gatsby-browser.js", + "gatsby-node.js", + "gatsby-browser.d.ts", + "gatsby-node.d.ts" + ], "main": "build/cjs/index.js", "module": "build/esm/index.js", "types": "build/types/index.d.ts", diff --git a/packages/hub/package.json b/packages/hub/package.json index 1b75ff7ca666..faef7cda93f1 100644 --- a/packages/hub/package.json +++ b/packages/hub/package.json @@ -9,6 +9,12 @@ "engines": { "node": ">=8" }, + "files": [ + "cjs", + "esm", + "types", + "types-ts3.8" + ], "main": "build/cjs/index.js", "module": "build/esm/index.js", "types": "build/types/index.d.ts", diff --git a/packages/integrations/package.json b/packages/integrations/package.json index 6505a33c08fc..5ffc239ac305 100644 --- a/packages/integrations/package.json +++ b/packages/integrations/package.json @@ -12,6 +12,12 @@ "publishConfig": { "access": "public" }, + "files": [ + "cjs", + "esm", + "types", + "types-ts3.8" + ], "main": "build/npm/cjs/index.js", "module": "build/npm/esm/index.js", "types": "build/npm/types/index.d.ts", diff --git a/packages/node-experimental/package.json b/packages/node-experimental/package.json index 0b9295e59943..a9e0b21aaba3 100644 --- a/packages/node-experimental/package.json +++ b/packages/node-experimental/package.json @@ -9,6 +9,12 @@ "engines": { "node": ">=14" }, + "files": [ + "cjs", + "esm", + "types", + "types-ts3.8" + ], "main": "build/cjs/index.js", "module": "build/esm/index.js", "types": "build/types/index.d.ts", diff --git a/packages/node/package.json b/packages/node/package.json index 5c93f0d94bf1..071e0babec46 100644 --- a/packages/node/package.json +++ b/packages/node/package.json @@ -9,6 +9,12 @@ "engines": { "node": ">=8" }, + "files": [ + "cjs", + "esm", + "types", + "types-ts3.8" + ], "main": "build/cjs/index.js", "module": "build/esm/index.js", "types": "build/types/index.d.ts", diff --git a/packages/opentelemetry-node/package.json b/packages/opentelemetry-node/package.json index 893d8b618215..44f20306560e 100644 --- a/packages/opentelemetry-node/package.json +++ b/packages/opentelemetry-node/package.json @@ -9,6 +9,12 @@ "engines": { "node": ">=8" }, + "files": [ + "cjs", + "esm", + "types", + "types-ts3.8" + ], "main": "build/cjs/index.js", "module": "build/esm/index.js", "types": "build/types/index.d.ts", diff --git a/packages/opentelemetry/package.json b/packages/opentelemetry/package.json index e7154a90edc1..7d9498996fca 100644 --- a/packages/opentelemetry/package.json +++ b/packages/opentelemetry/package.json @@ -9,6 +9,12 @@ "engines": { "node": ">=14" }, + "files": [ + "cjs", + "esm", + "types", + "types-ts3.8" + ], "main": "build/cjs/index.js", "module": "build/esm/index.js", "types": "build/types/index.d.ts", diff --git a/packages/react/package.json b/packages/react/package.json index 7579b83bf9f8..5293414ead65 100644 --- a/packages/react/package.json +++ b/packages/react/package.json @@ -9,6 +9,12 @@ "engines": { "node": ">=8" }, + "files": [ + "cjs", + "esm", + "types", + "types-ts3.8" + ], "main": "build/cjs/index.js", "module": "build/esm/index.js", "types": "build/types/index.d.ts", diff --git a/packages/remix/.npmignore b/packages/remix/.npmignore deleted file mode 100644 index e1bb7e5136bd..000000000000 --- a/packages/remix/.npmignore +++ /dev/null @@ -1,4 +0,0 @@ -# The paths in this file are specified so that they align with the file structure in `./build` after this file is copied -# into it by the prepack script `scripts/prepack.ts`. - -!/scripts/**/* diff --git a/packages/remix/package.json b/packages/remix/package.json index 4a60ee77d61c..b206252c8fcb 100644 --- a/packages/remix/package.json +++ b/packages/remix/package.json @@ -12,6 +12,13 @@ "engines": { "node": ">=14" }, + "files": [ + "cjs", + "esm", + "types", + "types-ts3.8", + "scripts" + ], "main": "build/cjs/index.server.js", "module": "build/esm/index.server.js", "browser": "build/esm/index.client.js", diff --git a/packages/replay-worker/package.json b/packages/replay-worker/package.json index f8428075d677..23940f558472 100644 --- a/packages/replay-worker/package.json +++ b/packages/replay-worker/package.json @@ -12,6 +12,12 @@ ] } }, + "files": [ + "cjs", + "esm", + "types", + "types-ts3.8" + ], "sideEffects": false, "private": true, "scripts": { diff --git a/packages/replay/package.json b/packages/replay/package.json index 65089f1ed56f..665cb8b3210e 100644 --- a/packages/replay/package.json +++ b/packages/replay/package.json @@ -12,6 +12,12 @@ ] } }, + "files": [ + "cjs", + "esm", + "types", + "types-ts3.8" + ], "sideEffects": false, "scripts": { "build": "run-p build:transpile build:types build:bundle", diff --git a/packages/serverless/package.json b/packages/serverless/package.json index 7ce0f1b2f13e..591888375979 100644 --- a/packages/serverless/package.json +++ b/packages/serverless/package.json @@ -9,6 +9,12 @@ "engines": { "node": ">=10" }, + "files": [ + "cjs", + "esm", + "types", + "types-ts3.8" + ], "main": "build/npm/cjs/index.js", "module": "build/npm/esm/index.js", "types": "build/npm/types/index.d.ts", diff --git a/packages/svelte/package.json b/packages/svelte/package.json index b0d2f85c5b99..f77abf2a86e8 100644 --- a/packages/svelte/package.json +++ b/packages/svelte/package.json @@ -9,6 +9,12 @@ "engines": { "node": ">=8" }, + "files": [ + "cjs", + "esm", + "types", + "types-ts3.8" + ], "main": "build/cjs/index.js", "module": "build/esm/index.js", "types": "build/types/index.d.ts", diff --git a/packages/sveltekit/package.json b/packages/sveltekit/package.json index 391a45940e19..2037a2550836 100644 --- a/packages/sveltekit/package.json +++ b/packages/sveltekit/package.json @@ -9,6 +9,12 @@ "engines": { "node": ">=16" }, + "files": [ + "cjs", + "esm", + "types", + "types-ts3.8" + ], "main": "build/cjs/index.server.js", "module": "build/esm/index.server.js", "browser": "build/esm/index.client.js", diff --git a/packages/tracing-internal/package.json b/packages/tracing-internal/package.json index 7177ed989ac2..65a0431576df 100644 --- a/packages/tracing-internal/package.json +++ b/packages/tracing-internal/package.json @@ -9,6 +9,12 @@ "engines": { "node": ">=8" }, + "files": [ + "cjs", + "esm", + "types", + "types-ts3.8" + ], "main": "build/cjs/index.js", "module": "build/esm/index.js", "types": "build/types/index.d.ts", diff --git a/packages/tracing/package.json b/packages/tracing/package.json index 8f5c58751592..a79725574494 100644 --- a/packages/tracing/package.json +++ b/packages/tracing/package.json @@ -9,6 +9,12 @@ "engines": { "node": ">=8" }, + "files": [ + "cjs", + "esm", + "types", + "types-ts3.8" + ], "main": "build/npm/cjs/index.js", "module": "build/npm/esm/index.js", "types": "build/npm/types/index.d.ts", diff --git a/packages/types/package.json b/packages/types/package.json index b21aaaee0e68..d148772ff61a 100644 --- a/packages/types/package.json +++ b/packages/types/package.json @@ -9,6 +9,12 @@ "engines": { "node": ">=8" }, + "files": [ + "cjs", + "esm", + "types", + "types-ts3.8" + ], "main": "build/cjs/index.js", "module": "build/esm/index.js", "types": "build/types/index.d.ts", diff --git a/packages/typescript/.npmignore b/packages/typescript/.npmignore deleted file mode 100644 index 457274275b7c..000000000000 --- a/packages/typescript/.npmignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!/tsconfig.json diff --git a/packages/typescript/package.json b/packages/typescript/package.json index 4f527af3605f..2b6210de2a3d 100644 --- a/packages/typescript/package.json +++ b/packages/typescript/package.json @@ -10,6 +10,9 @@ "publishConfig": { "access": "public" }, + "files": [ + "tsconfig.json" + ], "peerDependencies": { "typescript": "4.9.5" }, diff --git a/packages/utils/package.json b/packages/utils/package.json index fe04f12a4cd8..9ca7925bab1d 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -9,6 +9,12 @@ "engines": { "node": ">=8" }, + "files": [ + "cjs", + "esm", + "types", + "types-ts3.8" + ], "main": "build/cjs/index.js", "module": "build/esm/index.js", "types": "build/types/index.d.ts", diff --git a/packages/vercel-edge/package.json b/packages/vercel-edge/package.json index 3d96c7f7d517..1e3f1c80d267 100644 --- a/packages/vercel-edge/package.json +++ b/packages/vercel-edge/package.json @@ -9,6 +9,12 @@ "engines": { "node": ">=8" }, + "files": [ + "cjs", + "esm", + "types", + "types-ts3.8" + ], "main": "build/cjs/index.js", "module": "build/esm/index.js", "types": "build/types/index.d.ts", diff --git a/packages/vue/package.json b/packages/vue/package.json index a1189b8a87c7..c06a1ce83058 100644 --- a/packages/vue/package.json +++ b/packages/vue/package.json @@ -9,6 +9,12 @@ "engines": { "node": ">=8" }, + "files": [ + "cjs", + "esm", + "types", + "types-ts3.8" + ], "main": "build/cjs/index.js", "module": "build/esm/index.js", "types": "build/types/index.d.ts", diff --git a/packages/wasm/package.json b/packages/wasm/package.json index 4bf7315760a9..32cb82d6a387 100644 --- a/packages/wasm/package.json +++ b/packages/wasm/package.json @@ -9,6 +9,12 @@ "engines": { "node": ">=8" }, + "files": [ + "cjs", + "esm", + "types", + "types-ts3.8" + ], "main": "build/npm/cjs/index.js", "module": "build/npm/esm/index.js", "types": "build/npm/types/index.d.ts", diff --git a/scripts/prepack.ts b/scripts/prepack.ts index 9118226f08e7..65cd9ddbf631 100644 --- a/scripts/prepack.ts +++ b/scripts/prepack.ts @@ -11,9 +11,9 @@ import * as path from 'path'; const NPM_BUILD_DIR = 'build/npm'; const BUILD_DIR = 'build'; -const NPM_IGNORE = fs.existsSync('.npmignore') ? '.npmignore' : '../../.npmignore'; -const ASSETS = ['README.md', 'LICENSE', 'package.json', NPM_IGNORE] as const; +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'; @@ -53,13 +53,11 @@ if (!fs.existsSync(path.resolve(buildDir))) { // copy non-code assets to build dir ASSETS.forEach(asset => { const assetPath = path.resolve(asset); - if (!fs.existsSync(assetPath)) { - console.error(`\nERROR: Asset '${asset}' does not exist.`); - process.exit(1); + 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); } - 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 diff --git a/scripts/tarball-checksums.sh b/scripts/tarball-checksums.sh deleted file mode 100644 index 60487f9037d3..000000000000 --- a/scripts/tarball-checksums.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/sh - -# Get the directory of the script -script_dir=$(cd "$(dirname "$0")" && pwd) - -# Function to calculate SHA checksums for files -calculate_sha_checksum() { - file="$1" - # Strip the directory name from the file path - file_name=$(basename "$file") - sha_checksum=$(sha256sum "$file" | awk '{print $1}') - # Align the output - printf "%-48s: %s\n" "$file_name" "$sha_checksum" -} - -# Main function to process files recursively -process_files() { - # Find all ".tgz" files recursively - find "$script_dir/.." -type f -name "*.tgz" | while IFS= read -r file; do - calculate_sha_checksum "$file" - done -} - -# Call the main function to process files -process_files