Typescript refactor broke the dist
oliverjam opened this issue · comments
Our pipeline just caught a regression in the latest minor version. We're getting koaSwagger is not a function
whenever we try to initialise the middleware. I've reproduced the issue on Glitch here by installing the latest version and pasting the instructions from the Readme. If you run the server you can see the koaSwagger is not a function
errors.
It looks like there are 2 separate issues:
- The new TS-built version of
lib/index.js
exports the mainkoaSwagger
middleware withexports.default
instead ofmodule.exports
. This means ourconst koaSwagger = require('koa2-swagger-ui')
now gives us an object like this instead of the function we want:{ default: [Function: koaSwagger] }
- If we patch the export to fix this we then get an error because the middleware cannot find
index.hbs
. It looks like this is because Typescript is only copying over.ts
files in the build step. I pulled this repo and built locally and this is what mydist/
directory looks like compared tolib/
:
.
├── dist
│ ├── index.d.ts
│ ├── index.js
│ └── index.js.map
├── lib
│ ├── favicon-16x16.png
│ ├── favicon-32x32.png
│ ├── index.hbs
│ └── index.ts
I don't have any TS experience, but my brief investigation suggests that TS only supports copying across .ts
, .js
and .jsx
files, so the build process might need to include some other step for copying the other files.
Oh right
🎉 This issue has been resolved in version 2.11.1 🎉
The release is available on:
Your semantic-release bot 📦🚀