-
Notifications
You must be signed in to change notification settings - Fork 522
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
babel_library for babel support and compatibility with ts_devserver #217
Conversation
/cc @mprobst who is working on a similar transpilation for es6 sources and |
Hey @Globegitter would you like some help with this? I think Babel rules are an important missing area, and would help to get a chunk of the community interested in Bazel (I talked to James Kyle a bit this week) |
@alexeagle Yeah would be very open to help. I am back from holiday on Friday. Then I can look more at #211. A specific open question I had was how to handle node modules. To me it seems the more bazel way would be to specify each direct dependency directly on the js_library but it seems the direction for the js rules seems to just specify the whole node modules. And I was wondering if it even makes sense to specify that for each js_library target, or if that is just expected to be handled fully by the top level rules, such as ts_devserver and rollup_bundle? |
Okay let's try to schedule some time on Friday to work together on it?
…On Mon, Jun 4, 2018 at 2:30 AM Markus Padourek ***@***.***> wrote:
@alexeagle <https://github.com/alexeagle> Yeah would be very open to
help. I am back from holiday on Friday. Then I can look more at #211
<#211>. A specific open
question I had was how to handle node modules. To me it seems the more
bazel way would be to specify each direct dependency directly on the
js_library but it seems the direction for the js rules seems to just
specify the whole node modules. And I was wondering if it even makes sense
to specify that for each js_library target, or if that is just expected to
be handled fully by the top level rules, such as ts_devserver and
rollup_bundle?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#217 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAC5I6jSHMh332ghkmIhecwXanHZjnx0ks5t5P4jgaJpZM4UQa0d>
.
|
I just sent you an email. |
@Globegitter @alexeagle I'm looking forward to this! We want to incrementally convert our legacy Babel built projects to TypeScript with Bazel but without a js_library rule it's pretty awkward! |
…etter & simpler cli behaviour.
@Globegitter how is this going? LMK when you're ready for another review pass. |
@alexeagle yeah sorry for the long delay on this, it has not been on my immediate priority list for a while as we found other solutions but it is starting to become more relevant again. I am very close for it to be ready for another review, next week I should have time for the last touches. The benefit of it taking that time is I have gotten a much better sense of how things work with bazel internally :) |
I'm up for it. Babel support is a huge part of the javascript ecosystem and if we want to get Bazel actual adoption in js we really need to do it right. Happy to help if I can. |
@alexeagle Yep that sounds good, I could do both days but Friday would work a bit better. How do we best schedule this? |
fyi, I was getting the following error while trying to create a babel_library.
I resolved it by lifting the mkdirp code from npm_package/packager.js |
Should the output folder retain transpiled files that I've removed from the source package? |
@pward123 which version of node are you using? You need to be using at least 10.12, though I would recommend 10.13 as it is the latest LTS. |
And not sure I understand your second question - you mean if the transpiled files will stay in |
Ah, I've been sticking with 8.11 since I have a few legacy apps that can't move to 10 yet. |
If necessary I can also make the code backwards-compatible, it just seemed too nice to now have it available as native node api. |
But how is it going, are you getting these rules to work for you? |
I'm very green to Bazel so it wasn't totally pain free. However, I was able to get babel_library working on a very simple package. Putting together a solution for transpiling without all the rollup overhead was on my short list. I've also learned a fair amount about Bazel by looking through what you've done. Thanks! On the clean issue. Let's say I run ibazel and remove a file from my source. The babel_library would still retain the transpiled version of the deleted file in the bazel-out folder. I'll probably just end up copying internal/babel_library into my monorepo and modifying it for 8.x and also globby the js files from the out-dir then delete the ones that weren't transpiled this pass. |
Ahh, you are talking particularly about ibazel, I am not sure, it might just do the right thing if you are using But yeah copying this into you repo manually sounds like a good solution for now. Happy to hear any further feedback in how this can be improved or if it is working well for you. |
fyi, I've finished my first pass at moving the babel_library code into my own repo. One thing you might be interested in is the minor cleanup and removal of sync operations in babel.js |
Sorry I missed the thread about scheduling a VC. |
srcs = ["test.js"], | ||
babel = "@devserver_example_yarn_install//@bazel/babel/bin:babel", | ||
# Note: This rc file will only be found by babel when run in the devserver_example workspace | ||
# but not in the top-level one, due to how bazel currently handels pathing |
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.
I think it should be "handles".
@Globegitter thank you for the PR! there are some things I'd kindly ask you to address:
Possible fix I've figured out for it is to include
Again, thank you so much for submitting this PR 🙂 |
@vmax the The json |
Hey guys this looks exciting! Any plans to move forward with it? It would be a great tool to have before piping stuff to rollup_bundle. |
I'll pick this up now - I agree that babel is a good step before rollup (maybe we'd also want to use it after rollup to downlevel for older browsers) |
Hey @Globegitter do you have some patience to work with me to get this going again? I think we ought to start over and pull in some of your ideas and tests, because things have changed a lot since you worked on this:
I started a new branch at https://github.com/alexeagle/rules_nodejs/tree/babel - could we pair up to get that to parity with what you need? I haven't used Babel much. @pward123 are you still using rules_nodejs? I see that you also did some hacking on this rule. Want to help get it upstreamed? Thanks! |
We now run babel in the examples, so in theory you don't need a |
Closes bazel-contrib#217 PiperOrigin-RevId: 225095761
Closes bazel-contrib#217 PiperOrigin-RevId: 226071736
Closes bazel-contrib#217 PiperOrigin-RevId: 225095761
Closes bazel-contrib#217 PiperOrigin-RevId: 226071736
This is a first proof of concept that picks up on the ideas talked about in #149, #137 and #200 to have full js (using es6 modules) support with
ts_devserver
as well with the possibility of some incremental transpilation before passing to arollup_bundle
or equivalent.I ended up using babel for the js_library rules as it seems to be the easiest way to downlevel es6 modules to amd, this also opens up the nice possibility to reuse this for further transpilation in the future. This does not support node_module dependencies yet and probably has some other ways how it can be improved (e.g. there is the issue with #211) but I thought I would push this out before I go on holiday to have something to get the conversation started.