Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>bazel-importNew to Visual Studio Code? Get it now.
bazel-import

bazel-import

jacob-church

|
854 installs
| (0) | Free
Automatically add Bazel deps when you import code
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

bazel-import README

Automatically add/remove Bazel deps to build files when TS imports are included in or removed from a file. Manually fix Bazel deps.

Features

This extension detects change to TS files, takes note of new import and require statements, looks up corresponding Bazel build targets, and adds them to the nearest build file with buildozer.

This extension detects changes to TS files, takes note of removed import and require statements, checks other source files in the package, and deletes the dependencies from the nearest build file with buildozer if the dependency no longer exists.

This extension allows you to run dependency fixes on a user-selected file. It will update the build dependencies for the package in which the selected file is located, including both added and removed dependencies.

Requirements

This extension assumes:

  • you have buildozer installed on your system
  • you have bazel installed on your system
  • your changes capture a full import for automated updates (i.e., line adds/deletes instead of single character adds/deletes)
  • your build files have dependency array for manual updates
  • your vscode workspace folder is the same as your bazel workspace/repository root
  • your external dependencies are npm packages

Extension Settings

This extension contributes the following settings:

bazel-import.buildFile The file name convention where your build targets are defined
bazel-import.notifyChange Notify the user that a build file has been updated
bazel-import.enableDeletion Toggles automatic deletions
bazel-import.enableAddition Toggles automatic additions
bazel-import.maxPackageSize Maximum package size to be considered for deletion
bazel-import.maxCacheSize Maximum packages to cache
bazel-import.excludeDependencies Excludes dependencies from the dependency fix. Use for hidden dependencies, which you can find by querying the dependency label on your build file and comparing with the dependency array in the build file
bazel-import.fixDepsOnCurrent Automatically run deps fix on the current file instead of prompting the user to select one. Default false
bazel-import.kindPattern Pattern that selects the kind of rules for analysis. Uses this to find the bazel target to which a source file belongs. See bazel query documentation for `kind(pattern, ...)` for more information
bazel-import.importPathReplacements Replaces matches in fully qualified import paths.

For example, if an import path refers to generated files that lack build information, you can replace parts of those file paths to refer to generator files with build information.

bazel-import.defaultRoot Default path relative to the home directory for running commands if no workspace folder is found. The default bazel repository root
bazel-import.bazelShutdownOnActivation Shuts down a currently running bazel server when the extension first activates. May be useful for fixing issues with the bazel server.

Off by default.

Release Notes

1.0.0

Uses bazel queries for increased accuracy. Adds the ability to disable automatic additions and to run fix deps on the current file without prompting the user for a file selection.

Fixes issue where the open bazel file command would not open the bazel file

Removed settings:

  • External dependencies
  • Target prefixes
  • Import path prefixes

Added settings:

  • Toggle additions
  • Fix deps on current file
Advanced settings
  • Kind pattern
  • Import path replacements
  • Default Root
  • Bazel shutdown on activation

0.1.3

Registers a command to the extension (bazel-import.fixDeps) the runs dependency fix

Increased default maxPackageSize to 100, which can be modified in the settings. Enabled automatic deletion by default. This can be turned off by setting enabledDeletion to false in the settings

0.1.2

Fixes a critical bug in the dependencies

0.1.1 [Broken]

Do not use this version. Upgrade to v0.1.2 or later

Fixes a bug with that would add self-dependencies to build files

0.1.0 [Broken]

Do not use this version. Upgrade to v0.1.2 or later

Dependency removal

Monitors changes to TS files for removed import statements and deletes the dependencies from the nearest build file if the dependency no longer exists.

  • Disabled by default. Enable by setting enableDeletion to true in the extension settings
  • Default size is 10. maxPackageSize determines the number of source files for deletion to run.

Dependency fix

Updates the build dependencies for the package in which the selected file is located, including both added and removed dependencies.

  • Activated by clicking the status bar icon in the bottom right and selecting the current file or picking another ts/bazel file from the system file selector.

Status bar icon

  • If deletions are enabled, displays as a magic wand when the file is ready, a closed eye when the file is not supported, and a loading icon while the package is loading
  • Otherwise appears as a magic wand
  • On click allows users to a select a file. The dependencies for the packaging containing the file will be updated

0.0.4

Bug fixes

0.0.3

Bug fixes

0.0.2

Add bazel imports and command to open nearest build file

0.0.1

Initial release

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2025 Microsoft