From 2946ecdc16e5a869441cdf2b356a4b997c8de367 Mon Sep 17 00:00:00 2001 From: Evan Purkhiser Date: Wed, 8 May 2024 15:58:49 -0400 Subject: [PATCH] ref(node): Inject URL and URLSearchParams globals (#149) Some config may expect this --- src/config.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/config.ts b/src/config.ts index 90fbe48..4dbd972 100644 --- a/src/config.ts +++ b/src/config.ts @@ -1,6 +1,6 @@ import * as echarts from 'echarts'; import path from 'node:path'; -import vm from 'node:vm'; +import {runInNewContext} from 'node:vm'; import ConfigPoller from './configPolling'; import {logger} from './logging'; @@ -26,7 +26,15 @@ async function loadViaHttp(url: string, ac?: AbortController) { const exports = {default: null}; const module = {exports}; - vm.runInNewContext(configJavascript, {require, console, module, exports}); + + runInNewContext(configJavascript, { + URL, + URLSearchParams, + require, + console, + module, + exports, + }); return exports.default ?? module.exports?.default ?? module.exports; }