Skip to content

Commit 660b564

Browse files
bhleonardalexeagle
authored andcommitted
docs: add instructions for multiple sets of npm deps (bazel-contrib#1262)
1 parent 6b09b51 commit 660b564

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

docs/install.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,34 @@ jasmine_node_test(
265265
)
266266
```
267267

268+
#### Multiple sets of npm dependencies
269+
270+
If your workspace has multiple applications, each with their own `package.json`
271+
and npm deps, `yarn_install` (or `npm_install`) can be called separately for
272+
each.
273+
274+
```python
275+
workspace(
276+
name = "my_wksp",
277+
managed_directories = {"@app1_npm": ["app1/node_modules"],
278+
"@app2_npm": ["app2/node_modules"]}},
279+
)
280+
281+
yarn_install(
282+
name = "app1_npm",
283+
package_json = "//app1:package.json",
284+
yarn_lock = "//app1:yarn.lock",
285+
)
286+
287+
yarn_install(
288+
name = "app2_npm",
289+
package_json = "//app2:package.json",
290+
yarn_lock = "//app2:yarn.lock",
291+
)
292+
```
293+
294+
Your application would then reference its deps as (for example) `@app1//lodash`, or `@app2//jquery`.
295+
268296
#### Fine-grained npm package nodejs_binary targets
269297

270298
If an npm package lists one or more `bin` entry points in its `package.json`,

0 commit comments

Comments
 (0)