When using versions and letting npm install dedupe the packages, npm
audit does not work and it exits with a cryptic error:
The server said: Invalid package tree, run npm install to rebuild your package-lock.json
package.jsons are changed because dependencies are now sorted
tsconfig.jsons are changed because all referenced monorepo packages will
be added as project references
tsconfig.esm.jsons are changed because syncEsmConfig was run
It has different type definitions for some methods used in express and
TypeScript build fails because of it.
The solution is to use @types/express-serve-static-core instead.
TypeScript compiler needs to be configured to output ES6 module by
setting --module es6 or the equivalent tsconfig.json compilerOptions
parameter.
Since tsc --build does not accept compiler options flags, we need to
duplicate some of the configuration:
- specify separate output folder for ES6 module files (new
tsconfig.esm.json file)
- add "module" field for ES6 module (esm) output files to package.json
Hence, a script `scripts/sync-esm-config.js` was added to automate this
process.