-
Notifications
You must be signed in to change notification settings - Fork 361
feat: add support for Babel macros #268
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
0484b8f
to
7e4baa5
Compare
Personally I would wait on #263 before merging this to keep more natural evolution of the babel support in microbundle. OTOH some babel support is already merged in (async functions~) so there is no much harm in this one. |
@Andarist can I do something to speed up the release cycle? At my company we recently started using microbundle for a big open source effort we are conducting that will lead to the public release of a lot of npm packages. We'd like to help as we can to take advantage of this library. Thanks! |
You can investigate why this fails - #263 (comment) . Or you can help @esphen implement this - rollup/rollup-plugin-babel#275 (he has already started some work) |
@FezVrasta Thanks for offering to help out! I just dug into why the test on #263 fails, so no need to help out there anymore. Feel free to help out with rollup-plugin-babel if you want, though 🙂 This is a great suggestion, so we should definetely look into this once #263 is merged! |
this new fork includes: - developit/microbundle#271 - developit/microbundle#268 - developit/microbundle#265 these changes are planned to be merged upstream anytime soon
This seems useful enough to bring in. |
This would require adding a test before merging. |
may someone help me understand why the snapshots test are failing? The only difference seem the letters used to minify the variable names edit: |
a080a22
to
993097f
Compare
@Andarist I added a test for the macro plugin |
test/fixtures/macro/src/macro.js
Outdated
@@ -0,0 +1,20 @@ | |||
const { createMacro } = require('babel-plugin-macros'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this macro simply takes:
const name = macro();
and converts it to:
const name = 'name-macro';
I'm using this branch on my project and I noticed that if I reference a macro, it gets bundled in the dist file even if it should be treated as external. Do you guys have any idea on why this could be happening? Basically, if I use |
Ok so, the issue was that the styled macro replaces its own import with Adding it to the dependencies list is a "workaround", I'm not sure if there's any way to make this work in all the cases automatically tho. |
this new fork includes: - developit/microbundle#271 - developit/microbundle#268 - developit/microbundle#265 these changes are planned to be merged upstream anytime soon
@Andarist could we merge this now that Microbundle makes use of Babel internally? |
If you rebase once more 😇 I can merge it into dev which will be released soon (currently pre release) |
Should I edit |
Probably 🙃 |
e8cf8b3
to
5f471fb
Compare
I rebased on top of
The import looks right, I'm not sure what's wrong |
Weird issue, seems to be a problem with babel plugin macros or something 🤔 or rollup babel |
5f471fb
to
5c84970
Compare
nvm, our babel thing was broke |
oh, now everything else is broken 👌 |
5c84970
to
042a80e
Compare
🎉🎉 |
I think it'd be very useful to support Babel macros out of the box, they allow to use Babel without additional configuration so they can improve a lot the developer experience without adding extra configuration to Microbundle.
Zero config tools such as create-react-app already support it.