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

Change to preconstruct to build #1204

Merged
merged 17 commits into from
Apr 5, 2021

Conversation

alexanderchan
Copy link
Contributor

@alexanderchan alexanderchan commented Oct 2, 2020

As mentioned by @jxnblk in #668 (comment) there were some points related to TS and microbundle. This PR is just to show the changes that could be done to adopt preconstruct.tools that used by emotion that could be considered as an alternative build system.

On my machine it drops the library build time from about 60s to 10s (cached after the initial warm build) using yarn prepare

It has a few other benefits in addition to the speed of the build:

  • if yarn run preconstruct dev is run, the dev experience imho is improved in that dependent modules dist files link to the live version of the src files so that one doesn't need to wait for a re-build. Also, direct navigation to the original src file is possible from the other package
  • typescript config defaults to the top level tsconfig with no additional setup but can still be overridden, similarly babel defaults to the top level babel.config.js. Sub packages don't require having any build specific configuration

the preconstruct docs do a good job of highlighting more of their why.

Note that I left the development setup as yarn dev:init rather than setting up "postinstall": "preconstruct dev" but that's something to consider adding if we want to go forward with this type of change.

We could also remove the prepare in favour of a postinstall script since we don't technically need to build every time we install, saving us another 10s when we install.

@alexanderchan
Copy link
Contributor Author

closing but hopefully gives some ideas on an alternative build to microbundle

@hasparus
Copy link
Member

hasparus commented Nov 5, 2020

Thanks for the PR, @alexanderchan!

I'm reopening this. Lerna is a bit of a pain right now, and migration towards Preconstruct and Changesets seems like a great idea. Contributing to Emotion is way more enjoyable than contributing to Theme UI right now.

@atanasster @lachlanjc could skim over this PR and tell me what you think?

@hasparus hasparus reopened this Nov 5, 2020
@alexanderchan
Copy link
Contributor Author

@hasparus you're welcome! We've been enjoying using theme-ui and preconstruct for our builds (and not needing a watch step for dev) for our component library based on theme-ui so hopefully it works out here for you guys.

Thanks for mentioning changesets, I'll definitely have to look into that too. Let me know if there's anything else I can help with.

We'll probably need some help to resolve type issues from the typecheck. They appear to be valid and I'm not sure if we want to relax the types to be strict: false, but that will help with some of the errors.

@hasparus
Copy link
Member

hasparus commented Nov 8, 2020

We'll probably need some help to resolve type issues from the typecheck. They appear to be valid and I'm not sure if we want to relax the types to be strict: false, but that will help with some of the errors.

Oh, typecheck errors are actually something I don't suck at :D I'm gonna take a look.

@lachlanjc lachlanjc added the internal Changes only affect the internal API label Dec 3, 2020
@pkieltyka
Copy link

hey all, just FYI preconstruct v2 is out which irons out a few kinks from v1, the updates will be very minor to your PR here, but thought I'd mention it.

@hasparus hasparus closed this Dec 14, 2020
@hasparus hasparus deleted the branch system-ui:develop December 14, 2020 08:53
@hasparus hasparus reopened this Dec 14, 2020
@vercel
Copy link

vercel bot commented Dec 14, 2020

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/systemui/theme-ui/cjlkp9ktq
✅ Preview: https://theme-ui-git-add-preconstruct.systemui.vercel.app

@hasparus hasparus changed the base branch from master to develop December 14, 2020 09:10
@nandorojo nandorojo mentioned this pull request Dec 17, 2020
7 tasks
@hasparus hasparus merged commit 9107006 into system-ui:develop Apr 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
internal Changes only affect the internal API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants