Files
bun.sh/test/regression
Claude Bot 5ba168a554 Allow onLoad plugins to return null/undefined to fallback to filesystem
Fixes #5303

Previously, when a plugin's onLoad callback returned null or undefined,
Bun would throw a TypeError: "onLoad() expects an object returned".

This change allows plugins to return null/undefined to signal "no match"
and fallback to the default loading mechanism (filesystem or next plugin),
matching the behavior of onResolve.

This is useful for:
- Conditional file handling (only process certain files)
- Plugin chaining (let another plugin handle it)
- Leveraging Bun's built-in loading for some files

The implementation follows the same pattern as onResolve:
- null/undefined -> continue to next plugin/fallback
- Other non-objects (boolean, number, string) -> throw TypeError
- Objects -> validate and process

Note: In Bun.build() API (BundlerPlugin.ts), ALL non-object values
fallback (including primitives like true, 42, "string"), but the C++
layer used by runtime plugins follows stricter validation like onResolve.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-01 07:50:25 +00:00
..