Skip to content

Commit

Permalink
Monorepo Jest - remove now unnecessary Babel registration (#38146)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #38146

Now that `metro-react-native-babel-transformer` may be loaded from source without transformation, we can remove this workaround / potential footgun.

Jest uses Babel imperatively and doesn't rely on registration (require hooks), so registering within the preprocessor potentially conflicts and has caused problems before. This just tidies up some complexity we don't need.

Changelog: [Internal]

Reviewed By: christophpurrer

Differential Revision: D47162728

fbshipit-source-id: 06215f9bb7b8e71bcca0429d0bae9f20a22f45a8
  • Loading branch information
robhogan authored and facebook-github-bot committed Jul 3, 2023
1 parent 1202d39 commit 971bb81
Showing 1 changed file with 0 additions and 11 deletions.
11 changes: 0 additions & 11 deletions jest/preprocessor.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,6 @@ const nodeFiles = /[\\/]metro(?:-[^/]*)[\\/]/;
// hook. This is used below to configure babelTransformSync under Jest.
const {only: _, ...nodeBabelOptions} = metroBabelRegister.config([]);

// Register Babel to allow the transformer itself to be loaded from source.
if (process.env.FBSOURCE_ENV) {
// Internal: Use `@fb-scripts/babel-register` to re-use internal
// registration, rather than potentially clobbering it and conflicting with
// other Jest projects running in the same process.
// This package should *NOT* be a dependency of `@react-native/monorepo`.
// $FlowIgnore[cannot-resolve-module]
require('@fb-scripts/babel-register');
} else {
metroBabelRegister([nodeFiles]);
}
const transformer = require('metro-react-native-babel-transformer');

module.exports = {
Expand Down

0 comments on commit 971bb81

Please sign in to comment.