Rules_nodejs: Allow to set max-old-space-size for rollup or set it to a higher value by default

Created on 9 Sep 2019  路  5Comments  路  Source: bazelbuild/rules_nodejs

Running rollup_bundle on large projects results in node running out of memory. Setting templated_args = ["--node_options=--max-old-space-size=SOME_SIZE"] for the rollup nodejs_binary can prevent that. I'd suggest either setting this to a higher value by default, or making it configurable from the rollup_bundle rule.

Can Close? questiodocs

Most helpful comment

For anyone else who stumbles on this, rollup_bundle now takes a rollup_bin argument, so you can now do:

nodejs_binary(
    name = "rollup_bin",
    entry_point = "@npm//:node_modules/rollup/dist/bin/rollup",
    node_modules = "@npm//:node_modules",
    templated_args = ["--node_options=--max-old-space-size=<SOME_SIZE>"],
)

rollup_bundle(
    ...
    rollup_bin = ":rollup_bin",
)

All 5 comments

the templated_args applies to every execution of the binary, so we would need a different mechanism to allow the memory settings to be applied per-target.

I think creating your own nodejs_binary to run rollup is the right solution for this. We already document that for ts_library: https://github.com/bazelbuild/rules_nodejs/blob/master/docs/TypeScript.md#customizing-the-typescript-compiler-binary
so I think we should document this for other rules as well

Makes sense, but as far as I can tell there is no attribute to set the rollup executable on the rollup_bundle rule.

For anyone else who stumbles on this, rollup_bundle now takes a rollup_bin argument, so you can now do:

nodejs_binary(
    name = "rollup_bin",
    entry_point = "@npm//:node_modules/rollup/dist/bin/rollup",
    node_modules = "@npm//:node_modules",
    templated_args = ["--node_options=--max-old-space-size=<SOME_SIZE>"],
)

rollup_bundle(
    ...
    rollup_bin = ":rollup_bin",
)

This issue has been automatically marked as stale because it has not had any activity for 60 days. It will be closed if no further activity occurs in two weeks. Collaborators can add a "cleanup" or "need: discussion" label to keep it open indefinitely. Thanks for your contributions to rules_nodejs!

I just ran across this myself at work - I'll add this snippet to the docs thanks @jfaust

Was this page helpful?
0 / 5 - 0 ratings

Related issues

purkhusid picture purkhusid  路  6Comments

Toxicable picture Toxicable  路  6Comments

UebelAndre picture UebelAndre  路  4Comments

jmhodges picture jmhodges  路  7Comments

pauldraper picture pauldraper  路  6Comments