-
Notifications
You must be signed in to change notification settings - Fork 522
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(builtin): support for scoped modules in linker (#1199)
- Loading branch information
1 parent
051b592
commit 94abf68
Showing
9 changed files
with
85 additions
and
19 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
10 changes: 10 additions & 0 deletions
10
internal/linker/test/integration/dynamic_linked_scoped_pkg/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,10 @@ | ||
load("//internal/js_library:js_library.bzl", "js_library") | ||
|
||
package(default_visibility = ["//internal/linker/test:__subpackages__"]) | ||
|
||
js_library( | ||
name = "dynamic_linked_scoped_pkg", | ||
srcs = ["index.js"], | ||
module_from_src = True, | ||
module_name = "@linker_scoped/dynamic_linked", | ||
) |
5 changes: 5 additions & 0 deletions
5
internal/linker/test/integration/dynamic_linked_scoped_pkg/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,5 @@ | ||
function addD(str) { | ||
return `${str}_d`; | ||
} | ||
|
||
exports.addD = addD; |
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 |
---|---|---|
@@ -1 +1 @@ | ||
1.2.3_c_b_a | ||
1.2.3_a_b_c_d_e |
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 |
---|---|---|
@@ -1,14 +1,16 @@ | ||
// First-party package from ./static_linked_pkg | ||
// it should get resolved through runfiles | ||
// First-party "static linked" packages | ||
// they should get resolved through runfiles | ||
const a = require('static_linked'); | ||
// First-party package from ./dynamic_linked_pkg | ||
// it should get resolved from the execroot | ||
const e = require('@linker_scoped/static_linked'); | ||
// First-party "dynamic linked" packages | ||
// they should get resolved from the execroot | ||
const b = require('dynamic_linked'); | ||
const d = require('@linker_scoped/dynamic_linked'); | ||
// We've always supported `require('my_workspace')` for absolute imports like Google does it | ||
const c = require('build_bazel_rules_nodejs/internal/linker/test/integration/absolute_import'); | ||
|
||
// Third-party package installed in the root node_modules | ||
const semver = require('semver'); | ||
|
||
// This output should match what's in the golden.txt file | ||
console.log(a.addA(b.addB(c.addC(semver.clean(' =v1.2.3 '))))); | ||
console.log(e.addE(d.addD(c.addC(b.addB(a.addA(semver.clean(' =v1.2.3 '))))))); |
9 changes: 9 additions & 0 deletions
9
internal/linker/test/integration/static_linked_scoped_pkg/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,9 @@ | ||
load("//internal/js_library:js_library.bzl", "js_library") | ||
|
||
package(default_visibility = ["//internal/linker/test:__subpackages__"]) | ||
|
||
js_library( | ||
name = "static_linked_scoped_pkg", | ||
srcs = ["index.js"], | ||
module_name = "@linker_scoped/static_linked", | ||
) |
5 changes: 5 additions & 0 deletions
5
internal/linker/test/integration/static_linked_scoped_pkg/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,5 @@ | ||
function addE(str) { | ||
return `${str}_e`; | ||
} | ||
|
||
exports.addE = addE; |