Babel-cli docs incorrectly imply that Babel supports generic blob pattern matching in `ignore`/`only` and such
See original GitHub issueBug Report
Current Behavior
The file in src/__mocks__/@company
is processed but Glob will ignore that file when given the same pattern.
Input Code https://github.com/jcollum-nike/babel-glob-bug
Run node glob-test.js:
[ 'src/index.js' ]
[ 'src/index.js' ]
[ 'src/index.js' ]
Then run these commands:
# nr = npm run (alias)
nr --silent clean && nr --silent build:pass1 && tree cjs
Successfully compiled 1 file with Babel.
cjs
└── index.js
nr --silent clean && nr --silent build:pass2 && tree cjs
Successfully compiled 1 file with Babel.
cjs
└── index.js
nr --silent clean && nr --silent build:fail1 && tree cjs
Successfully compiled 2 files with Babel.
cjs
├── __mocks__
│ └── @company
│ └── some-fn.js
└── index.js
Expected behavior/code
The file in src/__mocks__/@company
is ignored in all three scenarios when processed with babel CLI.
Environment
- Babel version(s): 7.2.3 (@babel/core 7.3.4)
- Node/npm version: Node 8.15
- OS: OSX
- Monorepo: no
- How you are using Babel: cli in package.json
Issue Analytics
- State:
- Created 5 years ago
- Comments:11 (5 by maintainers)
Top Results From Across the Web
Babel CLI
Babel comes with a built-in CLI which can be used to compile files from the command line.
Read more >@babel/plugin-transform-unicode-regex - Package Manager
Intro. Babel is a tool that helps you write code in the latest version of JavaScript. When your supported environments don't support certain...
Read more >How do I tell Babel CLI to ignore any path with "__"
There seems to be some debate about whether Babel fully supports Glob patterns at the CLI level. I managed to get it working...
Read more >@babel/preset-env: Versions | Openbase
#14950 Emit @babel/cli source maps based on configuration files (@liuxingbaoyu) ... babel-plugin-transform-named-capturing-groups-regex , babel-standalone.
Read more >Why you don't need Babel - LogRocket Blog
Babel is a compiler that converts your modern JavaScript to run in older browsers. It can also perform other jobs such as converting...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
This is expected behavior, Babel has extremely minimal support for globs: https://babeljs.io/docs/en/options#matchpattern
We literally only global-match when
*
and**
are whole-path-segment placeholders, so__*
in this case would not be treated as a glob, but rather as a folder with that specific name.If you want to use more complex glob matching, you can always use a JS config file and pass a function that uses the
glob
library used in your example. Then you can toggle that with--env-name
or your own environment variable or whatever you’d like.I agree that the docs need to be updated. I’ve filed https://github.com/babel/website/issues/1986 since the website docs are not tracked in this repo.
The dependencies of a package really isn’t something to depend on when considering functionality, specially since Babel is split across many packages. Making assumptions based on that can lead to confusion exactly like what you’re raising here.
ignore
is a feature of Babel as a whole, not the CLI, so it is implemented@babel/core
which has no dependency onglob
.Gonna close since the doc update is tracked in the other repo, but happy to continue discussing.