You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 2925f8f
Browse filesBrowse the repository at this point in the historyBrowse files
Currently, the only available rule is `nodejs_binary` which allows you to run an application, either from sources you author or from those fetched from npm.
64
+
The `nodejs_binary` rule allows you to run an application by giving the entry point.
65
+
The entry point can come from an external dependency installed by the package manager,
66
+
or it can be a `.js` file from a package built by Bazel.
67
+
68
+
The `jasmine_node_test` rule allows you to write a test that executes in NodeJS.
69
+
70
+
### Running a program from npm
65
71
66
-
## Running a program from npm
67
72
If you have installed the [rollup] package, you could write this rule:
68
73
69
74
```python
@@ -81,9 +86,13 @@ and run it with
81
86
$ bazel run :rollup -- --help
82
87
```
83
88
89
+
See the `examples/rollup` directory in this repository.
90
+
84
91
[rollup]: https://www.npmjs.com/package/rollup
85
92
86
-
## Running a program from local sources
93
+
### Running a program from local sources
94
+
95
+
We can reference a path in the local workspace to run a program we write.
@@ -104,6 +113,20 @@ This example illustrates how to pass arguments to nodejs (as opposed to passing
104
113
The `data` attribute is optional, by default it includes the `node_modules` directory. To include your own
105
114
sources, include a file or target that produces JavaScript.
106
115
116
+
See the `examples/program` directory in this repository.
117
+
118
+
### Testing
119
+
120
+
The `jasmine_node_test` rule can be used to run unit tests in NodeJS, using the Jasmine framework.
121
+
Targets declared with this rule can be run with `bazel test`.
122
+
123
+
Attributes:
124
+
125
+
The `srcs` of a `jasmine_node_test` should include the test `.js` files.
126
+
The `deps` should include the production `.js` sources, or other rules which produce `.js` files, such as TypeScript.
127
+
128
+
The `examples/program/index.spec.js` file illustrates this. Another usage is in https://github.com/angular/tsickle/blob/master/test/BUILD
129
+
107
130
# Design
108
131
109
132
Most bazel rules include package management. That is, the `WORKSPACE` file installs your dependencies as well as the toolchain. In some environments, this is the normal workflow, for example in Java, Gradle and Maven are each both a build tool and a package manager.
0 commit comments