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

refactor(project): remove theme-preval.js #3243

Merged
merged 6 commits into from
May 15, 2023

Conversation

joshblack
Copy link
Member

@joshblack joshblack commented May 1, 2023

The theme-preval.js file is used alongside babel-plugin-preval to generate an object containing all the tokens and values from @primer/primitives. For an example of its output, see: https://unpkg.com/browse/@primer/react@35.25.1/lib-esm/theme-preval.js

This approach introduces some limitations, namely that:

  • It couples our project to babel and makes it difficult to switch to alternative bundlers (like TypeScript, esbuild, swc, etc)
  • It mixes CommonJS with ESM in a way that makes it difficult to use tools like api extractor to analyze our declaration files
  • It generates the largest file in our bundle at ~149kB uncompressed, 13.8kB gzip

The experiment here looks into removing our dependency on preval so that:

  • We can explore other bundlers in the future
  • We can simplify our bundler and babel setup by removing babel-plugin-preval along with transforms we use for mapping the emitted CommonJS to ESM
  • We can rely on tools like api extractor to extract types instead of manually preparing them for documenting and for CI tooling

From a user perspective, this change should not be noticeable. Even though @primer/primitives is currently emitting CommonJS, the size difference should be minimal as we were including the package contents in the emitted theme-preval.js file

@changeset-bot
Copy link

changeset-bot bot commented May 1, 2023

⚠️ No Changeset found

Latest commit: 3f03daa

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
Contributor

github-actions bot commented May 1, 2023

size-limit report 📦

Path Size
dist/browser.esm.js 115.85 KB (+19.87% 🔺)
dist/browser.umd.js 117.67 KB (+21.17% 🔺)

@joshblack joshblack temporarily deployed to github-pages May 1, 2023 17:41 — with GitHub Actions Inactive
@github-actions github-actions bot temporarily deployed to storybook-preview-3243 May 1, 2023 17:41 Inactive
@joshblack joshblack added the skip changeset This change does not need a changelog label May 1, 2023
@joshblack joshblack temporarily deployed to github-pages May 1, 2023 17:57 — with GitHub Actions Inactive
@github-actions github-actions bot temporarily deployed to storybook-preview-3243 May 1, 2023 17:57 Inactive
@joshblack joshblack changed the title [Experiment] refactor(project): remove theme-preval.js refactor(project): remove theme-preval.js May 4, 2023
@joshblack joshblack marked this pull request as ready for review May 4, 2023 20:50
@joshblack joshblack requested review from a team, langermank, siddharthkp and colebemis May 4, 2023 20:50
@joshblack
Copy link
Member Author

cc @colebemis would love your feedback here! 👀

@github-actions github-actions bot requested a deployment to storybook-preview-3243 May 4, 2023 20:55 Abandoned
@joshblack joshblack temporarily deployed to github-pages May 4, 2023 20:57 — with GitHub Actions Inactive
@github-actions github-actions bot temporarily deployed to storybook-preview-3243 May 4, 2023 20:57 Inactive
Copy link
Contributor

@colebemis colebemis left a comment

Choose a reason for hiding this comment

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

Since we're not using polished, I think removing theme-preval.js is a good idea 👍 This will make all our lives a lot easier. No more cache issues! 🎉

@joshblack joshblack deleted the experiment/remove-theme-preval branch May 15, 2023 19:41
broccolinisoup added a commit that referenced this pull request May 16, 2023
This was referenced May 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip changeset This change does not need a changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants