fix: strip UTF-8 BOM when using text loader#7635
Conversation
How to use the Graphite Merge QueueAdd the label graphite: merge-when-ready to this PR to add it to the merge queue. You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
✅ Deploy Preview for rolldown-rs canceled.
|
There was a problem hiding this comment.
Pull request overview
This PR fixes the text loader to correctly strip UTF-8 BOM (Byte Order Mark) from text files, aligning rolldown's behavior with esbuild and browser JSON modules. The fix ensures that when text files start with a UTF-8 BOM (\uFEFF), it is removed before the content is processed.
Key changes:
- Added UTF-8 BOM stripping logic in the text module type handler
- Updated test metadata to reflect the now-passing
loader_text_utf8_bomtest
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| crates/rolldown/src/utils/parse_to_ecma_ast.rs | Implements UTF-8 BOM stripping for text loader by checking for and removing the leading \uFEFF character before escaping |
| scripts/src/esbuild-tests/reasons.ts | Removes the failed test reason entry for loader_text_utf8_bom |
| scripts/src/esbuild-tests/snap-diff/summary/loader.md | Moves loader_text_utf8_bom from failed to passed test list |
| scripts/src/esbuild-tests/snap-diff/stats/stats.md | Updates test pass statistics (passed count: 666→667, pass ratio: 96.10%→96.25%) |
| crates/rolldown/tests/esbuild/loader/loader_text_utf8_bom/diff.md | Removes the diff file as the test now passes |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Merge activity
|
Made text loader strip the UTF-8 BOM. This aligns with the behavior of esbuild and JSON modules in browsers.
9c88984 to
9dc5f6d
Compare
## [1.0.0-beta.57] - 2025-12-24 ✨ TypeScript Project References Support - Rolldown now supports TypeScript project references when manually specifying a `tsconfig` - See more details: https://rolldown.rs/options/tsconfig 💥 Rename `__export` to `__exportAll` - Update `rolldown-plugin-dts` to the latest version for compatibility ### 💥 BREAKING CHANGES - tsconfig: enable project references support in manual mode (#7545) by @shulaoda ### 🚀 Features - add `CANNOT_CALL_NAMESPACE` warning (#7636) by @sapphi-red - add import path for unresolved import diagnostics (#7625) by @sapphi-red - optimize dynamic entry facade chunks by merging with common chunks when they are captured by common chunks (#7486) by @IWANABETHATGUY ### 🐛 Bug Fixes - rename `__export` to `__exportAll` to be compatible with `cjs-module-lexer` (#7640) by @IWANABETHATGUY - strip UTF-8 BOM when using text loader (#7635) by @sapphi-red - rolldown_plugin_replace: avoid crashing with invalid delimiters (#7621) by @sapphi-red ### 🚜 Refactor - export all filter functions (#7622) by @sxzz - allow multiple help messages in diagnostics (#7624) by @sapphi-red ### 📚 Documentation - add README.md to packages/rolldown (#7556) by @Copilot ### ⚡ Performance - use fsevents on macOS for file watching (#7596) by @sapphi-red ### 🧪 Testing - handle re-exports of external modules in CJS format (#7641) by @IWANABETHATGUY - update integration to use vite's rolldown-canary branch (#7633) by @shulaoda ### ⚙️ Miscellaneous Tasks - docs: fix Netlify ignore condition to detect docs changes across all PR commits (#7637) by @Copilot - deps: update rollup submodule for tests to v4.54.0 (#7630) by @sapphi-red - skip benchmarks for PRs with 'graphite: merge-when-ready' label (#7631) by @Boshen - deps: update esbuild for tests to 0.27.2 (#7629) by @sapphi-red - fix "update-test-dependencies" workflow (#7628) by @sapphi-red - deps: update test262 submodule for tests (#7626) by @sapphi-red - deps: update dependency oxlint to v1.35.0 (#7623) by @renovate[bot] Co-authored-by: shulaoda <[email protected]>

Made text loader strip the UTF-8 BOM. This aligns with the behavior of esbuild and JSON modules in browsers.