@sentry/core
Version:
Base implementation for all Sentry JavaScript SDKs
37 lines (36 loc) • 1.11 kB
JavaScript
// src/utils/exports.ts
/**
* Replaces constructor functions in module exports, handling read-only properties,
* and both default and named exports by wrapping them with the constructor.
*
* @param exports The module exports object to modify
* @param exportName The name of the export to replace (e.g., 'GoogleGenAI', 'Anthropic', 'OpenAI')
* @param wrappedConstructor The wrapped constructor function to replace the original with
* @returns void
*/
function replaceExports(exports, exportName, wrappedConstructor) {
const original = exports[exportName];
if (typeof original !== "function") return;
try {
exports[exportName] = wrappedConstructor;
} catch {
Object.defineProperty(exports, exportName, {
value: wrappedConstructor,
writable: true,
configurable: true,
enumerable: true
});
}
if (exports.default === original) try {
exports.default = wrappedConstructor;
} catch {
Object.defineProperty(exports, "default", {
value: wrappedConstructor,
writable: true,
configurable: true,
enumerable: true
});
}
}
export { replaceExports };
//# sourceMappingURL=exports.js.map