Skip to content

Commit

Permalink
fix: require of plugin that exports ES module
Browse files Browse the repository at this point in the history
Transpiled ES modules don't export the default export directly as
CommonJS modules, they always export an object and the default export is
under the key "default" in this object.
  • Loading branch information
jirutka committed Feb 13, 2020
1 parent 223f29e commit bf735d1
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,10 @@ const read = file => new Promise(resolve => fs.readFile(file, 'utf8', (error, da
resolve(data);
}));

const interopRequire = object => object && object.__esModule ? object.default : object;

const getPlugins = config => Object.keys(config.plugins || {})
.map(plugin => require(plugin)(config.plugins[plugin]));
.map(plugin => interopRequire(require(plugin))(config.plugins[plugin]));

const config = cfgResolve(cli);

Expand Down

0 comments on commit bf735d1

Please sign in to comment.