Skip to content

Commit ed5be68

Browse files
authored
Merge pull request #87 from ethereum/fix-imports
Rewrite imports: add .js extension, gh-86
2 parents 263279a + 7c33ac2 commit ed5be68

31 files changed

+105
-59
lines changed

.gitignore

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

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ethereum-cryptography",
3-
"version": "2.1.0",
3+
"version": "2.1.1",
44
"description": "All the cryptographic primitives used in Ethereum",
55
"contributors": [
66
{
@@ -296,8 +296,8 @@
296296
"build": "npm-run-all build:tsc",
297297
"build:tsc": "tsc --project tsconfig.prod.json && tsc --project tsconfig.prod.esm.json",
298298
"test": "npm-run-all test:node",
299-
"test:node": "mocha",
300-
"clean": "rimraf test-builds bip39 '*.js' '*.js.map' '*.d.ts' '*.d.ts.map' 'src/**/*.js'",
299+
"test:node": "cd test && npm install && cd .. && mocha",
300+
"clean": "rimraf test/test-builds bip39 '*.js' '*.js.map' '*.d.ts' '*.d.ts.map' 'src/**/*.js'",
301301
"lint": "eslint",
302302
"lint:fix": "eslint --fix",
303303
"browser-tests": "npm-run-all browser-tests:build browser-tests:test",
@@ -361,4 +361,4 @@
361361
"context": "browser"
362362
}
363363
}
364-
}
364+
}

scripts/build-browser-tests.sh

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
11
set -e
22

3+
cd ./test/
4+
echo "Install package to tests"
5+
# Cleanup old module build
6+
rm -rf ./node_modules
7+
npm install
8+
39
echo "Building tests with TypeScript"
4-
npx tsc --project tsconfig.json
10+
npx tsc --project ./tsconfig.json
511

612
echo "Building tests with Parcel"
7-
npx parcel build --no-cache --no-optimize test-builds/tsc/test/test-vectors/*.js --dist-dir test-builds/parcel --target parcel_tests
13+
npx parcel build --no-cache --no-optimize ./test-builds/tsc/test/test-vectors/*.js --dist-dir ./test-builds/parcel --target parcel_tests
814

915
echo "Building tests with Browserify"
10-
npx browserify test-builds/tsc/test/test-vectors/*.js > test-builds/browserify-build.js
16+
npx browserify ./test-builds/tsc/test/test-vectors/*.js > ./test-builds/browserify-build.js
1117

1218
echo "Building tests with webpack"
1319
npx webpack --mode development ./test-builds/tsc/test/test-vectors/*.js --output-path ./test-builds
1420

1521
echo "Building tests with Rollup"
16-
rollup -c test/rollup.config.js
22+
rollup -c ./rollup.config.js

src/aes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { crypto as cr } from "@noble/hashes/crypto";
2-
import { concatBytes, equalsBytes } from "./utils";
2+
import { concatBytes, equalsBytes } from "./utils.js";
33

44
const crypto: any = { web: cr };
55

src/blake2b.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { blake2b as _blake2b } from "@noble/hashes/blake2b";
2-
import { assertBytes } from "./utils";
2+
import { assertBytes } from "./utils.js";
33

44
export const blake2b = (msg: Uint8Array, outputLength = 64): Uint8Array => {
55
assertBytes(msg);

src/keccak.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
keccak_512
77
} from "@noble/hashes/sha3";
88
import { Hash } from "@noble/hashes/utils";
9-
import { wrapHash } from "./utils";
9+
import { wrapHash } from "./utils.js";
1010

1111
// Expose create only for keccak256
1212
interface K256 {

src/pbkdf2.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
} from "@noble/hashes/pbkdf2";
55
import { sha256 } from "@noble/hashes/sha256";
66
import { sha512 } from "@noble/hashes/sha512";
7-
import { assertBytes } from "./utils";
7+
import { assertBytes } from "./utils.js";
88

99
export async function pbkdf2(
1010
password: Uint8Array,

src/ripemd160.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
import { ripemd160 as _ripemd160 } from "@noble/hashes/ripemd160";
2-
import { wrapHash } from "./utils";
2+
import { wrapHash } from "./utils.js";
33

44
export const ripemd160 = wrapHash(_ripemd160);

src/scrypt.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { scrypt as _sync, scryptAsync as _async } from "@noble/hashes/scrypt";
2-
import { assertBytes } from "./utils";
2+
import { assertBytes } from "./utils.js";
33

44
type OnProgressCallback = (progress: number) => void;
55

src/secp256k1-compat.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { sha256 } from "@noble/hashes/sha256";
22
import { mod } from "@noble/curves/abstract/modular";
3-
import { secp256k1 } from "./secp256k1";
4-
import { assertBool, assertBytes, hexToBytes, toHex } from "./utils";
3+
import { secp256k1 } from "./secp256k1.js";
4+
import { assertBool, assertBytes, hexToBytes, toHex } from "./utils.js";
55

66
// Use `secp256k1` module directly.
77
// This is a legacy compatibility layer for the npm package `secp256k1` via noble-secp256k1

0 commit comments

Comments
 (0)