Skip to content
This repository was archived by the owner on Jun 5, 2021. It is now read-only.
This repository was archived by the owner on Jun 5, 2021. It is now read-only.

Enable non-relative imports with more node_modules granularity #19

Description

@enriched

Currently these rules recreate the same folder structure as the workspace for the build and symlink to an installed node_modules folder . To be able to refer to modules in a non-relative way (eg import { greet } from "greeter" rather than import { greet } from "../../../libs/shared-package/greeter" we can create node_modules folder with multiple hardlinks inside of it, similar to how pnpm does it.

Moving forward this could also enable more fine grained control of the npm modules that are available to a build. eg:

ts_library(
    name = "index",
    srcs = glob([
        "**/*.ts",
        "**/*.tsx",
    ]),
    tsconfig = "//:tsconfig.json",
    deps = [
        "@npm//lodash",
        "//packages/my-shared-lib",
    ],
)

To implement this, the existing NpmPackagesInfo provider will be handled by hardlinking all folders in installed_dir not starting with @ and all subfolders of folders starting with @. Any dep with a JsLibraryInfo provider will have its compiled_javascript_dir hardlinked into the node_modules directory if it has a new module_name field in it (the hardlink will be named module_name).

@fwouts does this proposal fit with these rules?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions