Skip to content

Commit b607860

Browse files
committed
use tsloader
1 parent 33895ec commit b607860

5 files changed

Lines changed: 248 additions & 155 deletions

File tree

config/webpack.config.dev.js

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ const getCSSModuleLocalIdent = require('react-dev-utils/getCSSModuleLocalIdent')
2121
const getClientEnvironment = require('./env');
2222
const paths = require('./paths');
2323

24-
const HardSourceWebpackPlugin = require('hard-source-webpack-plugin');
25-
const TsCheckerWebpackPlugin = require('ts-checker-webpack-plugin');
24+
// const HardSourceWebpackPlugin = require('hard-source-webpack-plugin');
25+
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
2626
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
2727

2828
// Webpack uses `publicPath` to determine where the app is being served from.
@@ -267,24 +267,18 @@ module.exports = {
267267
},
268268
],
269269
},
270-
271270
// Compile .tsx
272271
{
273-
test: /\.(ts|tsx)$/,
274-
include: paths.appSrc,
275-
use: [
276-
{
277-
loader: require.resolve('awesome-typescript-loader'),
278-
options: {
279-
// disable type checker - we will use it in fork plugin
280-
useCache: true,
281-
reportFiles: [
282-
paths.appSrc + '/**/*.{ts,tsx}'
283-
],
284-
forceIsolatedModules: true
285-
},
286-
},
287-
],
272+
test: /\.tsx?$/,
273+
include: paths.srcPaths,
274+
exclude: [/[/\\\\]node_modules[/\\\\]/],
275+
use: [{
276+
loader: require.resolve('ts-loader'),
277+
options: {
278+
// disable type checker - we will use it in fork plugin
279+
transpileOnly: true
280+
}
281+
}]
288282
},
289283
// "postcss" loader applies autoprefixer to our CSS.
290284
// "css" loader resolves paths in CSS and adds assets as dependencies.
@@ -393,11 +387,11 @@ module.exports = {
393387
// https://github.com/jmblog/how-to-optimize-momentjs-with-webpack
394388
// You can remove this if you don't use Moment.js:
395389
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
396-
new TsCheckerWebpackPlugin({
390+
new ForkTsCheckerWebpackPlugin({
397391
tsconfig: paths.appTsConfig,
398392
tslint: paths.appTsLint,
399393
}),
400-
new HardSourceWebpackPlugin()
394+
// new HardSourceWebpackPlugin()
401395
],
402396
// Some libraries import Node modules but don't use them in the browser.
403397
// Tell Webpack to provide empty mocks for them so importing them works.

config/webpack.config.prod.js

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -292,20 +292,18 @@ module.exports = {
292292
},
293293
],
294294
},
295-
// Compile .tsx?
295+
// Compile .tsx
296296
{
297-
test: /\.(ts|tsx)$/,
298-
include: paths.appSrc,
299-
use: [
300-
{
301-
loader: require.resolve('awesome-typescript-loader'),
302-
options: {
303-
reportFiles: [
304-
paths.appSrc + '/**/*.{ts,tsx}'
305-
],
306-
},
307-
},
308-
],
297+
test: /\.tsx?$/,
298+
include: paths.srcPaths,
299+
exclude: [/[/\\\\]node_modules[/\\\\]/],
300+
use: [{
301+
loader: require.resolve('ts-loader'),
302+
options: {
303+
// enable type checker
304+
transpileOnly: false
305+
}
306+
}]
309307
},
310308
// The notation here is somewhat confusing.
311309
// "postcss" loader applies autoprefixer to our CSS.

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
"eslint-plugin-jsx-a11y": "6.0.3",
4848
"eslint-plugin-react": "7.8.2",
4949
"file-loader": "1.1.11",
50+
"fork-ts-checker-webpack-plugin": "^0.4.2",
5051
"fs-extra": "5.0.0",
5152
"graphql": "0.13.2",
5253
"graphql-tag": "2.9.2",
@@ -72,15 +73,16 @@
7273
"sw-precache-webpack-plugin": "0.11.5",
7374
"thread-loader": "1.1.5",
7475
"ts-checker-webpack-plugin": "^0.3.0",
76+
"ts-loader": "^4.4.1",
7577
"tsconfig-paths-webpack-plugin": "^3.2.0",
7678
"tslint": "^5.10.0",
7779
"tslint-config-prettier": "^1.13.0",
7880
"tslint-react": "^3.6.0",
7981
"typescript": "^2.9.2",
8082
"uglifyjs-webpack-plugin": "1.2.5",
8183
"url-loader": "1.0.1",
82-
"webpack": "4.8.3",
83-
"webpack-dev-server": "3.1.4",
84+
"webpack": "^4.12.0",
85+
"webpack-dev-server": "^3.1.4",
8486
"webpack-manifest-plugin": "2.0.2",
8587
"whatwg-fetch": "2.0.4"
8688
},

scripts/start.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ process.on('unhandledRejection', err => {
2323
require('../config/env');
2424
// @remove-on-eject-begin
2525
// Do the preflight check (only happens before eject).
26-
const verifyPackageTree = require('./utils/verifyPackageTree');
27-
if (process.env.SKIP_PREFLIGHT_CHECK !== 'true') {
28-
verifyPackageTree();
29-
}
26+
// const verifyPackageTree = require('./utils/verifyPackageTree');
27+
// if (process.env.SKIP_PREFLIGHT_CHECK !== 'true') {
28+
// verifyPackageTree();
29+
// }
3030
// @remove-on-eject-end
3131

3232
const chalk = require('chalk');

0 commit comments

Comments
 (0)