Closed SeanReece closed 5 months ago
I think we can safely remove the map files. Would you like to send a PR?
@mcollina I would love to! Just wanted to confirm first.
I am not a frontend dev, but for some reason when opening developer tools in chrome it loads the map files. As I am not a frontend dev, I never invested time to understand why it does this. Maybe some frontend DX debugging feature.
@Uzlopak If you look at the bottom of the source files (swagger-ui-bundle.js for example), you'll see a comment that tells chrome where to find the source map //# sourceMappingURL=swagger-ui-bundle.js.map
. Testing this in chrome it gives me this error only when trying to view the source from "Sources" tab. I don't see any 404
s or console errors. For me, it doesn't seem to eagerly try to load them (at least I don't see anything from the network tab)
It doesn't make much sense to me for swagger-ui-dist to provide source files in the first place 🤔 If I wanted to debug swagger-ui I think I would pull the swagger-ui repo and run it from there. 😄
In case we should remove those statements as well.
@mcollina
Is there a reason to vendorize swagger-ui?
We need to process it https://github.com/fastify/fastify-swagger-ui/blob/master/scripts/prepare-swagger-ui.js as well as it used to break between versions, so it would have to be pinned.
I think the only reason we are vendoring it, is because we could be run in the possbility that swagger-ui is not installed on node_modules root?!
@SeanReece
What i like about this issue is, that even my comment, which was just about a small sideeffect of loading map files, got the necessary attention.
This is the spirit of OSS.
Thank you @SeanReece
Prerequisites
Fastify version
4.26.0
Plugin version
2.1.0
Node.js version
20
Operating system
macOS
Operating system version (i.e. 20.04, 11.3, 10)
14.2
Description
It appears as though the
@fastify/swagger-ui
package is quite large. ~2x our next largest package.Looks like this is because the swagger source map files are shipped with the package.
~2.8MB
in source maps.Is it necessary to include source maps in the published package?
This might not seem like a big issue for server side dependencies, but this installing larger packages does increase build times and deploy times, if only slightly.
Of course using something like
clean-modules
does remove.map
files but that doesn't change the fact thatnpm install
still has to pull the.map
files first.Steps to Reproduce
> npm install @fastify/swagger-ui
> ls -lhS ./node_modules/@fastify/swagger-ui/static
Expected Behavior
No response