Skip to content

Commit 4c258bd

Browse files
committed
fix: browser bundle to use pure es modules
Fixes #8
1 parent 9c745be commit 4c258bd

8 files changed

+21
-5
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ typings/
8484
# End of https://www.gitignore.io/api/node
8585

8686
/dist
87+
/esm
8788
/*.tgz
8889
/*.cpuprofile
8990
/targets.json

.npmignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
!/dist
3-
!/pkg
3+
!/esm
44
!/*.ts
55
!/*.js
66
!/targets.json

Makefile

+3-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ RUST_WASM_OUT = $(patsubst %, dist/wasm/%/blake3_js_bg.wasm, $(TARGETS))
66
RUST_NATIVE_SRC = $(wildcard rs/native/src/*.rs)
77
RUST_NATIVE_OUT = dist/native.node
88
TS_SRC = $(wildcard ts/*.ts)
9-
TS_OUT = pkg/index.js
9+
TS_OUT = dist/index.js esm/index.js
1010

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

@@ -34,6 +34,7 @@ endif
3434

3535
$(TS_OUT): $(TS_SRC) $(RUST_WASM_OUT)
3636
./node_modules/.bin/tsc
37+
./node_modules/.bin/tsc -p tsconfig.esm.json
3738

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

4546
clean:
46-
rm -rf pkg dist
47+
rm -rf esm dist
4748

4849
prepare-binaries: $(TS_OUT)
4950
git checkout generate-binary

browser.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export * from './dist/browser';
1+
export * from './esm/browser';

browser.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export * from './dist/browser';
1+
export * from './esm/browser';

changelog.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 2.0.1 - 2019-01-23
4+
5+
- fix browser bundle to use pure es modules (fixes [#8](https://github.com/connor4312/blake3/issues/8))
6+
37
## 2.0.0 - 2019-01-19
48

59
- **breaking** the simple `hash` function no longer takes an encoding in its second parameter. Use `hash(data).toString(<encoding>)` instead.

package.json

+3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
"webassembly",
1010
"wasm"
1111
],
12+
"sideEffects": false,
13+
"module": "./esm/index",
14+
"browser": "./esm/browser/index",
1215
"main": "./dist/index",
1316
"scripts": {
1417
"install": "node -e \"try{require('./dist/build/install')}catch(e){}\"",

tsconfig.esm.json

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"module": "ESNext",
5+
"outDir": "./esm"
6+
}
7+
}

0 commit comments

Comments
 (0)