fix loaders used by Module._extensions (#23291)

### What does this PR do?
Three things:
- JSCommonJSExtensions.cpp `onAssign` was returning out of sync numbers
instead of `BunLoaderTypeJS`/`BunLoaderTypeNAPI`/...
- `bun.schema.api.Loader._none` was 255 instead of 254 like
`BunLoaderTypeNone`
- `Bun__transpileFile` used `bun.options.Loader.Optional` instead of
`bun.schema.api.Loader`. `bun.options.Loader` does not have a type kept
in sync in C++.
### How did you verify your code works?
Added tests that make sure the correct loader is used for modules
required with custom _extensions functions
This commit is contained in:
Dylan Conway
2025-10-06 06:40:15 -07:00
committed by GitHub
parent 639d998055
commit 166c8ff4f0
7 changed files with 532 additions and 50 deletions

View File

@@ -1600,9 +1600,10 @@ pub export fn Bun__transpileFile(
ret: *jsc.ErrorableResolvedSource,
allow_promise: bool,
is_commonjs_require: bool,
force_loader_type: bun.options.Loader.Optional,
_force_loader_type: bun.schema.api.Loader,
) ?*anyopaque {
jsc.markBinding(@src());
const force_loader_type: bun.options.Loader.Optional = .fromAPI(_force_loader_type);
var log = logger.Log.init(jsc_vm.transpiler.allocator);
defer log.deinit();