Skip to content

Commit

Permalink
ESM CJS builds (#5904)
Browse files Browse the repository at this point in the history
* base tsconfig

* build specific tsconfig

* build scripts for esm and cjs

* tsconfig fix for tests

* integration test fix

* webpack custom tsconf to ts-loader

* doc pointing to conf

* linter ts config

* docs config

* explicitly override module type in build outputs

* tsconf update

* fix ethereumjs/tx import issue for pure ESM

* changelog andpackage.json updates

* types at first

* updated build script

* change log sync
  • Loading branch information
jdevcs authored Mar 28, 2023
1 parent dd33e17 commit 0781d8a
Show file tree
Hide file tree
Showing 164 changed files with 1,018 additions and 184 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module.exports = {
},
parserOptions: {
ecmaVersion: 2016,
project: './tsconfig.json',
project: './tsconfig.base.json',
tsconfigRootDir: __dirname,
sourceType: 'module',
},
Expand Down
2 changes: 1 addition & 1 deletion .eslintrc.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = {
parserOptions: {
project: './tsconfig.json',
project: './tsconfig.base.json',
tsconfigRootDir: __dirname,
},
extends: ['web3-base/ts-jest'],
Expand Down
69 changes: 69 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -1319,10 +1319,79 @@ should use 4.0.1-alpha.0 for testing.

### Added

#### web3

- Added hybrid build (ESM and CJS) of library (#5904)

#### web3-core

- Added hybrid build (ESM and CJS) of library (#5904)

#### web3-errors

- Added hybrid build (ESM and CJS) of library (#5904)

#### web3-eth

- Added hybrid build (ESM and CJS) of library (#5904)

#### web3-eth-abi

- Added hybrid build (ESM and CJS) of library (#5904)

#### web3-eth-accounts

- Added hybrid build (ESM and CJS) of library (#5904)

#### web3-eth-contract

- Added hybrid build (ESM and CJS) of library (#5904)
- `input` is now an acceptable property for `ContractInitOptions` in place of `data` (either can be used, but `input` is used withing the

#### web3-eth-ens

- Added hybrid build (ESM and CJS) of library (#5904)

#### web3-eth-iban

- Added hybrid build (ESM and CJS) of library (#5904)

#### web3-eth-personal

- Added hybrid build (ESM and CJS) of library (#5904)

#### web3-net

- Added hybrid build (ESM and CJS) of library (#5904)

#### web3-providers-http

- Added hybrid build (ESM and CJS) of library (#5904)

#### web3-providers-ipc

- Added hybrid build (ESM and CJS) of library (#5904)

#### web3-providers-ws

- Added hybrid build (ESM and CJS) of library (#5904)

#### web3-rpc-methods

- Added hybrid build (ESM and CJS) of library (#5904)

#### web3-types

- Added hybrid build (ESM and CJS) of library (#5904)

#### web3-utils

- Added hybrid build (ESM and CJS) of library (#5904)

#### web3-validator

- Added hybrid build (ESM and CJS) of library (#5904)

### Removed

#### web3-core
Expand Down
6 changes: 4 additions & 2 deletions docs/tsconfig.docs.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
{
"extends": "../tsconfig.json",
"extends": "../tsconfig.base.json",
"compilerOptions": {
"declarationDir": "dts",
"outDir": "dts"
"outDir": "dts",
"declaration": true,
"declarationMap": true
},
"include": ["../packages/*/src/**/*", "../packages/*/types/**/*"]
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"build:web": "lerna run build:web --stream",
"build:web:analyze": "lerna run build:web:analyze --stream",
"build:docs": "cd docs && yarn install && yarn build",
"changelog": "ts-node scripts/changelog/src/index.ts",
"changelog": "ts-node -P scripts/changelog/tsconfig.json scripts/changelog/src/index.ts",
"clean": "lerna run clean --stream --parallel",
"ganache:start": "WEB3_SYSTEM_TEST_BACKEND=ganache && ./scripts/ganache.sh start",
"ganache:start:background": "WEB3_SYSTEM_TEST_BACKEND=ganache && ./scripts/ganache.sh start 1",
Expand Down
2 changes: 1 addition & 1 deletion packages/web3-core/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module.exports = {
extends: '../../.eslintrc.js',
parserOptions: {
project: './tsconfig.json',
project: './tsconfig.esm.json',
tsconfigRootDir: __dirname,
},
};
4 changes: 4 additions & 0 deletions packages/web3-core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

- Added hybrid build (ESM and CJS) of library (#5904)

### Changed

- If a transaction object with a `data` property is passed to `txInputOptionsFormatter`, it will now be replaced with `input` (#5915)
Expand Down
15 changes: 13 additions & 2 deletions packages/web3-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,15 @@
"name": "web3-core",
"version": "4.0.1-rc.0",
"description": "Web3 core tools for sub-packages. This is an internal package.",
"main": "lib/index.js",
"main": "./lib/commonjs/index.js",
"module": "./lib/esm/index.js",
"exports": {
".": {
"types": "./lib/types/index.d.ts",
"import": "./lib/esm/index.js",
"require": "./lib/commonjs/index.js"
}
},
"repository": "https://github.com/ChainSafe/web3.js",
"author": "ChainSafe Systems",
"license": "LGPL-3.0",
Expand All @@ -16,7 +24,10 @@
"scripts": {
"clean": "rimraf dist && rimraf lib",
"prebuild": "yarn clean",
"build": "tsc --build",
"build": "yarn build:cjs & yarn build:esm & yarn build:types",
"build:cjs": "tsc --build tsconfig.cjs.json && echo '{\"type\": \"commonjs\"}' > ./lib/commonjs/package.json",
"build:esm": "tsc --build tsconfig.esm.json && echo '{\"type\": \"module\"}' > ./lib/esm/package.json",
"build:types": "tsc --build tsconfig.types.json",
"build:check": "node -e \"require('./lib')\"",
"lint": "eslint --ext .js,.ts .",
"lint:fix": "eslint --fix --ext .js,.ts .",
Expand Down
2 changes: 1 addition & 1 deletion packages/web3-core/test/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../tsconfig",
"extends": "../tsconfig.cjs.json",
"compilerOptions": {
"declaration": false,
"declarationMap": false
Expand Down
9 changes: 9 additions & 0 deletions packages/web3-core/tsconfig.cjs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"outDir": "./lib/commonjs",
"declaration": true,
"module": "commonjs"
},
"include": ["src/**/*"]
}
8 changes: 8 additions & 0 deletions packages/web3-core/tsconfig.esm.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"outDir": "./lib/esm",
"module": "es2020"
},
"include": ["src/**/*"]
}
7 changes: 0 additions & 7 deletions packages/web3-core/tsconfig.json

This file was deleted.

10 changes: 10 additions & 0 deletions packages/web3-core/tsconfig.types.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"declarationDir": "./lib/types",
"declaration": true,
"declarationMap": true,
"emitDeclarationOnly": true
},
"include": ["src/**/*"]
}
2 changes: 1 addition & 1 deletion packages/web3-errors/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module.exports = {
extends: '../../.eslintrc.js',
parserOptions: {
project: './tsconfig.json',
project: './tsconfig.esm.json',
tsconfigRootDir: __dirname,
},
};
4 changes: 4 additions & 0 deletions packages/web3-errors/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

- Added hybrid build (ESM and CJS) of library (#5904)

### Changed

- `gasLimit` is no longer accepted as a parameter for `MissingGasError` and `TransactionGasMismatchError, and is also no longer included in error message (#5915)
15 changes: 13 additions & 2 deletions packages/web3-errors/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,15 @@
"name": "web3-errors",
"version": "1.0.0-rc.0",
"description": "This package has web3 error classes",
"main": "lib/index.js",
"main": "./lib/commonjs/index.js",
"module": "./lib/esm/index.js",
"exports": {
".": {
"types": "./lib/types/index.d.ts",
"import": "./lib/esm/index.js",
"require": "./lib/commonjs/index.js"
}
},
"repository": "https://github.com/ChainSafe/web3.js",
"author": "ChainSafe Systems",
"license": "LGPL-3.0",
Expand All @@ -16,7 +24,10 @@
"scripts": {
"clean": "rimraf dist && rimraf lib",
"prebuild": "yarn clean",
"build": "tsc --build",
"build": "yarn build:cjs & yarn build:esm & yarn build:types",
"build:cjs": "tsc --build tsconfig.cjs.json && echo '{\"type\": \"commonjs\"}' > ./lib/commonjs/package.json",
"build:esm": "tsc --build tsconfig.esm.json && echo '{\"type\": \"module\"}' > ./lib/esm/package.json",
"build:types": "tsc --build tsconfig.types.json",
"build:check": "node -e \"require('./lib')\"",
"lint": "eslint --ext .js,.ts .",
"lint:fix": "eslint --fix --ext .js,.ts .",
Expand Down
10 changes: 10 additions & 0 deletions packages/web3-errors/tsconfig.cjs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"outDir": "./lib/commonjs",
"esModuleInterop": true,
"declaration": true,
"module": "commonjs"
},
"include": ["src/**/*"]
}
9 changes: 9 additions & 0 deletions packages/web3-errors/tsconfig.esm.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"outDir": "./lib/esm",
"esModuleInterop": true,
"module": "es2020"
},
"include": ["src/**/*"]
}
1 change: 0 additions & 1 deletion packages/web3-errors/tsconfig.json

This file was deleted.

10 changes: 10 additions & 0 deletions packages/web3-errors/tsconfig.types.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"declarationDir": "./lib/types",
"declaration": true,
"declarationMap": true,
"emitDeclarationOnly": true
},
"include": ["src/**/*"]
}
2 changes: 1 addition & 1 deletion packages/web3-eth-abi/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module.exports = {
extends: '../../.eslintrc.js',
parserOptions: {
project: './tsconfig.json',
project: './tsconfig.esm.json',
tsconfigRootDir: __dirname,
},
};
4 changes: 4 additions & 0 deletions packages/web3-eth-abi/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added

- Added hybrid build (ESM and CJS) of library (#5904)

### Removed

- Removed `formatDecodedObject` function (#5934)
15 changes: 13 additions & 2 deletions packages/web3-eth-abi/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,15 @@
"name": "web3-eth-abi",
"version": "4.0.1-rc.0",
"description": "Web3 module encode and decode EVM in/output.",
"main": "lib/index.js",
"main": "./lib/commonjs/index.js",
"module": "./lib/esm/index.js",
"exports": {
".": {
"types": "./lib/types/index.d.ts",
"import": "./lib/esm/index.js",
"require": "./lib/commonjs/index.js"
}
},
"repository": "https://github.com/ethereum/web3.js/tree/4.x/packages/web3-eth-abi",
"author": "ChainSafe Systems",
"license": "LGPL-3.0",
Expand All @@ -16,7 +24,10 @@
"scripts": {
"clean": "rimraf dist && rimraf lib",
"prebuild": "yarn clean",
"build": "tsc --build",
"build": "yarn build:cjs & yarn build:esm & yarn build:types",
"build:cjs": "tsc --build tsconfig.cjs.json && echo '{\"type\": \"commonjs\"}' > ./lib/commonjs/package.json",
"build:esm": "tsc --build tsconfig.esm.json && echo '{\"type\": \"module\"}' > ./lib/esm/package.json",
"build:types": "tsc --build tsconfig.types.json",
"build:check": "node -e \"require('./lib')\"",
"lint": "eslint --ext .js,.ts .",
"lint:fix": "eslint --fix --ext .js,.ts .",
Expand Down
2 changes: 1 addition & 1 deletion packages/web3-eth-abi/test/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../tsconfig",
"extends": "../tsconfig.cjs.json",
"compilerOptions": {
"declaration": false,
"declarationMap": false
Expand Down
10 changes: 10 additions & 0 deletions packages/web3-eth-abi/tsconfig.cjs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"outDir": "./lib/commonjs",
"esModuleInterop": true,
"declaration": true,
"module": "commonjs"
},
"include": ["src/**/*"]
}
9 changes: 9 additions & 0 deletions packages/web3-eth-abi/tsconfig.esm.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"outDir": "./lib/esm",
"esModuleInterop": true,
"module": "es2020"
},
"include": ["src/**/*"]
}
7 changes: 0 additions & 7 deletions packages/web3-eth-abi/tsconfig.json

This file was deleted.

10 changes: 10 additions & 0 deletions packages/web3-eth-abi/tsconfig.types.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"declarationDir": "./lib/types",
"declaration": true,
"declarationMap": true,
"emitDeclarationOnly": true
},
"include": ["src/**/*"]
}
Loading

0 comments on commit 0781d8a

Please sign in to comment.