@@ -62,14 +62,26 @@ module.exports = function(webpackEnv) {
62
62
const isEnvDevelopment = webpackEnv === 'development' ;
63
63
const isEnvProduction = webpackEnv === 'production' ;
64
64
65
- const workspacesMainFields = [ workspacesConfig . packageEntry , 'main' ] ;
65
+ const workspacesMainFields = [
66
+ workspacesConfig . packageEntry ,
67
+ 'browser' ,
68
+ 'module' ,
69
+ 'main' ,
70
+ ] ;
66
71
const mainFields =
67
72
isEnvDevelopment && workspacesConfig . development
68
73
? workspacesMainFields
69
74
: isEnvProduction && workspacesConfig . production
70
75
? workspacesMainFields
71
76
: undefined ;
72
77
78
+ const includePaths =
79
+ isEnvDevelopment && workspacesConfig . development
80
+ ? [ paths . appSrc , ...workspacesConfig . paths ]
81
+ : isEnvProduction && workspacesConfig . production
82
+ ? [ paths . appSrc , ...workspacesConfig . paths ]
83
+ : paths . appSrc ;
84
+
73
85
// Webpack uses `publicPath` to determine where the app is being served from.
74
86
// It requires a trailing slash, or the file assets will get an incorrect path.
75
87
// In development, we always serve from the root. This makes config easier.
@@ -342,11 +354,13 @@ module.exports = function(webpackEnv) {
342
354
loader : require . resolve ( 'eslint-loader' ) ,
343
355
} ,
344
356
] ,
345
- include : isEnvDevelopment && workspacesConfig . development
346
- ? [ paths . appSrc , workspacesConfig . paths ]
347
- : isEnvProduction && workspacesConfig . production
348
- ? [ paths . appSrc , workspacesConfig . paths ]
349
- : paths . appSrc ,
357
+ include : includePaths ,
358
+ // Don't lint typescript files outside the main package because it has problems with some syntax rules, e.g. abstract
359
+ exclude : useTypeScript
360
+ ? file =>
361
+ / \. t s x ? / . test ( path . extname ( file ) ) &&
362
+ ! file . startsWith ( paths . appSrc )
363
+ : undefined ,
350
364
} ,
351
365
{
352
366
// "oneOf" will traverse all following loaders until one will
@@ -368,12 +382,7 @@ module.exports = function(webpackEnv) {
368
382
// The preset includes JSX, Flow, TypeScript, and some ESnext features.
369
383
{
370
384
test : / \. ( j s | m j s | j s x | t s | t s x ) $ / ,
371
- include :
372
- isEnvDevelopment && workspacesConfig . development
373
- ? [ paths . appSrc , workspacesConfig . paths ]
374
- : isEnvProduction && workspacesConfig . production
375
- ? [ paths . appSrc , workspacesConfig . paths ]
376
- : paths . appSrc ,
385
+ include : includePaths ,
377
386
loader : require . resolve ( 'babel-loader' ) ,
378
387
options : {
379
388
customize : require . resolve (
@@ -656,6 +665,10 @@ module.exports = function(webpackEnv) {
656
665
typescript : resolve . sync ( 'typescript' , {
657
666
basedir : paths . appNodeModules ,
658
667
} ) ,
668
+ compilerOptions : {
669
+ skipLibCheck : true ,
670
+ suppressOutputPathCheck : true ,
671
+ } ,
659
672
async : isEnvDevelopment ,
660
673
useTypescriptIncrementalApi : true ,
661
674
checkSyntacticErrors : true ,
@@ -667,7 +680,7 @@ module.exports = function(webpackEnv) {
667
680
'!**/src/setupProxy.*' ,
668
681
'!**/src/setupTests.*' ,
669
682
] ,
670
- watch : paths . appSrc ,
683
+ watch : includePaths ,
671
684
silent : true ,
672
685
// The formatter is invoked directly in WebpackDevServerUtils during development
673
686
formatter : isEnvProduction ? typescriptFormatter : undefined ,
0 commit comments