build: hide --loader warning when ESM import patch is installed (#48282)

Similar to the Rules NodeJS require patch, we have an ESM import patch
as of the AIO Bazel migration (to support ESM scripts better).

This script uses `--loader`, an experimental NodeJS flag. This is
similar to how `ts-node` uses it. We should disable the warnings
as it results in a lot of unreadable Bazel output and the warnings
are okay to be ignored. Note that we cannot fine-grain disable
the specific warning so all others would be disabled too.

Realistically we haven't seen any in the past and long-term we will
be not relying on patched resolution anyway (looking at `rules_js`).

PR Close #48282
This commit is contained in:
Paul Gschwendtner 2022-11-29 15:41:22 +00:00 committed by Andrew Scott
parent aa66f703d2
commit 35151ea0ca

View file

@ -413,6 +413,7 @@ def _apply_esm_import_patch(env, templated_args, data):
env = dict(env, **{"NODE_MODULES_WORKSPACE_NAME": _node_modules_workspace_name()})
templated_args = templated_args + [
"--node_options=--loader=file:///$$(rlocation $(rootpath //tools/esm-loader:esm-loader.mjs))",
"--node_options=--no-warnings", # `--loader` is an experimental feature with warnings.
]
data = data + [
"//tools/esm-loader",