forked from bazel-contrib/rules_nodejs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(esbuild): add link_workspace_root for workspace absolute imports
Fixes bazel-contrib#2474
- Loading branch information
Showing
8 changed files
with
74 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
load("//:index.bzl", "generated_file_test") | ||
load("//packages/esbuild/test:tests.bzl", "esbuild") | ||
|
||
esbuild( | ||
name = "bundle", | ||
entry_point = "main.js", | ||
format = "esm", | ||
link_workspace_root = True, | ||
deps = [ | ||
"//packages/esbuild/test/workspace-mapping/module-one", | ||
"//packages/esbuild/test/workspace-mapping/module-two", | ||
], | ||
) | ||
|
||
# esbuild will put the filepath in a comment within the non-minified file, | ||
# on different platforms this will cause the golden test to differ | ||
# strip them here | ||
# note that this regex doesn't strip the sourcemap URI comment | ||
genrule( | ||
name = "strip_bundle_comments", | ||
srcs = ["bundle.js"], | ||
outs = ["bundle.stripped.js"], | ||
cmd = "cat $(location :bundle.js) | sed \"s#// .*##\" > $@", | ||
) | ||
|
||
generated_file_test( | ||
name = "bundle_test", | ||
src = "bundle.golden.txt", | ||
generated = "bundle.stripped.js", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
var __defProp = Object.defineProperty; | ||
var __name = (target, value) => __defProp(target, "name", {value, configurable: true}); | ||
|
||
|
||
var getId = /* @__PURE__ */ __name(() => "module-one", "getId"); | ||
|
||
|
||
var getId2 = /* @__PURE__ */ __name(() => "module-two", "getId"); | ||
|
||
|
||
var main_default = `Full ID: ${getId} - ${getId2}`; | ||
export { | ||
main_default as default | ||
}; | ||
//# sourceMappingURL=bundle.js.map |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import {getId as m1Id} from 'build_bazel_rules_nodejs/packages/esbuild/test/workspace-mapping/module-one'; | ||
import {getId as m2Id} from 'build_bazel_rules_nodejs/packages/esbuild/test/workspace-mapping/module-two'; | ||
|
||
export default `Full ID: ${m1Id} - ${m2Id}`; |
8 changes: 8 additions & 0 deletions
8
packages/esbuild/test/workspace-mapping/module-one/BUILD.bazel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
load("//internal/js_library:js_library.bzl", "js_library") | ||
|
||
package(default_visibility = ["//packages/esbuild/test:__subpackages__"]) | ||
|
||
js_library( | ||
name = "module-one", | ||
srcs = [":index.js"], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const getId = () => 'module-one'; |
8 changes: 8 additions & 0 deletions
8
packages/esbuild/test/workspace-mapping/module-two/BUILD.bazel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
load("//internal/js_library:js_library.bzl", "js_library") | ||
|
||
package(default_visibility = ["//packages/esbuild/test:__subpackages__"]) | ||
|
||
js_library( | ||
name = "module-two", | ||
srcs = [":index.js"], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const getId = () => 'module-two'; |