Trying to make it work with babel-preset-env
See original GitHub issueBabel-env let you determine the plugins and polyfills you need based on your targeted browser, which is really cool https://github.com/babel/babel/tree/master/experimental/babel-preset-env
But I’m having a hard time trying to make it work with universal-import
.
If I use a conventional .babelrc
file like this, it works perfectly:
{
"presets": ["es2015", "react", "stage-2"],
"plugins": [["emotion", { "inline": true }], "universal-import"],
"env": {
"development": {
"plugins": ["react-hot-loader/babel"]
}
}
}
But when I switch to babel-env
, universal-import
fails to transpile the imports:
This is my current .babelrc
:
{
"env": {
"devClient": {
"presets": [
["env", {
"targets": { "browsers": ["android >= 4.4", "ios_saf > 9", "and_chr >= 56"] },
"useBuiltIns": "usage"
}],
"react"
],
"plugins": [["emotion", { "inline": true }], "universal-import", "react-hot-loader/babel"],
},
"devServer": {
"presets": [
["env", {
"targets": { "node": "current" }
}],
"react"
],
"plugins": [["emotion", { "inline": true }], "universal-import"],
}
}
}
Any idea?
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:9 (9 by maintainers)
Top Results From Across the Web
babel-preset-es2015 -> babel-preset-env - Babel.js
We're super excited that you're trying to use ES2015 syntax, but instead of continuing yearly presets, the team recommends using babel-preset-env.
Read more >What is @babel/preset-env and why do I need it? - Jakob Lind
The most common way to use Babel is together with a build system such as webpack. When using Babel with a build tool...
Read more >Babel & preset-env. Compile to environments, not… - codeburst
Babel preset -env is a preset that compiles down to a minimum of ES5 ( preset-es2015 ), but can also take a browser...
Read more >How babel preset-env, core-js, and browserslistrc work together
Babel can use plugins for transpiling newer JavaScript syntax. Presets instead are collection of plugins. @babel/preset-env is a collection of ...
Read more >Unable to run a node.js file with @babel/preset-env
I'm trying to run a simple node.js file which needs the @babel/preset-env preset. The moment I run the js file, I get a...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yes. I am migrating a project from
nextjs
andstyled-components
toreact-universal
andemotion
😃My first step is to use emotion in
inline
mode and once everything is working try the switch toextractStatic
to see if there’s an improvement in performance. As you can see in ourbabel-env
conf, we are not worried about IE11, although I dislike having to use css variables for dynamic styles, instead of javascript variables.it was. but you can’t really develop these modern babel-based apps without at least stage 2.