diff --git a/package.json b/package.json index 51b21583ab1..c3ad4266c39 100644 --- a/package.json +++ b/package.json @@ -77,7 +77,9 @@ "prettier-plugin-organize-imports": "^3.2.3", "stylelint": "^14.14.1", "stylelint-config-prettier": "^9.0.4", - "stylelint-config-standard": "^29.0.0" + "stylelint-config-standard": "^29.0.0", + "tsconfig-paths": "^4.2.0", + "tsconfig-paths-webpack-plugin": "^4.1.0" }, "resolutions": { "quill": "^1.3.6", diff --git a/packages/commonwealth/webpack/webpack.base.config.js b/packages/commonwealth/webpack/webpack.base.config.js index 17112992ecf..92822c20bb4 100644 --- a/packages/commonwealth/webpack/webpack.base.config.js +++ b/packages/commonwealth/webpack/webpack.base.config.js @@ -2,6 +2,7 @@ const path = require('path'); const webpack = require('webpack'); const HtmlWebpackPlugin = require('html-webpack-plugin'); const HtmlWebpackInjectAttributesPlugin = require('html-webpack-inject-attributes-plugin'); +const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin'); require('dotenv').config(); @@ -150,6 +151,7 @@ module.exports = { }, }, resolve: { + plugins: [new TsconfigPathsPlugin({})], extensions: ['.ts', '.tsx', '.mjs', '.js', '.jsx', '.svg'], modules: [ '../client/scripts', @@ -158,14 +160,6 @@ module.exports = { 'node_modules', // local node modules '../node_modules', // global node modules ], - alias: { - 'common-common': path.resolve(__dirname, '../../common-common'), - 'chain-events': path.resolve(__dirname, '../../chain-events'), - 'token-balance-cache': path.resolve( - __dirname, - '../../token-balance-cache', - ), - }, fallback: { fs: false, net: false, @@ -184,13 +178,7 @@ module.exports = { { // ignore ".spec.ts" test files in build test: /^(?!.*\.spec\.ts$).*(?:\.ts)$/, - include: [ - path.resolve(__dirname, '../client'), - path.resolve(__dirname, '../shared'), - path.resolve(__dirname, '../../common-common'), - path.resolve(__dirname, '../../chain-events'), - path.resolve(__dirname, '../../token-balance-cache'), - ], + loader: 'esbuild-loader', options: { loader: 'ts', diff --git a/tsconfig.json b/tsconfig.json index 383a67a75e3..c1d875cdb6c 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -20,5 +20,8 @@ "discord-bot": ["./packages/discord-bot"], "discord-bot/*": ["./packages/discord-bot/*"] } + }, + "ts-node": { + "require": ["tsconfig-paths/register"] } } diff --git a/yarn.lock b/yarn.lock index cdb7dc719c2..25b46c2c1b5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -23616,6 +23616,15 @@ tsc-alias@^1.7.0: normalize-path "^3.0.0" plimit-lit "^1.2.6" +tsconfig-paths-webpack-plugin@^4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/tsconfig-paths-webpack-plugin/-/tsconfig-paths-webpack-plugin-4.1.0.tgz#3c6892c5e7319c146eee1e7302ed9e6f2be4f763" + integrity sha512-xWFISjviPydmtmgeUAuXp4N1fky+VCtfhOkDUFIv5ea7p4wuTomI4QTrXvFBX2S4jZsmyTSrStQl+E+4w+RzxA== + dependencies: + chalk "^4.1.0" + enhanced-resolve "^5.7.0" + tsconfig-paths "^4.1.2" + tsconfig-paths@^3.5.0: version "3.9.0" resolved "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.9.0.tgz" @@ -23626,7 +23635,7 @@ tsconfig-paths@^3.5.0: minimist "^1.2.0" strip-bom "^3.0.0" -tsconfig-paths@^4.2.0: +tsconfig-paths@^4.1.2, tsconfig-paths@^4.2.0: version "4.2.0" resolved "https://registry.yarnpkg.com/tsconfig-paths/-/tsconfig-paths-4.2.0.tgz#ef78e19039133446d244beac0fd6a1632e2d107c" integrity sha512-NoZ4roiN7LnbKn9QqE1amc9DJfzvZXxF4xDavcOWt1BPkdx+m+0gJuPM+S0vCe7zTJMYUP0R8pO2XMr+Y8oLIg==