Skip to content

Commit

Permalink
fix: require fork-ts-checker-webpack-plugin at runtime
Browse files Browse the repository at this point in the history
It depends on typescript, so if we find tsconfig.js, then only
we `require` it during runtime. If we do a static import, then
since it depends on typescript, it will fail.
  • Loading branch information
swashata committed Oct 29, 2018
1 parent b35d9ac commit 4c00180
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/scripts/src/config/WebpackConfigHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import {
PresetOptions,
} from '@wpackio/babel-preset-base/lib/preset';
import cleanWebpackPlugin from 'clean-webpack-plugin';
import ForkTsCheckerWebpackPlugin from 'fork-ts-checker-webpack-plugin';
import fs from 'fs';
import miniCssExtractPlugin from 'mini-css-extract-plugin';
import path from 'path';
Expand Down Expand Up @@ -265,6 +264,9 @@ export class WebpackConfigHelper {
// Add ts checker plugin if project has tsconfig.json
const tsconfigPath = path.resolve(this.cwd, './tsconfig.json');
if (this.fileExists(tsconfigPath)) {
// dynamic require forktschecker otherwise it will throw error
// tslint:disable-next-line:variable-name
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
plugins.push(
new ForkTsCheckerWebpackPlugin({
tsconfig: tsconfigPath,
Expand Down

0 comments on commit 4c00180

Please sign in to comment.