Skip to content

Commit fedef11

Browse files
committed
Add hybrid common.js - ESM support. Bump deps. Closes #79, #80, #14
1 parent a2fffce commit fedef11

File tree

6 files changed

+34
-6
lines changed

6 files changed

+34
-6
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@
66
/test-builds
77
/node_modules
88
/.parcel-cache
9+
/esm

.vscode/settings.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"files.exclude": {
3+
"*.{js,d.ts,js.map,d.ts.map}": true,
4+
"esm/*.{js,d.ts,js.map,d.ts.map}": true
5+
}
6+
}

esm/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"type": "module"
3+
}

package.json

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ethereum-cryptography",
3-
"version": "2.0.0",
3+
"version": "2.1.0",
44
"description": "All the cryptographic primitives used in Ethereum",
55
"contributors": [
66
{
@@ -21,13 +21,14 @@
2121
"bip39/wordlists/*.js",
2222
"bip39/wordlists/*.d.ts",
2323
"*.js",
24-
"*.d.ts"
24+
"*.d.ts",
25+
"esm"
2526
],
2627
"dependencies": {
27-
"@noble/curves": "1.0.0",
28-
"@noble/hashes": "1.3.0",
28+
"@noble/curves": "1.1.0",
29+
"@noble/hashes": "1.3.1",
2930
"@scure/bip32": "1.3.0",
30-
"@scure/bip39": "1.2.0"
31+
"@scure/bip39": "1.2.1"
3132
},
3233
"browser": {
3334
"crypto": false
@@ -36,7 +37,7 @@
3637
"scripts": {
3738
"prepare": "npm run build",
3839
"build": "npm-run-all build:tsc",
39-
"build:tsc": "tsc --project tsconfig.prod.json",
40+
"build:tsc": "tsc --project tsconfig.prod.json && tsc --project tsconfig.prod.esm.json",
4041
"test": "npm-run-all test:node",
4142
"test:node": "mocha",
4243
"clean": "rimraf test-builds bip39 '*.js' '*.js.map' '*.d.ts' '*.d.ts.map' 'src/**/*.js'",

src/utils.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ export function wrapHash(hash: (msg: Uint8Array) => Uint8Array) {
5151
};
5252
}
5353

54+
declare const globalThis: Record<string, any> | undefined;
55+
5456
// TODO(v3): switch away from node crypto, remove this unnecessary variable.
5557
export const crypto: { node?: any; web?: any } = (() => {
5658
const webCrypto =

tsconfig.prod.esm.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"compilerOptions": {
3+
"target": "es2020",
4+
"lib": ["es2020", "dom"],
5+
"module": "es6",
6+
"moduleResolution": "node",
7+
"strict": true,
8+
"rootDir": "src",
9+
"outDir": "esm"
10+
},
11+
"include": [
12+
"src/**/*.ts"
13+
],
14+
"exclude": []
15+
}

0 commit comments

Comments
 (0)