Skip to content

Commit ae7c90b

Browse files
authoredMar 13, 2024··
Merge pull request #4 from riisi/extend-example
Demonstrate more javascript backend functionality
2 parents 3b69ab4 + 5b01479 commit ae7c90b

14 files changed

+7048
-16
lines changed
 

‎.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,7 @@
44
/.pids
55
/.pants.workdir.file_lock*
66

7+
node_modules
8+
9+
# Build output when build invoked with `npm run build`
10+
dist_npm

‎.prettierrc.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Example prettier config - try changing this and running `pants fmt ::`
2+
# See https://prettier.io/docs/en/configuration.html for more options
3+
singleQuote: true

‎BUILD

+15-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,15 @@
1-
package_json(name="hello_pkg")
1+
package_json(
2+
name="hello_pkg",
3+
scripts=[
4+
node_test_script(
5+
coverage_args=["--coverage", "--coverage-directory=.coverage/"],
6+
coverage_output_files=[".coverage/lcov-report/index.html"],
7+
coverage_output_directories=[".coverage/lcov-report"],
8+
),
9+
node_build_script(
10+
entry_point="build",
11+
extra_env_vars=["FOO=BAR"],
12+
output_files=["dist_npm/index.js"],
13+
),
14+
],
15+
)

‎README.md

+26
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,32 @@ Try these out in this repo.
1717

1818
```
1919
pants dependencies src/index.js
20+
pants dependencies --transitive src/index.js
21+
```
22+
23+
## Lint and format
24+
25+
```
26+
pants lint ::
27+
pants fmt ::
28+
```
29+
30+
## Test
31+
32+
```
33+
pants test ::
34+
pants test --use-coverage ::
35+
```
36+
37+
The example is configured to use Jest as the test runner via `package.json` "scripts.test" key.
38+
Mocha is also supported by the Javascript backend.
39+
40+
## Package
41+
42+
The example uses esbuild to package the source into a single file in the `dist` directory.
43+
44+
```
45+
pants package ::
2046
```
2147

2248
## Generate lockfiles

0 commit comments

Comments
 (0)
Please sign in to comment.