| # npm packages are split into different node_modules directories based on their |
| # usage. |
| # 1. @npm (node_modules) - contains packages to run tests, check code, etc... |
| # It is expected that @npm is used ONLY to run tools. No packages from @npm |
| # are used by other code in gerrit. |
| # 2. @tools_npm (tools/node_tools/node_modules) - the tools/node_tools folder |
| # contains self-written tools which are run for building and/or testing. The |
| # @tools_npm directory contains all the packages needed to run this tools. |
| # 3. @ui_npm (polygerrit-ui/app/node_modules) - packages with source code which |
| # are necessary to run polygerrit and to bundle it. Only code from these |
| # packages can be included in the final bundle for polygerrit. @ui_npm folder |
| # must not have devDependencies. All devDependencies must be placed in |
| # @ui_dev_npm. |
| # 4. @ui_dev_npm (polygerrit-ui/node_modules) - devDependencies for polygerrit. |
| # The packages from these folder can be used for testing, but must not be |
| # included in the final bundle. |
| # 5. @plugins_npm (plugins/node_modules) - plugin dependencies for polygerrit |
| # plugins. The packages here are expected to be used in plugins. |
| # Note: separation between @ui_npm and @ui_dev_npm is necessary because with |
| # rules_nodejs we can't generate two external repositories from the same |
| # package.json. At the same time we want to avoid accidental usages of code |
| # from devDependencies in polygerrit bundle. |
| |
| rules_ts_ext = use_extension("@aspect_rules_ts//ts:extensions.bzl", "ext", dev_dependency = True) |
| rules_ts_ext.deps( |
| ts_version_from = "//:package.json", |
| ) |
| use_repo(rules_ts_ext, "npm_typescript") |
| |
| # The node version is read from //:.nvmrc, the cross-tool convention file |
| # also honored by nvm and CI -- Bazel and the yarn dev flow share one pin. |
| # Versions unknown to the pinned rules_nodejs release are auto-fetched and |
| # recorded in MODULE.bazel.lock (rules_nodejs >= 6.7.5). |
| node = use_extension("@rules_nodejs//nodejs:extensions.bzl", "node") |
| node.toolchain(node_version_from_nvmrc = "//:.nvmrc") |
| |
| npm = use_extension("@aspect_rules_js//npm:extensions.bzl", "npm") |
| npm.npm_translate_lock( |
| name = "npm", |
| data = [ |
| "//:package.json", |
| "//:pnpm-workspace.yaml", |
| ], |
| pnpm_lock = "//:pnpm-lock.yaml", |
| update_pnpm_lock = True, |
| yarn_lock = "//:yarn.lock", |
| ) |
| use_repo(npm, "npm") |
| |
| # Keep no_optional=True. |
| # ui_npm is the browser/runtime dependency set for PolyGerrit. |
| # If this is removed, aspect_rules_js npm_translate_lock defaults to installing |
| # optionalDependencies from the full transitive graph (not just from our root |
| # package.json). In this repo that pulls in Resemble.js -> canvas -> |
| # prebuild-install/native helper packages, which changes the realized |
| # node_modules tree and breaks license generation. |
| # This differs from normal pnpm behavior, which may skip platform-unneeded |
| # optional deps. |
| npm.npm_translate_lock( |
| name = "ui_npm", |
| data = [ |
| "//polygerrit-ui/app:package.json", |
| "//polygerrit-ui/app:pnpm-workspace.yaml", |
| ], |
| no_optional = True, |
| pnpm_lock = "//polygerrit-ui/app:pnpm-lock.yaml", |
| update_pnpm_lock = True, |
| yarn_lock = "//polygerrit-ui/app:yarn.lock", |
| ) |
| use_repo(npm, "ui_npm") |
| |
| npm.npm_translate_lock( |
| name = "ui_dev_npm", |
| data = [ |
| "//polygerrit-ui:package.json", |
| "//polygerrit-ui:pnpm-workspace.yaml", |
| ], |
| pnpm_lock = "//polygerrit-ui:pnpm-lock.yaml", |
| update_pnpm_lock = True, |
| yarn_lock = "//polygerrit-ui:yarn.lock", |
| ) |
| use_repo(npm, "ui_dev_npm") |
| |
| npm.npm_translate_lock( |
| name = "tools_npm", |
| data = [ |
| "//tools/node_tools:package.json", |
| "//tools/node_tools:pnpm-workspace.yaml", |
| ], |
| pnpm_lock = "//tools/node_tools:pnpm-lock.yaml", |
| update_pnpm_lock = True, |
| yarn_lock = "//tools/node_tools:yarn.lock", |
| ) |
| use_repo(npm, "tools_npm") |
| |
| npm.npm_translate_lock( |
| name = "plugins_npm", |
| data = [ |
| "//plugins:package.json", |
| "//plugins:pnpm-workspace.yaml", |
| ], |
| pnpm_lock = "//plugins:pnpm-lock.yaml", |
| update_pnpm_lock = True, |
| yarn_lock = "//plugins:yarn.lock", |
| ) |
| use_repo(npm, "plugins_npm") |