Skip to content

Commit

Permalink
Add ES module build
Browse files Browse the repository at this point in the history
  • Loading branch information
gentooboontoo committed Mar 25, 2018
1 parent c98b590 commit 77c47e7
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
22 changes: 16 additions & 6 deletions Makefile
Expand Up @@ -3,14 +3,24 @@ SPECFILES := $(shell find $(SPEC_DIR) -iname '*.js')
SOURCE_DIR := src
SOURCES := $(shell find $(SOURCE_DIR) -iname '*.js')
LINTEDFILES := $(SOURCES) $(SPECFILES)
DISTFILE := build/quantities.js
BUILD_DIR := build
ESM_FILE := $(BUILD_DIR)/quantities.esm.js
UMD_FILE := $(BUILD_DIR)/quantities.js
DIST_FILES := $(ESM_FILE) $(UMD_FILE)
BANNER := $(shell cat LICENSE)

build: $(DISTFILE)
build: $(DIST_FILES)

$(DISTFILE): $(SOURCES)
rollup --output.file=$(DISTFILE) \
--output.format=umd \
$(UMD_FILE): $(SOURCES)
rollup --file=$(UMD_FILE) \
--format=umd \
--name=Qty \
--banner="`echo '/*'; cat LICENSE; echo '*/'`" \
src/quantities.js

$(ESM_FILE): $(SOURCES)
rollup --file=$(ESM_FILE) \
--format=es \
--name=Qty \
--banner="`echo '/*'; cat LICENSE; echo '*/'`" \
src/quantities.js
Expand All @@ -26,6 +36,6 @@ bench:
bin/bench.rb

clean:
rm -f $(DISTFILE)
rm -f $(DIST_FILES)

.PHONY: bench build clean lint test
2 changes: 1 addition & 1 deletion bin/release.sh
Expand Up @@ -6,7 +6,7 @@ VERSION=$(cat RELEASE)
TAG=v${VERSION}

git add History.md README.md bower.json package.json \
RELEASE src/quantities.js build/quantities.js
RELEASE src/quantities.js build/quantities.js build/quantities.esm.js
git commit -m "Release ${TAG}"
git tag "${TAG}"
git push github master "${TAG}"
Expand Down
1 change: 1 addition & 0 deletions package.json
@@ -1,6 +1,7 @@
{
"name": "js-quantities",
"main": "./build/quantities.js",
"module": "./build/quantities.esm.js",
"readmeFilename": "README.md",
"description": "JavaScript library for quantity calculation and unit conversion",
"version": "1.7.0",
Expand Down

0 comments on commit 77c47e7

Please sign in to comment.