Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Swagger API documentation is broken in esbuild bundle #2915

Closed
MatsG23 opened this issue Feb 13, 2023 · 3 comments
Closed

Swagger API documentation is broken in esbuild bundle #2915

MatsG23 opened this issue Feb 13, 2023 · 3 comments

Comments

@MatsG23
Copy link

MatsG23 commented Feb 13, 2023

When I use Fastify in combination with Swagger, the API documentation can not be accessed when running the bundle file by esbuild.

When I run the bundle file, I can see this error in the console:

"root" path "[path to one level above the project folder]/static" must exist

Trying to access the API documentation at http://localhost:3000/documentation then fails with a 404 HTTP error. The documentation thing when I run the unbundled code project.
My guess is that the code in the bundle somehow infers with the @fastify/swagger dynamic documentation generation so that the output path for the Swagger documentation HTML page is incorrect.

You can easily reproduce the issue in this project (further instructions given): https://github.com/MatsG23/esbuild-issue

@evanw
Copy link
Owner

evanw commented Feb 13, 2023

Here's what the first page of esbuild's documentation says about bundling for node:

You also may not want to bundle your dependencies with esbuild. There are many node-specific features that esbuild doesn't support while bundling such as __dirname, import.meta.url, fs.readFileSync, and *.node native binary modules. You can exclude all of your dependencies from the bundle by setting packages to external:

esbuild app.jsx --bundle --platform=node --packages=external

I'm closing this issue because esbuild is already working as expected. The answer to your question is already in the documentation.

@evanw evanw closed this as not planned Won't fix, can't repro, duplicate, stale Feb 13, 2023
@MatsG23
Copy link
Author

MatsG23 commented Feb 14, 2023

Is it planned to add support for these node-specific features in the future?

@evanw
Copy link
Owner

evanw commented Feb 14, 2023

No, I don’t plan on doing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants