Open cschuet opened 11 months ago
I've been working on this in a branch: https://github.com/bazelbuild/examples/compare/nextjs_standalone
Some observations:
.next/standalone
output directory. patch_node_fs = False
would stop that happening, but causes a different error, it appears in that branchworkaround.js
which tries to do that by hooking process.on('exit', ...)
- however it's getting run many times, and seems to run too early, as webpack then errors that it can't find node_modules entries--sandbox_debug
(and possibly --noincompatible_sandbox_hermetic_tmp
) cause the output to be better-formed such that I was able to get the build action to succeed, and even run node server.js
in the resulting output treeSorry I ran out of time to work on this, I had a short-term funding source for 30min of hand-on-help but we only scheduled two of those.
@gregmagolan has a solution for this now.
We were able to get next start
to work without needed standalone mode.
Would be good to get a proper example landed here in the future but for now here is a link to a delta with some comments on the changes: https://github.com/be9/bazelbuild-examples/pull/2/files
Since the example is bzlmod only we should probably fix the bzlmod toolchain issue first: https://github.com/aspect-build/rules_js/issues/1530
Thanks for putting together the Bazel Next.js example. Next.js support with Bazel is something I have been hoping for for a while.
I haven't found an easy way to deploy the generated artifacts on Vercel though, so I have been exploring open-next as an open-source alternative. Open-next requires building the next.js app though in "standalone" mode as far as I understand and that I have not been able to get to work with Bazel.
I updated the
next.config.js
toHowever when running
bazel build //next.js:next
the build fails withCan someone point me in the right direction here?
Has anyone found an alternative way to deploy the bazel generated artifacts to either Vecel, AWS or GCP?
Thanks, Cheers