Skip to content

fix: handle native binary addon assets (.node, .dll, .so, .wasm) in Rspack loader config - #103

Merged
pastelsky merged 1 commit into
masterfrom
fix/ignore-native-binary-assets
Aug 10, 2026
Merged

fix: handle native binary addon assets (.node, .dll, .so, .wasm) in Rspack loader config#103
pastelsky merged 1 commit into
masterfrom
fix/ignore-native-binary-assets

Conversation

@pastelsky

Copy link
Copy Markdown
Owner

Problem

Packages that publish prebuilt native binary addons or executables (e.g. SQLite drivers, Rust/Go node addons) previously failed with an unhandled UnexpectedBuildError (surfaced as HTTP 500) because Rspack attempted to parse binary bytes as JavaScript syntax:

× Module parse failed:
╰─▶ × JavaScript parse error: Unexpected character '\u{7f}'
       ╭────
     0 │ \x7FELF\x02\x01\x01...

Solution

  1. Add type: 'asset/resource' loader rules for native binary file extensions (.node, .exe, .dll, .so, .dylib) and type: 'asset/inline' for .wasm in makeRspackConfig.ts.
  2. Add a new test fixture (tests/fixtures/errors/native-binary) containing a .node binary ELF header file.
  3. Add a slow integration test in tests/slow/error-handling.test.ts verifying that packages containing native binary addons build cleanly without throwing JS lexer errors.

Verification

  • Fast Unit Tests: 60 / 60 Passed (corepack yarn test)
  • Slow Integration Tests: 12 / 12 Passed (corepack yarn vitest run tests/slow/error-handling.test.ts)
  • Formatting & Type Check: 0 Warnings, 0 Errors (corepack yarn check)

…o, .wasm)

Packages that include compiled native binary addons or executables (e.g. SQLite
drivers, Rust/Go binary addons) previously failed with an unhandled
UnexpectedBuildError because Rspack attempted to parse binary bytes as
JavaScript syntax (throwing Unexpected character '\u{7f}' or '\0').

Add asset loader rules in makeRspackConfig.ts for .node, .exe, .dll, .so, .dylib,
and .wasm extensions. Add native-binary test fixture and integration test.
@pastelsky
pastelsky force-pushed the fix/ignore-native-binary-assets branch from 3c3e4eb to a4d12ec Compare August 10, 2026 15:57
@pastelsky
pastelsky merged commit a37efea into master Aug 10, 2026
1 of 3 checks passed
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.

1 participant