From 363f592ebbd35da1f8b6a74e440c934ca88c74c2 Mon Sep 17 00:00:00 2001 From: sealday Date: Mon, 29 Jul 2024 16:44:18 +0800 Subject: [PATCH] fix: monaco require (#1404) Co-authored-by: sealday Reviewed-on: https://git.daoyoucloud.com/daoyoucloud/tachybase/pulls/1404 --- packages/core/client/src/application/Application.tsx | 5 +++-- packages/core/client/src/application/utils/remotePlugins.ts | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/core/client/src/application/Application.tsx b/packages/core/client/src/application/Application.tsx index 6367e6933..f3dd52e00 100644 --- a/packages/core/client/src/application/Application.tsx +++ b/packages/core/client/src/application/Application.tsx @@ -33,7 +33,7 @@ import { WebSocketClient, WebSocketClientOptions } from './WebSocketClient'; declare global { interface Window { - tbDefine: RequireJS['define']; + define: RequireJS['define']; } } @@ -132,7 +132,8 @@ export class Application { private initRequireJs() { this.requirejs = getRequireJs(); defineGlobalDeps(this.requirejs); - window.tbDefine = this.requirejs.define; + window.define = this.requirejs.define; + window.require = this.requirejs.require; } private addDefaultProviders() { diff --git a/packages/core/client/src/application/utils/remotePlugins.ts b/packages/core/client/src/application/utils/remotePlugins.ts index 95eca9604..17ea0adbf 100644 --- a/packages/core/client/src/application/utils/remotePlugins.ts +++ b/packages/core/client/src/application/utils/remotePlugins.ts @@ -8,7 +8,7 @@ import type { RequireJS } from './requirejs'; */ export function defineDevPlugins(plugins: Record) { Object.entries(plugins).forEach(([packageName, plugin]) => { - window.tbDefine(`${packageName}/client`, () => plugin); + window.define(`${packageName}/client`, () => plugin); }); } @@ -16,7 +16,7 @@ export function defineDevPlugins(plugins: Record) { * @internal */ export function definePluginClient(packageName: string) { - window.tbDefine(`${packageName}/client`, ['exports', packageName], function (_exports: any, _pluginExports: any) { + window.define(`${packageName}/client`, ['exports', packageName], function (_exports: any, _pluginExports: any) { Object.defineProperty(_exports, '__esModule', { value: true, });