yargs-parser
Advanced tools
Comparing version
/** | ||
* @fileoverview Main entrypoint for libraries using yargs-parser in Node.js | ||
* CJS and ESM environments. | ||
* | ||
@@ -10,2 +9,3 @@ * @license | ||
var _a, _b, _c; | ||
/* eslint-disable n/no-unpublished-import */ | ||
import { format } from 'util'; | ||
@@ -16,2 +16,3 @@ import { normalize, resolve } from 'path'; | ||
import { readFileSync } from 'fs'; | ||
import { createRequire } from 'node:module'; | ||
// See https://github.com/yargs/yargs-parser#supported-nodejs-versions for our | ||
@@ -21,3 +22,3 @@ // version support policy. The YARGS_MIN_NODE_VERSION is used for testing only. | ||
? Number(process.env.YARGS_MIN_NODE_VERSION) | ||
: 12; | ||
: 20; | ||
const nodeVersion = (_b = (_a = process === null || process === void 0 ? void 0 : process.versions) === null || _a === void 0 ? void 0 : _a.node) !== null && _b !== void 0 ? _b : (_c = process === null || process === void 0 ? void 0 : process.version) === null || _c === void 0 ? void 0 : _c.slice(1); | ||
@@ -32,2 +33,3 @@ if (nodeVersion) { | ||
const env = process ? process.env : {}; | ||
const require = createRequire ? createRequire(import.meta.url) : undefined; | ||
const parser = new YargsParser({ | ||
@@ -41,4 +43,2 @@ cwd: process.cwd, | ||
resolve, | ||
// TODO: figure out a way to combine ESM and CJS coverage, such that | ||
// we can exercise all the lines below: | ||
require: (path) => { | ||
@@ -68,1 +68,3 @@ if (typeof require !== 'undefined') { | ||
export default yargsParser; | ||
// special syntax to allow unqualified default export from CommonJS | ||
export { yargsParser as 'module.exports' }; |
@@ -6,2 +6,3 @@ /** | ||
*/ | ||
/* eslint-disable prefer-arrow-callback */ | ||
import { tokenizeArgString } from './tokenize-arg-string.js'; | ||
@@ -8,0 +9,0 @@ import { DefaultValuesForTypeKey } from './yargs-parser-types.js'; |
@@ -5,2 +5,13 @@ # Changelog | ||
## [22.0.0](https://github.com/yargs/yargs-parser/compare/yargs-parser-v21.1.1...yargs-parser-v22.0.0) (2025-05-26) | ||
### ⚠ BREAKING CHANGES | ||
* yargs is now ESM first ([#503](https://github.com/yargs/yargs-parser/issues/503)) | ||
### Features | ||
* yargs is now ESM first ([#503](https://github.com/yargs/yargs-parser/issues/503)) ([6d69295](https://github.com/yargs/yargs-parser/commit/6d692953ade099375c6c5e131367968b07ae8470)) | ||
## [21.1.1](https://github.com/yargs/yargs-parser/compare/yargs-parser-v21.1.0...yargs-parser-v21.1.1) (2022-08-04) | ||
@@ -7,0 +18,0 @@ |
{ | ||
"name": "yargs-parser", | ||
"version": "21.1.1", | ||
"version": "22.0.0", | ||
"description": "the mighty option parser used by yargs", | ||
"main": "build/index.cjs", | ||
"main": "build/lib/index.js", | ||
"exports": { | ||
".": [ | ||
{ | ||
"import": "./build/lib/index.js", | ||
"require": "./build/index.cjs" | ||
"import": "./build/lib/index.js" | ||
}, | ||
"./build/index.cjs" | ||
"./build/lib/index.js" | ||
], | ||
@@ -21,7 +20,6 @@ "./browser": [ | ||
"scripts": { | ||
"check": "standardx '**/*.ts' && standardx '**/*.js' && standardx '**/*.cjs'", | ||
"fix": "standardx --fix '**/*.ts' && standardx --fix '**/*.js' && standardx --fix '**/*.cjs'", | ||
"pretest": "rimraf build && tsc -p tsconfig.test.json && cross-env NODE_ENV=test npm run build:cjs", | ||
"test": "c8 --reporter=text --reporter=html mocha test/*.cjs", | ||
"test:esm": "c8 --reporter=text --reporter=html mocha test/*.mjs", | ||
"check": "gts lint", | ||
"fix": "gts fix", | ||
"pretest": "rimraf build && tsc -p tsconfig.test.json", | ||
"test": "c8 --reporter=text --reporter=html mocha test/*.mjs", | ||
"test:browser": "start-server-and-test 'serve ./ -p 8080' http://127.0.0.1:8080/package.json 'node ./test/browser/yargs-test.cjs'", | ||
@@ -33,4 +31,2 @@ "pretest:typescript": "npm run pretest", | ||
"compile": "tsc", | ||
"postcompile": "npm run build:cjs", | ||
"build:cjs": "rollup -c", | ||
"prepare": "npm run compile" | ||
@@ -56,25 +52,20 @@ }, | ||
"devDependencies": { | ||
"@types/chai": "^4.2.11", | ||
"@types/mocha": "^9.0.0", | ||
"@types/node": "^16.11.4", | ||
"@typescript-eslint/eslint-plugin": "^3.10.1", | ||
"@typescript-eslint/parser": "^3.10.1", | ||
"c8": "^7.3.0", | ||
"chai": "^4.2.0", | ||
"@babel/eslint-parser": "^7.27.1", | ||
"@babel/preset-typescript": "^7.27.1", | ||
"@types/chai": "^5.2.1", | ||
"@types/mocha": "^10.0.10", | ||
"@types/node": "^22.15.3", | ||
"@typescript-eslint/eslint-plugin": "^8.29.1", | ||
"@typescript-eslint/parser": "^8.31.1", | ||
"c8": "^10.1.3", | ||
"chai": "^5.2.0", | ||
"cross-env": "^7.0.2", | ||
"eslint": "^7.0.0", | ||
"eslint-plugin-import": "^2.20.1", | ||
"eslint-plugin-node": "^11.0.0", | ||
"gts": "^3.0.0", | ||
"mocha": "^10.0.0", | ||
"puppeteer": "^16.0.0", | ||
"rimraf": "^3.0.2", | ||
"rollup": "^2.22.1", | ||
"rollup-plugin-cleanup": "^3.1.1", | ||
"rollup-plugin-ts": "^3.0.2", | ||
"eslint": "^8.57.1", | ||
"gts": "^5.3.1", | ||
"mocha": "^11.1.0", | ||
"puppeteer": "^24.6.1", | ||
"rimraf": "^6.0.1", | ||
"serve": "^14.0.0", | ||
"standardx": "^7.0.0", | ||
"start-server-and-test": "^1.11.2", | ||
"ts-transform-default-export": "^1.0.2", | ||
"typescript": "^4.0.0" | ||
"start-server-and-test": "^2.0.11", | ||
"typescript": "^5.8.3" | ||
}, | ||
@@ -88,9 +79,4 @@ "files": [ | ||
"engines": { | ||
"node": ">=12" | ||
}, | ||
"standardx": { | ||
"ignore": [ | ||
"build" | ||
] | ||
"node": "^20.19.0 || ^22.12.0 || >=23" | ||
} | ||
} |
18
-21.74%7
-46.15%85628
-33.35%10
-9.09%1254
-45.34%