title: How to make a Bazel TypeScript monorepo with individually deployable packages
body: <p>I've been trying to get a bazel monorepo with typescript to work. I have a couple of requirements in mind.</p>
  <ol>
  <li>I should be able to import local packages using @myworkspace/ instead of ../../../ and so on, without needing Bazel. This is mostly so I get autocomplete while I'm writing.</li>
  <li>The @myworkspace/ package should be the same during development and build time but only Bazel-managed dependencies should be resolved on imports when running sandboxed. Just so I know if I've messed up the name of the package in the js_library rule.</li>
  <li>There should only be one lock file for the whole project. All dependencies should be located at root/node_modules.</li>
  <li>It should be possible to individually deploy node packages i.e. @myworkspace/myCloudFunction.</li>
  <li>It should be possible to include local dependencies in packages that will deployed.</li>
  </ol>
  <p>I'm new to Bazel and it seems like it requires some mentality changes when coming from the NPM ecosystem. After googling, I've managed to find something that works for points 1 and 2 (But I might be wrong). I've published the playground repo at <a href="https://github.com/vitorelourenco/bazelmono-ts" rel="noreferrer">https://github.com/vitorelourenco/bazelmono-ts</a> (pretty much a copy from <a href="https://github.com/lokshunhung/bazel-ts-monorepo" rel="noreferrer">https://github.com/lokshunhung/bazel-ts-monorepo</a> with some ideas I took from <a href="https://github.com/angular/angular" rel="noreferrer">https://github.com/angular/angular</a>)</p>
  <p>My questions about points 3 and 4:
  Say I want the lib Lodash available on package @myworkspace/cloudFunction that will be deployed to Google Cloud Functions. If I install Lodash in the @myworkspace/cloudFunction folder, then Lodash will be added to package.json but I'll have a second node_modules folder and a second yarn.lock file, I don't want that. But if I install it in root/, then Lodash will not be added to the dependencies listed on package.json located at @myworkspace/cloudFunction, and when I deploy it, it won't install. Is there a smart way to handle this issue?</p>
  <p>Point 5 is very similar. Ideally, the final Bazel output would have the local dependencies bundled in and ready to use but I can't seem to figure out a way to do it yet. I've tried adding a pkg_npm rule to //packages/app in the playgroup repo but couldn't get it to include //packages/common in it.</p>