-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Support Buffer results from Webpack loaders #8902
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me!
🟢 Turbopack Benchmark CI successful 🟢Thanks |
✅ This change can build |
@@ -479,7 +479,7 @@ const transform = ( | |||
if (!result.result) return reject(new Error("No result from loaders")); | |||
const [source, map] = result.result; | |||
resolve({ | |||
source, | |||
source: Buffer.isBuffer(source) ? source.toString("utf8") : source, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The result might be some binary data that is not an utf-8 string.
E. g. some image-processing-loader can return an image.
|
Added to vercel/next.js#68397 |
The result from a webpack loader can be a string or a buffer: https://webpack.js.org/api/loaders/#thiscallback
The mdx loader uses this:
https://github.com/mdx-js/mdx/blob/e780a972c29584851c2a131f2984a7470aa8c2f2/packages/loader/lib/index.js#L93
Stringify the Buffer before sending it over to Rust