.babelrc ignore field seems to be ignored - babeljs

I've got a .babelrc file at the root of a project:
{
"presets": ["es2015"],
"ignore": [
"src"
]
}
When I compile it with babel src --out-dir dist, the src folder is still compiled onto the dist folder.
However, when I launch the command babel src --out-dir dist --ignore src, nothing is compiled.
Why is the ignore property of my .babelrc being ignored?
By the way, I've tried with some subfolder or files, and the same issue occurs.

This was an issue with babel-cli.
It has been fixed in v6.14.0. Here is the changelog for this version: https://github.com/babel/babel/releases/tag/v6.14.0

Related

Babel7 not excluding files/folders with --ignore

babel src --out-dir dist --copy-files --ignore **/*.test.js
This is the line that i try to execute with yarn inside a script in package.json but still builds inside dist folder test files...Still not working via .babelrc

BabelJS: Doesn't find all .js files in directory

Babel doesn't find all of my .js/.es6 files in my directory.
I have this directory structure:
src/
assets/
sample/
models.es6
scripts/
playground.es6
If I run babel src --out-dir dist --source-maps --copy-files --presets env, it only transpiles /src/assets/sample/models.es6 and doesnt go through src/scripts/playground.es6.
What am I doing wrong?
Looking forward to your response!
You can do like below :
babel src/** --out-dir lib
more at official doc
Compile Directories
Compile the entire src directory and output it to the lib directory. You may use --out-dir or -d. This doesn’t overwrite any other files or directories in lib.
if you still stuck, you can use gulp or grunt or webpack to load/transpile mupltiple directives from different locations.
Hope it helps
I found the problem. It has barely to do with Babel.
Inside the src/assets/** is my Realm database sample.realm (https://realm.io). The file itself doesnt cause the problem. But if you open the sample.realm file with Realm Studio on MacOSX, a file called sample.realm.note gets created. This file causes babel to not exit the transpile task.

Babel file structure is duplicating

Using latest babel preset. My .babelrc contains
{
"presets": ["env"]
}
In my package.json, I run it as follows:
"build:babel": "babel app.js app/** venue/** -d build",
My original code structure is:
But after running babel my build folder looks like the following:
The problem I'm seeing is that it's building the file in the sub-directories correctly but it also putting it into the root build folder. Example: "containers" is in the build folder under app/plugins/containers which is correct. But its also in the root build folder. Also, the files "border, button, card, checkbox, click, color_picker, ..." belong in other sub-directories (which it is), but is also in the root build folder.
I'm wondering if I'm running it incorrectly?

Why am I getting a babel errors from a .babelrc file in a parent directory

I was recently trying to debug errors in a next.js getting started project and realized that it didn't like a .babelrc file in a parent directory.
My questions are:
Why is the project throwing an error on a .babelrc configuration file in a parent directory that's not part of the project? Does it recursively look for a babel configuration file in all parent directories or did I at some point configure babel to look at that config file? How can I check what that configuration is?
Is this a quirk of next.js that makes it look for a configuration file in a parent directory?
I forgot if I had added that .babelrc configuration in the parent directory - is that something that I needed? What is the configuration? How should I update it to make the error go away?
ERROR in ./pages/index.js
Module build failed: ReferenceError: [BABEL] /Users/me/Projects/foo/foo-web/pages/index.js:
Using removed Babel 5 option: /Users/me/Projects/.babelrc.optional
- Put the specific transforms you want in the `plugins` option
.babelrc
"optional": ["es7.classProperties"]
babel is looking first .babelrc file is present in the root directory
you have to create the .babelrc file
npm install babel-plugin-transform-runtime
insert to .babelrc
{
"plugins": [
"transform-runtime"
]
}
more info

babel CLI copy nonjs files

I'm running a babel cli command
babel src --out-dir lib
To copy the es6 scripts from src into lib. However, it wont copy css/scss files I have in the src/ folder. Is there a way to make it copy them as well?
Babel has the copy files option for this:
babel src --out-dir lib --copy-files
Note: It is true that babels primary purpose is to process javascript files, but babel's big suite of tools these day often makes it unnecessary to go for more complex build script setups as gulp and alike.
A gulp-less setup could be adding this to packages.json:
{
...
"devDependencies": {
"babel": "*",
"babel-cli": "^6.4.0",
"babel-preset-es2015": "^6.3.13"
},
"scripts": {
"watch": "babel --watch src --out-dir lib --source-maps inline --copy-files",
"build": "babel src --out-dir lib --source-maps inline --copy-files"
},
"babel": {
"presets": [
"es2015"
]
}
}
I found a way to do this by using the ncp module
npm install ncp
This module is basically like a cp except it works on
This isn't a global module, so to run this we use
node -e \"require('ncp').ncp('./src', './lib')\" && babel src --out-dir lib