blomqma / next-rest-framework

Type-safe, self-documenting APIs for Next.js
https://next-rest-framework.vercel.app
Other
134 stars 17 forks source link

Feature Request: Allow esbuild config adjustments #128

Closed joshdavenport closed 6 months ago

joshdavenport commented 6 months ago

Am currently using Lucia and as a result, during the build, esbuild complains about @node-rs/bcrypt and @node-rs/argon2.

Screenshot 2024-02-19 at 18 03 56

Definitely not a problem inherent to this library, however I believe I could easily resolve by marking them as external in the esbuild build arguments, but there's no way to do so. That's only based on initial research though, not 100% sure what I need to add. For my purposes I'm likely going to work out the needed change and patch but figured maybe this is a scenario somebody else could encounter.

If this was to be a thing, not sure if this would be best placed as an argument to generate (something like --esbuild-config) or as an argument to docsApiRoute etc. Naturally opening this up means the end user could seriously break stuff, but as long as it came with relevant warnings in the docs then it'd allow workarounds when needed.

blomqma commented 6 months ago

I believe this could be solved by using the ESBuild packages option which excludes all dependencies of an ESBuild entry point from the bundle. Those dependencies are also not needed by Next REST Framework as it only analyses it's own modules usages in the entry points when running the CLI commands.

blomqma commented 6 months ago

I believe this could be solved by using the ESBuild packages option which excludes all dependencies of an ESBuild entry point from the bundle. Those dependencies are also not needed by Next REST Framework as it only analyses it's own modules usages in the entry points when running the CLI commands.

@joshdavenport I have now created an experimental release v5.1.4-beta.1 that introduces this ESBuild option for a potential fix, please let me know if upgrading to this version doesn't address your issue.

joshdavenport commented 4 months ago

Hey @blomqma, just returned to the project I was working on last month when I reported this. Thanks for looking into it in Feb, really appreciated.

The packages option introduced in v5.1.4-beta.1 does look to have worked but it's later removed, as it appears other reported issues. Such is life, some codebases need it, some actively don't!

At the moment I'm relying on patches where I'm actually rather patching in an external value rather than setting packages to true. Would a safer route of allowing extensibility on only some esbuild config properties rather than allowing full config extensibility be something you're open to?