Ensure webpack does not try to transpile server files. Fixes #1016
This MR provides a
tsconfig.json file for the client.
What are the problems ?
- The way
ts-loaderis currently configured, makes it impossible to transpile
client/, because the loader implicitly uses the
tsconfig.jsonat the root of the project, which excludes the
client/directory, and includes
server/(this is the cause of #1016 (closed)).
How to fix : create a proper tsconfig.json file for the client.
- The full transpiling of the server/shared directories is done for each TS file in the
shareddirectory (this would be the same if the client directory would be in the scope of the transpiler.
How to fix : ts-loader has an option to transpile only the files to be added to the bundle:
onlyCompileBundledFiles(see : https://github.com/TypeStrong/ts-loader#onlycompilebundledfiles). This could be useful.
- If we activate
checkJsoption, the transpiler also checks
node_modulesfiles: https://github.com/TypeStrong/ts-loader/issues/702 (proposed fix does not work) How to fix : 2 options (they can be combined).
- disable checkJs option in ts-loader config (in webpack.config.js), to override client
onlyCompileBundledFiles, so only the ts files are checked
- Create a
tsconfig.jsonfor the client which could be use directly by
checkJs: true). When used with
tsc, this will check the code, including the js.
- Add a yarn command to trigger the check of the client including the js, but not generate the JS code.
- In the
webpack.config.js, declare the new
tsconfig.jsonis the configFile to be used. Ask
ts-loaderto only compile the files which match the rules (and not the full project each time), thanks to
On master :
[tonio@zenbook kresus]$ time ./node_modules/.bin/webpack real 0m17,938s user 0m32,150s sys 0m0,816s
[tonio@zenbook kresus]$ time ./node_modules/.bin/webpack real 0m14,007s user 0m25,507s sys 0m0,726s