babel --ignore option doesn't work with star at the end of patterns
See original GitHub issueBug Report
- I would like to work on a fix!
Current behavior
Running a command such as babel src --out-dir dist --ignore '**/*.test.*'
does not exclude files that should match *.test.*
(e.g. thing.test.js
). It does work when using --ignore '**/*.test.js'
, but that means each possible extension (e.g. .js
, .jsx
) has to be ignored individually.
Input Code
$ npx babel --version
7.10.5 (@babel/core 7.11.4)
$ ls src
thing.js thing.test.js
$ npx babel src --out-dir dist --ignore '**/*.test.js' # works
Successfully compiled 1 file with Babel (230ms).
$ ls dist
thing.js
$ npx babel src --out-dir dist --ignore '**/*.test.*' # does not work
Successfully compiled 2 files with Babel (232ms).
$ ls dist
thing.js thing.test.js
thing.js
and thing.test.js
are just empty files.
Expected behavior
*
at the end of the glob pattern should work, and files that match should be ignored.
Babel Configuration (babel.config.js, .babelrc, package.json#babel, cli command, .eslintrc)
- No config files, CLI commands are above.
Environment
$ npx envinfo --preset babel
npx: installed 1 in 4.212s
System:
OS: Linux 5.8 Arch Linux
Binaries:
Node: 14.8.0 - /usr/bin/node
Yarn: 1.22.4 - /usr/bin/yarn
npm: 6.14.7 - /usr/bin/npm
npmPackages:
@babel/cli: ^7.10.5 => 7.10.5
@babel/core: ^7.11.4 => 7.11.4
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Options - Babel.js
If all patterns fail to match, the current configuration object is considered inactive and is ignored during config processing. This option is most...
Read more >Babel ignore several directories - Stack Overflow
You can ignore multiple directories and specify a globbing pattern within the .babelrc file like this { ..., "ignore": [ "node_modules" ...
Read more >API - ESBuild
This API call is used by the command-line interface if no input files are provided and the --bundle flag is not present. In...
Read more >Localization and internationalization Unicode TEX ... - TeXDoc
No hyphenation patterns were preloaded for (babel) the language 'LANG' ... EXAMPLE Some classes load babel with a hardcoded language option.
Read more >@babel/preset-react | Yarn - Package Manager
:rocket: [New Feature]; :bug: [Bug Fix]; :memo: [Documentation] ...
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
I contend that it is a bug because the behavior is not documented.
some.*
is never supported to match any extensions. https://github.com/babel/babel/blob/2984f0cb882ea6d51033f37945e47eb2d9eb4760/packages/babel-core/src/config/pattern-to-regex.js#L39Babel implements a very limited simple pattern that supports only
**
,*
and*.ext
. As a workaround, you can specify it multiple timesNote that
ignore
supports RegEx and function, you can also use a functionDocs: https://babel.dev/docs/en/options#matchpattern
Feel free to submit a PR if you would like
.*
be supported.