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
esbuild fails on Generating static pages
step in serverless Next.js applications
#14
Comments
I had issues with Next.JS / Webpack breaking You can set I use this in my Next.JS site: if(process.platform === "win32"){
process.env.ESBUILD_BINARY_PATH = path.join(process.cwd(), 'node_modules', 'esbuild', 'esbuild.exe')
}else{
process.env.ESBUILD_BINARY_PATH = path.join(process.cwd(), 'node_modules', 'esbuild', 'bin', 'esbuild')
} |
@Arcath could you add a link to that on the README somewhere? |
You know what... The more I think about this, the more I think we should probably support this out of the box 🤔 We know where the esbuild binary should be, so we can set that env variable ourselves if it's not already set. |
@kentcdodds I was thinking the same thing. I was thinking this is all it would need: if(__dirname === "" && !process.env.ESBUILD_BINARY_PATH){
//FIX
} That way we fix it if we need to and don't interferrer with anyones overrides |
In case anyone also using this with NextJS in netlify, somehow My workaround is this: if (process.env.NETLIFY && !process.env.ESBUILD_BINARY_PATH) {
if (process.platform === 'win32') {
process.env.ESBUILD_BINARY_PATH = path.join(
process.cwd(),
'node_modules',
'esbuild',
'esbuild.exe'
);
} else {
process.env.ESBUILD_BINARY_PATH = path.join(
process.cwd(),
'node_modules',
'esbuild',
'bin',
'esbuild'
);
}
} |
@Arcath, I'm not sure I understand how |
Actually, now that I understand this a bit more, this seems like a bug in webpack/next. Could we get it fixed there instead? |
Thats what it came out as in my testing, I added
I came across this vercel/next.js#14341 (comment) where they are implying that removing |
I'm just worried that the solution will be too magical. I'd rather folks do the extra work themselves. We can make the issue and fix more prominent in the docs if that helps though. |
Maybe if we check if our |
Yeah, I'd be willing to accept a PR for that 👍 |
Oh... Actually that might be tricky and it's hard to explain. I'll build this myself. |
Reviews welcome: #21 |
* feat: warn when __dirname is messed up Closes #14 * fix types * don't warn if ESBUILD_BINARY_PATH is already set
🎉 This issue has been resolved in version 3.2.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
mdx-bundler
version: 3.1.2node
version: any (tried 12, 14, and 15.12)npm
version: 7.6.3Relevant code or config: repl.it of bug
What you did: Added
target: "serverless"
to a next.js project with mdx-bundlerWhat happened:
Reproduction repository: https://replit.com/@TheoBr/mdx-bundler-static-demo#README.md
Problem description: Seems to be an issue with how esbuild is run in next.js's
serverless
path. Not functionality I'm super familiar with, I just know that netlify forces it to be enabled. (fwiw I've had no issues using this with vercel (see: tt.fm)Suggested solution: Bug EvanW or Guillermo maybe? I'm lost on this one
The text was updated successfully, but these errors were encountered: