Skip to content

Commit

Permalink
fix: split tsconfig to reduce package size (Uniswap#85)
Browse files Browse the repository at this point in the history
* fix: import types explicitly

* fix: split tsconfigs for package sizing

* Fix code style issues with Prettier

Co-authored-by: Lint Action <[email protected]>
  • Loading branch information
zzmp and lint-action authored Mar 29, 2022
1 parent 1dc4f12 commit 3ebf637
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 21 deletions.
14 changes: 5 additions & 9 deletions bin/cli
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
#!/usr/bin/env node

const fs = require("fs");
const path = require("path");
const project = path.join(__dirname, "../tsconfig.json");
const dev = fs.existsSync(project);
const project = path.join(__dirname, "../tsconfig.oclif.json");

if (dev) {
require("ts-node").register({
project,
compilerOptions: { preserveSymlinks: true },
});
}
require("ts-node").register({
project,
compilerOptions: { preserveSymlinks: true },
});

require('@oclif/command').run()
.catch(require('@oclif/errors/handle'))
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@
"typescript": "^4.2.2"
},
"files": [
"build/main",
"build/module",
"build/main/src",
"build/module/src",
"!**/*.spec.*",
"!**/*.json",
"CHANGELOG.md",
Expand Down
2 changes: 1 addition & 1 deletion src/providers/swap-router-provider.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ApprovalTypes } from '@uniswap/router-sdk';
import { Currency, CurrencyAmount } from '@uniswap/sdk-core';
import { SwapRouter02__factory } from '../types/other';
import { SwapRouter02__factory } from '../types/other/factories/SwapRouter02__factory';
import { log } from '../util';
import { IMulticallProvider } from './multicall-provider';

Expand Down
2 changes: 1 addition & 1 deletion src/providers/token-provider.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Token } from '@uniswap/sdk-core';
import _ from 'lodash';
import { IERC20Metadata__factory } from '../types/v3';
import { IERC20Metadata__factory } from '../types/v3/factories/IERC20Metadata__factory';
import { ChainId, log } from '../util';
import { IMulticallProvider } from './multicall-provider';
import { ProviderConfig } from './provider';
Expand Down
2 changes: 1 addition & 1 deletion src/providers/v2/pool-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Token } from '@uniswap/sdk-core';
import { Pair } from '@uniswap/v2-sdk';
import retry, { Options as RetryOptions } from 'async-retry';
import _ from 'lodash';
import { IUniswapV2Pair__factory } from '../../types/v2';
import { IUniswapV2Pair__factory } from '../../types/v2/factories/IUniswapV2Pair__factory';
import { ChainId, CurrencyAmount } from '../../util';
import { log } from '../../util/log';
import { poolToString } from '../../util/routes';
Expand Down
2 changes: 1 addition & 1 deletion src/providers/v3/pool-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Token } from '@uniswap/sdk-core';
import { computePoolAddress, FeeAmount, Pool } from '@uniswap/v3-sdk';
import retry, { Options as RetryOptions } from 'async-retry';
import _ from 'lodash';
import { IUniswapV3PoolState__factory } from '../../types/v3';
import { IUniswapV3PoolState__factory } from '../../types/v3/factories/IUniswapV3PoolState__factory';
import { ChainId } from '../../util';
import { V3_CORE_FACTORY_ADDRESS } from '../../util/addresses';
import { log } from '../../util/log';
Expand Down
6 changes: 2 additions & 4 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,8 @@
// "emitDecoratorMetadata": true /* Enables experimental support for emitting type metadata for decorators. */,

"lib": ["es2017", "dom"],
"types": ["node", "jest"],
"typeRoots": ["node_modules/@types", "src/types"]
"types": ["node", "jest"]
},
"include": ["src/**/*.ts", "cli/**/*.ts"],
"exclude": ["node_modules/**"],
"include": ["src/index.ts"],
"compileOnSave": false
}
3 changes: 1 addition & 2 deletions tsconfig.module.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@
"target": "es2018",
"outDir": "build/module",
"module": "esnext"
},
"exclude": ["node_modules/**"]
}
}
4 changes: 4 additions & 0 deletions tsconfig.oclif.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "./tsconfig",
"include": ["cli/**/*.ts"]
}

0 comments on commit 3ebf637

Please sign in to comment.