Skip to content

Conversation

@Lyrkan
Copy link
Collaborator

@Lyrkan Lyrkan commented Oct 5, 2018

This PR closes #342 by allowing to configure the js/jsx loaders' exclude rule by using configureBabel().

For instance:

Encore.configureBabel(
    () => {},
    { exclude: /foo/ }
);

Note that it doesn't change the default behavior that excludes node_modules and bower_components.

Edit:

Also adds an include_node_modules option to use the default exclude rule but only include some Node modules (can't be used if the exclude option is also set):

Encore.configureBabel(
    () => {},
    { include_node_modules: ['foo', 'bar', 'baz'] }
);

@Lyrkan Lyrkan force-pushed the babel-exclude-config branch from cf28209 to 71793c0 Compare October 6, 2018 10:12
@Lyrkan Lyrkan force-pushed the babel-exclude-config branch 2 times, most recently from 11c911e to f05d4d2 Compare October 18, 2018 19:06
@Lyrkan Lyrkan force-pushed the babel-exclude-config branch from f05d4d2 to 714a732 Compare October 18, 2018 19:32
index.js Outdated
* // change the babelConfig
* }, {
* // set optional Encore-specific options
* // exclude: /(node_modules|bower_components)/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small detail: but could we add include_node_modules here too with a decent example? It's documented below, but at first glance, I thought this was the only option :)


if (!Array.isArray(options[optionKey])) {
throw new Error('Option "include_node_modules" passed to configureBabel() must be an Array.');
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great error checking and messages as usual!

@Lyrkan Lyrkan force-pushed the babel-exclude-config branch from 5deed94 to a07238c Compare October 20, 2018 15:10
@weaverryan
Copy link
Member

Thank you @Lyrkan! Great work as usual!

@weaverryan weaverryan merged commit a07238c into symfony:master Oct 26, 2018
weaverryan added a commit that referenced this pull request Oct 26, 2018
…eBabel (Lyrkan)

This PR was squashed before being merged into the master branch (closes #401).

Discussion
----------

Allow to configure the JS exclude rules through configureBabel

This PR closes #342 by allowing to configure the js/jsx loaders' exclude rule by using `configureBabel()`.

For instance:

```js
Encore.configureBabel(
    () => {},
    { exclude: /foo/ }
);
```

Note that it doesn't change the default behavior that excludes `node_modules` and `bower_components`.

**Edit:**

Also adds an `include_node_modules` option to use the default `exclude` rule but only include some Node modules (can't be used if the `exclude` option is also set):

```js
Encore.configureBabel(
    () => {},
    { include_node_modules: ['foo', 'bar', 'baz'] }
);
```

Commits
-------

a07238c Add an example of calling configureBabel with the "include_node_modules" option
714a732 Add "include_node_modules" option to configureBabel
6c8f073 Allow to configure the JS exclude rules through configureBabel
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.

Configuration setting to run babel on vendor files

2 participants