fork-ts-checker-webpack-plugin (Issue #561)
fork-ts-checker-webpack-plugin
is not referencing module declarations as specified in tsconfig.json > compilerOptions.typeRoots
.
npm install
npm run build:tsc
- Observe no build error
npm run build:webpack
- Observe build error:
Hash: 18f26cef5e5db950fb3c
Version: webpack 4.41.2
Time: 1962ms
Built at: 03/11/2021 9:49:16 AM
2 assets
Entrypoint index = index.js
[1] ./src/ts/Acme.png 61 bytes {0} [built]
[2] ./src/ts/index.tsx 189 bytes {0} [built]
+ 3 hidden modules
ERROR in src/ts/index.tsx:3:22
TS2307: Cannot find module './Acme.png' or its corresponding type declarations.
1 | import React from 'react';
2 |
> 3 | import AcmeLogo from './Acme.png';
| ^^^^^^^^^^^^
4 |
5 | const IndexComponent: React.FC = () => {
6 | return <img src={AcmeLogo}/>;
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! [email protected] build: `webpack --color --env production`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the [email protected] build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
- Update webpack.config.js to add the following to the
configOverwrite.include
array passed to theForkTsCheckerWebpackPlugin
plugin in webpack.config.js:
'./src/types/**/*.ts'
- Re-run
npm run build:webpack
- Observe no build error