diff --git a/packages/core/package.json b/packages/core/package.json index 9f8a39f87c..c343e3c0e6 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -278,6 +278,7 @@ "eslint-plugin-react": "^7.32.2", "eslint-plugin-react-hooks": "^4.6.0", "eslint-plugin-unused-imports": "^2.0.0", + "fork-ts-checker-webpack-plugin": "^7.3.0", "identity-obj-proxy": "^3.0.0", "ignore-loader": "^0.1.2", "include-media": "^1.4.9", diff --git a/packages/core/webpack/common.ts b/packages/core/webpack/common.ts index 6751ad303f..2f5672c94a 100644 --- a/packages/core/webpack/common.ts +++ b/packages/core/webpack/common.ts @@ -5,6 +5,7 @@ import type webpack from "webpack"; import path from "path"; +import ForkTsCheckerPlugin from "fork-ts-checker-webpack-plugin"; import webpackLensMain from "./main"; import { buildDir } from "./vars"; @@ -27,7 +28,9 @@ const webpackLensCommon = (): webpack.Configuration => { optimization: { minimize: false, }, - plugins: [], + plugins: [ + new ForkTsCheckerPlugin({}), + ], }; }; diff --git a/packages/core/webpack/main.ts b/packages/core/webpack/main.ts index 58476c4e68..ea93bcd30d 100755 --- a/packages/core/webpack/main.ts +++ b/packages/core/webpack/main.ts @@ -6,6 +6,7 @@ import path from "path"; import type webpack from "webpack"; import nodeExternals from "webpack-node-externals"; +import ForkTsCheckerPlugin from "fork-ts-checker-webpack-plugin"; import { iconsAndImagesWebpackRules } from "./renderer"; import { DefinePlugin } from "webpack"; import { buildDir, isDevelopment } from "./vars"; @@ -54,8 +55,8 @@ const webpackLensMain = (): webpack.Configuration => { use: { loader: "ts-loader", options: { + transpileOnly: true, compilerOptions: { - declaration: true, sourceMap: false, }, }, @@ -69,6 +70,16 @@ const webpackLensMain = (): webpack.Configuration => { CONTEXT_MATCHER_FOR_NON_FEATURES: `/\\.injectable(\\.${platform})?\\.tsx?$/`, CONTEXT_MATCHER_FOR_FEATURES: `/\\/(main|common)\\/.+\\.injectable(\\.${platform})?\\.tsx?$/`, }), + new ForkTsCheckerPlugin({ + typescript: { + mode: "write-dts", + configOverwrite: { + compilerOptions: { + declaration: true, + }, + }, + }, + }), ], }; }; diff --git a/packages/core/webpack/renderer.ts b/packages/core/webpack/renderer.ts index 50c5023e0a..d5bddf6461 100755 --- a/packages/core/webpack/renderer.ts +++ b/packages/core/webpack/renderer.ts @@ -7,6 +7,7 @@ import path from "path"; import type webpack from "webpack"; import MiniCssExtractPlugin from "mini-css-extract-plugin"; import CircularDependencyPlugin from "circular-dependency-plugin"; +import ForkTsCheckerPlugin from "fork-ts-checker-webpack-plugin"; import type { WebpackPluginInstance } from "webpack"; import { optimize, DefinePlugin } from "webpack"; import nodeExternals from "webpack-node-externals"; @@ -67,6 +68,7 @@ export function webpackLensRenderer(): webpack.Configuration { use: { loader: "ts-loader", options: { + transpileOnly: true, compilerOptions: { declaration: true, sourceMap: false, @@ -85,6 +87,7 @@ export function webpackLensRenderer(): webpack.Configuration { CONTEXT_MATCHER_FOR_NON_FEATURES: `/\\.injectable(\\.${platform})?\\.tsx?$/`, CONTEXT_MATCHER_FOR_FEATURES: `/\\/(renderer|common)\\/.+\\.injectable(\\.${platform})?\\.tsx?$/`, }), + new ForkTsCheckerPlugin({}), new CircularDependencyPlugin({ cwd: __dirname, diff --git a/packages/core/yarn.lock b/packages/core/yarn.lock index 63e901a045..ba95b15db1 100644 --- a/packages/core/yarn.lock +++ b/packages/core/yarn.lock @@ -4496,7 +4496,7 @@ cosmiconfig@^6.0.0: path-type "^4.0.0" yaml "^1.7.2" -cosmiconfig@^7.0.0: +cosmiconfig@^7.0.0, cosmiconfig@^7.0.1: version "7.1.0" resolved "https://registry.yarnpkg.com/cosmiconfig/-/cosmiconfig-7.1.0.tgz#1443b9afa596b670082ea46cbd8f6a62b84635f6" integrity sha512-AdmX6xUzdNASswsFtmwSt7Vj8po9IuqXm0UXz7QKPuEUmPB4XyjGfaAr2PSuELMwkRMVH1EpIkX5bTZGRB3eCA== @@ -6229,6 +6229,24 @@ forever-agent@~0.6.1: resolved "https://registry.yarnpkg.com/forever-agent/-/forever-agent-0.6.1.tgz#fbc71f0c41adeb37f96c577ad1ed42d8fdacca91" integrity sha1-+8cfDEGt6zf5bFd60e1C2P2sypE= +fork-ts-checker-webpack-plugin@^7.3.0: + version "7.3.0" + resolved "https://registry.yarnpkg.com/fork-ts-checker-webpack-plugin/-/fork-ts-checker-webpack-plugin-7.3.0.tgz#a9c984a018493962360d7c7e77a67b44a2d5f3aa" + integrity sha512-IN+XTzusCjR5VgntYFgxbxVx3WraPRnKehBFrf00cMSrtUuW9MsG9dhL6MWpY6MkjC3wVwoujfCDgZZCQwbswA== + dependencies: + "@babel/code-frame" "^7.16.7" + chalk "^4.1.2" + chokidar "^3.5.3" + cosmiconfig "^7.0.1" + deepmerge "^4.2.2" + fs-extra "^10.0.0" + memfs "^3.4.1" + minimatch "^3.0.4" + node-abort-controller "^3.0.1" + schema-utils "^3.1.1" + semver "^7.3.5" + tapable "^2.2.1" + form-data@^2.5.0: version "2.5.1" resolved "https://registry.yarnpkg.com/form-data/-/form-data-2.5.1.tgz#f2cbec57b5e59e23716e128fe44d4e5dd23895f4" @@ -9280,6 +9298,11 @@ node-abi@^3.3.0: dependencies: semver "^7.3.5" +node-abort-controller@^3.0.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/node-abort-controller/-/node-abort-controller-3.1.1.tgz#a94377e964a9a37ac3976d848cb5c765833b8548" + integrity sha512-AGK2yQKIjRuqnc6VkX2Xj5d+QW8xZ87pa1UK6yA6ouUyuxfHuMP6umE5QK7UmTeOAymo+Zx1Fxiuw9rVx8taHQ== + node-addon-api@^1.6.3: version "1.7.2" resolved "https://registry.yarnpkg.com/node-addon-api/-/node-addon-api-1.7.2.tgz#3df30b95720b53c24e59948b49532b662444f54d" @@ -12014,7 +12037,7 @@ tailwindcss@^3.2.4: quick-lru "^5.1.1" resolve "^1.22.1" -tapable@^2.1.1, tapable@^2.2.0: +tapable@^2.1.1, tapable@^2.2.0, tapable@^2.2.1: version "2.2.1" resolved "https://registry.yarnpkg.com/tapable/-/tapable-2.2.1.tgz#1967a73ef4060a82f12ab96af86d52fdb76eeca0" integrity sha512-GNzQvQTOIP6RyTfE2Qxb8ZVlNmw0n88vp1szwWRimP02mnTsx3Wtn5qRdqY9w2XduFNUgvOwhNnQsjwCp+kqaQ==