Skip to content

fix(loader): preserve string BOM across native boundaries - #15632

Merged
SyMind merged 6 commits into
mainfrom
codex/loader-utf8-bom
Sep 14, 2026
Merged

SyMind merged 6 commits into
mainfrom
codex/loader-utf8-bom

Conversation

@intellild

@intellild intellild commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Motivation

A loader-produced string is transported through the native bridge as a Buffer. Without preserving its original type, the next JavaScript loader treats it as binary input and strips its leading BOM.

For example, in normal execution order producer (JS) -> builtin:test-passthrough-loader -> consumer (JS), returning the string "\uFEFFhello" incorrectly delivers "hello" to the non-raw consumer.

Changes

  • Populate the existing Rust-to-JavaScript __internal__utf8Hint from the native content variant.
  • Restore string content before normal JavaScript loader execution, preserving its leading BOM.
  • Keep the existing BOM stripping behavior for Buffer-to-string conversion and preserve BOM bytes for raw loaders.
  • Add regression coverage for JS-only and JS/native/JS chains, parallel on/off, string/Buffer outputs, and normal/raw consumers.

Validation

  • Rust/JavaScript build and clippy passed.
  • BOM regression tests: 17 passed.
  • Raw/string loader regression tests: 8 passed.
  • Disabling the JavaScript hint read reproduces BOM loss in the new regression test; restoring it makes the test pass.

by OpenAI Codex

@intellild
intellild force-pushed the codex/loader-utf8-bom branch from 72fab19 to dc1bf27 Compare September 11, 2026 03:13
@intellild
intellild changed the base branch from codex/loader-metadata to main September 11, 2026 03:14
@github-actions

github-actions Bot commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

📦 Binary Size-limit

Comparing 9252ebe to chore(ci): enable Corepack for resolver PnP fixtures (#15640) by Jiahan Chen

❌ Size increased by 4.00KB from 68.48MB to 68.49MB (⬆️0.01%)

@intellild
intellild marked this pull request as ready for review September 11, 2026 03:19
@intellild
intellild requested a review from hardfist as a code owner September 11, 2026 03:19
@github-actions

github-actions Bot commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Rsdoctor Bundle Diff Analysis

Found 5 projects in monorepo, 0 projects with changes.

📊 Quick Summary
Project Total Size Gzip Size Change Gzip Change
popular-libs 1.7 MB 523.6 KB 0 0
react-10k 5.3 MB 1.3 MB 0 0
react-1k 799.1 KB 217.5 KB 0 0
react-5k 2.6 MB 662.0 KB 0 0
ui-components 4.9 MB 1.4 MB 0 0

Generated by Rsdoctor GitHub Action

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Sep 11, 2026

Copy link
Copy Markdown

Deploying rspack with  Cloudflare Pages  Cloudflare Pages

Latest commit: 2aff5ee
Status: ✅  Deploy successful!
Preview URL: https://41d98317.rspack-v2.pages.dev
Branch Preview URL: https://codex-loader-utf8-bom.rspack-v2.pages.dev

View logs

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: dc1bf2701b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/rspack_binding_api/src/plugins/js_loader/context.rs Outdated
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 11, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-12T00:14:05.519690Z 9252ebe New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@codspeed

codspeed Bot commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 50 untouched benchmarks
⏩ 47 skipped benchmarks1


Comparing codex/loader-utf8-bom (9252ebe) with main (c1e4c9f)

Open in CodSpeed

Footnotes

  1. 47 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@intellild

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bb06c7ff3d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/rspack/src/loader-runner/index.ts Outdated
@intellild
intellild requested review from SyMind and ahabhgk September 11, 2026 08:20

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: be9ff94dfc

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/rspack_binding_api/src/plugins/js_loader/context.rs
@intellild

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Bravo.

Reviewed commit: 4bb7cfebdc

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@intellild
intellild force-pushed the codex/loader-utf8-bom branch from 5e78635 to 9252ebe Compare September 12, 2026 00:11
@SyMind
SyMind merged commit df236e5 into main Sep 14, 2026
46 checks passed
@SyMind
SyMind deleted the codex/loader-utf8-bom branch September 14, 2026 02:23
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.

2 participants