Skip to content

Commit 7ec47a3

Browse files
holgerd77acolytec3
andauthored
Monorepo: Set "type": "module" in package.json files (default ESM internally) (#3494)
* Do a simple test and see what happens (Util) (npm i works, test:node works, lint works, docs do not work (maybe unrelated), examples work) * Switch all other libraries over * Move view specialized debug functionality out of trie src since debug module causes too much problem in this intense usage setup (not ESM ready) * Trie import fixes * VM example file extension renaming * Fix VM examples * Import fix * Make the switch-over in tsconfig files * Fix some new lint failures * Bugfix (wrong import extension) * Import file extension fixes * Fix benchmarks * Fix various import issues * Remove duplicative node types and clean up references --------- Co-authored-by: acolytec3 <[email protected]>
1 parent c6ff99a commit 7ec47a3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+127
-150
lines changed

config/tsconfig.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
"sourceMap": true,
44
"declaration": true,
55
"declarationMap": true,
6-
"module": "Node16",
7-
"moduleResolution": "node",
6+
"module": "NodeNext",
7+
"moduleResolution": "NodeNext",
88
"emitDecoratorMetadata": true,
99
"experimentalDecorators": true,
1010
"esModuleInterop": false,

config/tsconfig.prod.cjs.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
{
2-
"extends": "./tsconfig.json"
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"module": "Node16",
5+
"moduleResolution": "node"
6+
}
37
}

config/tsconfig.prod.esm.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
11
{
2-
"extends": "./tsconfig.json",
3-
"compilerOptions": {
4-
"module": "esnext"
5-
}
2+
"extends": "./tsconfig.json"
63
}

packages/block/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
},
1717
"license": "MPL-2.0",
1818
"author": "mjbecze ([email protected])",
19-
"type": "commonjs",
19+
"type": "module",
2020
"main": "dist/cjs/index.js",
2121
"module": "dist/esm/index.js",
2222
"exports": {

packages/blockchain/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
},
1717
"license": "MPL-2.0",
1818
"author": "mjbecze <[email protected]>",
19-
"type": "commonjs",
19+
"type": "module",
2020
"main": "dist/cjs/index.js",
2121
"module": "dist/esm/index.js",
2222
"exports": {

packages/blockchain/src/consensus/clique.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,8 @@ import type { Blockchain } from '../index.js'
1818
import type { Consensus, ConsensusOptions } from '../types.js'
1919
import type { Block, BlockHeader } from '@ethereumjs/block'
2020
import type { CliqueConfig } from '@ethereumjs/common'
21-
const { debug: createDebugLogger } = debugDefault
2221

23-
const debug = createDebugLogger('blockchain:clique')
22+
const debug = debugDefault('blockchain:clique')
2423

2524
// Magic nonce number to vote on adding a new signer
2625
export const CLIQUE_NONCE_AUTH = hexToBytes('0xffffffffffffffff')

packages/blockchain/src/consensus/ethash.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export class EthashConsensus implements Consensus {
4444
public async genesisInit(): Promise<void> {}
4545
public async setup({ blockchain }: ConsensusOptions): Promise<void> {
4646
this.blockchain = blockchain
47-
this._ethash = new Ethash(this.blockchain.db as any)
47+
this._ethash = new Ethash(this.blockchain!.db as any)
4848
}
4949
public async newBlock(): Promise<void> {}
5050
}

packages/blockchain/src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Blockchain } from '.'
1+
import type { Blockchain } from './index.js'
22
import type { Block, BlockHeader } from '@ethereumjs/block'
33
import type { Common, ConsensusAlgorithm } from '@ethereumjs/common'
44
import type { AsyncEventEmitter, DB, DBObject, GenesisState } from '@ethereumjs/util'

packages/blockchain/tsconfig.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"extends": "../../config/tsconfig.json",
33
"include": ["src/**/*.ts", "src/**/*.json", "test/**/*.ts"],
44
"compilerOptions": {
5-
"types": ["node"],
65
"typeRoots": ["node_modules/@types"]
76
}
87
}

packages/client/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020
},
2121
"license": "MPL-2.0",
2222
"author": "Vinay Pulim ([email protected])",
23+
"type": "module",
2324
"main": "dist/esm/bin/cli.js",
2425
"types": "dist/esm/src/index.d.ts",
25-
"type": "module",
2626
"bin": {
2727
"ethereumjs": "dist/esm/bin/cli.js"
2828
},

0 commit comments

Comments
 (0)