swagger-api / swagger-api/swagger-ui
swagger-ui-dist takes an obnoxiously long time to `require()`
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 29k
- Forks
- 9.3k
- Avg merge
- 2d 23h
- Merged PRs (30d)
- 25
Description
| Q | A |
|---|---|
| Bug or feature request? | bug |
| Which Swagger/OpenAPI version? | any |
| Which Swagger-UI version? | 3.14.0 |
| How did you install Swagger-UI? | npm |
| Which browser & version? | n/a |
| Which operating system? | OS/X |
Expected Behavior
'swagger-ui-dist' is a package that exports a single function which gives you the name of a directory that you can serve static content from, so I'd expect require('swagger-ui-dist') to be blindingly fast.
For example:
$ time node -e 'require("path"); console.log(path.resolve(__dirname, "."))'
real 0m0.156s
user 0m0.095s
sys 0m0.052s
0.15 second, and that includes a console.log(), which is slow.
Current Behavior
$ time node -e 'require("swagger-ui-dist")'
real 0m1.439s
user 0m1.020s
sys 0m0.221s
1.4 seconds!
Context
This slows down startup of every app that users swagger-ui-dist.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue identifies swagger-ui-dist and its npm require() path, but no source file or test. Start by profiling package startup against the reported Node command and inspect the package entry point. Done means require("swagger-ui-dist") completes substantially faster without changing the package's exported behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- performance, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100