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

refactor: move argument methods out of the Command class #56

Merged
merged 13 commits into from
Nov 27, 2020

Conversation

merceyz
Copy link
Contributor

@merceyz merceyz commented Nov 21, 2020

What's the problem this PR addresses?

It's currently impossible for rollup and webpack to treeshake methods from classes so even if you're only using Command.String arguments all the other types will be included in the bundle

How did you fix it?

Move the argument methods out of the Command class

README.md Outdated Show resolved Hide resolved
@arcanis
Copy link
Owner

arcanis commented Nov 23, 2020

I'm still not fan of Argument (looks too much like arguments imo) 🤔 What about Option?

Apart from that it sounds good to me - perhaps a test to ensure that the tree shaking works would help potential regression (for example if we change the build system later on).

@merceyz merceyz force-pushed the merceyz/treeshake branch 2 times, most recently from 0a3cc9b to 333b39f Compare November 26, 2020 18:18
@merceyz
Copy link
Contributor Author

merceyz commented Nov 26, 2020

I'm still not fan of Argument (looks too much like arguments imo) thinking What about Option?

Sounds better and I totally agree 👍

perhaps a test to ensure that the tree shaking works would help potential regression (for example if we change the build system later on).

Test added 👍

@merceyz merceyz marked this pull request as ready for review November 26, 2020 18:18
const code = await result.generate({ format: 'esm' });

// @ts-expect-error - matchSnapshot is added by a plugin
expect(code.output[0].code.replace(/\r\n?/g, '\n')).to.matchSnapshot(this);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure snapshots are the right tool here, they will be very susceptible to changes 🤔

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated the test to instead check the added size; should have lower noise but still catch treeshaking problems.

@arcanis arcanis merged commit d54ccbe into arcanis:master Nov 27, 2020
@merceyz merceyz deleted the merceyz/treeshake branch November 27, 2020 10:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants