diff --git a/browser.d.ts b/browser.d.ts new file mode 100644 index 000000000..21f3fc691 --- /dev/null +++ b/browser.d.ts @@ -0,0 +1,5 @@ +import {YargsFactory} from './build/lib/yargs-factory'; + +declare const Yargs: ReturnType; + +export default Yargs; diff --git a/lib/yerror.ts b/lib/yerror.ts index b282e0975..1daed0f6a 100644 --- a/lib/yerror.ts +++ b/lib/yerror.ts @@ -2,6 +2,8 @@ export class YError extends Error { name = 'YError'; constructor(msg?: string | null) { super(msg || 'yargs error'); - Error.captureStackTrace(this, YError); + if (Error.captureStackTrace) { + Error.captureStackTrace(this, YError); + } } } diff --git a/package.json b/package.json index b9c7cb6bf..ac9efb6d6 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,10 @@ "import": "./helpers/helpers.mjs", "require": "./helpers/index.js" }, + "./browser": { + "import": "./browser.mjs", + "types": "./browser.d.ts" + }, "./yargs": [ { "require": "./yargs"