feat(typescript): add JSNamedModuleInfo provider to ts_library outputs (#1215)

All rules that require devmode named sources are updated to use JSNamedModuleInfo. The rules affected are karma, protractor, ts_devserver, ts_proto_library (in labs) & npm_package.

Some related non-breaking changes:

* node_module_library scripts attribute renamed to named_module_srcs. node_module_library is currently not part of the public API and in user code the npm targets are generated by generate_build_file.ts by yarn_install & npm_install.

BREAKING CHANGES:

The following breaking changes are from internal details so they should not affect most users. Some some downstream projects, however, such as Angular rely on these internal details and will need to be updated accordingly when updating to the next release.

* sources_aspect from /internal/node/node.bzl and /internal/common/sources_aspect.bzl is removed; its functionality was duplicate to what JSNamedModuleInfo providers
* NodeModuleSources is removed and its sources field is moved to NpmPackageInfo; sources in the removed scripts field are provided by the JSNamedModuleInfo provider which node_module_library now provides
* collect_node_modules_aspect renamed to just node_modules_aspect

fix: nodejs_binary doesn't need declaration files
29 files changed
tree: 8b49e3db6b30300336692fba5616a68ce3d4fafc
  1. .bazelci/
  2. .circleci/
  3. .github/
  4. .vscode/
  5. docs/
  6. e2e/
  7. examples/
  8. internal/
  9. packages/
  10. scripts/
  11. third_party/
  12. toolchains/
  13. tools/
  14. .bazelignore
  15. .bazelrc
  16. .clang-format
  17. .gitignore
  18. .npmrc
  19. AUTHORS
  20. BUILD.bazel
  21. CHANGELOG.md
  22. CODE_OF_CONDUCT.md
  23. CODEOWNERS
  24. commitlint.config.js
  25. common.bazelrc
  26. CONTRIBUTING.md
  27. CONTRIBUTORS
  28. declaration_provider.bzl
  29. defs.bzl
  30. DEVELOPING.md
  31. index.bzl
  32. index.for_docs.bzl
  33. LICENSE
  34. package.bzl
  35. package.json
  36. providers.bzl
  37. README.md
  38. renovate.json
  39. tsconfig.json
  40. WORKSPACE
  41. yarn.lock
README.md

NodeJS rules for Bazel

Circle CIBazel CI
CircleCIBuild status

This is beta-quality software. Breaking changes are likely.

The nodejs rules integrate NodeJS development toolchain and runtime with Bazel.

This toolchain can be used to build applications that target a browser runtime, so this repo can be thought of as “JavaScript rules for Bazel” as well.

Documentation

Comprehensive documentation for installing and using the rules, including generated API docs: https://bazelbuild.github.io/rules_nodejs/

Quickstart

This is the fastest way to get started. See the installation documentation for details and alternative methods.

$ npm init @bazel

or if you prefer yarn,

$ yarn create @bazel

These commands are equivalent to npx @bazel/create which downloads the latest version of the @bazel/create package from npm and runs the program contained.

See the output of the tool for command-line options and next steps.

Adopters

Thanks to the following active users!

Open-source repositories:

Organizations:

Not on this list? Send a PR to add your repo or organization!

User testimonials

From Lewis Hemens at Dataform:

At Dataform we manage a number of NPM packages, Webpack builds, Node services and Java pipelines across two separate repositories. This quickly became hard for us to manage, development was painful and and deploying code required a many manual steps. We decided to dive in and migrate our build system entirely to Bazel. This was a gradual transition that one engineer did over the course of about 2 months, during which we had both Bazel and non bazel build processes in place. Once we had fully migrated, we saw many benefits to all parts of our development workflow:

  • Faster CI: we enabled the remote build caching which has reduced our average build time from 30 minutes to 5 (for the entire repository)
  • Improvements to local development: no more random bash scripts that you forget to run, incremental builds reduced to seconds from minutes
  • Simplified deployment processes: we can deploy our code to environments in Kubernetes with just one command that builds and pushes images
  • A monorepo that scales: adding new libraries or packages to our repo became easy, which means we do it more and end up write more modular, shared, maintainable code
  • Developing across machine types: our engineers have both Macbooks and Linux machines, bazel makes it easy to build code across both
  • Developer setup time: New engineers can build all our code with just 3 dependencies - bazel, docker and the JVM. The last engineer to join our team managed to build all our code in < 30 minutes on a brand new, empty laptop

Documentation site

https://bazelbuild.github.io/rules_nodejs/