New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: babel-register preset-env not applied in node_modules #13895
Comments
Hey @serdec! We really appreciate you taking the time to report an issue. The collaborators on this project attempt to help as many people as possible, but we're a limited number of volunteers, so it's possible this won't be addressed swiftly. If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack community that typically always has someone willing to help. You can sign-up here for an invite. |
Babel does compile react-native but this file uses Flow syntax, which is not supported by preset-env because it is not Standard JavaScript. You can add |
thanks Huang, that solved the problem. However a few other problems of variables and environment not properly set come up (e.g DEV not defined which i solved defining it globally). Any suggestion on how to properly transpile react-native modules so that it is possible to use them with other testing frameworks other than jest? |
You may try if |
I don't think using Due to how |
hey @nicolo-ribaudo thanks for your answer. You are actually right and the However, The problems that i encounter now don't seem related to javascript syntax or transpilation in general, but rather to some missing setup that happens when react-native is run on ios or android. I checked how Would be nice to hear what you guys think of that |
I tried cloning your repository, but I don't fully understand the problem.
|
You could try using https://www.npmjs.com/package/babel-plugin-module-resolver to map that missing file to a custom mock. |
thanks Nicolo', yes i guess at this stage the problem is not related to babel anymore, but rather to I doubt that simply mapping the |
馃捇
How are you using Babel?
@babel/register or @babel/node
Input code
I get the following error when trying to transpile the
react-native
modules inside thenode_modules
i created the following repo to reproduce the issue
https://github.com/serdec/babel-register-react-native-issue-preset-env
Configuration file name
babel.config.js
Configuration
Current and expected behavior
@babel/register
applies the@babel/preset-env
correctly to the files inside the package but not on those inside thenode_modules
i would expect that the same presets are applied when transpiling
node_modules
Environment
System:
OS: macOS 12.0.1
Binaries:
Node: 14.15.4 - ~/.nvm/versions/node/v14.15.4/bin/node
Yarn: 1.22.11 - ~/.nvm/versions/node/v14.15.4/bin/yarn
npm: 8.1.1 - ~/.nvm/versions/node/v14.15.4/bin/npm
npmPackages:
@babel/core: ^7.15.8 => 7.15.8
@babel/plugin-transform-runtime: ^7.15.8 => 7.15.8
@babel/preset-env: ^7.15.8 => 7.15.8
@babel/register: ^7.15.3 => 7.15.3
@babel/runtime: ^7.12.5 => 7.15.4
@babel/runtime-corejs2: ^7.15.4 => 7.15.4
babel-jest: ^26.6.3 => 26.6.3
eslint: 7.14.0 => 7.14.0
jest: ^26.6.3 => 26.6.3
metro-react-native-babel-preset: ^0.66.2 => 0.66.2
react-native: 0.66.1 => 0.66.1
Possible solution
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: