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

Support Buffer results from Webpack loaders #8902

Closed
wants to merge 2 commits into from

Conversation

mischnic
Copy link
Contributor

@mischnic mischnic commented Aug 1, 2024

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

Copy link

vercel bot commented Aug 1, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
examples-basic-web ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 1, 2024 1:28pm
examples-designsystem-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 1, 2024 1:28pm
examples-gatsby-web ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 1, 2024 1:28pm
examples-kitchensink-blog ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 1, 2024 1:28pm
examples-native-web ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 1, 2024 1:28pm
examples-nonmonorepo ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 1, 2024 1:28pm
examples-svelte-web ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 1, 2024 1:28pm
examples-tailwind-web ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 1, 2024 1:28pm
examples-vite-web ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 1, 2024 1:28pm
rust-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 1, 2024 1:28pm

Copy link
Member

@timneutkens timneutkens left a 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!

Copy link
Contributor

github-actions bot commented Aug 1, 2024

🟢 Turbopack Benchmark CI successful 🟢

Thanks

Copy link
Contributor

github-actions bot commented Aug 1, 2024

✅ This change can build next-swc

@@ -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,
Copy link
Member

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.

Copy link
Contributor

github-actions bot commented Aug 1, 2024

⚠️ CI failed ⚠️

The following steps have failed in CI:

  • Turbopack Rust tests (mac/win, non-blocking)

See workflow summary for details

@mischnic
Copy link
Contributor Author

mischnic commented Aug 2, 2024

Added to vercel/next.js#68397

@mischnic mischnic closed this Aug 2, 2024
@mischnic mischnic deleted the mischnic/allow-webpack-buffer-result branch August 2, 2024 12:06
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

Successfully merging this pull request may close these issues.

3 participants