I try to build a node module using @bazel/typescript and npm_package rules of bazel using bazel build //core:package
. Below is my BUILD file
package(default_visibility = ["//visibility:public"])
load("@npm_bazel_typescript//:index.bzl", "ts_library")
load("@build_bazel_rules_nodejs//:defs.bzl", "npm_package")
ts_library(
name = "core",
srcs = glob(["*.ts"]),
)
npm_package(
name = "package",
srcs = ["package.json"],
deps = [":core"],
replacements = {"//internal/": "//"},
)
Then I run bazel run //core:package.pack
and it generates a .tgz
file and I install this module by running npm install ./xxx.tgz -s
. Everything works well until I try to import this module using import * as core from 'core';
It gives me error says Error: Cannot find module 'core/index'
The declaration files of the module looks like this
/// <amd-module name="core/index" />
export * from './public_api';
/// <amd-module name="core/public_api" />
export declare const foo = "foo";
export declare const bar = "bar";
My questions are:
- it is not able to imported because it is a amd module?
- how to I resolve this issue?
Please help!!!