Skip to content

Conversation

@ihmels
Copy link
Contributor

@ihmels ihmels commented Sep 29, 2019

This PR allows you to configure @babel/preset-env by calling Encore.configureBabelPresetEnv() without the need to create a .babelrc and lose the ability to activate presets automatically.

Encore
    .configureBabelPresetEnv((config) => {
        config.corejs = 3;
        config.useBuiltIns = 'usage';
        config.include = ['foo-plugin'];
    });

The options corejs and useBuiltIns of Encore.configureBabel() should be deprecated.

@weaverryan
Copy link
Member

This makes sense - it's the one preset we add, so indeed, why not allow it to be configured. Thanks Yannick for the nice PR!

weaverryan added a commit that referenced this pull request Oct 7, 2019
This PR was merged into the master branch.

Discussion
----------

Allow to configure babel env preset

This PR allows you to configure `@babel/preset-env` by calling `Encore.configureBabelPresetEnv()` without the need to create a `.babelrc` and lose the ability to activate presets automatically.

```js
Encore
    .configureBabelPresetEnv((config) => {
        config.corejs = 3;
        config.useBuiltIns = 'usage';
        config.include = ['foo-plugin'];
    });
```
The options `corejs` and `useBuiltIns` of `Encore.configureBabel()` should be deprecated.

Commits
-------

261aa81 Allow to configure babel env preset
@weaverryan weaverryan merged commit 261aa81 into symfony:master Oct 7, 2019
weaverryan added a commit that referenced this pull request Nov 23, 2019
…ome deprecations (Lyrkan)

This PR was merged into the master branch.

Discussion
----------

Add .babelrc error to configureBabelPresetEnv and remove some deprecations

Since we do not configure `@babel/preset-env` if there is a `.babelrc` file (or something similar) it makes sense to add the same warning we already have for the `Encore.configureBabel()` function to `Encore.configureBabelPresetEnv()`:

> The "callback" argument of \<function\> will not be used because your app already provides an external Babel configuration (a ".babelrc" file, ".babelrc.js" file or "babel" key in "package.json

This PR also removes some deprecation that were added by #642.
We talked about them with @weaverryan and it's probably not worth removing the `useBuiltIns` and `corejs` options of `Encore.configureBabel()`:
* they are currently recommended by the flex recipe
* it allows us to document them/check them easier than with a callback

Commits
-------

5154b38 Add .babelrc warning to configureBabelPresetEnv and remove some deprecations
@stollr
Copy link

stollr commented Dec 29, 2023

Would be nice if an explanation or link to a resource could be added, where it is explained how to use this configureBabelPresetEnv for a newbie in the webpack/encore/babel/react world ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants