fix(mdx-loader): fix cross-compiler cache randomly loading mdx with client/server envs (#10553)

This commit is contained in:
Sébastien Lorber 2024-10-03 23:20:57 +02:00 committed by GitHub
parent 05f3c203a2
commit 9e473bd080
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 86 additions and 18 deletions

View file

@ -132,3 +132,20 @@ export async function compileToJSX({
);
}
}
// TODO Docusaurus v4, remove temporary polyfill when upgrading to Node 22+
export interface PromiseWithResolvers<T> {
promise: Promise<T>;
resolve: (value: T | PromiseLike<T>) => void;
reject: (reason?: any) => void;
}
// TODO Docusaurus v4, remove temporary polyfill when upgrading to Node 22+
export function promiseWithResolvers<T>(): PromiseWithResolvers<T> {
// @ts-expect-error: it's fine
const out: PromiseWithResolvers<T> = {};
out.promise = new Promise((resolve, reject) => {
out.resolve = resolve;
out.reject = reject;
});
return out;
}