Skip to content
This repository has been archived by the owner on Jul 9, 2021. It is now read-only.

Commit

Permalink
feat: Add support for TypeScript project references (#991)
Browse files Browse the repository at this point in the history
* Update all package.json and tsconfig.json

* fix(contracts): Make test/utils/web3_wrapper.ts compatible with project refs

* Fix webpack config for 0x.js

* Fix linter errors by adding rootDir to tsconfig.json as needed

* Add build:ts and watch:ts commands to package.json

* Update sra-spec to work with project references

* Update tsconfig.json with latest new/removed packages

* Add TypeScript as devDependency at root

* Add missing rootDir to forwarder-helper package

* Use a separate tsconfig file for typedoc

* Fix linter errors

* Apply PR feedback (add comments)

* Fix 0x.js tsconfig
  • Loading branch information
albrow committed Aug 29, 2018
1 parent f44644a commit e7d5ceb
Show file tree
Hide file tree
Showing 80 changed files with 276 additions and 182 deletions.
4 changes: 3 additions & 1 deletion package.json
Expand Up @@ -23,10 +23,11 @@
"install:all": "yarn install",
"wsrun": "wsrun",
"lerna": "lerna",
"watch": "wsrun watch_without_deps $PKG --fast-exit -r --stages --done-criteria='complete|successfully'",
"build": "wsrun build $PKG --fast-exit -r --stages",
"build:no_website": "wsrun build $PKG --fast-exit -r --stages --exclude @0xproject/website",
"build:monorepo_scripts": "PKG=@0xproject/monorepo-scripts yarn build",
"build:ts": "tsc -b",
"watch:ts": "tsc -b -w",
"clean": "wsrun clean $PKG --fast-exit -r --parallel",
"remove_node_modules": "lerna clean --yes; rm -rf node_modules",
"rebuild": "run-s clean build",
Expand All @@ -51,6 +52,7 @@
"npm-run-all": "^4.1.2",
"prettier": "^1.11.1",
"source-map-support": "^0.5.6",
"typescript": "3.0.1",
"wsrun": "^2.2.0"
},
"resolutions": {
Expand Down
5 changes: 2 additions & 3 deletions packages/0x.js/package.json
Expand Up @@ -15,7 +15,6 @@
"main": "lib/index.js",
"types": "lib/index.d.ts",
"scripts": {
"watch_without_deps": "tsc -w",
"build": "yarn build:all",
"build:all": "run-p build:umd:prod build:commonjs",
"lint": "tslint --project . --exclude **/src/generated_contract_wrappers/**/*",
Expand All @@ -25,8 +24,8 @@
"coverage:report:lcov": "nyc report --reporter=text-lcov > coverage/lcov.info",
"clean": "shx rm -rf _bundles lib test_temp src/generated_contract_wrappers generated_docs",
"build:umd:prod": "NODE_ENV=production webpack",
"build:commonjs": "tsc",
"docs:json": "typedoc --excludePrivate --excludeExternals --target ES5 --json $JSON_FILE_PATH $PROJECT_FILES"
"build:commonjs": "tsc -b",
"docs:json": "typedoc --excludePrivate --excludeExternals --target ES5 --tsconfig typedoc-tsconfig.json --json $JSON_FILE_PATH $PROJECT_FILES"
},
"config": {
"postpublish": {
Expand Down
5 changes: 3 additions & 2 deletions packages/0x.js/tsconfig.json
@@ -1,7 +1,8 @@
{
"extends": "../../tsconfig",
"compilerOptions": {
"outDir": "lib"
"outDir": "lib",
"rootDir": "src"
},
"include": ["./src/**/*", "./test/**/*"]
"include": ["./src/**/*"]
}
7 changes: 7 additions & 0 deletions packages/0x.js/typedoc-tsconfig.json
@@ -0,0 +1,7 @@
{
"extends": "../../typedoc-tsconfig",
"compilerOptions": {
"outDir": "lib"
},
"include": ["./src/**/*", "./test/**/*"]
}
5 changes: 5 additions & 0 deletions packages/0x.js/webpack.config.js
Expand Up @@ -47,8 +47,13 @@ module.exports = {
use: [
{
loader: 'awesome-typescript-loader',
// tsconfig.json contains some options required for
// project references which do not work with webback.
// We override those options here.
query: {
declaration: false,
declarationMap: false,
composite: false,
},
},
],
Expand Down
3 changes: 1 addition & 2 deletions packages/abi-gen/package.json
Expand Up @@ -8,10 +8,9 @@
"main": "lib/src/index.js",
"types": "lib/src/index.d.ts",
"scripts": {
"watch_without_deps": "tsc -w",
"lint": "tslint --project .",
"clean": "shx rm -rf lib",
"build": "tsc",
"build": "tsc -b",
"test": "yarn run_mocha",
"run_mocha": "mocha --require source-map-support/register --require make-promises-safe lib/test/**/*_test.js --bail --exit",
"test:circleci": "yarn test:coverage",
Expand Down
3 changes: 2 additions & 1 deletion packages/abi-gen/tsconfig.json
@@ -1,7 +1,8 @@
{
"extends": "../../tsconfig",
"compilerOptions": {
"outDir": "lib"
"outDir": "lib",
"rootDir": "."
},
"include": ["./src/**/*", "./test/**/*"]
}
3 changes: 1 addition & 2 deletions packages/assert/package.json
Expand Up @@ -8,8 +8,7 @@
"main": "lib/src/index.js",
"types": "lib/src/index.d.ts",
"scripts": {
"watch_without_deps": "tsc -w",
"build": "tsc",
"build": "tsc -b",
"clean": "shx rm -rf lib test_temp",
"lint": "tslint --project .",
"run_mocha": "mocha --require source-map-support/register --require make-promises-safe lib/test/**/*_test.js --exit",
Expand Down
3 changes: 2 additions & 1 deletion packages/assert/tsconfig.json
@@ -1,7 +1,8 @@
{
"extends": "../../tsconfig",
"compilerOptions": {
"outDir": "lib"
"outDir": "lib",
"rootDir": "."
},
"include": ["./src/**/*", "./test/**/*"]
}
3 changes: 1 addition & 2 deletions packages/base-contract/package.json
Expand Up @@ -8,8 +8,7 @@
"main": "lib/src/index.js",
"types": "lib/src/index.d.ts",
"scripts": {
"watch_without_deps": "tsc -w",
"build": "tsc",
"build": "tsc -b",
"clean": "shx rm -rf lib",
"test": "yarn run_mocha",
"rebuild_and_test": "run-s clean build test",
Expand Down
3 changes: 2 additions & 1 deletion packages/base-contract/tsconfig.json
@@ -1,7 +1,8 @@
{
"extends": "../../tsconfig",
"compilerOptions": {
"outDir": "lib"
"outDir": "lib",
"rootDir": "."
},
"include": ["src/**/*", "test/**/*"]
}
5 changes: 2 additions & 3 deletions packages/connect/package.json
Expand Up @@ -15,8 +15,7 @@
"main": "lib/src/index.js",
"types": "lib/src/index.d.ts",
"scripts": {
"watch_without_deps": "tsc -w",
"build": "tsc",
"build": "tsc -b",
"clean": "shx rm -rf lib test_temp generated_docs",
"copy_test_fixtures": "copyfiles -u 2 './test/fixtures/**/*.json' ./lib/test/fixtures",
"lint": "tslint --project .",
Expand All @@ -26,7 +25,7 @@
"test:coverage": "nyc npm run test --all && yarn coverage:report:lcov",
"coverage:report:lcov": "nyc report --reporter=text-lcov > coverage/lcov.info",
"test:circleci": "yarn test:coverage",
"docs:json": "typedoc --excludePrivate --excludeExternals --target ES5 --json $JSON_FILE_PATH $PROJECT_FILES"
"docs:json": "typedoc --excludePrivate --excludeExternals --target ES5 --tsconfig typedoc-tsconfig.json --json $JSON_FILE_PATH $PROJECT_FILES"
},
"config": {
"postpublish": {
Expand Down
3 changes: 2 additions & 1 deletion packages/connect/tsconfig.json
@@ -1,7 +1,8 @@
{
"extends": "../../tsconfig",
"compilerOptions": {
"outDir": "lib"
"outDir": "lib",
"rootDir": "."
},
"include": ["./src/**/*", "./test/**/*"]
}
7 changes: 7 additions & 0 deletions packages/connect/typedoc-tsconfig.json
@@ -0,0 +1,7 @@
{
"extends": "../../typedoc-tsconfig",
"compilerOptions": {
"outDir": "lib"
},
"include": ["./src/**/*", "./test/**/*"]
}
5 changes: 2 additions & 3 deletions packages/contract-wrappers/package.json
Expand Up @@ -11,8 +11,7 @@
"main": "lib/src/index.js",
"types": "lib/src/index.d.ts",
"scripts": {
"watch_without_deps": "yarn pre_build && tsc -w",
"build": "yarn pre_build && tsc",
"build": "yarn pre_build && tsc -b",
"pre_build": "run-s update_artifacts_v2_beta update_artifacts_v2 generate_contract_wrappers copy_artifacts",
"generate_contract_wrappers": "abi-gen --abis 'src/artifacts/@(Exchange|DummyERC20Token|DummyERC721Token|ZRXToken|ERC20Token|ERC721Token|WETH9|ERC20Proxy|ERC721Proxy|Forwarder|OrderValidator).json' --template ../contract_templates/contract.handlebars --partials '../contract_templates/partials/**/*.handlebars' --output src/contract_wrappers/generated --backend ethers",
"lint": "tslint --project . --exclude **/src/contract_wrappers/**/* --exclude **/lib/**/*",
Expand All @@ -26,7 +25,7 @@
"copy_artifacts": "copyfiles -u 2 './src/artifacts/**/*.json' ./lib/src/artifacts",
"clean": "shx rm -rf _bundles lib test_temp test/artifacts src/contract_wrappers/generated src/artifacts generated_docs",
"run_mocha": "mocha --require source-map-support/register --require make-promises-safe lib/test/**/*_test.js lib/test/global_hooks.js --timeout 10000 --bail --exit",
"docs:json": "typedoc --excludePrivate --excludeExternals --target ES5 --json $JSON_FILE_PATH $PROJECT_FILES"
"docs:json": "typedoc --excludePrivate --excludeExternals --target ES5 --tsconfig typedoc-tsconfig.json --json $JSON_FILE_PATH $PROJECT_FILES"
},
"config": {
"contracts_v2_beta": "AssetProxyOwner Exchange ERC20Proxy ERC20Token ERC721Proxy ERC721Token WETH9 ZRXToken Forwarder OrderValidator",
Expand Down
3 changes: 2 additions & 1 deletion packages/contract-wrappers/tsconfig.json
@@ -1,7 +1,8 @@
{
"extends": "../../tsconfig",
"compilerOptions": {
"outDir": "lib"
"outDir": "lib",
"rootDir": "."
},
"include": ["./src/**/*", "./test/**/*"]
}
7 changes: 7 additions & 0 deletions packages/contract-wrappers/typedoc-tsconfig.json
@@ -0,0 +1,7 @@
{
"extends": "../../typedoc-tsconfig",
"compilerOptions": {
"outDir": "lib"
},
"include": ["./src/**/*", "./test/**/*"]
}
3 changes: 1 addition & 2 deletions packages/contracts/package.json
Expand Up @@ -11,8 +11,7 @@
"test": "test"
},
"scripts": {
"watch_without_deps": "yarn pre_build && tsc -w",
"build": "yarn pre_build && tsc",
"build": "yarn pre_build && tsc -b",
"pre_build": "run-s compile copy_artifacts generate_contract_wrappers",
"copy_artifacts": "copyfiles -u 4 '../migrations/artifacts/2.0.0/**/*' ./lib/artifacts;",
"test": "yarn run_mocha",
Expand Down
4 changes: 2 additions & 2 deletions packages/contracts/test/utils/web3_wrapper.ts
@@ -1,5 +1,5 @@
import { devConstants, env, EnvVars, web3Factory } from '@0xproject/dev-utils';
import { prependSubprovider } from '@0xproject/subproviders';
import { prependSubprovider, Web3ProviderEngine } from '@0xproject/subproviders';
import { logUtils } from '@0xproject/utils';
import { Web3Wrapper } from '@0xproject/web3-wrapper';
import * as _ from 'lodash';
Expand Down Expand Up @@ -47,7 +47,7 @@ const ganacheConfigs = {
};
const providerConfigs = testProvider === ProviderType.Ganache ? ganacheConfigs : gethConfigs;

export const provider = web3Factory.getRpcProvider(providerConfigs);
export const provider: Web3ProviderEngine = web3Factory.getRpcProvider(providerConfigs);
const isCoverageEnabled = env.parseBoolean(EnvVars.SolidityCoverage);
const isProfilerEnabled = env.parseBoolean(EnvVars.SolidityProfiler);
const isRevertTraceEnabled = env.parseBoolean(EnvVars.SolidityRevertTrace);
Expand Down
6 changes: 2 additions & 4 deletions packages/contracts/tsconfig.json
Expand Up @@ -2,13 +2,11 @@
"extends": "../../tsconfig",
"compilerOptions": {
"outDir": "lib",
"baseUrl": ".",
"declaration": false,
"allowJs": true
"rootDir": "."
},
"include": [
"./globals.d.ts",
"./contract_wrappers",
"./generated_contract_wrappers",
"./src/**/*",
"./utils/**/*",
"./test/**/*",
Expand Down
3 changes: 1 addition & 2 deletions packages/dev-utils/package.json
Expand Up @@ -8,8 +8,7 @@
"main": "lib/src/index.js",
"types": "lib/src/index.d.ts",
"scripts": {
"watch_without_deps": "tsc -w",
"build": "tsc",
"build": "tsc -b",
"test": "yarn run_mocha",
"rebuild_and_test": "run-s clean build test",
"test:circleci": "yarn test:coverage",
Expand Down
3 changes: 2 additions & 1 deletion packages/dev-utils/tsconfig.json
@@ -1,7 +1,8 @@
{
"extends": "../../tsconfig",
"compilerOptions": {
"outDir": "lib"
"outDir": "lib",
"rootDir": "."
},
"include": ["./src/**/*", "./test/**/*"]
}
5 changes: 2 additions & 3 deletions packages/ethereum-types/package.json
Expand Up @@ -8,11 +8,10 @@
"main": "lib/index.js",
"types": "lib/index.d.ts",
"scripts": {
"watch_without_deps": "tsc -w",
"build": "tsc",
"build": "tsc -b",
"clean": "shx rm -rf lib generated_docs",
"lint": "tslint --project .",
"docs:json": "typedoc --excludePrivate --excludeExternals --target ES5 --json $JSON_FILE_PATH $PROJECT_FILES"
"docs:json": "typedoc --excludePrivate --excludeExternals --target ES5 --tsconfig typedoc-tsconfig.json --json $JSON_FILE_PATH $PROJECT_FILES"
},
"config": {
"postpublish": {
Expand Down
3 changes: 2 additions & 1 deletion packages/ethereum-types/tsconfig.json
Expand Up @@ -2,7 +2,8 @@
"extends": "../../tsconfig",
"compilerOptions": {
"typeRoots": ["../../node_modules/@types"],
"outDir": "lib"
"outDir": "lib",
"rootDir": "src"
},
"include": ["src/**/*"]
}
8 changes: 8 additions & 0 deletions packages/ethereum-types/typedoc-tsconfig.json
@@ -0,0 +1,8 @@
{
"extends": "../../typedoc-tsconfig",
"compilerOptions": {
"typeRoots": ["../../node_modules/@types"],
"outDir": "lib"
},
"include": ["src/**/*"]
}
3 changes: 1 addition & 2 deletions packages/fill-scenarios/package.json
Expand Up @@ -5,8 +5,7 @@
"main": "lib/index.js",
"types": "lib/index.d.ts",
"scripts": {
"watch_without_deps": "yarn pre_build && tsc -w",
"build": "yarn pre_build && tsc",
"build": "yarn pre_build && tsc -b",
"pre_build": "run-s update_artifacts generate_contract_wrappers",
"update_artifacts": "for i in ${npm_package_config_contracts}; do copyfiles -u 4 ../migrations/artifacts/2.0.0-beta-testnet/$i.json lib/artifacts; done;",
"generate_contract_wrappers": "abi-gen --abis 'lib/artifacts/@(Exchange|DummyERC20Token|DummyERC721Token).json' --template ../contract_templates/contract.handlebars --partials '../contract_templates/partials/**/*.handlebars' --output src/generated_contract_wrappers --backend ethers",
Expand Down
3 changes: 2 additions & 1 deletion packages/fill-scenarios/tsconfig.json
@@ -1,7 +1,8 @@
{
"extends": "../../tsconfig",
"compilerOptions": {
"outDir": "lib"
"outDir": "lib",
"rootDir": "src"
},
"include": ["src/**/*"]
}
4 changes: 2 additions & 2 deletions packages/forwarder-helper/package.json
Expand Up @@ -20,7 +20,7 @@
"build": "tsc && copyfiles -u 3 './lib/src/monorepo_scripts/**/*' ./scripts",
"manual:postpublish": "yarn build; node ./scripts/postpublish.js",
"docs:stage": "node scripts/stage_docs.js",
"docs:json": "typedoc --excludePrivate --excludeExternals --target ES5 --json $JSON_FILE_PATH $PROJECT_FILES",
"docs:json": "typedoc --excludePrivate --excludeExternals --target ES5 --tsconfig typedoc-tsconfig.json --json $JSON_FILE_PATH $PROJECT_FILES",
"upload_docs_json": "aws s3 cp generated_docs/index.json $S3_URL --profile 0xproject --grants read=uri=http://acs.amazonaws.com/groups/global/AllUsers --content-type application/json"
},
"config": {
Expand Down Expand Up @@ -63,7 +63,7 @@
"nyc": "^11.0.1",
"shx": "^0.2.2",
"tslint": "5.11.0",
"typedoc": "0xProject/typedoc",
"typedoc": "0.12.0",
"typescript": "3.0.1"
},
"publishConfig": {
Expand Down
3 changes: 2 additions & 1 deletion packages/forwarder-helper/tsconfig.json
@@ -1,7 +1,8 @@
{
"extends": "../../tsconfig",
"compilerOptions": {
"outDir": "lib"
"outDir": "lib",
"rootDir": "."
},
"include": ["./src/**/*", "./test/**/*"]
}
7 changes: 7 additions & 0 deletions packages/forwarder-helper/typedoc-tsconfig.json
@@ -0,0 +1,7 @@
{
"extends": "../../typedoc-tsconfig",
"compilerOptions": {
"outDir": "lib"
},
"include": ["./src/**/*", "./test/**/*"]
}
5 changes: 2 additions & 3 deletions packages/json-schemas/package.json
Expand Up @@ -8,7 +8,7 @@
"main": "lib/src/index.js",
"types": "lib/src/index.d.ts",
"scripts": {
"watch_without_deps": "tsc -w",
"build": "tsc -b",
"lint": "tslint --project .",
"test": "yarn run_mocha",
"rebuild_and_test": "run-s clean build test",
Expand All @@ -17,8 +17,7 @@
"test:circleci": "yarn test:coverage",
"run_mocha": "mocha --require source-map-support/register --require make-promises-safe lib/test/**/*_test.js --exit",
"clean": "shx rm -rf lib test_temp generated_docs",
"build": "tsc",
"docs:json": "typedoc --excludePrivate --excludeExternals --target ES5 --json $JSON_FILE_PATH $PROJECT_FILES"
"docs:json": "typedoc --excludePrivate --excludeExternals --target ES5 --tsconfig typedoc-tsconfig.json --json $JSON_FILE_PATH $PROJECT_FILES"
},
"config": {
"postpublish": {
Expand Down
5 changes: 3 additions & 2 deletions packages/json-schemas/tsconfig.json
@@ -1,7 +1,8 @@
{
"extends": "../../tsconfig",
"compilerOptions": {
"outDir": "lib"
"outDir": "lib",
"rootDir": "."
},
"include": ["./src/**/*", "./test/**/*"]
"include": ["./src/**/*", "./test/**/*", "./schemas/**/*"]
}
7 changes: 7 additions & 0 deletions packages/json-schemas/typedoc-tsconfig.json
@@ -0,0 +1,7 @@
{
"extends": "../../typedoc-tsconfig",
"compilerOptions": {
"outDir": "lib"
},
"include": ["./src/**/*", "./test/**/*"]
}

0 comments on commit e7d5ceb

Please sign in to comment.