-
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
rollup_bundle should use write_amd_names_shim #137
Comments
Angular uses that undocumented The commonjs plugin causes problems, for example it tries to load rxjs commonjs distro which doesn't tree-shake well. We'd need the right assertions in tests to prevent the commonjs plugin loading code that was built by bazel. Can you share the use case? I assume you'd like to bundle some off-the-shelf JS library with your app? |
"for example it tries to load rxjs commonjs distro which doesn't tree-shake well" :/ i've noticed "I assume you'd like to bundle some off-the-shelf JS library with your app" exactly, specifically protobufjs at the moment. there are several other libs as well. Unfortunately cjs is just unavoidable ATM, practically speaking. |
One update re: "The commonjs plugin causes problems, for example it tries to load rxjs commonjs distro which doesn't tree-shake well." IIUC that's actually the fault of the rxjs package.json file previously only declaring It appears then that the real fix is for package maintainers to migrate towards explicit es6 module support. In the meanwhile, providing cjs support by default (or at least optionally) seems reasonable. |
I think it would be great in general if it was possible to have an easy way to provide further rollup plugins. Just testing this out and we are also in the need of the json plugin, the babel plugin, etc. But thanks @alexeagle for the pointer on how Angular does it currently. That should more than do for the time being. |
@Globegitter someone has proposed a Back to the primary thread here - I added an |
@alexeagle yeah you are right about that the json plugin is for a bazel non-idiomatic usage. This comment is also related #149 (comment) |
@gregmagolan merged a change to the |
Here's what I ended up with to get the protobuf example in rules_typescript to bundle with rollup: https://github.com/gregmagolan/rules_typescript/blob/e771ee7f29868a3ab0e763afbf1b161d68606cdd/examples/protocol_buffers/BUILD.bazel#L64. Rollup treats the protobuf imports as globals and the protobuf code needs to be loaded outside of the bundle in a script tag. Will think about this some more about how to make it simpler but this is one way to do it. The rest of the diff is here: https://github.com/bazelbuild/rules_typescript/pull/204/files#diff-3db4baf0fd0becb125c0e7860df3637eR64 |
@gregmagolan can we close this one? |
I think this can be closed now that the new |
Hi all,
Thanks for this package, it's coming along nicely. What are the plans for supporting commonjs style dependencies in rollup bundles? In rollup_bundle.bzl I see that there is currently an unused
TMPL_additional_plugins
, however I'm unsure of the planned format of this, given that in the rollup.config.js is simply expecting the contents to either be previously required, or a full require+call expression (e.g.require('myplugin')()
)?https://github.com/bazelbuild/rules_nodejs/blob/master/internal/rollup/rollup.config.js#L108
In any case, the rollup-plugin-commonjs is common enough that it probably warrants inclusion in the base set of plugins by default (bazelResolve, nodeResolve, and commonjsResolve).
I've hacked in default support for commonjsResolve into my own fork, however it was done w/o any thought to integrating it with the
rollup_bundle
rule give it's only for my use case.erickj@d4c8322
What's the future direction here w/ either actually implementing TMPL_additional_plugins or first party support for the cjs plugin?
The text was updated successfully, but these errors were encountered: