-
Notifications
You must be signed in to change notification settings - Fork 995
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
feat!: adds support for ESM and Deno #1708
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Refs: #1706 |
bcoe
commented
Aug 8, 2020
index.mjs
Outdated
import { YargsFactory } from './build/lib/yargs-factory.js' | ||
|
||
// TODO: stop using createRequire as soon as we've ported: cliui, y18n, etc. | ||
import { createRequire } from 'module'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@QmarkC if once we port y18n
and cliui
we'll be getting darn close to an ESM version of yargs.
Note that createRequire
is Node.js specific, so won't port well to other runtimes.
bcoe
commented
Aug 8, 2020
This was referenced Nov 25, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Using the work in
yargs-parser
as a starting point, this PR begins refactoring yargs such that it can easily target ESM, Deno, and CJS.TODO:
move y18n to ESM.I'm happy to land this as an improvement after this PR.module ends up being a fairly ridiculouswith the decision not to yet ship typings, we get the unpacked size down to396.3k
, is there anything we can do to reduce this size?327.7 kB
and the packed size to78.7 kB
. It would be good to reduce this more, but it's a start:* I've started minifying the
build/index.cjs
output; this gets us down to248kb
, this is reasonable given the current published version is230kb
.* @mikeal convinced me that the annoyance of a minified build probably isn't worth the reduced package size, let's stick with the
327.7kb
for now.* by removing comments from the build target, without minifying, the target size becomes
unpacked size: 286.3 kB
, this is very close to the current published size of231kb
.Notable Breaking Changes:
require('yargs/yargs')
will work, whereasrequire('yargs/yargs.js')
will not.