Questions tagged [babel-preset-env]

73 questions
88
votes
2 answers

Confused about useBuiltIns option of @babel/preset-env (using Browserslist Integration)

I'm working on a web project using Babel 7 with Webpack 4. I've never used Babel before and can't really understand some parts of it. Based on the documentation I'm using @babel/preset-env because it seems the recommended way (especially for…
szegheo
  • 4,175
  • 4
  • 31
  • 35
30
votes
2 answers

Babel Preset does not provide support on IE11 for Object.assign - "Object doesn't support property or method 'assign'"

I am using babel-preset-env version - 1.6.1 for my react app, i am getting a error on IE :- Object doesn't support property or method 'assign' this is my .babelrc :- { "presets": [ "react", [ "env", { "targets":…
Ayesha Mundu
  • 1,075
  • 2
  • 11
  • 18
20
votes
1 answer

What is best practice for `@babel/preset-env` + `useBuiltIns` + `@babel/runtime` + `browserslistrc`

I get different output for different configurations of @babel/preset-env with useBuiltIns used in combination with @babel/transform-runtime. I've read the documentation, but haven't been able to figure out what the best practice should be. For…
Bernard Leech
  • 756
  • 7
  • 14
15
votes
3 answers

Babel with babel-preset-env seems to ignore browserslist config

I’m testing Babel with browserslist in an npm script. Here is my current package.json, in which Babel is doing what I expect: { "name": "npm-scripts-igloo", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { …
15
votes
5 answers

Plugin/Preset files are not allowed to export objects, only functions

I'm getting this error after updating react-native to "^0.56.0": bundling failed: Error: Plugin/Preset files are not allowed to export objects, only functions. In /Users/ben/vepo/frontend/node_modules/babel-preset-flow/lib/index.js I tried to do…
BeniaminoBaggins
  • 11,202
  • 41
  • 152
  • 287
14
votes
2 answers

Do I need to import core-js/stable and regenerator-runtime/runtime when using @babel/preset-env with useBuiltIns:'usage'?

I use babel 7.8.3 together with @babel/preset-env, useBuiltIns: 'usage' and corejs: 3. The documentation for @babel/preset-env is not clear to me. Do I need to add the following lines at the top of my entry file or is it done automatically by…
wube
  • 923
  • 2
  • 10
  • 22
9
votes
2 answers

what does the "modules:auto" means in @babel/preset-env field?

the babel docs say the modules default option is auto, what does the auto means? does it transform the "import" to "require" or not? what's the difference between "modules: false" and "modules: auto"? it seems they are the same result; I'm learning…
lastStranger
  • 185
  • 2
  • 9
7
votes
9 answers

React: Couldn't find preset "env react" relative to directory "src"

I have added presets react and env into my react project using the command below: yarn global add babel-preset-react@6.24.1 babel-preset-env@1.5.2 My package.json file has updated the presets and looks like the following: { "name":…
Akrit
  • 91
  • 1
  • 4
6
votes
0 answers

Unable to polyfill `Object.fromEntries` using babel/preset-env

Am I misunderstanding something about or misconfiguring babel/preset-env? I'm using babel configs for vite using vitejs/plugin-legacy, but for AstroJS project. plugins: [ legacy({ targets: ['defaults', 'not IE 11', 'ios_saf > 10'] }) ] From…
Chill3n
  • 61
  • 1
  • 2
6
votes
0 answers

Do I still need to use babel-preset-env and Babel plugins if I am using babel-polyfill?

My understanding is that the Babel Polyfill emulates a full ES6 environment, whereas babel-preset-env compiles ES6 (and beyond) to ES5 automatically based on the environments (browsers) you need to support. I have a few questions regarding…
tomhughes
  • 4,597
  • 2
  • 24
  • 33
5
votes
1 answer

Rollup + @babel/preset-env + @babel/polyfill

When using Rollup how can you get it to work with both @babel/preset-env and @babel/polyfill? The docs mentioned to add useBuiltIns: 'usage' but when I do this I get a require is not defined error in console. Below is what I have so far; is there a…
Maurice
  • 325
  • 2
  • 12
4
votes
3 answers

Module not found: Error: You attempted to import babel-preset which falls outside of the project src/ directory

I'm developing an application created using create-react-app But then I needed to use mediainfojs library, this library requires wasm files, and based on what I understood I couldn't add it using create-react-app, I had to eject it. After ejecting…
dfranca
  • 5,156
  • 2
  • 32
  • 60
4
votes
1 answer

Polyfill using browserlist in Gatsby always provided

I was experimenting with Gatsby and polyfills using browserlist, which is supported by Gatsby (doc). Using the default browserlist config, I get the expected result which creates polyfills for IE11 and a working alert. See my github repo example.…
Albert Skibinski
  • 499
  • 4
  • 21
4
votes
1 answer

How can I configure babel/preset-env to include core-js URLSearchParams polyfill?

I'm using URLSearchParams in my app. The code is transpiled with babel, using babel/preset-env and core-js@3 to include polyfills needed for the browsers I target. This is my babelrc: { "presets": [ [ "@babel/preset-env", { …
Lars Nyström
  • 5,786
  • 3
  • 32
  • 33
4
votes
1 answer

Multiple webpack bundles with browserslist and babel preset-env

I am bundling using Webpack 4. I have multiple Webpack configurations exported in webpack.config.js. First configuration is to bundle lient code targeting browsers. Second configuration is to bundle server code targeting node. I am specifying these…
geeko
  • 2,649
  • 4
  • 32
  • 59
1
2 3 4 5