From 0301cb285b2e85b48a397fe58d565196654d9754 Mon Sep 17 00:00:00 2001 From: Moti Zilberman Date: Fri, 6 May 2022 04:43:09 -0700 Subject: [PATCH] Stop publishing jest/preprocessor.js to npm Summary: Changelog: [Breaking][General] Remove jest/preprocessor from the react-native package Using `react-native/jest/preprocessor` outside of the React Native repo has been deprecated since D34820086 (https://github.com/facebook/react-native/commit/c1e9aa9a272aed3cba60c4aeff783eeb8bffce68). Here, we make this file private and stop publishing it to npm. The supported method of using Jest in React Native projects is using the [Jest preset](https://jestjs.io/docs/tutorial-react-native) shipped as part of the `react-native` package. NOTE: We could probably make some of the other files under `jest/` private as well, but we should go through a separate deprecation cycle with those, in case they are also being used externally by some projects. I'm leaving that for future followup at the moment. Reviewed By: GijsWeterings Differential Revision: D36132939 fbshipit-source-id: 300ffa6cf16232573cd3a79a34c14daaafd7aa43 --- jest.config.js | 2 +- jest/preprocessor.js | 40 ------------------- .../preprocessor.js} | 0 package.json | 7 ++-- 4 files changed, 5 insertions(+), 44 deletions(-) delete mode 100644 jest/preprocessor.js rename jest/{preprocessor_DO_NOT_USE.js => private/preprocessor.js} (100%) diff --git a/jest.config.js b/jest.config.js index 2561d8e2571f86..512bd1b538ef76 100644 --- a/jest.config.js +++ b/jest.config.js @@ -13,7 +13,7 @@ module.exports = { transform: { '^.+\\.(bmp|gif|jpg|jpeg|mp4|png|psd|svg|webp)$': '/jest/assetFileTransformer.js', - '.*': './jest/preprocessor_DO_NOT_USE.js', + '.*': './jest/private/preprocessor.js', }, setupFiles: ['./jest/setup.js'], timers: 'fake', diff --git a/jest/preprocessor.js b/jest/preprocessor.js deleted file mode 100644 index b63c603a940df9..00000000000000 --- a/jest/preprocessor.js +++ /dev/null @@ -1,40 +0,0 @@ -/** - * Copyright (c) Meta Platforms, Inc. and affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - * - * @format - * @flow - */ - -/* eslint-env node */ - -'use strict'; - -// NOTE: Avoiding using a package like 'chalk' here, for simplicity -const YELLOW = process.stderr.isTTY ? '\u001b[33m' : ''; -const BOLD = process.stderr.isTTY ? '\u001b[1m' : ''; -const RESET = process.stderr.isTTY ? '\u001b[0m' : ''; -const UNDERLINE = process.stderr.isTTY ? '\u001b[4m' : ''; - -console.warn( - '\n' + - YELLOW + - BOLD + - 'react-native/jest/preprocessor.js' + - RESET + - YELLOW + - ' is deprecated and will be removed.\n' + - 'Use "preset": "react-native" in your Jest config instead.\n' + - 'See ' + - UNDERLINE + - 'https://jestjs.io/docs/tutorial-react-native' + - RESET + - YELLOW + - ' for more setup instructions.' + - RESET + - '\n', -); - -module.exports = require('./preprocessor_DO_NOT_USE'); diff --git a/jest/preprocessor_DO_NOT_USE.js b/jest/private/preprocessor.js similarity index 100% rename from jest/preprocessor_DO_NOT_USE.js rename to jest/private/preprocessor.js diff --git a/package.json b/package.json index 1245a7b359cd64..471be965906009 100644 --- a/package.json +++ b/package.json @@ -14,9 +14,6 @@ "outputName": "js-test-results.xml" }, "files": [ - "!template/node_modules", - "!template/package-lock.json", - "!template/yarn.lock", "android", "cli.js", "flow", @@ -25,6 +22,7 @@ "interface.js", "jest-preset.js", "jest", + "!jest/private", "Libraries", "LICENSE", "local-cli", @@ -60,6 +58,9 @@ "sdks/hermes-engine.podspec", "template.config.js", "template", + "!template/node_modules", + "!template/package-lock.json", + "!template/yarn.lock", "third-party-podspecs" ], "scripts": {