-
-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add support for linking js_library as 1p npm deps
- Loading branch information
1 parent
92c9b19
commit aaf9a93
Showing
20 changed files
with
286 additions
and
57 deletions.
There are no files selected for viewing
19 changes: 10 additions & 9 deletions
19
.aspect/rules/external_repository_action_cache/npm_translate_lock_LTE4Nzc1MDcwNjU=
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,26 +1,27 @@ | ||
# @generated | ||
# Input hashes for repository rule npm_translate_lock(name = "npm", pnpm_lock = "//:pnpm-lock.yaml"). | ||
# Input hashes for repository rule npm_translate_lock(name = "npm", pnpm_lock = "@@//:pnpm-lock.yaml"). | ||
# This file should be checked into version control along with the pnpm-lock.yaml file. | ||
.npmrc=-2065072158 | ||
pnpm-lock.yaml=-1732975623 | ||
pnpm-lock.yaml=-813031333 | ||
examples/npm_deps/patches/[email protected]=-442666336 | ||
package.json=-275319675 | ||
pnpm-workspace.yaml=-871530930 | ||
pnpm-workspace.yaml=-1178830835 | ||
examples/js_binary/package.json=-41174383 | ||
examples/macro/package.json=857146175 | ||
examples/npm_deps/package.json=283109008 | ||
examples/npm_deps/package.json=-1377141392 | ||
examples/npm_package/libs/lib_a/package.json=-1377103079 | ||
examples/npm_package/packages/pkg_a/package.json=-1053875011 | ||
examples/npm_package/packages/pkg_b/package.json=-994654274 | ||
examples/npm_package/packages/pkg_a/package.json=1006424040 | ||
examples/npm_package/packages/pkg_b/package.json=1041247977 | ||
examples/webpack_cli/package.json=1911342006 | ||
js/private/coverage/bundle/package.json=-1543718929 | ||
js/private/image/package.json=-1260474848 | ||
js/private/test/image/package.json=1286417612 | ||
js/private/test/js_run_devserver/package.json=-260856079 | ||
js/private/worker/src/package.json=1608383745 | ||
npm/private/test/package.json=1756993924 | ||
npm/private/test/vendored/lodash-4.17.21.tgz=-1206623349 | ||
npm/private/test/npm_package/package.json=-1991705133 | ||
npm/private/test/vendored/is-odd/package.json=1041695223 | ||
npm/private/test/vendored/semver-max/package.json=578664053 | ||
examples/linked_empty_node_modules/package.json=-1039372825 | ||
examples/npm_package/packages/pkg_d/package.json=1110895851 | ||
js/private/image/package.json=-1260474848 | ||
js/private/test/image/package.json=1286417612 | ||
js/private/test/js_run_devserver/package.json=-260856079 |
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
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
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,30 +1,21 @@ | ||
load("@aspect_rules_js//npm:defs.bzl", "npm_package") | ||
load("@aspect_rules_js//js:defs.bzl", "js_library") | ||
load("@npm//:defs.bzl", "npm_link_all_packages") | ||
|
||
npm_link_all_packages(name = "node_modules") | ||
|
||
# Use js_library so that npm_package picks up our transitive sources from deps | ||
# via the JsInfo provider. | ||
js_library( | ||
name = "lib", | ||
# The terminal npm_package target for this package. This target is linked | ||
# manually in the root of the pnpm workspace with `npm_link_package`. | ||
npm_package( | ||
name = "pkg_b", | ||
srcs = [ | ||
"index.js", | ||
"package.json", | ||
], | ||
data = [ | ||
# Runtime non-dev dependencies propagate to downstream binary and npm_link_package (via npm_package) targets | ||
":node_modules/acorn", | ||
":node_modules/uuid", | ||
# npm deps must be added explicitly as this package is linked manually | ||
# so deps are _not_ picked up from the pnpm lock file | ||
":node_modules", | ||
], | ||
) | ||
|
||
# The terminal npm_package target for this package. This target is linked | ||
# manually in the root of the pnpm workspace with `npm_link_package`. | ||
npm_package( | ||
name = "pkg_b", | ||
srcs = [":lib"], | ||
include_runfiles = False, | ||
package = "@mycorp/pkg-b", | ||
visibility = ["//visibility:public"], | ||
) |
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,3 +1,3 @@ | ||
# @mycorp/pkg-a package | ||
# @mycorp/pkg-b package | ||
|
||
'@mycorp/pkg-b' is an example of a package that is linked manually with `npm_link_package` where it is used. |
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,19 @@ | ||
load("@aspect_rules_js//js:defs.bzl", "js_library") | ||
load("@npm//:defs.bzl", "npm_link_all_packages") | ||
|
||
npm_link_all_packages(name = "node_modules") | ||
|
||
js_library( | ||
name = "pkg_d", | ||
srcs = [ | ||
"index.js", | ||
"package.json", | ||
], | ||
visibility = ["//visibility:public"], | ||
# because we're linking this js_library, we must explictly add our npm dependendies to `deps` so | ||
# they are picked up my the linker. npm dependendies in `data` are not propogated through the | ||
# linker when linking a js_libary. | ||
deps = [ | ||
":node_modules", | ||
], | ||
) |
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,3 @@ | ||
# @mycorp/pkg-d package | ||
|
||
'@mycorp/pkg-d' is an example of a first party package that is linked as a js_library |
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,19 @@ | ||
/** | ||
* @fileoverview minimal test program that requires a third-party package from npm | ||
*/ | ||
const acorn = require('acorn') | ||
const { v4: uuid } = require('uuid') | ||
|
||
function toAst(program) { | ||
return JSON.stringify(acorn.parse(program, { ecmaVersion: 2020 })) + '\n' | ||
} | ||
|
||
function getAcornVersion() { | ||
return acorn.version | ||
} | ||
|
||
module.exports = { | ||
toAst, | ||
getAcornVersion, | ||
uuid, | ||
} |
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 @@ | ||
{ | ||
"name": "@mycorp/pkg-d", | ||
"private": true, | ||
"dependencies": { | ||
"uuid": "8.3.2" | ||
}, | ||
"peerDependencies": { | ||
"acorn": "8.x.x" | ||
} | ||
} |
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
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
Oops, something went wrong.