Skip to content

swagger-ui-dist takes an obnoxiously long time to require() #4502

Open
@jwalton

Description

@jwalton
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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions