diff options
author | 2023-05-30 00:30:47 -0700 | |
---|---|---|
committer | 2023-05-30 00:30:47 -0700 | |
commit | 481f916f3f3048c2d8f8bb6ccb657f89e9f1d679 (patch) | |
tree | 4ddcb85c3d7ffacdef5d7bb0a657728902cfcb45 | |
parent | 85565d95d5f600718d239782d58d06c6c5efc37c (diff) | |
download | bun-481f916f3f3048c2d8f8bb6ccb657f89e9f1d679.tar.gz bun-481f916f3f3048c2d8f8bb6ccb657f89e9f1d679.tar.zst bun-481f916f3f3048c2d8f8bb6ccb657f89e9f1d679.zip |
More comments
-rw-r--r-- | src/bun.js/bindings/CommonJSModuleRecord.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/bun.js/bindings/CommonJSModuleRecord.cpp b/src/bun.js/bindings/CommonJSModuleRecord.cpp index ba49f0e14..d7fe6161a 100644 --- a/src/bun.js/bindings/CommonJSModuleRecord.cpp +++ b/src/bun.js/bindings/CommonJSModuleRecord.cpp @@ -351,6 +351,7 @@ JSC::SourceCode createCommonJSModule( false, false, EvalContextType::None, nullptr, nullptr, ECMAMode::sloppy()); if (UNLIKELY(!executable && !throwScope.exception())) { + // I'm not sure if this case happens, but it's better to be safe than sorry. throwSyntaxError(globalObject, throwScope, "Failed to compile CommonJS module."_s); } @@ -380,6 +381,13 @@ JSC::SourceCode createCommonJSModule( JSValue result = moduleObject->exportsObject(); + // The developer can do something like: + // + // Object.defineProperty(module, 'exports', {get: getter}) + // + // In which case, the exports object is now a GetterSetter object. + // + // We can't return a GetterSetter object to ESM code, so we need to call it. if (!result.isEmpty() && (result.isGetterSetter() || result.isCustomGetterSetter())) { auto* clientData = WebCore::clientData(vm); |