Skip to content

Commit

Permalink
fix: import yargs/yargs in esm projects (#2151)
Browse files Browse the repository at this point in the history
  • Loading branch information
hongaar committed May 11, 2022
1 parent db35423 commit 95aed1c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -22,6 +22,7 @@
},
"./yargs": [
{
"import": "./yargs.mjs",
"require": "./yargs"
},
"./yargs"
Expand Down
10 changes: 10 additions & 0 deletions yargs.mjs
@@ -0,0 +1,10 @@
// TODO: consolidate on using a helpers file at some point in the future, which
// is the approach currently used to export Parser and applyExtends for ESM:
import pkg from './build/index.cjs';
const {applyExtends, cjsPlatformShim, Parser, processArgv, Yargs} = pkg;
Yargs.applyExtends = (config, cwd, mergeExtends) => {
return applyExtends(config, cwd, mergeExtends, cjsPlatformShim);
};
Yargs.hideBin = processArgv.hideBin;
Yargs.Parser = Parser;
export default Yargs;

0 comments on commit 95aed1c

Please sign in to comment.