Skip to content

Commit 1fc6217

Browse files
authored
Add typescript support (web3#3652)
* modernize web3-core * add tsconfig * add tsc to package.json * ignore lib * build works * tests pass * update script * remove old dist * address comments * change main * bump cache * add build step to ci * add pre build step for ci tests * remove comments * update changelog * revert to old dist
1 parent b0b135c commit 1fc6217

File tree

52 files changed

+473
-206
lines changed

Some content is hidden

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

52 files changed

+473
-206
lines changed

.github/workflows/build.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
path: |
2727
node_modules
2828
*/*/node_modules
29-
key: 0-${{ runner.os }}-node12-${{ hashFiles('**/package-lock.json') }}
29+
key: 2-${{ runner.os }}-node12-${{ hashFiles('**/package-lock.json') }}
3030
- run: bash ./scripts/install.sh
3131
if: steps.cache-deps.outputs.cache-hit != 'true'
3232
- run: bash ./scripts/ci.sh
@@ -48,7 +48,7 @@ jobs:
4848
path: |
4949
node_modules
5050
*/*/node_modules
51-
key: 0-${{ runner.os }}-node${{ matrix.node }}-${{ hashFiles('**/package-lock.json') }}
51+
key: 2-${{ runner.os }}-node${{ matrix.node }}-${{ hashFiles('**/package-lock.json') }}
5252
- run: bash ./scripts/install.sh
5353
if: steps.cache-deps.outputs.cache-hit != 'true'
5454
- run: bash ./scripts/ci.sh
@@ -78,7 +78,7 @@ jobs:
7878
path: |
7979
node_modules
8080
*/*/node_modules
81-
key: 0-${{ runner.os }}-node12-${{ hashFiles('**/package-lock.json') }}
81+
key: 2-${{ runner.os }}-node12-${{ hashFiles('**/package-lock.json') }}
8282
- run: bash ./scripts/install.sh
8383
if: steps.cache-deps.outputs.cache-hit != 'true'
8484
- run: bash ./scripts/ci.sh

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@ contracts/
1919
migrations/
2020
truffle-config.js
2121
test/config/ensAddresses.json
22+
*/**/lib

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,12 @@ Released with 1.0.0-beta.37 code base.
270270

271271
### Added
272272

273+
- Support for typescript files (.ts) to be writtern alongside regular .js files (#3652)
274+
273275
### Changed
274276

277+
- `npm run build` now uses TSC to compile (.js allowed) and the build folder is now located under `lib` (#3652)
278+
- Modernized web3-core to use newer es syntax (#3652)
279+
275280
### Fixed
276281

package-lock.json

Lines changed: 153 additions & 118 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@
1717
"scripts": {
1818
"version": "npm run build",
1919
"postinstall": "npm run bootstrap",
20-
"build": "npm run bootstrap && webpack && cp -r ./dist ./packages/web3",
20+
"build": "npm run bootstrap && lerna run tsc && webpack && cp -r ./dist ./packages/web3",
2121
"publish": "lerna publish",
2222
"bootstrap": "lerna bootstrap --hoist",
2323
"lint": "jshint *.js packages",
24-
"test": "mocha --grep E2E --invert; jshint *.js packages",
25-
"test:unit": "nyc --no-clean --silent _mocha -- -R spec --grep E2E --invert --exit",
24+
"test": "mocha -R spec --require ts-node/register --grep E2E --invert",
25+
"test:unit": "nyc --no-clean --silent _mocha -- -R spec --require ts-node/register --grep E2E --invert --exit",
2626
"test:cov": "npm run cov:clean; npm run test:unit; npm run test:e2e:clients; npm run cov:merge_reports",
2727
"dtslint": "lerna run dtslint",
2828
"depcheck": "lerna exec dependency-check -- --missing --verbose .",
@@ -128,6 +128,7 @@
128128
"nyc": "^14.1.1",
129129
"pify": "^4.0.1",
130130
"sandboxed-module": "^2.0.3",
131+
"ts-node": "^8.10.2",
131132
"typescript": "^3.9.5",
132133
"underscore": "1.9.1",
133134
"wait-port": "^0.2.6",

packages/web3-bzz/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@
99
},
1010
"types": "types/index.d.ts",
1111
"scripts": {
12+
"tsc": "tsc -b tsconfig.json",
1213
"dtslint": "dtslint --localTs ../../node_modules/typescript/lib types"
1314
},
14-
"main": "src/index.js",
15+
"main": "lib/index.js",
1516
"dependencies": {
1617
"@types/node": "^12.12.6",
1718
"got": "9.6.0",

packages/web3-bzz/tsconfig.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"extends": "../../tsconfig.json",
3+
"compilerOptions": {
4+
"outDir": "./lib"
5+
},
6+
"include": [
7+
"./src"
8+
]
9+
}

packages/web3-core-helpers/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@
99
},
1010
"types": "types/index.d.ts",
1111
"scripts": {
12+
"tsc": "tsc -b tsconfig.json",
1213
"dtslint": "dtslint --localTs ../../node_modules/typescript/lib types"
1314
},
14-
"main": "src/index.js",
15+
"main": "lib/index.js",
1516
"dependencies": {
1617
"underscore": "1.9.1",
1718
"web3-eth-iban": "1.2.11",
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"extends": "../../tsconfig.json",
3+
"compilerOptions": {
4+
"outDir": "./lib"
5+
},
6+
"include": [
7+
"./src"
8+
]
9+
}

packages/web3-core-method/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@
99
},
1010
"types": "types/index.d.ts",
1111
"scripts": {
12+
"tsc": "tsc -b tsconfig.json",
1213
"dtslint": "dtslint --localTs ../../node_modules/typescript/lib types"
1314
},
14-
"main": "src/index.js",
15+
"main": "lib/index.js",
1516
"dependencies": {
1617
"@ethersproject/transactions": "^5.0.0-beta.135",
1718
"underscore": "1.9.1",

0 commit comments

Comments
 (0)