Skip to content

Commit

Permalink
fix: browser bundle to use pure es modules
Browse files Browse the repository at this point in the history
Fixes #8
  • Loading branch information
connor4312 committed Jan 24, 2020
1 parent 9c745be commit 4c258bd
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ typings/
# End of https://www.gitignore.io/api/node

/dist
/esm
/*.tgz
/*.cpuprofile
/targets.json
Expand Down
2 changes: 1 addition & 1 deletion .npmignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
!/dist
!/pkg
!/esm
!/*.ts
!/*.js
!/targets.json
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ RUST_WASM_OUT = $(patsubst %, dist/wasm/%/blake3_js_bg.wasm, $(TARGETS))
RUST_NATIVE_SRC = $(wildcard rs/native/src/*.rs)
RUST_NATIVE_OUT = dist/native.node
TS_SRC = $(wildcard ts/*.ts)
TS_OUT = pkg/index.js
TS_OUT = dist/index.js esm/index.js

all: $(RUST_WASM_OUT) $(RUST_NATIVE_OUT) $(TS_OUT)

Expand Down Expand Up @@ -34,6 +34,7 @@ endif

$(TS_OUT): $(TS_SRC) $(RUST_WASM_OUT)
./node_modules/.bin/tsc
./node_modules/.bin/tsc -p tsconfig.esm.json

$(RUST_WASM_OUT): $(RUST_WASM_SRC)
wasm-pack build rs/wasm --$(MODE) -t $(word 3, $(subst /, ,$@)) -d ../../$(dir $@)
Expand All @@ -43,7 +44,7 @@ ifeq ($(MODE), release)
endif

clean:
rm -rf pkg dist
rm -rf esm dist

prepare-binaries: $(TS_OUT)
git checkout generate-binary
Expand Down
2 changes: 1 addition & 1 deletion browser.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from './dist/browser';
export * from './esm/browser';
2 changes: 1 addition & 1 deletion browser.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from './dist/browser';
export * from './esm/browser';
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 2.0.1 - 2019-01-23

- fix browser bundle to use pure es modules (fixes [#8](https://github.com/connor4312/blake3/issues/8))

## 2.0.0 - 2019-01-19

- **breaking** the simple `hash` function no longer takes an encoding in its second parameter. Use `hash(data).toString(<encoding>)` instead.
Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
"webassembly",
"wasm"
],
"sideEffects": false,
"module": "./esm/index",
"browser": "./esm/browser/index",
"main": "./dist/index",
"scripts": {
"install": "node -e \"try{require('./dist/build/install')}catch(e){}\"",
Expand Down
7 changes: 7 additions & 0 deletions tsconfig.esm.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"module": "ESNext",
"outDir": "./esm"
}
}

0 comments on commit 4c258bd

Please sign in to comment.