I've got an issue, I've added babel:false but not working.
{
test: /\.js(x)?$/,
use: [{
loader: 'babel-loader',
options: {
babelrc: false,
presets: [
[
require('babel-preset-es2015'),
],
require('babel-preset-stage-3'),
],
plugins: [
require('babel-plugin-transform-object-rest-spread'),
require('babel-plugin-transform-class-properties'),
require('babel-plugin-syntax-dynamic-import'),
],
},
}],
exclude: /node_module/,
},
When I run webpack, it still read .babelrc options, what's wrong with it?
Thanks!
Webpack Version:
2.5.1
Babel Core Version:
6.24.1
Babel Loader Version:
7.0.0
Please tell us about your environment:
OSX 10.x
Current behavior:
babelrc: false not working still read .babelrc
Expected/desired behavior:
not reading .babelrc only read options from babel-loader
I am having the same issue as well.
@thecodegoddess
Are u using it with vue? I've found that vue-loader only use .babelrc.
But I've found some solution for it.
no, not with vue.
I'm having a hard time to replicate your problem, can you provide a small project example please?
@Couto
Thanks a lot! Just figure out how this error happens with vue.
I test code in .js files it worked really fine, but in .vue files it fails.
I update the code like this and works.
plugins: [
new webpack.LoaderOptionsPlugin({
options: {
vue: {
loaders: {
js: `babel-loader?${JSON.stringify(babelOptions)}`,
},
},
},
}),
],
But I don't know @thecodegoddess 's promblem, maybe you can @thecodegoddess .
Thanks!
I had the same issue where I could not get babelrc: false to work. The solution I am working on at the moment is to change the name of the .babelrc file to something else (._babelrc) so babel-loader can't find it and then pass the config in by hand like this:
server.babel.js
const fs = require('fs');
const babelrc = fs.readFileSync('./._babelrc');
const config = JSON.parse(babelrc);
require('babel-core/register')(config);
and then require that at the top of any init file I have for the rest of my code like this:
index.js
require('./server.babel');
const server = require('./server');
server();
but non of this would be necessary if I understood where in the webpack config to use babelrc: false assuming it works at all.
I was trying to get Webpack / Babel-loader / react all working today and had a bunch of issues with version 7.1.0.
First read and exist were both required with parens, meaning including index.js was causing exceptions:
var read = require("./utils/read")();
After I fixed that (by removing the parens as in the latest version), I started running into this tickets error. On my version I changed line 117 to read:
babelrc: loaderOptions.babelrc && (exists(loaderOptions.babelrc) ? read(loaderOptions.babelrc) : resolveRc(path.dirname(filename))),
which seems to effectively allow the process to proceed. I am passing in the full babel rc as loaderOptions (as I was trying to get any of this to work all day). Tomorrow I will try checking out the latest version and see if I can make better process. With all those changes though, I was able to use webpack/babel/react and compile the jsx files into modules.
Not sure if anyone wants to merge that patch, but it should restore the ability to pass babelrc=false to skip reading a config file and since I had already tracked that down and patched it, I figured I would offer it.
Is there a test for this? It seems I'm getting this in v7.1.5.
still not working.
Still still not working :P
where can I find babelrc: false option? in which file please!
@mohsenuss91 there's an example in the issue description.
Most helpful comment
Is there a test for this? It seems I'm getting this in v7.1.5.