Repository navigation
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary:
jest/preprocessor.jsruns files undermetro-*package paths through themetro-babel-registeroptions withsourceType: 'script'. In script mode the CommonJS transform skips the file, soimport/exportinpackages/metro-config/src/index.flow.jsstay as they are and any test that requires@react-native/metro-configfails withSyntaxError: Cannot use import statement outside a module. This switches it to'unambiguous', like the React Native branch below it already uses, so ES module files get transformed and CommonJS files stay scripts.Fixes #60029
Changelog:
[INTERNAL] [FIXED] - Transform ES modules in Node package files in the Jest preprocessor
Test Plan:
Added
packages/metro-config/src/__tests__/index-test.js, which loads@react-native/metro-configfrom source. It fails on main with theSyntaxErrorfrom the issue and passes with this change.yarn testshows the same results as on main (generate-artifacts-executor-test.jsand oneInspectorProxyCdpRewritingHacks-test.jscase also fail on main on my machine).yarn flow focus-check, eslint and prettier are clean on the changed files.