45 Commits

Author SHA1 Message Date
Nicolò Ribaudo
ae06baf22f
Add support for babel.config.mjs and .babelrc.mjs (#10903)
* Add support for babel.config.mjs and .babelrc.mjs

* Use path.extname
2020-01-10 23:14:29 +01:00
Nicolò Ribaudo
bea1b0d0af
Add support for .cjs config files (#10599)
* Remove duplicate config loading logic and errors

* Add support for .cjs config files

* Add tests

* [tests] Fallback for fs.promises on node 6
2019-11-04 00:24:44 +01:00
Devon Govett
3a5e8a8dd4 Add support for babel.config.json (#10501)
* Add support for babel.config.json root config

* Throw if multiple configuration files are found

* Add tests
2019-10-29 19:37:50 +01:00
Nicolò Ribaudo
b459f6a0a4
Add windows to travis (#10249)
* Add windows to travis

* Update

* Do not use sh file on windows

* Fix whitespace

* Unify command

* ./ doesn't work on windows

* Remove all ./ usages

* Run windows test before others

* fix: normalize filename when generating sources

sources should be URL.

* fix: replace normalized path to cwd

* chore: add nodePlatform task options

* fix: normalize preset-env filename output

* chore: replace normalized path to CWD on win32 platform

* limit transform-react-source to run on linux and darwin

* test: escapeRegExp on testcases

* test: add test for babel --filename on windows

* test: double babel-node/cli test timeout

* chore: workaround windows build does not stop

* chore: remove redundant condition

* refactor: rename `nodePlatform` to `os`
2019-09-26 20:59:17 +02:00
Huáng Jùnliàng
8da9d8b4b8 feat(errors): validate preset when filename is absent (#10181)
* feat(errors): validate preset when filename is absent

Closes #10154

* fix: test overrides for filename compulsory

* docs: rewrite validate error message

per https://github.com/babel/babel/pull/10181#discussion_r301607986

* polish error message
2019-09-06 18:09:19 +02:00
Logan Smyth
fd9ebf9e1d
Remove option-filtering options from the final options results. (#8315)
| Q                        | A <!--(Can use an emoji 👍) -->
| ------------------------ | ---
| Fixed Issues?            | Fixes https://github.com/babel/babel-loader/issues/642
| Patch: Bug Fix?          | Y
| Major: Breaking Change?  | N
| Minor: New Feature?      |
| Tests Added + Pass?      | Yes
| Documentation PR Link    | <!-- If only readme change, add `[skip ci]` to your commits -->
| Any Dependency Changes?  |
| License                  | MIT

Since these were getting left in, things that loaded the config, and then passed in back to Babel would get `test` and such _twice_, which could lead to either bad configuration merging, or no configuration at all if the patterns were relative to different directories, as was the case in https://github.com/babel/babel-loader/issues/642.
2018-07-13 07:01:11 -07:00
Logan Smyth
53e4d74ebe
Treat all filenames as absolute paths. (#8044) 2018-05-24 20:56:19 -07:00
Logan Smyth
69cca412eb
Make the filename option, as exposed to the plugins, consistently relative to the working directory (#7956)
| Q                        | A <!--(Can use an emoji 👍) -->
| ------------------------ | ---
| Fixed Issues?            | 
| Patch: Bug Fix?          | Y
| Major: Breaking Change?  | N
| Minor: New Feature?      |
| Tests Added + Pass?      | Yes
| Documentation PR         | <!-- If so, add `[skip ci]` to your commit message to skip CI -->
| Any Dependency Changes?  |
| License                  | MIT

Currently the `opts.filename` value exposed to plugins is just whatever the user passed. While it _could_ be relative to the working directory, if Babel was passed an absolute URL, it'll be absolute.

This PR explicitly ensures the filename is a relative path based on the working directory. This also exposes an officially endorsed API for reading the working directory path.
2018-05-21 17:10:57 -07:00
Logan Smyth
98f0808a22 Ensure the the config file isn't re-processed when users load a partial config and then pass it back to Babel. 2018-05-11 17:49:12 -07:00
Logan Smyth
acf509bab5
Upgrade Babel to self-host with beta.46 (#7784) 2018-04-27 15:04:37 -07:00
Logan Smyth
a67eb25547 Only search for .babelrc files in the 'root' package by default. 2018-04-20 17:00:53 -07:00
Deven Bansod
95894397eb Migrate babel-cli and babel-generator tests to use jest-expect (#7549) 2018-04-11 13:12:56 -05:00
Deven Bansod
f3f0197890 Migrate babel-core tests to use jest-expect (#7513)
* Used codemods at: https://gist.github.com/devenbansod/03c5cff857661e076cbec72fcb2e7eb3 along with some manual intervention and review
2018-03-10 11:40:28 +01:00
Daniel Tschinder
3e95830646
Migrate to jest (#7455) 2018-03-03 10:58:19 +01:00
Logan Smyth
c292140254 Implement an 'overrides' config array to process in order for overrides. 2018-01-05 12:47:47 -08:00
Logan Smyth
f4a24a38ca Allow config objects to use test/include/exclude to limit application to specific files. 2018-01-05 12:47:47 -08:00
Logan Smyth
758fd0369c Rewrite config chain loading to build chain recursively to keep caching readable. 2017-12-21 19:06:36 -08:00
Logan Smyth
cdf420d4d8
Rewrite config chain tests to use public loadOptions API. (#6909) 2017-11-25 18:25:20 -08:00
Logan Smyth
18ea5aca51 Expose a 'cwd' option for Babel's root options. 2017-11-24 19:43:25 -08:00
Logan Smyth
74439889d8 Centralize envName lookup using caching sidechannel. 2017-11-15 10:05:48 -08:00
Logan Smyth
64abf75d1f Perform option validation up front to avoid repeating assertions. 2017-10-25 15:55:58 -07:00
Logan Smyth
3673fbbd52 Refactor config item processing. 2017-10-25 15:55:58 -07:00
aardito2
bfa167cc21 Add additional tests for ignore/only (#5647) 2017-10-12 20:20:07 -05:00
Logan Smyth
fc448ca8f2 Flatten, process, and cache incoming options by key. 2017-09-27 11:20:27 -07:00
Brian Ng
e4b35f680d
Run prettier 2017-06-27 12:15:00 -05:00
Logan Smyth
d1d812edff Fix a regression from adding negation support in #5625. (#5641) 2017-04-17 18:13:37 -07:00
Logan Smyth
1c078e5a76 Add tests for caching API and .babelrc.js functions. 2017-04-17 11:20:34 -07:00
Logan Smyth
d1c954b36f Allow negation of ignore and only patterns. (#5625) 2017-04-12 11:10:33 -07:00
Logan Smyth
d39400c9d5 Separate config/plugin loading from config processing. (#5563) 2017-04-04 14:48:48 -07:00
Kai Cataldo
1f2f63ccdf Fix: config lookup logic in babel-core (#5550)
This fixes a bug that was causing the config lookup to stop
when a package.json file was found even if it did not contain a
"babel" key.
2017-03-27 11:54:57 -07:00
Logan Smyth
12a2124d16 Move the deeply nested option logic to a toplevel folder. 2017-03-17 00:03:58 -07:00
Logan Smyth
bf13ed4da0 Limit where certain arguments are allowed in Babel config. 2017-03-17 00:03:58 -07:00
Logan Smyth
39c862c195 Make only/ignore relative to cwd/config file and move only/ignore checking all to core. (#5487)
* Make only/ignore relative to cwd/config file and move only/ignore checking all to core.
2017-03-16 23:22:43 -07:00
Logan Smyth
b6194a8533 Merge pull request #5467 from loganfsmyth/clean-options
Misc reorganizing and prep for ignore/only refactoring
2017-03-16 20:25:20 -07:00
Logan Smyth
dd1bc3b183 Resolve programmatic/CLI arguments from cwd, not file being compiled. (#5466) 2017-03-14 16:56:00 -07:00
Logan Smyth
bf4664b430 Invert the resolution order of config-chain to process higher-priority items first. 2017-03-14 13:39:57 -07:00
Kai Cataldo
d054cd0ea8 Add support for .babelrc.js files 2017-03-07 16:44:24 -05:00
Brian Ng
8a82cc060a Run new lint rules (#5413) 2017-03-04 10:46:01 -05:00
Sergey Rubanov
292c3ca206 Refactor test packages to use ES modules instead of CJS (#5138) 2017-01-16 11:25:04 -05:00
Henry Zhu
672adba9a1 enable prefer const (#5113) 2017-01-14 09:48:52 -05:00
Andrew Levine
9f8ab29213 Change usage of "suite"/"test" in unit-tests to "describe"/"it" (#4734)
Fixes #4733
2016-10-15 18:45:35 -04:00
Andrew Levine
c0038221d7 Run ESLint on test files, and fix lint errors in test files (#4732) 2016-10-15 18:27:48 -04:00
James Talmage
0a9cbe6e83 git commit add test for package.json config 2016-07-07 16:58:22 -04:00
James Talmage
8e84196eb8 add tests for env options 2016-07-07 16:36:34 -04:00
James Talmage
62ad67e5d9 add tests for build-config-chain 2016-07-03 23:58:44 -04:00