Giter Club home page Giter Club logo

example-bazel-nestjs-local-package-dependency's Introduction

example bazel setup with nestjs + local package import

Important points

Should install all package.jsons in WORKSPACE file

# WORKSPACE
yarn_install(
    # Name this npm so that Bazel Label references look like @npm//package
    name = "npm_shared",
    package_json = "//shared:package.json",
    yarn_lock = "//shared:yarn.lock",
)

# customize yarn_install names for each package
yarn_install(
    # Name this npm so that Bazel Label references look like @npm//package
    name = "npm_server_api",
    package_json = "//server/api:package.json",
    yarn_lock = "//server/api:yarn.lock",
)

Imported package should use ts_library function, not ts_project

  • There might be a way using ts_project, but it seems that it needs package.json containing all dependencies of packages in root directory (See https://github.com/dataform-co/dataform).

  • So this example used ts_library as imported package.

  • IMPORTANT You should write package_name attribute with the same package name in package.json, as package_name = "shared" in this example.

  • See shared/BUILD.bazel

Importing package should add imported package as {workspace_name}/{package_name} in package.json dependency

In this example, server/api package imported shared as below in package.json

"dependency": {
    ...,
    "bazel_nestjs_with_shared/shared": "file:../../shared",
    ...
}

Importing package should use ts_project and import bazel package properly

See server/api/src/BUILD.bazel.

You can import in both ways as //shared or //shared:shared.

Should sync Incremental and SourceMap option in tsconfig.json and ts_project in BUILD.bazel

Should use ts_config function in BUILD.bazel to use NestJS's tsconfig extending feature - tsconfig.build.json -> tsconfig.json

example-bazel-nestjs-local-package-dependency's People

Contributors

cooco119 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.