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 all 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
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
build/
test/
example/
helpers/
10 changes: 0 additions & 10 deletions helpers.mjs

This file was deleted.

10 changes: 10 additions & 0 deletions helpers/helpers.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import {applyExtends as _applyExtends} from '../build/lib/utils/apply-extends.js';
import {hideBin} from '../build/lib/utils/process-argv.js';
import Parser from 'yargs-parser';
import shim from '../lib/platform-shims/esm.mjs';

const applyExtends = (config, cwd, mergeExtends) => {
return _applyExtends(config, cwd, mergeExtends, shim);
};

export {applyExtends, hideBin, Parser};
14 changes: 14 additions & 0 deletions helpers/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
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,
};
3 changes: 3 additions & 0 deletions helpers/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"type": "commonjs"
}
8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
"./index.cjs"
],
"./helpers": {
"import": "./helpers.mjs",
"require": "./yargs"
"import": "./helpers/helpers.mjs",
"require": "./helpers/index.js"
},
"./yargs": [
{
Expand All @@ -33,7 +33,8 @@
"files": [
"browser.mjs",
"index.cjs",
"helpers.mjs",
"helpers/*.js",
"helpers/*",
"index.mjs",
"yargs",
"build",
Expand Down Expand Up @@ -99,6 +100,7 @@
"standardx": {
"ignore": [
"build",
"helpers",
"**/example/**",
"**/platform-shims/esm.mjs"
]
Expand Down
2 changes: 1 addition & 1 deletion test/esm/helpers.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

import * as assert from 'assert';
import {applyExtends, hideBin, Parser} from '../../helpers.mjs';
import {applyExtends, hideBin, Parser} from '../../helpers/helpers.mjs';
import {describe, it} from 'mocha';

describe('helpers', () => {
Expand Down
2 changes: 1 addition & 1 deletion yargs
Original file line number Diff line number Diff line change
@@ -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