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

Proposal for simplifying build system #267

Open
hamstu opened this issue Nov 30, 2020 · 2 comments
Open

Proposal for simplifying build system #267

hamstu opened this issue Nov 30, 2020 · 2 comments
Assignees

Comments

@hamstu
Copy link
Contributor

@hamstu hamstu commented Nov 30, 2020

Overview

I propose we change the build system for @bufferapp/ui to use Rollup, remove the generated docs site, and switch to Storybook for component documentation.

📹 Watch video overview (10 min)


🗞️ Move to Rollup

Rollup is popular module bundler most commonly used for packaging libraries. Right now in @bufferapp/ui we use Babel by itself to transpile the source code into CommonJS and then Publish on NPM. Rollup won't replace Babel, as it is a tool which, like webpack, uses Babel to transpile and then produce a bundled file.

It's highly configurable, but also very simple, which allows for a lot of control for library authors. For example, it's trivial to produce two builds; your classic CommonJS version (const foo = require('foo')) and an ES Modules version (import foo from 'foo'). The latter when processed by webpack makes it easier for our apps to do tree-shaking / dead code elimination; i.e., smaller bundles!

Many well known 3rd party libraries are bundled with Rollup (Vue, Ember, Preact, D3, Three.js, Moment, and many more) and so I believe we'll also greatly benefit from the community knowledge and support here.

🗑️ Remove the BDS documentation

With BDS documentation being moved into Notion, we no longer need to build or maintain our own copy in this library. The code for this custom-built documentation system – while very powerful – is very complex in code and configuration. By removing it we can reduce cognitive load on engineers and focus more on building and packaging a best-in-class component library.

Once removed I propose we use Storybook. Storybook has matured a lot over the last few years and I think it will easily meet our needs for component building / testing, as well as developer-focused documentation. A script could likely be written to transform existing documentation files to the Storybook 'stories' format, making the migration easier.

Same as the current docs site, we could have the Storybook automatically deployed via Github Pages to the BDS site URL.

Improved Testing

This might be more of a nice-to-have, but I also love React Testing Library (props to @MayaUribe for introducing that in Publish). Some of our current tests are focused very much on testing implementation details and could be improved with a better approach.

[Spike] Proof of concept

I did a quick spike on bundling @bufferapp/ui with Rollup, which you can see here if you're interested: https://github.com/bufferapp/ui-proposal

@gmzjuliana
Copy link
Contributor

@gmzjuliana gmzjuliana commented Dec 2, 2020

hey @hamstu thanks for putting this together 🌮 I love your proposal, it sounds like it addresses a lot of pain points we currently face (the bundling, inability to tree shake, document website and minimal testing) and super elegantly too! I was just checking out the new versions of storybook the other day and I'd be excited to use it for this 😄 For the testing, I think there are quite a few fans of react testing library on the team so keen to check it out as well!

I wish I had some questions or things to add but this is all very complete 🎉

@MayaUribe
Copy link
Contributor

@MayaUribe MayaUribe commented Dec 3, 2020

Hi there @hamstu!

First off, I love the way you laid out this proposal over here! 🤩 I'll copy this format in the future 😂

I really like your proposal overall, +1 to all that @gmzjuliana said, I love the idea of using storybook, and as you mentioned in the video, the latest versions have lots of new and very useful features, we can potentially test more things as we build components by using the addons, like a11y, and coming from Publish where we use it, I can really see the value of adding it, especially if we are moving the documentation to Notion.

And last but not least, testing 🐙🧪
⚡️ YES! ⚡️ I think this repo it's an ideal candidate to use react-testing-library because it's a strictly component-based project -we don't handle stores- and it would be extremely straightforward to start testing. Because this is a project consumed by all our products having good tests here is a great one to have.

I'd love to see this happening 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
8 participants
You can’t perform that action at this time.