| 1 | import { register } from "node:module"; |
| 2 | |
| 3 | const stubs = { |
| 4 | "@wecom/aibot-node-sdk": new URL("./sdk-stubs/wecom.mjs", import.meta.url).href, |
| 5 | "@larksuiteoapi/node-sdk": new URL("./sdk-stubs/lark.mjs", import.meta.url).href |
| 6 | }; |
| 7 | |
| 8 | const hook = ` |
| 9 | const stubs = ${JSON.stringify(stubs)}; |
| 10 | export async function resolve(specifier, context, nextResolve) { |
| 11 | if (stubs[specifier]) return { url: stubs[specifier], shortCircuit: true }; |
| 12 | return nextResolve(specifier, context); |
| 13 | } |
| 14 | `; |
| 15 | |
| 16 | register(`data:text/javascript,${encodeURIComponent(hook)}`); |
| 17 |