mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
fix(account-data-editor): restore Ace load ordering
This commit is contained in:
@@ -79,8 +79,20 @@ vi.mock('react-ace', async () => {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
vi.mock('ace-builds/src-noconflict/mode-json', () => ({}));
|
vi.mock('ace-builds/src-noconflict/mode-json', () => {
|
||||||
vi.mock('ace-builds/src-noconflict/theme-monokai', () => ({}));
|
if (!(globalThis as typeof globalThis & { ace?: unknown }).ace) {
|
||||||
|
throw new Error('mode-json imported before ace');
|
||||||
|
}
|
||||||
|
|
||||||
|
return {};
|
||||||
|
});
|
||||||
|
vi.mock('ace-builds/src-noconflict/theme-monokai', () => {
|
||||||
|
if (!(globalThis as typeof globalThis & { ace?: unknown }).ace) {
|
||||||
|
throw new Error('theme-monokai imported before ace');
|
||||||
|
}
|
||||||
|
|
||||||
|
return {};
|
||||||
|
});
|
||||||
vi.mock('ace-builds/esm-resolver', () => {
|
vi.mock('ace-builds/esm-resolver', () => {
|
||||||
if (!(globalThis as typeof globalThis & { ace?: unknown }).ace) {
|
if (!(globalThis as typeof globalThis & { ace?: unknown }).ace) {
|
||||||
throw new Error('ace is not defined');
|
throw new Error('ace is not defined');
|
||||||
|
|||||||
@@ -23,13 +23,15 @@ type EditorState = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const loadAce = async () => {
|
const loadAce = async () => {
|
||||||
const aceModulePromise = import('react-ace');
|
const aceModule = await import('react-ace');
|
||||||
const workerJsonModulePromise = import('ace-builds/src-noconflict/worker-json?url');
|
// Do not start these before react-ace resolves; Ace chunks read the global ace
|
||||||
const modeJsonPromise = import('ace-builds/src-noconflict/mode-json');
|
// binding while evaluating and fail in production modules if they race ahead.
|
||||||
const themeMonokaiPromise = import('ace-builds/src-noconflict/theme-monokai');
|
const [workerJsonModule] = await Promise.all([
|
||||||
const resolverPromise = aceModulePromise.then(() => import('ace-builds/esm-resolver'));
|
import('ace-builds/src-noconflict/worker-json?url'),
|
||||||
const [aceModule, workerJsonModule] = await Promise.all([aceModulePromise, workerJsonModulePromise, resolverPromise, modeJsonPromise, themeMonokaiPromise]);
|
import('ace-builds/esm-resolver'),
|
||||||
// esm-resolver waits for react-ace so it can see the global ace instance.
|
import('ace-builds/src-noconflict/mode-json'),
|
||||||
|
import('ace-builds/src-noconflict/theme-monokai'),
|
||||||
|
]);
|
||||||
const mod = aceModule.default;
|
const mod = aceModule.default;
|
||||||
const Editor = typeof mod === 'function' ? mod : (mod as unknown as { default: typeof mod }).default;
|
const Editor = typeof mod === 'function' ? mod : (mod as unknown as { default: typeof mod }).default;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user