mirror of
https://github.com/oven-sh/bun
synced 2026-02-17 14:22:01 +00:00
fix(node): emit warning for unimplemented module.register()
module.register() is used by OpenTelemetry and other tooling to register ESM loader hooks. Since this feature is not yet implemented in Bun, this change emits a process warning to inform users that their loaders will not be invoked, along with a pointer to Bun's plugin API as an alternative. Fixes #3775 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#include "root.h"
|
||||
#include "headers-handwritten.h"
|
||||
#include "NodeModuleModule.h"
|
||||
#include "BunProcess.h"
|
||||
|
||||
#include <JavaScriptCore/JSCInlines.h>
|
||||
#include <JavaScriptCore/VM.h>
|
||||
@@ -870,6 +871,13 @@ JSC_DEFINE_HOST_FUNCTION(jsFunctionSyncBuiltinESMExports,
|
||||
|
||||
JSC_DEFINE_HOST_FUNCTION(jsFunctionRegister, (JSGlobalObject * globalObject, JSC::CallFrame* callFrame))
|
||||
{
|
||||
auto& vm = globalObject->vm();
|
||||
Bun::Process::emitWarning(
|
||||
globalObject,
|
||||
jsString(vm, String("module.register() is not implemented in Bun. Loaders registered with module.register() will not be invoked. To intercept and transform modules, consider using Bun's plugin API: https://bun.sh/docs/bundler/plugins"_s)),
|
||||
jsString(vm, String("Warning"_s)),
|
||||
jsString(vm, String("BUN_UNSUPPORTED_REGISTER"_s)),
|
||||
jsUndefined());
|
||||
return JSC::JSValue::encode(JSC::jsUndefined());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user