New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't modify babel rule to exclude bootstrap in node_module #558
Comments
Something more... if I copy the babel config from file babel.js to .babelrc:
It doesn't work neither. I have tried to replicate the logic of option
The callback is executed when run
it works as expected. I can't find the difference between the two methods so I think there is something in the middle that breaks my alternative when using the .babelrc file. |
Note that in the latest version of Encore, you can now use the |
Yeah, I know! But my question is about the difference in the two methods because it seems that using |
Hi @ger86, I can't see any reason why it wouldn't work since the I did a quick test with the following files and it seems to be fine: // webpack.config.js
const Encore = require('@symfony/webpack-encore');
Encore
.disableSingleRuntimeChunk()
.setOutputPath('build/')
.setPublicPath('/')
.cleanupOutputBeforeBuild()
.addEntry('main', './src/index.js')
;
const config = Encore.getWebpackConfig();
const babelLoader = config.module.rules.find(
rule =>
rule.use &&
rule.use[0] &&
rule.use[0].loader === 'babel-loader'
);
babelLoader.exclude = /node_modules\/(?!bootstrap\/).*/;
module.exports = config; // src/index.js
require('bootstrap/js/src/popover.js'); Without the
With it:
Would you be able to share a repository that could show this issue? |
Sure, I will post a repository with the failing code this weekend. Thanks |
Hi, As you will see, when there is a .babelrc file, you get the spread operator in the resulting file. Thanks |
@ger86 I think that the No matter which one of the config listed in your However, it doesn't do it with the same config than the one used for your files:
As noted on the following page a |
Hi @ger86, Just a simple question, what's your need to transpile Bootstrap source code, when you can only include what you need of Bootstrap thanks to the files in import 'bootstrap/js/dist/dropdown' |
@Johann-S Not sure how useful it would be (if at all), but one possible use-case would be to use their own targets instead of the ones used during Bootstrap's release process. |
Ahhh, maybe that is the "problem" what causes that behaviour. I don't know about another |
Yes, because when Bootstrap 4 was released the files in dist was not ES6 modules, so I can't use in that way.. |
@ger86 according to what you said, you should think about updating your Bootstrap version because we released several security fixes and you'll be able to use the dist files |
Hi,
Last year I found a solution to allow Babel to process files in
node_modules
using something like this:But in the recent versions, when I run
yarn run encore production
I get the files from Bootstrap without being transpiled, which not happens in my regular files.I am using the file babelrc to configure Babel:
The weird thing is that if I configure Babel through webpack.config.js:
it works perfect. So I don't know the difference between the two solutions. Is there any implementation detail under this case that causes the first solution not valid (as I said, last year it works well)?
The text was updated successfully, but these errors were encountered: