From 3be2338cb18bce102b65a2df3d22add2680fc13e Mon Sep 17 00:00:00 2001 From: Philip Schlusslicht Date: Mon, 31 Oct 2022 02:54:10 +0100 Subject: [PATCH] Emit ESM bundle (#484) --- BUILD | 21 ++++++++++++++++++++- package.json | 1 + 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/BUILD b/BUILD index d85beff..0b83047 100644 --- a/BUILD +++ b/BUILD @@ -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", @@ -28,6 +28,7 @@ ts_library( ) for format, args in { "cjs": [], + "esm": [], "umd": [ # Downlevel (transpile) to ES5. "-p", @@ -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. @@ -131,6 +149,7 @@ pkg_npm( ], nested_packages = [ ":npm-cjs", + ":npm-esm", ":npm-min", ":npm-umd", ], diff --git a/package.json b/package.json index 2a1e848..1ede605 100644 --- a/package.json +++ b/package.json @@ -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",