bug: `@react-native/polyfills/error-guard.js` not transpiled in distrobution

See original GitHub issue

Description

In trying to integrate @swc/jest into our React Native codebase - it was discovered that one of the files (error-guard) was not being transpiled correctly. I’m not sure if this is by design or not - but the sibling files do not have types. So my guess is that this is not intended.

Version

0.66.1

Output of npx react-native info

System:
    OS: macOS 12.2.1
    CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 38.22 MB / 32.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 16.13.2 - ~/.nvm/versions/node/v16.13.2/bin/node
    Yarn: 1.19.2 - /usr/local/bin/yarn
    npm: 8.1.2 - ~/.nvm/versions/node/v16.13.2/bin/npm
    Watchman: 2021.10.18.00 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.10.1 - /Users/theryn.groetken/.rbenv/shims/pod
  SDKs:
    iOS SDK:
      Platforms: DriverKit 21.2, iOS 15.2, macOS 12.1, tvOS 15.2, watchOS 8.3
    Android SDK: Not Found
  IDEs:
    Android Studio: 4.2 AI-202.7660.26.42.7486908
    Xcode: 13.2.1/13C100 - /usr/bin/xcodebuild
  Languages:
    Java: 11.0.8 - /usr/bin/javac
  npmPackages:
    @react-native-community/cli: 6.1.0 => 6.1.0
    react: 17.0.2 => 17.0.2
    react-native: 0.66.1 => 0.66.1
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

Steps to reproduce

See https://github.com/therynamo/SWCJestRepro#swcjestrepro

Snack, code example, screenshot, or link to a repository

https://github.com/therynamo/SWCJestRepro

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:11
  • Comments:9

github_iconTop GitHub Comments

7reactions
kopax-polyconseilcommented, Jul 19, 2022

Is it possible to have an update on this? Our repository suffer with jest and supporting @swc/jest for testing would be really cool.

3reactions
mikemeyer30commented, Sep 23, 2022

I am also encountering this problem…

RN Version 0.65.2

npx react-native info:

    OS: macOS 12.5.1
    CPU: (8) arm64 Apple M1
    Memory: 92.84 MB / 16.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 16.13.1 - /usr/local/bin/node
    Yarn: 1.22.17 - /opt/homebrew/bin/yarn
    npm: 8.1.4 - /opt/homebrew/bin/npm
    Watchman: 2022.08.08.00 - /opt/homebrew/bin/watchman
  Managers:
    CocoaPods: 1.11.3 - /usr/local/bin/pod
  SDKs:
    iOS SDK:
      Platforms: DriverKit 21.4, iOS 16.0, macOS 12.3, tvOS 16.0, watchOS 9.0
    Android SDK:
      API Levels: 23, 25, 29, 30, 31, 33
      Build Tools: 28.0.3, 29.0.2, 29.0.3, 30.0.2, 30.0.3, 31.0.0, 31.0.0
      Android NDK: 20.0.5594570
  IDEs:
    Android Studio: 2021.1 AI-211.7628.21.2111.8139111
    Xcode: 14.0/14A309 - /usr/bin/xcodebuild
  Languages:
    Java: 1.8.0_322 - /usr/bin/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: 17.0.2 => 17.0.2 
    react-native: ^0.65.2 => 0.65.2 
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

jest.config.js:

module.exports = {
  // Automatically clear mock calls, instances, contexts and results before every test
  clearMocks: true,

  // Indicates whether the coverage information should be collected while executing the test
  collectCoverage: true,

  // The directory where Jest should output its coverage files
  coverageDirectory: 'coverage',

  // A preset that is used as a base for Jest's configuration
  preset: 'jest-expo',

  // The paths to modules that run some code to configure or set up the testing environment before each test
  setupFiles: ['<rootDir>/mocks/mockLibs.js'],

  // The glob patterns Jest uses to detect test files
  testMatch: ['**/__tests__/**/*.[jt]s?(x)', '**/?(*.)+(spec|test).[tj]s?(x)'],

  // An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
  transformIgnorePatterns: [
    'node_modules/(?!@react-native|react-native)',
    'node_modules/(?!@react-native/polyfills/)',
    'node_modules/(?!(jest-)?@react-navigation|@react-native-community|@react-navigation-redux-helpers)',
    'node_modules/(?!(jest-runtime))',
  ],
};

babel.config.js:

module.exports = {
  presets: [
    '@babel/preset-react',
    [
      '@babel/preset-env',
      {
        targets: {
          node: 'current',
        },
      },
    ],
  ],
};

If anyone knows of any work arounds, will gladly give you the stronger of my two kidneys

Read more comments on GitHub >

github_iconTop Results From Across the Web

node_modules/react-native/Libraries/polyfills/error-guard.js ...
I tried various solutions suggested like adding transformIgnorePatterns but to no avail. can someone help me here ? javascript · reactjs · react ......
Read more >
transformignorepatterns - You.com | The AI Search Engine ...
This error shows that "react-native" has not been transformed: ... /Users/xxx/xxx/dev/node_modules/@react-native/polyfills/error-guard.js: Missing semicolon ...
Read more >
react-native/polyfills
The CDN for @react-native/polyfills. ... console.js, 17.6 kB, application/javascript. error-guard.js, 3.65 kB, application/javascript.
Read more >
realm | Yarn - Package Manager
This project hosts the JavaScript versions of Realm. Currently we support React Native (JSC & Hermes on iOS & Android), Node.js and Electron...
Read more >
TypeScript is a waste of time. Change my mind.
Working with older browsers - polyfills or Babel. Static typing and type inference - see point below. 2 - Typed JS is long...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found