GSI - Employe Self Service Mobile
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

12 lines
380 B

2 months ago
  1. const { pathToFileURL } = require("url");
  2. exports.dynamicImport = function(mod) {
  3. if (mod.startsWith("file://")) return import(mod);
  4. if (mod.startsWith("/")) return import(pathToFileURL(mod).toString());
  5. try {
  6. const path = require.resolve(mod);
  7. return import(pathToFileURL(path).toString());
  8. } catch(e) {
  9. return Promise.reject(e);
  10. }
  11. }