Skip to content

Commit

Permalink
fix: expose helpers for legacy versions of Node.js (#1801)
Browse files Browse the repository at this point in the history
  • Loading branch information
bcoe committed Nov 15, 2020
1 parent cb01c98 commit 107deaa
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 15 deletions.
1 change: 1 addition & 0 deletions .eslintignore
@@ -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
@@ -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
@@ -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
@@ -0,0 +1,3 @@
{
"type": "commonjs"
}
8 changes: 5 additions & 3 deletions package.json
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
@@ -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
@@ -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

0 comments on commit 107deaa

Please sign in to comment.