Replace .npmignore files, ignore all test/fixture/docs directories (#50784)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/50784

Migrates us from several `.npmignore` files to `package.json#files`, for the main `react-native` package.

This reduces the size of our npm package by 38 files — in particular, catching previously missed `__tests__` and `__docs__` directories.

```diff
- npm notice package size: 4.4 MB
- npm notice unpacked size: 23.7 MB
- npm notice total files: 4533
+ npm notice package size: 4.4 MB
+ npm notice unpacked size: 23.7 MB
+ npm notice total files: 4533
```

NOTE: `"files"` or `.npmignore` — one or the other!
- Having `.npmignore` at the package root does not behave(!). Having `"files"` as one source of truth is better and safer. See https://github.com/npm/cli/issues/6221.

Changelog: [Internal]

Reviewed By: hoxyq

Differential Revision: D73185321

fbshipit-source-id: 429c9fec4f447d63440a38bb8e3f3ce3bd155414
This commit is contained in:
Alex Hunt
2025-04-17 12:48:28 -07:00
committed by Facebook GitHub Bot
parent cd5991c648
commit d1cf58484d
9 changed files with 25 additions and 34 deletions
@@ -1 +0,0 @@
__tests__
@@ -1,9 +0,0 @@
# Make sure we never publish ReactAndroid/build (Gradle output)
# or ReactAndroid/.cxx (CMake output) to npm.
# Those folders are huge (> 100MB)!
/build/
.cxx/
# Exclude buck config/jars for third-party libraries
src/main/third-party/
# Exclude Android & JVM tests
src/test/
@@ -1,3 +0,0 @@
# Make sure we never publish the build and artifacts folders to npm.
build/
artifacts/
@@ -1,3 +0,0 @@
# Make sure we never publish the build folders to npm.
build/
.cxx/
+25 -12
View File
@@ -49,48 +49,61 @@
"React",
"!React/Fabric/RCTThirdPartyFabricComponentsProvider.*",
"ReactAndroid",
"!ReactAndroid/.cxx",
"!ReactAndroid/build",
"!ReactAndroid/external-artifacts/artifacts",
"!ReactAndroid/external-artifacts/build",
"!ReactAndroid/hermes-engine/.cxx",
"!ReactAndroid/hermes-engine/build",
"!ReactAndroid/src/main/third-party",
"!ReactAndroid/src/test",
"ReactApple",
"ReactCommon",
"README.md",
"rn-get-polyfills.js",
"scripts/bundle.js",
"scripts/cocoapods",
"scripts/codegen",
"scripts/compose-source-maps.js",
"scripts/find-node-for-xcode.sh",
"scripts/bundle.js",
"scripts/generate-codegen-artifacts.js",
"scripts/generate-provider-cli.js",
"scripts/generate-specs-cli.js",
"scripts/codegen",
"!scripts/codegen/__tests__",
"!scripts/codegen/__test_fixtures__",
"scripts/hermes/hermes-utils.js",
"scripts/hermes/prepare-hermes-for-build.js",
"scripts/ios-configure-glog.sh",
"scripts/xcode/ccache-clang++.sh",
"scripts/xcode/ccache-clang.sh",
"scripts/xcode/ccache.conf",
"scripts/xcode/with-environment.sh",
"scripts/native_modules.rb",
"scripts/node-binary.sh",
"scripts/packager.sh",
"scripts/packager-reporter.js",
"scripts/packager.sh",
"scripts/react_native_pods_utils/script_phases.rb",
"scripts/react_native_pods_utils/script_phases.sh",
"scripts/react_native_pods.rb",
"scripts/cocoapods",
"!scripts/cocoapods/__tests__",
"scripts/react-native-xcode.sh",
"scripts/xcode/ccache-clang.sh",
"scripts/xcode/ccache-clang++.sh",
"scripts/xcode/ccache.conf",
"scripts/xcode/with-environment.sh",
"sdks/.hermesversion",
"sdks/hermes-engine",
"sdks/hermesc",
"settings.gradle.kts",
"src",
"!src/private/testing",
"template.config.js",
"template",
"!template/node_modules",
"!template/package-lock.json",
"!template/yarn.lock",
"third-party-podspecs",
"types"
"types",
"!**/__docs__/**",
"!**/__fixtures__/**",
"!**/__flowtests__/**",
"!**/__mocks__/**",
"!**/__test_fixtures__/**",
"!**/__tests__/**",
"!**/__typetests__/**"
],
"scripts": {
"prepack": "node ./scripts/prepack.js",
-2
View File
@@ -1,2 +0,0 @@
# Make sure we never publish __test__ folders (Gradle output)
**/__*tests__/
-2
View File
@@ -1,2 +0,0 @@
__tests__
private/testing
@@ -1 +0,0 @@
__docs__
-1
View File
@@ -1 +0,0 @@
__typetests__