Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: expose helpers for legacy versions of Node.js #1801

Merged
merged 3 commits into from Nov 15, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 15 additions & 0 deletions helpers
@@ -0,0 +1,15 @@
// TODO: remove this file once Node 10 is EOL:
const {
applyExtends,
cjsPlatformShim,
Parser,
processArgv,
} = require('./build/index.cjs');

module.exports = {
applyExtends: (config, cwd, mergeExtends) => {
return applyExtends(config, cwd, mergeExtends, cjsPlatformShim);
},
hideBin: processArgv.hideBin,
Parser,
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm confused, why an extensionless file instead of a helpers dir with a package.json that has "type": "commonjs" and an index.js file?

The current approach will be way more likely cause problems with parsers and resolvers (admittedly, ones with bugs, but i can't even confidently say resolve would work properly with this)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I appreciate that having a subfolder would cleanup the top level a bit too, we could pull the mjs in there

1 change: 1 addition & 0 deletions package.json
Expand Up @@ -34,6 +34,7 @@
"browser.mjs",
"index.cjs",
"helpers.mjs",
"helpers",
"index.mjs",
"yargs",
"build",
Expand Down
2 changes: 1 addition & 1 deletion yargs
@@ -1,5 +1,5 @@
// 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:
// is the approach currently used to export Parser and applyExtends for ESM:
const {applyExtends, cjsPlatformShim, Parser, Yargs, processArgv} = require('./build/index.cjs')
Yargs.applyExtends = (config, cwd, mergeExtends) => {
return applyExtends(config, cwd, mergeExtends, cjsPlatformShim)
Expand Down