Merge pull request #4688 from Rotzbua/remove_import_polyfill

fix(polyfill): remove import module polyfill
This commit is contained in:
Nick O'Leary 2024-05-13 14:39:33 +01:00 committed by GitHub
commit cf26209790
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -28,11 +28,6 @@ let installEnabled = true;
let installAllowList = ['*'];
let installDenyList = [];
let IMPORT_SUPPORTED = true;
const nodeVersionParts = process.versions.node.split(".").map(v => parseInt(v));
if (nodeVersionParts[0] < 12 || (nodeVersionParts[0] === 12 && nodeVersionParts[1] < 17)) {
IMPORT_SUPPORTED = false;
}
function getInstallDir() {
return path.resolve(settings.userDir || process.env.NODE_RED_HOME || ".");
@ -110,18 +105,6 @@ function requireModule(module) {
return require(moduleDir);
}
function importModule(module) {
if (!IMPORT_SUPPORTED) {
// On Node < 12.17 - fall back to try a require
return new Promise((resolve, reject) => {
try {
const mod = requireModule(module);
resolve(mod);
} catch(err) {
reject(err);
}
});
}
if (!registryUtil.checkModuleAllowed( module, null,installAllowList,installDenyList)) {
const e = new Error("Module not allowed");
e.code = "module_not_allowed";