Pass dirname as extra metadata to preset constructor.#4834
Pass dirname as extra metadata to preset constructor.#4834hzoo merged 9 commits intobabel:masterfrom
dirname as extra metadata to preset constructor.#4834Conversation
Sometimes a preset would like to know where it should resolve relative paths from (e.g. https://github.com/tleunen/babel-plugin-module-resolver) and this extra information makes that possible.
Codecov Report
@@ Coverage Diff @@
## master #4834 +/- ##
=======================================
Coverage 89.44% 89.44%
=======================================
Files 204 204
Lines 9949 9949
Branches 2689 2689
=======================================
Hits 8899 8899
Misses 1050 1050
Continue to review full report at Codecov.
|
|
/cc @hzoo? 😄 |
|
Let me know if you need anything from me @hzoo 😄 |
|
Should we add this to plugins too? |
|
@loganfsmyth I wouldn't be opposed personally, some plugins might make use of it. |
|
I am strongly in favour of doing this for presets. It would enable babel/babel-preset-env#26 to Just Work ™️ (see babel/babel-preset-env#161 for an alternative approach without this change to core, involving passing an explicit path in preset options) Re: Doing the same for plugins -
With that in mind - @hzoo @loganfsmyth, what are your thoughts about merging this? I'm thinking this just needs a test case and is otherwise ready to go. |
|
Hey @motiz88! It looks like one or more of your builds have failed. I've copied the relevant info below to save you some time. |
This adds a check for `dirname`’s existence and correctness to the `resolve-addons-relative-to-file` test, and serves as a minimal example of a path-aware preset.
|
I've added a minimal test for this (on the back of an existing test, which is not ideal but I think reasonable here). @izaakschroeder I hope you don't mind my fiddling with your branch 😅 All done now as far as I'm concerned. @xtuc thanks for the review, want to merge this? |
|
Oh no by all means, happy to have this making progress @motiz88 😄 |
|
Cool! Then I could make some changes to babel/babel-preset-env#161 and use |
|
Let me know if you need anything else from me @loganfsmyth, @motiz88. 🎉 |
|
Awesome! @hzoo Can you let me know what version this lands in? Thanks so much! |
|
Sorry for the super long delay, next release so probably this week/next? |
|
No worries, that sounds great! 👌 |
|
Sorry for the nag, but any further idea when this is going out? 😄 Thanks! |
* Use https://github.com/babel/babel-preset-env for the majority of compatbility plugins. * Detect proper working directory for path resolution with babel/babel#4834. * Add tests for path resolution. * Add plugins for `react` optimizations. * Update dependencies to latest versions.
* Pass `dirname` as extra metadata to preset constructor. Sometimes a preset would like to know where it should resolve relative paths from (e.g. https://github.com/tleunen/babel-plugin-module-resolver) and this extra information makes that possible. * Test for `dirname` passed into preset constructor This adds a check for `dirname`’s existence and correctness to the `resolve-addons-relative-to-file` test, and serves as a minimal example of a path-aware preset.
Sometimes a preset would like to know where it should resolve relative paths from (e.g. any preset that uses https://github.com/tleunen/babel-plugin-module-resolver) and this extra information makes that possible.