Skip to content
This repository was archived by the owner on Dec 16, 2025. It is now read-only.

Commit 74be4cf

Browse files
Added support for NPM.
Published the codlab-elements on NPM
1 parent 87c08e5 commit 74be4cf

5 files changed

Lines changed: 93 additions & 1 deletion

File tree

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ bazel-*
33
.drone.sec.yml
44
.idea/
55
debug.test
6-
*pb.go
6+
*pb.go
7+
node_modules

BUILD.bazel

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,15 @@ genrule(
1717
],
1818
cmd = "zip -j $@ $(SRCS)",
1919
)
20+
21+
genrule(
22+
name = "npm_dist",
23+
outs = ["npm_dist.zip"],
24+
srcs = [
25+
"LICENSE",
26+
"package.json",
27+
"//codelab-elements:README.md",
28+
"//codelab-elements:all_files",
29+
],
30+
cmd = "zip -j $@ $(SRCS)",
31+
)

codelab-elements/README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,26 @@ Here's an index.html obtaining the codelab-elements from Google Cloud Storage:
155155
</html>
156156
```
157157

158+
## NPM
159+
160+
The library is published on NPM.js at: https://www.npmjs.com/package/codelab-elements
161+
162+
We also support a build workflow using NPM. To build the library run fro the root of the repo:
163+
164+
```bash
165+
# Install dependencies. This takes care of installing the right version of Bazel.
166+
npm install
167+
168+
# Build the library
169+
npm run build
170+
171+
# The output is a zip file under bazel-genfiles
172+
ls bazel-genfiles npm_dist.zip
173+
174+
# Publish a new version of the library to NPM
175+
npm run dist
176+
```
177+
158178
## Notes
159179

160180
This is not an official Google product.

package-lock.json

Lines changed: 38 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"name": "codelab-elements",
3+
"version": "1.0.0",
4+
"description": "Custom elements for codelabs",
5+
"main": "index.js",
6+
"scripts": {
7+
"clean": "node_modules/.bin/bazel clean",
8+
"build": "node_modules/.bin/bazel build npm_dist",
9+
"test": "node_modules/.bin/bazel test --test_output=all codelab-elements/demo:hello_test",
10+
"pub": "npm run clean && npm run build && cd bazel-genfiles && unzip npm_dist.zip -d npm_dist && npm publish npm_dist"
11+
},
12+
"author": "Google",
13+
"repository": {
14+
"type": "git",
15+
"url": "https://github.com/googlecodelabs/tools.git"
16+
},
17+
"license": "Apache-2.0",
18+
"devDependencies": {
19+
"@bazel/bazel": "^0.18.1"
20+
}
21+
}

0 commit comments

Comments
 (0)