Skip to content

Commit

Permalink
Emit ESM bundle (#484)
Browse files Browse the repository at this point in the history
  • Loading branch information
schlusslicht authored Oct 31, 2022
1 parent ebc00c8 commit 3be2338
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
21 changes: 20 additions & 1 deletion BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ load("@npm//@bazel/typescript:index.bzl", "ts_library")
load("@build_bazel_rules_nodejs//:index.bzl", "pkg_npm")
load("@npm//@bazel/rollup:index.bzl", "rollup_bundle")

### Produce umd and cjs bundles
### Produce umd, cjs and esm bundles

ts_library(
name = "dev",
Expand All @@ -28,6 +28,7 @@ ts_library(
)
for format, args in {
"cjs": [],
"esm": [],
"umd": [
# Downlevel (transpile) to ES5.
"-p",
Expand Down Expand Up @@ -67,6 +68,23 @@ pkg_npm(
],
)

genrule(
name = "incremental-dom-esm",
srcs = [":bundle.esm.js"],
outs = ["dist/incremental-dom-esm.js"],
cmd = "cp $(locations :bundle.esm.js) $@",
)

pkg_npm(
name = "npm-esm",
substitutions = {
"const DEBUG = true;": "const DEBUG = false;",
},
deps = [
":incremental-dom-esm",
],
)

### Produce minified bundle

## Create a second index so that it can have a reference to the release/ directory.
Expand Down Expand Up @@ -131,6 +149,7 @@ pkg_npm(
],
nested_packages = [
":npm-cjs",
":npm-esm",
":npm-min",
":npm-umd",
],
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "incremental-dom",
"version": "0.7.0",
"description": "An in-place virtual DOM library",
"exports": "dist/incremental-dom-esm.js",
"main": "dist/incremental-dom-cjs.js",
"author": "The Incremental DOM Authors",
"license": "Apache-2.0",
Expand Down

0 comments on commit 3be2338

Please sign in to comment.