|
| 1 | +import { createRequire } from 'module'; |
| 2 | +const require = createRequire(import.meta.url); |
| 3 | +// @ts-ignore |
| 4 | +globalThis.require = require; |
| 5 | + |
1 | 6 | import { defineConfig } from './src/config'; |
2 | | -import { MSWPlugin } from '@objectstack/plugin-msw'; |
3 | | -import { ObjectQLPlugin } from '@objectstack/objectql'; |
| 7 | +// @ts-ignore |
| 8 | +import * as MSWPluginPkg from '@objectstack/plugin-msw'; |
| 9 | +// @ts-ignore |
| 10 | +import * as ObjectQLPluginPkg from '@objectstack/objectql'; |
| 11 | +// @ts-ignore |
| 12 | +import * as HonoServerPluginPkg from '@objectstack/plugin-hono-server'; |
| 13 | + |
| 14 | +const MSWPlugin = MSWPluginPkg.MSWPlugin || (MSWPluginPkg as any).default?.MSWPlugin || (MSWPluginPkg as any).default; |
| 15 | +const ObjectQLPlugin = ObjectQLPluginPkg.ObjectQLPlugin || (ObjectQLPluginPkg as any).default?.ObjectQLPlugin || (ObjectQLPluginPkg as any).default; |
| 16 | +const HonoServerPlugin = HonoServerPluginPkg.HonoServerPlugin || (HonoServerPluginPkg as any).default?.HonoServerPlugin || (HonoServerPluginPkg as any).default; |
| 17 | + |
| 18 | +// FIX: Ensure init is own property for runtime compatibility |
| 19 | +class PatchedMSWPlugin extends MSWPlugin { |
| 20 | + constructor(...args: any[]) { |
| 21 | + super(...args); |
| 22 | + // @ts-ignore |
| 23 | + this.init = this.init.bind(this); |
| 24 | + // @ts-ignore |
| 25 | + this.start = this.start?.bind(this); |
| 26 | + } |
| 27 | +} |
| 28 | + |
| 29 | +class PatchedHonoServerPlugin extends HonoServerPlugin { |
| 30 | + constructor(...args: any[]) { |
| 31 | + super(...args); |
| 32 | + // @ts-ignore |
| 33 | + this.init = this.init.bind(this); |
| 34 | + // @ts-ignore |
| 35 | + this.start = this.start?.bind(this); |
| 36 | + } |
| 37 | +} |
| 38 | + |
4 | 39 | import ConsolePluginConfig from './plugin.js'; |
5 | 40 | import crmConfig from '@object-ui/example-crm/objectstack.config'; |
6 | 41 | import todoConfig from '@object-ui/example-todo/objectstack.config'; |
@@ -47,8 +82,7 @@ export default defineConfig({ |
47 | 82 |
|
48 | 83 | plugins: [ |
49 | 84 | new ObjectQLPlugin(), |
50 | | - new MSWPlugin(), |
51 | | - FixedConsolePlugin |
| 85 | + new PatchedMSWPlugin(), new PatchedHonoServerPlugin(), FixedConsolePlugin |
52 | 86 | ], |
53 | 87 |
|
54 | 88 | // ============================================================================ |
|
0 commit comments