load-esm.js 264 B

123456789101112
  1. 'use strict';
  2. const {pathToFileURL} = require('url');
  3. module.exports = async filename => {
  4. const mod = await import(pathToFileURL(filename));
  5. if ('default' in mod === false) {
  6. throw new Error(`${filename} has no default export`);
  7. }
  8. return mod.default;
  9. };