Skip to content
This repository has been archived by the owner on May 11, 2023. It is now read-only.

Add rollup to build library. #22

Merged
merged 2 commits into from
Jan 15, 2020
Merged

Add rollup to build library. #22

merged 2 commits into from
Jan 15, 2020

Conversation

parkerziegler
Copy link
Contributor

This PR adds rollup to build renature for distribution on npm 🎉 I mostly just copied my configuration from next-urql since that's worked pretty well for me. That version is based off of urql's rollup config minus all the buble stuff. When we really want to shave more bytes we can bring in buble.

Any feedback is welcome! I haven't yet tested this, but will locally by symlinking a little sandbox app. Once we get that verified and get Travis in, I think we can release v0.1.0-rc.0. I'm going to use rc's on this project as a way of getting features out quick without needing to contemplate semver challenges for every tiny thing.

@kitten and @JoviDeCroock tagging you b/c you seem to have a knack for shaving bytes 😉

rollup.config.js Outdated
typescript({
typescript: require('typescript'),
}),
babel({ extensions, include: ['src/**/*'], exclude: 'node_modules/**' }),
Copy link

@JoviDeCroock JoviDeCroock Jan 15, 2020

Choose a reason for hiding this comment

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

The output that will come out is ES6 and won't be compatible some browsers (IE11 edge,...) this because tsconfig has ES2015 target and babel config has current node. bsconfig also seems to target ES6.

next-urql works correctly since it just passed in @babel/env without any options so it compiles down to the lowest target

If we're not planning on any custom transformations I'd say this is actually a pretty good case for microbundle usage can be seen here

They've stopped using bublé under the hood and transitioned to babel to support modern presets now as well (serve a modern bundle for a modern browser)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch! I didn't even notice that, but in looking at the non-minified build output now there definitely is some ES6 in there 😅 🆒 I'll give microbundle a shot!

Copy link

@kitten kitten Jan 15, 2020

Choose a reason for hiding this comment

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

I think it’s also worth just copying what we have for urql and combining it with what we have in Wonka (it already looks pretty similar)

Happy to send some commits over for that!

Basically, we use TypeScript to compile to certain helpers but not much, we then use Buble because it handles classes and spreading/rest operators the best, lastly we use Babel only for the “detail” work, like making sure that we have a unified helper for Object.assign

We also recently added closure-compiler but that can mangle code which may not be a good choice for renature.

We also make sure that our Rollup configs are always self-sufficient. So we define all configs in there on their own, and don’t rely on external Babel configs, etc

Copy link
Contributor Author

@parkerziegler parkerziegler Jan 15, 2020

Choose a reason for hiding this comment

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

I'd love to have you send over some commits if you have the time! I did manage to get microbundle working with pretty minimal effort, but I'd like to see what you have in mind. Agreed that I don't think it's quite worth getting full closure compiler stuff in just yet, but everything else sounds good 😄

Also FYI you may hit some TS errors when compiling. I got around them just now, but did find an issue with genType where it'll sometimes generate unused generics 😬 All of the fixes can be found in this commit: 85a0c9a

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants