Comments (6)
Heres my full babel.config.js
:
No conditionals and just the couple of plugins you see at the bottom of the plugins array.
module.exports = function (api) {
api.cache(true)
return {
presets: [
'module:metro-react-native-babel-preset',
'module:react-native-dotenv',
'@lingui/babel-preset-react'
],
plugins: [
[
'babel-plugin-root-import',
{
paths: [
{
rootPathPrefix: '~',
rootPathSuffix: 'src/'
},
{
rootPathPrefix: '#',
rootPathSuffix: 'Tests/'
}
]
}
],
['@babel/plugin-proposal-pipeline-operator', { proposal: 'minimal' }],
'macros'
]
}
}
from babel-plugin-root-import.
@juddey thanks for the help. Updated the README.
from babel-plugin-root-import.
Hey @brigand, here's a config with a babel.config.js
and the latest version of React-Native (0.57).
RN 56+ uses webpack 4 so I wonder if this renders the "env plugins array" redundant now...? I've never heard of the 'env plugins array' and I've been doing RN for about a year. Anyway, this works a treat for me.
I'll PR something up with the below if I haven't misunderstood the problem. Let me know.
plugins: [
[
'babel-plugin-root-import',
{
paths: [
{
rootPathPrefix: '~',
rootPathSuffix: 'src/'
},
{
rootPathPrefix: '#',
rootPathSuffix: 'Tests/'
}
]
}
]
]
from babel-plugin-root-import.
Babel 6 had a special way to define config for different NODE_ENV
values within a JSON file. If react-native is on Babel 7 (where the babel.config.js file was introduced), I'm good with just giving Babel 7 instructions.
Is there any other babel-related code in your project, or conditionals in the babel.config.js file?
from babel-plugin-root-import.
@brigand No probs! You beat me to the PR though. 😄 Have a great day!
from babel-plugin-root-import.
We switched to using babel-plugin-module-resolve
instead.
I have it working just fine on React Native 0.56.1:
package.json
"devDependencies": {
"babel-plugin-module-resolver": "3.2.0"
}
.babelrc
{
"plugins": [
[ "module-resolver", { "root": ["./src"] } ]
]
}
index.android.js
import Constants from "Constants";
from babel-plugin-root-import.
Related Issues (20)
- Problems with root import HOT 4
- cannot resolve error with create react app build script HOT 2
- React Native App MacOS process.cwd() got path in node_modules. HOT 3
- Don't let typescript get confused HOT 3
- ctags broken with root import
- Codacy Badge not found HOT 3
- play nice with import/order HOT 3
- Error: .plugins[0][1] must be an object, false, or undefined (Multiple custom prefixes) HOT 1
- Consider adding monorepo VSCode instructions HOT 2
- .rootPathPrefix is not a valid Plugin property HOT 3
- Not working with jest HOT 6
- unable to find '.../.../.../src' HOT 7
- Not compatible with babel-plugin-transform-imports HOT 2
- Please keep github & npm latest version numbers in sync
- Not working with Jest and typescript HOT 3
- Converting dynamic import HOT 4
- error Unable to resolve module `@/Routers` from `src/App.tsx`: @/Routers could not be found within the project. HOT 4
- Cannot webpack-build when depending on a package that uses your plugin HOT 1
- not working with storybook HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from babel-plugin-root-import.