Skip to content

Commit

Permalink
Swap esm with cjs in lib dir
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmillr committed Mar 17, 2024
1 parent 36f2f4e commit 21174b4
Show file tree
Hide file tree
Showing 14 changed files with 50 additions and 45 deletions.
1 change: 1 addition & 0 deletions lib/cjs/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "type": "commonjs" }
File renamed without changes.
36 changes: 18 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
"lib",
"src"
],
"main": "lib/index.js",
"module": "lib/esm/index.js",
"types": "lib/index.d.ts",
"main": "lib/cjs/index.js",
"module": "lib/index.js",
"types": "lib/cjs/index.d.ts",
"dependencies": {
"@noble/curves": "~1.4.0",
"@noble/hashes": "~1.4.0",
Expand All @@ -29,29 +29,29 @@
"license": "MIT",
"exports": {
".": {
"types": "./lib/index.d.ts",
"import": "./lib/esm/index.js",
"default": "./lib/index.js"
"types": "./lib/cjs/index.d.ts",
"import": "./lib/index.js",
"default": "./lib/cjs/index.js"
},
"./abi": {
"types": "./lib/abi/index.d.ts",
"import": "./lib/esm/abi/index.js",
"default": "./lib/abi/index.js"
"types": "./lib/cjs/abi/index.d.ts",
"import": "./lib/abi/index.js",
"default": "./lib/cjs/abi/index.js"
},
"./net": {
"types": "./lib/net/index.d.ts",
"import": "./lib/esm/net/index.js",
"default": "./lib/net/index.js"
"types": "./lib/cjs/net/index.d.ts",
"import": "./lib/net/index.js",
"default": "./lib/cjs/net/index.js"
},
"./tx": {
"types": "./lib/tx.d.ts",
"import": "./lib/esm/tx.js",
"default": "./lib/tx.js"
"types": "./lib/cjs/tx.d.ts",
"import": "./lib/tx.js",
"default": "./lib/cjs/tx.js"
},
"./utils": {
"types": "./lib/utils.d.ts",
"import": "./lib/esm/utils.js",
"default": "./lib/utils.js"
"types": "./lib/cjs/utils.d.ts",
"import": "./lib/utils.js",
"default": "./lib/cjs/utils.js"
}
},
"keywords": [
Expand Down
14 changes: 7 additions & 7 deletions test/abi.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@ import { deepStrictEqual, throws } from 'node:assert';
import { describe, should } from 'micro-should';
import { bytesToHex, hexToBytes, utf8ToBytes } from '@noble/hashes/utils';
import * as P from 'micro-packed';
import * as abi from '../lib/esm/abi/decoder.js';
import { strip0x } from '../lib/esm/utils.js';
import { CONTRACTS, decodeData, decodeEvent, decodeTx } from '../lib/esm/abi/index.js';
import * as abi from '../lib/abi/decoder.js';
import { strip0x } from '../lib/utils.js';
import { CONTRACTS, decodeData, decodeEvent, decodeTx } from '../lib/abi/index.js';

import { default as ERC20 } from '../lib/esm/abi/erc20.js';
import { default as ERC20 } from '../lib/abi/erc20.js';
import {
default as UNISWAP_V2_ROUTER,
UNISWAP_V2_ROUTER_CONTRACT,
} from '../lib/esm/abi/uniswap-v2.js';
} from '../lib/abi/uniswap-v2.js';
import {
default as UNISWAP_V3_ROUTER,
UNISWAP_V3_ROUTER_CONTRACT,
} from '../lib/esm/abi/uniswap-v3.js';
} from '../lib/abi/uniswap-v3.js';
import {
default as KYBER_NETWORK_PROXY,
KYBER_NETWORK_PROXY_CONTRACT,
} from '../lib/esm/abi/kyber.js';
} from '../lib/abi/kyber.js';

const hex = { encode: bytesToHex, decode: hexToBytes };

Expand Down
4 changes: 2 additions & 2 deletions test/eip1191.test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { deepStrictEqual, throws } from 'node:assert';
import { describe, should } from 'micro-should';
import { hexToBytes } from '@noble/hashes/utils';
import { addr } from '../lib/esm/address.js';
import { Transaction } from '../lib/esm/index.js';
import { addr } from '../lib/address.js';
import { Transaction } from '../lib/index.js';

