Replace deprecated awesome-typescript-loader with ts-loader
Replace awesome-typescript-loader
awesome-typescript-loader is no longer maintained and is incompatible with the recent versions of typescript. This commit replaces awesome-typescript-loader with ts-loader in the documentation examples
currently, creating a react project following the documentation yields the following error:
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: awesome-typescript-loader@5.2.1
npm ERR! Found: typescript@5.4.5
npm ERR! node_modules/typescript
npm ERR! dev typescript@"^5.4.5" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer typescript@"^2.7 || ^3" from awesome-typescript-loader@5.2.1
npm ERR! node_modules/awesome-typescript-loader
npm ERR! dev awesome-typescript-loader@"^5.2.1" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: typescript@3.9.10
npm ERR! node_modules/typescript
npm ERR! peer typescript@"^2.7 || ^3" from awesome-typescript-loader@5.2.1
npm ERR! node_modules/awesome-typescript-loader
npm ERR! dev awesome-typescript-loader@"^5.2.1" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR!
npm ERR! For a full report see:
This error is fixed by using ts-loader.
Fix tsconfig.json
the include path given in the example tsconfig.json causes the following error:
> guilebook@0.0.1 build
> webpack --mode production
assets by status 283 bytes [cached] 1 asset
./js/ts/index.tsx 39 bytes [built] [code generated] [2 errors]
ERROR in /home/shriram/Workspace/my-test/pub/tsconfig.json
./js/ts/index.tsx /home/shriram/Workspace/my-test/pub/tsconfig.json
[tsl] ERROR
TS18003: No inputs were found in config file 'tsconfig.json'. Specified 'include' paths were '["./pub/js/ts/**/*"]' and 'exclude' paths were '["node_modules"]'.
ts-loader-default_e3b0c44298fc1c14
ERROR in ./js/ts/index.tsx
Module build failed (from ./node_modules/ts-loader/index.js):
Error: error while parsing tsconfig.json
at Object.loader (/home/shriram/Workspace/my-test/pub/node_modules/ts-loader/dist/index.js:18:18)
webpack 5.91.0 compiled with 2 errors in 392 ms
This is fixed by using the relative path within the pub folder.