UNPKG

467 BJavaScriptView Raw
1const {pathToFileURL} = require('url');
2
3// Hack to avoid Module.runMain on node 18.6.0
4// Keeping it simple for now, isolated in this file.
5// Could theoretically probe `getFormat` impl to determine if `import()` or `Module._load()` is best
6// Note that I attempted a try-catch around `Module._load`, but it poisons some sort of cache such that subsequent `import()` is impossible.
7exports.run = function(entryPointPath) {
8 import(pathToFileURL(entryPointPath));
9}