const VECTORS = [
{
Expand Down
2 changes: 1 addition & 1 deletion test/ens.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { deepStrictEqual } from 'node:assert';
import { describe, should } from 'micro-should';
import { bytesToHex } from '@noble/hashes/utils';
import { namehash } from '../lib/esm/net/ens.js';
import { namehash } from '../lib/net/ens.js';

describe('ENS', () => {
should('namehash', () => {
Expand Down
4 changes: 2 additions & 2 deletions test/fee.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { deepStrictEqual } from 'node:assert';
import { describe, should } from 'micro-should';
import { Transaction } from '../lib/esm/index.js';
import { ethDecimal, gweiDecimal } from '../lib/esm/utils.js';
import { Transaction } from '../lib/index.js';
import { ethDecimal, gweiDecimal } from '../lib/utils.js';

// NOTE: other libraries doesn't support fee estimation, so there is no crosstests for now :(
// But we need some tests to avoid accidental breakage.
Expand Down
6 changes: 3 additions & 3 deletions test/net.test.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions test/rlp.test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { deepStrictEqual, throws } from 'node:assert';
import { describe, should } from 'micro-should';
import { hexToBytes } from '@noble/hashes/utils';
import { RLP } from '../lib/esm/tx.js';
import { ethHex, ethHexNoLeadingZero } from '../lib/esm/utils.js';
import { RLP } from '../lib/tx.js';
import { ethHex, ethHexNoLeadingZero } from '../lib/utils.js';
import { ENCODE_TESTS, DECODE_TESTS, INVALID } from './vectors/monorepo/rlp.js';
import { getEthersVectors, getViemVectors } from './util.js';
import { default as RLP_TEST } from './vectors/ethereum-tests/RLPTests/rlptest.json' assert { type: 'json' };
Expand Down
6 changes: 3 additions & 3 deletions test/tx.test.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { deepStrictEqual, throws } from 'node:assert';
import { inspect } from 'node:util';
import { describe, should } from 'micro-should';
import { addr, Transaction, messenger } from '../lib/esm/index.js';
import { RawTx, RlpTx, __tests } from '../lib/esm/tx.js';
import { add0x, createDecimal, ethHex, formatters } from '../lib/esm/utils.js';
import { addr, Transaction, messenger } from '../lib/index.js';
import { RawTx, RlpTx, __tests } from '../lib/tx.js';
import { add0x, createDecimal, ethHex, formatters } from '../lib/utils.js';
import { default as TX_VECTORS } from './vectors/transactions.json' assert { type: 'json' };
import { default as EIP155_VECTORS } from './vectors/eip155.json' assert { type: 'json' };
import * as ethTests from './vectors/eth-tests-tx-vectors.js';
Expand Down
6 changes: 3 additions & 3 deletions test/uniswap.test.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { deepStrictEqual, throws } from 'node:assert';
import { describe, should } from 'micro-should';
import { bytesToHex, concatBytes, hexToBytes } from '@noble/hashes/utils';
import * as uniswap2 from '../lib/esm/net/uniswap-v2.js';
import * as uniswap3 from '../lib/esm/net/uniswap-v3.js';
import { ethDecimal, strip0x } from '../lib/esm/utils.js';
import * as uniswap2 from '../lib/net/uniswap-v2.js';
import * as uniswap3 from '../lib/net/uniswap-v3.js';
import { ethDecimal, strip0x } from '../lib/utils.js';

const vitalik = '0xd8da6bf26964af9d7eed9e03e53415d37aa96045';
const TS = 1876543210;
Expand Down
4 changes: 2 additions & 2 deletions test/vanity-generator.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { addr } from '../lib/esm/index.js';
import { add0x } from '../lib/esm/utils.js';
import { addr } from '../lib/index.js';
import { add0x } from '../lib/utils.js';
function search(letters) {
// speed-up: `import { secp256k1 } from '@noble/curves/secp256k1'; secp256k1.utils.precompute(16)`
const prefix = add0x(letters);
Expand Down
4 changes: 3 additions & 1 deletion tsconfig.esm.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
{
"extends": "@paulmillr/jsbt/tsconfigs/esm.json",
"compilerOptions": {
"outDir": "lib/esm"
"outDir": "lib",
"declaration": true,
"declarationMap": true
},
"include": ["src"],
"exclude": ["node_modules", "lib"]
Expand Down
4 changes: 3 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
{
"extends": "@paulmillr/jsbt/tsconfigs/cjs.json",
"compilerOptions": {
"outDir": "lib"
"outDir": "lib/cjs",
"declaration": false,
"declarationMap": false
},
"include": ["src"],
"exclude": ["node_modules", "lib"]
Expand Down

0 comments on commit 21174b4

Please sign in to comment.