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

Only produce one build #1856

Merged
merged 2 commits into from
Feb 26, 2024
Merged

Only produce one build #1856

merged 2 commits into from
Feb 26, 2024

Conversation

ahuth
Copy link
Contributor

@ahuth ahuth commented Feb 23, 2024

Instead of producing 2 builds (cjs + esm), only produce one (cjs).

Why? Well, supporting dual builds is notoriously hard.

For my specific case, I'm working on making EDS support Vite in Remix

  • I'm finding it challenging to make it work
  • Especially getting Vite to understand EDS's internal imports
  • I think it'll be easier to have just a CJS build and take advantage of Vite's dependency pre-bundling to convert to ESM

ESM is the future, and one day (like this year sometime) we should be able to use ESM in all our Remix apps and then change EDS to export esm modules directly.

TODO:

@ahuth ahuth requested a review from booc0mtaco February 23, 2024 20:48
@ahuth ahuth requested a review from a team as a code owner February 23, 2024 20:48
@ahuth
Copy link
Contributor Author

ahuth commented Feb 23, 2024

Dang, why commitlint failing 🤔

Copy link

codecov bot commented Feb 23, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.68%. Comparing base (f55f9cb) to head (be341c0).

Additional details and impacted files
@@            Coverage Diff             @@
##              v14    #1856      +/-   ##
==========================================
+ Coverage   92.61%   92.68%   +0.07%     
==========================================
  Files         148      148              
  Lines        2856     2856              
  Branches      776      776              
==========================================
+ Hits         2645     2647       +2     
+ Misses        195      192       -3     
- Partials       16       17       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Supporting both cjs and esm is painful. esm is the future, but let's simplify
the EDS build for now, and then update to esm at some point in the future.
Rollup already generates the type declarations.
@jeremiah-clothier
Copy link
Contributor

Dang, why commitlint failing 🤔

Yeahhh I haven't gotten around to fixing this. I think commit messages with ' cause a parsing error

"build:clean": "rm -rf lib/",
"build:declarations": "tsc --emitDeclarationOnly --project tsconfig.build.json",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Rollup is already producing type definitions, so this step is redundant. The types generated by each step are exactly the same.

preserveModulesRoot: 'src',
sourcemap: true,
interop: 'auto',
},
Copy link
Contributor Author

@ahuth ahuth Feb 23, 2024

Choose a reason for hiding this comment

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

For posterity: there's an interesting thing here (including in the current EDS) where rollup is tree shaking out index.js files, but leaving the types for them...

So for example, the lib/Button directory ends up looking like this:

lib/Button
  Button.js
  Button.d.ts
  index.d.ts <- There's an index.d.ts, but no corresponding index.js!

But, crucially, the import/export statements in the output are such that everything still works.

Basically, when doing import {Button} from 'eds'

  • Node or bundlers load Button.js directly
  • TypeScript thinks you're loading Button through index.js (which doesn't exist)
  • But everything still works

Just an oddity I noticed and wanted to note.

We could stop that behavior by adding treeshake: false to the rollup config. Doing that results in everything lining up, but prints some warnings and I'm not sure if there are any ramifications or not.

See rollup/rollup#3916

Copy link
Contributor

Choose a reason for hiding this comment

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

@ahuth we can create a ticket to disable tree-shaking and to fix the warnings, if that's the right direction to go for now? thoughts?

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 idea. I'll create it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

https://czi-tech.atlassian.net/browse/EFI-1643

Right now it's in the Medley epic. If there's somewhere better let me know.

Copy link
Contributor

@booc0mtaco booc0mtaco left a comment

Choose a reason for hiding this comment

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

LGTM. Should be trivial to modify/revert if we discover any problems with this one as well before merging back to next

@ahuth ahuth merged commit 67d4d29 into v14 Feb 26, 2024
8 checks passed
@ahuth ahuth deleted the ah-one-build branch February 26, 2024 15:50
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.

3 participants