forked from bazel-contrib/rules_nodejs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnode.html
More file actions
720 lines (648 loc) · 24.3 KB
/
node.html
File metadata and controls
720 lines (648 loc) · 24.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
<!--
Documentation generated by Skydoc
-->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width initial-scale=1" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Executing programs</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,600,700" type="text/css">
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<link rel="stylesheet" href="https://code.getmdl.io/1.1.1/material.green-light_blue.min.css">
<script defer src="https://code.getmdl.io/1.1.1/material.min.js"></script>
<link rel="stylesheet" href="/rules_nodejs/main.css">
</head>
<body>
<div class="mdl-layout mdl-js-layout mdl-layout--fixed-drawer
mdl-layout--fixed-header">
<header class="mdl-layout__header">
<div class="mdl-layout__header-row">
<span class="mdl-layout-title">Executing programs</span>
</div>
</header>
<div class="mdl-layout__drawer">
<span class="mdl-layout-title">Bazel</span>
<nav class="drawer-nav">
<ul class="drawer-nav">
<li><a href="/rules_nodejs/index.html">Overview</a></li>
<li>
<a href="/rules_nodejs/common/check_bazel_version.html">Check Bazel version</a>
<ul>
<li><a href="/rules_nodejs/common/check_bazel_version.html#overview">Overview</a></li>
</ul>
</li>
<li>
<a href="/rules_nodejs/history-server/history_server.html">Run history-server</a>
<ul>
</ul>
</li>
<li>
<a href="/rules_nodejs/http-server/http_server.html">Run http-server</a>
<ul>
</ul>
</li>
<li>
<a href="/rules_nodejs/jasmine_node_test/jasmine_node_test.html">NodeJS testing</a>
<ul>
<li><a href="/rules_nodejs/jasmine_node_test/jasmine_node_test.html#overview">Overview</a></li>
</ul>
</li>
<li>
<a href="/rules_nodejs/node/node.html">Executing programs</a>
<ul>
<li><a href="/rules_nodejs/node/node.html#overview">Overview</a></li>
<li>
<a href="/rules_nodejs/node/node.html#nodejs_binary">
nodejs_binary
</a>
</li>
<li>
<a href="/rules_nodejs/node/node.html#nodejs_test">
nodejs_test
</a>
</li>
</ul>
</li>
<li>
<a href="/rules_nodejs/node/node_repositories.html">Install NodeJS & Yarn</a>
<ul>
<li><a href="/rules_nodejs/node/node_repositories.html#overview">Overview</a></li>
</ul>
</li>
<li>
<a href="/rules_nodejs/npm_install/npm_install.html">Install npm packages</a>
<ul>
<li><a href="/rules_nodejs/npm_install/npm_install.html#overview">Overview</a></li>
</ul>
</li>
<li>
<a href="/rules_nodejs/npm_package/npm_package.html">npm packaging</a>
<ul>
<li><a href="/rules_nodejs/npm_package/npm_package.html#overview">Overview</a></li>
<li>
<a href="/rules_nodejs/npm_package/npm_package.html#npm_package">
npm_package
</a>
</li>
</ul>
</li>
<li>
<a href="/rules_nodejs/rollup/rollup_bundle.html">Rollup bundling</a>
<ul>
<li><a href="/rules_nodejs/rollup/rollup_bundle.html#overview">Overview</a></li>
<li>
<a href="/rules_nodejs/rollup/rollup_bundle.html#rollup_bundle">
rollup_bundle
</a>
</li>
</ul>
</li>
</ul>
</nav>
</div>
<main class="mdl-layout__content">
<div class="page-content">
<h1>Executing programs</h1>
<nav class="toc">
<h2><a href="#overview">Overview</a></h2>
<h2>Rules</h2>
<ul>
<li><a href="#nodejs_binary">nodejs_binary</a></li>
<li><a href="#nodejs_test">nodejs_test</a></li>
</ul>
<h2>Macros</h2>
<ul>
<li><a href="#nodejs_binary_macro">nodejs_binary_macro</a></li>
<li><a href="#nodejs_test_macro">nodejs_test_macro</a></li>
</ul>
</nav>
<hr>
<h2 id="overview">Overview</h2>
<p>These rules run the node binary with the given sources.</p>
<p>They support module mapping: any targets in the transitive dependencies with
a <code>module_name</code> attribute can be <code>require</code>d by that name.</p>
<hr>
<h2 id="nodejs_binary_macro">nodejs_binary_macro</h2>
<pre>nodejs_binary_macro(<a href="#nodejs_binary_macro.name">name</a>, <a href="#nodejs_binary_macro.data">data</a>, <a href="#nodejs_binary_macro.args">args</a>, <a href="#nodejs_binary_macro.visibility">visibility</a>, <a href="#nodejs_binary_macro.tags">tags</a>, <a href="#nodejs_binary_macro.testonly">testonly</a>, <a href="#nodejs_binary_macro.**kwargs">**kwargs</a>)</pre>
<p>This macro exists only to wrap the nodejs_binary as an .exe for Windows.</p>
<p>This is exposed in the public API at <code>//:defs.bzl</code> as <code>nodejs_binary</code>, so most
users loading <code>nodejs_binary</code> are actually executing this macro.</p>
<h3 id="nodejs_binary_macro_args">Attributes</h3>
<table class="params-table">
<colgroup>
<col class="col-param" />
<col class="col-description" />
</colgroup>
<tbody>
<tr id="nodejs_binary_macro.name">
<td><code>name</code></td>
<td>
<p><code><a href="https://bazel.build/docs/build-ref.html#name">Name</a>; Required</code></p>
<p>name of the label</p>
</td>
</tr>
<tr id="nodejs_binary_macro.data">
<td><code>data</code></td>
<td>
<p><code>List of strings; Optional</code></p>
<p>runtime dependencies</p>
</td>
</tr>
<tr id="nodejs_binary_macro.args">
<td><code>args</code></td>
<td>
<p><code>List of strings; Optional</code></p>
<p>applied to the wrapper binary</p>
</td>
</tr>
<tr id="nodejs_binary_macro.visibility">
<td><code>visibility</code></td>
<td>
<p><code>Unknown; Optional</code></p>
<p>applied to the wrapper binary</p>
</td>
</tr>
<tr id="nodejs_binary_macro.tags">
<td><code>tags</code></td>
<td>
<p><code>List of strings; Optional</code></p>
<p>applied to the wrapper binary</p>
</td>
</tr>
<tr id="nodejs_binary_macro.testonly">
<td><code>testonly</code></td>
<td>
<p><code>Integer; Optional</code></p>
<p>applied to nodejs_binary and wrapper binary</p>
</td>
</tr>
<tr id="nodejs_binary_macro.**kwargs">
<td><code>**kwargs</code></td>
<td>
<p><code>Unknown; Optional</code></p>
<p>passed to the nodejs_binary</p>
</td>
</tr>
</tbody>
</table>
<hr>
<h2 id="nodejs_test_macro">nodejs_test_macro</h2>
<pre>nodejs_test_macro(<a href="#nodejs_test_macro.name">name</a>, <a href="#nodejs_test_macro.data">data</a>, <a href="#nodejs_test_macro.args">args</a>, <a href="#nodejs_test_macro.visibility">visibility</a>, <a href="#nodejs_test_macro.tags">tags</a>, <a href="#nodejs_test_macro.**kwargs">**kwargs</a>)</pre>
<p>This macro exists only to wrap the nodejs_test as an .exe for Windows.</p>
<p>This is exposed in the public API at <code>//:defs.bzl</code> as <code>nodejs_test</code>, so most
users loading <code>nodejs_test</code> are actually executing this macro.</p>
<h3 id="nodejs_test_macro_args">Attributes</h3>
<table class="params-table">
<colgroup>
<col class="col-param" />
<col class="col-description" />
</colgroup>
<tbody>
<tr id="nodejs_test_macro.name">
<td><code>name</code></td>
<td>
<p><code><a href="https://bazel.build/docs/build-ref.html#name">Name</a>; Required</code></p>
<p>name of the label</p>
</td>
</tr>
<tr id="nodejs_test_macro.data">
<td><code>data</code></td>
<td>
<p><code>List of strings; Optional</code></p>
<p>runtime dependencies</p>
</td>
</tr>
<tr id="nodejs_test_macro.args">
<td><code>args</code></td>
<td>
<p><code>List of strings; Optional</code></p>
<p>applied to the wrapper binary</p>
</td>
</tr>
<tr id="nodejs_test_macro.visibility">
<td><code>visibility</code></td>
<td>
<p><code>Unknown; Optional</code></p>
<p>applied to the wrapper binary</p>
</td>
</tr>
<tr id="nodejs_test_macro.tags">
<td><code>tags</code></td>
<td>
<p><code>List of strings; Optional</code></p>
<p>applied to the wrapper binary</p>
</td>
</tr>
<tr id="nodejs_test_macro.**kwargs">
<td><code>**kwargs</code></td>
<td>
<p><code>Unknown; Optional</code></p>
<p>passed to the nodejs_test</p>
</td>
</tr>
</tbody>
</table>
<hr>
<h2 id="nodejs_binary">nodejs_binary</h2>
<pre>nodejs_binary(<a href="#nodejs_binary.name">name</a>, <a href="#nodejs_binary.data">data</a>, <a href="#nodejs_binary.bootstrap">bootstrap</a>, <a href="#nodejs_binary.configuration_env_vars">configuration_env_vars</a>, <a href="#nodejs_binary.entry_point">entry_point</a>, <a href="#nodejs_binary.install_source_map_support">install_source_map_support</a>, <a href="#nodejs_binary.node">node</a>, <a href="#nodejs_binary.node_modules">node_modules</a>, <a href="#nodejs_binary.templated_args">templated_args</a>)</pre>
<p>Runs some JavaScript code in NodeJS.</p>
<h3 id="nodejs_binary_args">Attributes</h3>
<table class="params-table">
<colgroup>
<col class="col-param" />
<col class="col-description" />
</colgroup>
<tbody>
<tr id="nodejs_binary.name">
<td><code>name</code></td>
<td>
<p><code><a href="https://bazel.build/docs/build-ref.html#name">Name</a>; Required</code></p>
<p>A unique name for this rule.</p>
</td>
</tr>
<tr id="nodejs_binary.data">
<td><code>data</code></td>
<td>
<p><code>List of <a href="https://bazel.build/docs/build-ref.html#labels">labels</a>; Optional; Default is []</code></p>
<p>Runtime dependencies which may be loaded during execution.</p>
</td>
</tr>
<tr id="nodejs_binary.bootstrap">
<td><code>bootstrap</code></td>
<td>
<p><code>List of strings; Optional; Default is []</code></p>
<p>JavaScript modules to be loaded before the entry point.
For example, Angular uses this to patch the Jasmine async primitives for
zone.js before the first <code>describe</code>.</p>
</td>
</tr>
<tr id="nodejs_binary.configuration_env_vars">
<td><code>configuration_env_vars</code></td>
<td>
<p><code>List of strings; Optional; Default is []</code></p>
<p>Pass these configuration environment variables to the resulting binary.
Chooses a subset of the configuration environment variables (taken from ctx.var), which also
includes anything specified via the --define flag.
Note, this can lead to different outputs produced by this rule.</p>
</td>
</tr>
<tr id="nodejs_binary.entry_point">
<td><code>entry_point</code></td>
<td>
<p><code><a href="https://bazel.build/docs/build-ref.html#labels">Label</a>; Required</code></p>
<p>The script which should be executed first, usually containing a main function.</p>
<pre><code> If the entry JavaScript file belongs to the same package (as the BUILD file),
you can simply reference it by its relative name to the package directory:
```
nodejs_binary(
name = "my_binary",
...
entry_point = ":file.js",
)
```
You can specify the entry point as a typescript file so long as you also include
the ts_library target in data:
```
ts_library(
name = "main",
srcs = ["main.ts"],
)
nodejs_binary(
name = "bin",
data = [":main"]
entry_point = ":main.ts",
)
```
The rule will use the corresponding `.js` output of the ts_library rule as the entry point.
If the entry point target is a rule, it should produce a single JavaScript entry file that will be passed to the nodejs_binary rule.
For example:
```
filegroup(
name = "entry_file",
srcs = ["main.js"],
)
nodejs_binary(
name = "my_binary",
entry_point = ":entry_file",
)
```
The entry_point can also be a label in another workspace:
```
nodejs_binary(
name = "history-server",
entry_point = "@npm//:node_modules/history-server/modules/cli.js",
data = ["@npm//history-server"],
)
```
</code></pre>
</td>
</tr>
<tr id="nodejs_binary.install_source_map_support">
<td><code>install_source_map_support</code></td>
<td>
<p><code>Boolean; Optional; Default is True</code></p>
<p>Install the source-map-support package.
Enable this to get stack traces that point to original sources, e.g. if the program was written
in TypeScript.</p>
</td>
</tr>
<tr id="nodejs_binary.node">
<td><code>node</code></td>
<td>
<p><code><a href="https://bazel.build/docs/build-ref.html#labels">Label</a>; Optional; Default is @nodejs//:node_bin</code></p>
<p>The node entry point target.</p>
</td>
</tr>
<tr id="nodejs_binary.node_modules">
<td><code>node_modules</code></td>
<td>
<p><code><a href="https://bazel.build/docs/build-ref.html#labels">Label</a>; Optional; Default is //:node_modules_none</code></p>
<p>The npm packages which should be available to <code>require()</code> during
execution.</p>
<pre><code> This attribute is DEPRECATED. As of version 0.13.0 the recommended approach
to npm dependencies is to use fine grained npm dependencies which are setup
with the `yarn_install` or `npm_install` rules. For example, in targets
that used a `//:node_modules` filegroup,
```
nodejs_binary(
name = "my_binary",
...
node_modules = "//:node_modules",
)
```
which specifies all files within the `//:node_modules` filegroup
to be inputs to the `my_binary`. Using fine grained npm dependencies,
`my_binary` is defined with only the npm dependencies that are
needed:
```
nodejs_binary(
name = "my_binary",
...
data = [
"@npm//foo",
"@npm//bar",
...
],
)
```
In this case, only the `foo` and `bar` npm packages and their
transitive deps are includes as inputs to the `my_binary` target
which reduces the time required to setup the runfiles for this
target (see https://github.com/bazelbuild/bazel/issues/5153).
The @npm external repository and the fine grained npm package
targets are setup using the `yarn_install` or `npm_install` rule
in your WORKSPACE file:
yarn_install(
name = "npm",
package_json = "//:package.json",
yarn_lock = "//:yarn.lock",
)
For other rules such as `jasmine_node_test`, fine grained
npm dependencies are specified in the `deps` attribute:
```
jasmine_node_test(
name = "my_test",
...
deps = [
"@npm//jasmine",
"@npm//foo",
"@npm//bar",
...
],
)
```
</code></pre>
</td>
</tr>
<tr id="nodejs_binary.templated_args">
<td><code>templated_args</code></td>
<td>
<p><code>List of strings; Optional; Default is []</code></p>
<p>Arguments which are passed to every execution of the program.
To pass a node startup option, prepend it with <code>--node_options=</code>, e.g.
<code>--node_options=--preserve-symlinks</code></p>
</td>
</tr>
</tbody>
</table>
<hr>
<h2 id="nodejs_test">nodejs_test</h2>
<pre>nodejs_test(<a href="#nodejs_test.name">name</a>, <a href="#nodejs_test.data">data</a>, <a href="#nodejs_test.bootstrap">bootstrap</a>, <a href="#nodejs_test.configuration_env_vars">configuration_env_vars</a>, <a href="#nodejs_test.entry_point">entry_point</a>, <a href="#nodejs_test.expected_exit_code">expected_exit_code</a>, <a href="#nodejs_test.install_source_map_support">install_source_map_support</a>, <a href="#nodejs_test.node">node</a>, <a href="#nodejs_test.node_modules">node_modules</a>, <a href="#nodejs_test.templated_args">templated_args</a>)</pre>
<p>Identical to <code>nodejs_binary</code>, except this can be used with <code>bazel test</code> as well.
When the binary returns zero exit code, the test passes; otherwise it fails.</p>
<p><code>nodejs_test</code> is a convenient way to write a novel kind of test based on running
your own test runner. For example, the <code>ts-api-guardian</code> library has a way to
assert the public API of a TypeScript program, and uses <code>nodejs_test</code> here:
<a href="https://github.com/angular/angular/blob/master/tools/ts-api-guardian/index.bzl">https://github.com/angular/angular/blob/master/tools/ts-api-guardian/index.bzl</a></p>
<p>If you just want to run a standard test using a test runner like Karma or Jasmine,
use the specific rules for those test runners, e.g. <code>jasmine_node_test</code>.</p>
<p>To debug a Node.js test, we recommend saving a group of flags together in a "config".
Put this in your <code>tools/bazel.rc</code> so it's shared with your team:</p>
<pre><code># Enable debugging tests with --config=debug
test:debug --test_arg=--node_options=--inspect-brk --test_output=streamed --test_strategy=exclusive --test_timeout=9999 --nocache_test_results
</code></pre>
<p>Now you can add <code>--config=debug</code> to any <code>bazel test</code> command line.
The runtime will pause before executing the program, allowing you to connect a
remote debugger.</p>
<h3 id="nodejs_test_args">Attributes</h3>
<table class="params-table">
<colgroup>
<col class="col-param" />
<col class="col-description" />
</colgroup>
<tbody>
<tr id="nodejs_test.name">
<td><code>name</code></td>
<td>
<p><code><a href="https://bazel.build/docs/build-ref.html#name">Name</a>; Required</code></p>
<p>A unique name for this rule.</p>
</td>
</tr>
<tr id="nodejs_test.data">
<td><code>data</code></td>
<td>
<p><code>List of <a href="https://bazel.build/docs/build-ref.html#labels">labels</a>; Optional; Default is []</code></p>
<p>Runtime dependencies which may be loaded during execution.</p>
</td>
</tr>
<tr id="nodejs_test.bootstrap">
<td><code>bootstrap</code></td>
<td>
<p><code>List of strings; Optional; Default is []</code></p>
<p>JavaScript modules to be loaded before the entry point.
For example, Angular uses this to patch the Jasmine async primitives for
zone.js before the first <code>describe</code>.</p>
</td>
</tr>
<tr id="nodejs_test.configuration_env_vars">
<td><code>configuration_env_vars</code></td>
<td>
<p><code>List of strings; Optional; Default is []</code></p>
<p>Pass these configuration environment variables to the resulting binary.
Chooses a subset of the configuration environment variables (taken from ctx.var), which also
includes anything specified via the --define flag.
Note, this can lead to different outputs produced by this rule.</p>
</td>
</tr>
<tr id="nodejs_test.entry_point">
<td><code>entry_point</code></td>
<td>
<p><code><a href="https://bazel.build/docs/build-ref.html#labels">Label</a>; Required</code></p>
<p>The script which should be executed first, usually containing a main function.</p>
<pre><code> If the entry JavaScript file belongs to the same package (as the BUILD file),
you can simply reference it by its relative name to the package directory:
```
nodejs_binary(
name = "my_binary",
...
entry_point = ":file.js",
)
```
You can specify the entry point as a typescript file so long as you also include
the ts_library target in data:
```
ts_library(
name = "main",
srcs = ["main.ts"],
)
nodejs_binary(
name = "bin",
data = [":main"]
entry_point = ":main.ts",
)
```
The rule will use the corresponding `.js` output of the ts_library rule as the entry point.
If the entry point target is a rule, it should produce a single JavaScript entry file that will be passed to the nodejs_binary rule.
For example:
```
filegroup(
name = "entry_file",
srcs = ["main.js"],
)
nodejs_binary(
name = "my_binary",
entry_point = ":entry_file",
)
```
The entry_point can also be a label in another workspace:
```
nodejs_binary(
name = "history-server",
entry_point = "@npm//:node_modules/history-server/modules/cli.js",
data = ["@npm//history-server"],
)
```
</code></pre>
</td>
</tr>
<tr id="nodejs_test.expected_exit_code">
<td><code>expected_exit_code</code></td>
<td>
<p><code>Integer; Optional; Default is 0</code></p>
<p>The expected exit code for the test. Defaults to 0.</p>
</td>
</tr>
<tr id="nodejs_test.install_source_map_support">
<td><code>install_source_map_support</code></td>
<td>
<p><code>Boolean; Optional; Default is True</code></p>
<p>Install the source-map-support package.
Enable this to get stack traces that point to original sources, e.g. if the program was written
in TypeScript.</p>
</td>
</tr>
<tr id="nodejs_test.node">
<td><code>node</code></td>
<td>
<p><code><a href="https://bazel.build/docs/build-ref.html#labels">Label</a>; Optional; Default is @nodejs//:node_bin</code></p>
<p>The node entry point target.</p>
</td>
</tr>
<tr id="nodejs_test.node_modules">
<td><code>node_modules</code></td>
<td>
<p><code><a href="https://bazel.build/docs/build-ref.html#labels">Label</a>; Optional; Default is //:node_modules_none</code></p>
<p>The npm packages which should be available to <code>require()</code> during
execution.</p>
<pre><code> This attribute is DEPRECATED. As of version 0.13.0 the recommended approach
to npm dependencies is to use fine grained npm dependencies which are setup
with the `yarn_install` or `npm_install` rules. For example, in targets
that used a `//:node_modules` filegroup,
```
nodejs_binary(
name = "my_binary",
...
node_modules = "//:node_modules",
)
```
which specifies all files within the `//:node_modules` filegroup
to be inputs to the `my_binary`. Using fine grained npm dependencies,
`my_binary` is defined with only the npm dependencies that are
needed:
```
nodejs_binary(
name = "my_binary",
...
data = [
"@npm//foo",
"@npm//bar",
...
],
)
```
In this case, only the `foo` and `bar` npm packages and their
transitive deps are includes as inputs to the `my_binary` target
which reduces the time required to setup the runfiles for this
target (see https://github.com/bazelbuild/bazel/issues/5153).
The @npm external repository and the fine grained npm package
targets are setup using the `yarn_install` or `npm_install` rule
in your WORKSPACE file:
yarn_install(
name = "npm",
package_json = "//:package.json",
yarn_lock = "//:yarn.lock",
)
For other rules such as `jasmine_node_test`, fine grained
npm dependencies are specified in the `deps` attribute:
```
jasmine_node_test(
name = "my_test",
...
deps = [
"@npm//jasmine",
"@npm//foo",
"@npm//bar",
...
],
)
```
</code></pre>
</td>
</tr>
<tr id="nodejs_test.templated_args">
<td><code>templated_args</code></td>
<td>
<p><code>List of strings; Optional; Default is []</code></p>
<p>Arguments which are passed to every execution of the program.
To pass a node startup option, prepend it with <code>--node_options=</code>, e.g.
<code>--node_options=--preserve-symlinks</code></p>
</td>
</tr>
</tbody>
</table>
</div>
<footer class="mdl-mini-footer">
<div class="mdl-mini-footer__left-section">
<div class="mdl-logo">Bazel</div>
<ul class="mdl-mini-footer__link-list">
<li><a href="https://bazel.build">Home</a></li>
<li><a href="https://github.com/bazelbuild">GitHub</a></li>
</ul>
</div>
</footer>
</main>
</div>
</body>
</html>