Skip to content

Commit 95aed1c

Browse files
authored
fix: import yargs/yargs in esm projects (#2151)
1 parent db35423 commit 95aed1c

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
},
2323
"./yargs": [
2424
{
25+
"import": "./yargs.mjs",
2526
"require": "./yargs"
2627
},
2728
"./yargs"

yargs.mjs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// TODO: consolidate on using a helpers file at some point in the future, which
2+
// is the approach currently used to export Parser and applyExtends for ESM:
3+
import pkg from './build/index.cjs';
4+
const {applyExtends, cjsPlatformShim, Parser, processArgv, Yargs} = pkg;
5+
Yargs.applyExtends = (config, cwd, mergeExtends) => {
6+
return applyExtends(config, cwd, mergeExtends, cjsPlatformShim);
7+
};
8+
Yargs.hideBin = processArgv.hideBin;
9+
Yargs.Parser = Parser;
10+
export default Yargs;

0 commit comments

Comments
 (0)