Skip to content

Commit

Permalink
ref(node): Inject URL and URLSearchParams globals (#149)
Browse files Browse the repository at this point in the history
Some config may expect this
  • Loading branch information
evanpurkhiser authored May 8, 2024
1 parent 5668da5 commit 2946ecd
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/config.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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;
}
Expand Down

0 comments on commit 2946ecd

Please sign in to comment.