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

Bundles to Webpack when not needed #131

Closed
arietrouw opened this issue Nov 12, 2020 · 2 comments · Fixed by #137
Closed

Bundles to Webpack when not needed #131

arietrouw opened this issue Nov 12, 2020 · 2 comments · Fixed by #137

Comments

@arietrouw
Copy link

I am using the library as a compile-time type checking with TypeScript, but the way that the exports are done, the root .js file is included anyway in the bundle. Is there any way to just add the types to my project without the runtime support?

@Eyas
Copy link
Collaborator

Eyas commented Nov 13, 2020

The .js is only needed if you use enum values e.g. ActionStatusType.CompletedActionStatus.

I would expect that tree-shaking gets rid of that from the bundle if you don't use it.

I did consider using const enums for enumerations at some point (which are inlined by tsc), but these unfortunately don't play well with Babel.

TBH I've been considering making the backwards-incompatible change of simply forcing people to use string literals (which was enabled by #43), but was hoping tree-shaking worked for most people.

@Eyas
Copy link
Collaborator

Eyas commented Nov 25, 2020

I'm thinking more about this.

Even when minified, the size of the code here is 20kb. For strings that you're not really using.

The goal is for tree-shaking to be set-up on one's code and have all this be inlined. But it might be desirable not to depend on the user setting this up correctly.

The problem is the change is backwards-incompatible. I think the right call is:

  • In the upcoming version, mark all exported enum variables as @deprecated, and encourage users to use the string literal instead.
  • Release 0.8.0 which only incudes the inlined strings.

This was referenced Nov 25, 2020
@Eyas Eyas closed this as completed in #137 Nov 25, 2020
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 a pull request may close this issue.

2 participants