Repository created to address fastify/fastify#2404.
cd csjorcd esmnpm inpm start- Test csj folder build using http://127.0.0.1:8000, and http://127.0.0.1:9000 for the esm folder.
- I have created two folders to highlight how TypeScript behaves when
esModuleInteropis either true or false. - I locked fastify and plugin versions to versions that match the problem being discussed in afore-mentioned GitHub issue.
- For csj folder I copied the types for all 4 plugins used into the typings folder and ensured the default export is done using the
export =form becauseexport defaultdoes not work when"esModuleInterop": false.- For
fastify-cookieI also modified the types to move the named exports into a declared namespace (declare namespace fastifyCookie {...}). - For
fastify-sessionI also had to modify the types (copied from here) because installed types are not compatible with fastify v3. - For
fastify-websocketI copied the types from this pull request: fastify/fastify-websocket#73
- For
- For the esm folder I used the official types because they use the
export defaultform which works with"esModuleInterop": true.
IMPORTANT to note that the fastify-session import in the esm folder uses the same types from the csj folder (see paths property in ./esm/tsconfig.json). The point of this is to show that export = works regardless if esModuleInterop is true or false, whilst export default works on when esModuleInterop is true.