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

build: build with tsup and esbuild #2187

Merged
merged 1 commit into from
Sep 6, 2022
Merged

build: build with tsup and esbuild #2187

merged 1 commit into from
Sep 6, 2022

Conversation

denkristoffer
Copy link
Collaborator

@denkristoffer denkristoffer commented Sep 1, 2022

This PR moves Forma 36 from Parcel to esbuild (through tsup)

Note that the size limit GitHub action check is NOT going to go green on this PR since the build output is different than our main branch.

Why?

Mainly because we've been having issues with Parcel. Circle CI has often been throwing segmentation faults during the build process lately, requiring us to restart failed builds all the time. esbuild is super fast but it doesn't output types and it's not going to.

Instead we use tsup which is a wrapper around esbuild that DOES let us build types. It's still really fast, although the type compilation slows us down a bunch. Without it this PR can build all our components in about 17 seconds on my machine ⚡

What we might need to discuss

tsup builds everything to dist directories. I've currently set it to build a CommonJS file to dist/index.js and an ESM file to dist/index.mjs. esbuild does not let us build UMD. In my opinion that's fine, except we currently provide it, so to avoid breaking changes this PR still uses Microbundle to build the @contentful/f36-components package, which has the following output:

  • index.js – CommonJS
  • index.modern.mjs– Uses Microbundle's "Modern mode" which means it transpiles ESM with Babels – actually really cool 👍
  • index.mjs – ESM
  • index.umd.js – UMD

It would be good to drop UMD support when we can.

@vercel
Copy link

vercel bot commented Sep 1, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
forma-36 ✅ Ready (Inspect) Visit Preview Sep 6, 2022 at 7:29AM (UTC)

@changeset-bot
Copy link

changeset-bot bot commented Sep 1, 2022

⚠️ No Changeset found

Latest commit: cfe572c

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions
Copy link

github-actions bot commented Sep 5, 2022

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
f36-components 0 B (-100% 🔽) 0 ms (-100% 🔽) 0 ms (-100% 🔽) 0 ms
Modern 0 B (+100% 🔺) 0 ms (+100% 🔺) 0 ms (-100% 🔽) 0 ms
Module 0 B (+100% 🔺) 0 ms (+100% 🔺) 0 ms (-100% 🔽) 0 ms
UMD 0 B (-100% 🔽) 0 ms (-100% 🔽) 0 ms (-100% 🔽) 0 ms

@@ -1,31 +1,31 @@
export * from '@contentful/f36-collapse';
export * from '@contentful/f36-accordion';
Copy link
Contributor

Choose a reason for hiding this comment

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

A - Z 😁

minify: true,
platform: 'browser',
sourcemap: true,
target: 'es2016',
Copy link
Collaborator Author

@denkristoffer denkristoffer Sep 6, 2022

Choose a reason for hiding this comment

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

Maybe we can bump the target version to something newer, what do you think?

Copy link
Contributor

@bgutsol bgutsol Sep 6, 2022

Choose a reason for hiding this comment

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

I'd say we either use es6/es2015 - a kinda recommended standard for supporting most browsers, or we use any later version, but then there is no guarantee for support of all new es features in all modern browsers.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Our official stance is we support the latest 2 major versions of a browser. Other than Safari, this gives us a very modern base.

https://www.contentful.com/faq/about-contentful/#which-browsers-does-contentful-support

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

And consumers can always transpile the library themselves if they want to support something else.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

According to caniuse.com we can safely bump to es2020 – what do you think @bgutsol @massao ?

Copy link
Contributor

Choose a reason for hiding this comment

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

ok 👍

Copy link
Contributor

@burakukula burakukula left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@bgutsol bgutsol left a comment

Choose a reason for hiding this comment

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

NICE 🏅

@denkristoffer denkristoffer merged commit 31ae96f into main Sep 6, 2022
@denkristoffer denkristoffer deleted the build/esbuild branch September 6, 2022 11:27
denkristoffer added a commit to Wake1st/forma-36 that referenced this pull request Oct 5, 2022
@cf-remylenoir cf-remylenoir mentioned this pull request Oct 27, 2023
8 tasks
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.

4 participants