cli icon indicating copy to clipboard operation
cli copied to clipboard

chore: migrate entrypoint of CLI to esm modules

Open lukasholzer opened this issue 3 years ago โ€ข 9 comments

๐ŸŽ‰ Thanks for submitting a pull request! ๐ŸŽ‰

Summary

As the esm module migration is such a big thing I try to split it up into small chunks and try to use both cjs and esm in a grace period to do a incremental migration.


For us to review and ship your PR efficiently, please perform the following steps:

  • [x] Open a bug/issue before writing your code ๐Ÿง‘โ€๐Ÿ’ป. This ensures we can discuss the changes and get feedback from everyone that should be involved. If you`re fixing a typo or something that`s on fire ๐Ÿ”ฅ (e.g. incident related), you can skip this step.
  • [x] Read the contribution guidelines ๐Ÿ“–. This ensures your code follows our style guide and passes our tests.
  • [x] Update or add tests (if any source code was changed or added) ๐Ÿงช
  • [x] Update or add documentation (if features were changed or added) ๐Ÿ“
  • [x] Make sure the status checks below are successful โœ…

A picture of a cute animal (not mandatory, but encouraged)

lukasholzer avatar Jan 28 '22 11:01 lukasholzer

๐Ÿ“Š Benchmark results

Comparing with c2f4f1dcac42ea12f1810c18a849ac73a3138e7c

Package size: 364 MB

โฌ†๏ธ 0.73% increase vs. c2f4f1dcac42ea12f1810c18a849ac73a3138e7c

^  360 MB  360 MB  360 MB  360 MB  360 MB  360 MB  360 MB  360 MB  360 MB  360 MB  360 MB  360 MB  364 MB 
โ”‚   โ”Œโ”€โ”€โ”    โ”Œโ”€โ”€โ”    โ”Œโ”€โ”€โ”    โ”Œโ”€โ”€โ”    โ”Œโ”€โ”€โ”    โ”Œโ”€โ”€โ”    โ”Œโ”€โ”€โ”    โ”Œโ”€โ”€โ”    โ”Œโ”€โ”€โ”    โ”Œโ”€โ”€โ”    โ”Œโ”€โ”€โ”    โ”Œโ”€โ”€โ”    โ”Œโ”€โ”€โ”  
โ”‚   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |โ–’โ–’|  
โ”‚   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |โ–’โ–’|  
โ”‚   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |โ–’โ–’|  
โ”‚   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |โ–’โ–’|  
โ”‚   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |โ–’โ–’|  
โ”‚   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |โ–’โ–’|  
โ”‚   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |โ–’โ–’|  
โ”‚   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |โ–’โ–’|  
โ”‚   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |โ–’โ–’|  
โ”‚   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |โ–’โ–’|  
โ”‚   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |โ–’โ–’|  
โ”‚   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |โ–’โ–’|  
โ”‚   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |โ–’โ–’|  
โ”‚   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |โ–’โ–’|  
โ”‚   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |โ–’โ–’|  
โ”‚   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |โ–’โ–’|  
โ”‚   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |โ–’โ–’|  
โ”‚   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |โ–’โ–’|  
โ”‚   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |โ–’โ–’|  
โ”‚   |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |  |    |โ–’โ–’|  
โ””โ”€โ”€โ”€โ”ดโ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”ดโ”€โ”€>
    T-12    T-11    T-10    T-9     T-8     T-7     T-6     T-5     T-4     T-3     T-2     T-1      T    
Legend
  • T-30 (c2f4f1dcac42ea12f1810c18a849ac73a3138e7c): 361 MB
  • T-29 (cc2c6ddbb457fbde044b8097afbb2d8f8281d5cb): 361 MB
  • T-28 (3d40fe1f6c8a4a877579acd80a9230226b931656): 361 MB
  • T-27 (1fcb0e32390081c8ec45d1a31d32a8367cc98b64): 361 MB
  • T-26 (e76355677415300eb3c69be17aeba76c177ec53d): 361 MB
  • T-25 (be0bb11a080dc91ae456f84f2a76fe4d1bfa3410): 361 MB
  • T-24 (d6d99d3bc32451df1d961df683cc06c0323808a8): 361 MB
  • T-23 (d5d421d0cc10b449d5c5d8470bac7e9fec6cdfc7): 361 MB
  • T-22 (432774f3ede4b97e0b990b81e60d595dde520147): 360 MB
  • T-21 (93b64cf7c2d8beb82d893b114037c57a80892f94): 360 MB
  • T-20 (cd7af03c024a412e12fb0bd5295f4fe0977c94e0): 360 MB
  • T-19 (c8281ec992c958a053d297b21894a0b8f137cd2b): 360 MB
  • T-18 (54040d846342d4c9f774cfcc74862fbdc94dad49): 360 MB
  • T-17 (19815158e0f4ce32bf73990c53fa6bd6dda34e39): 360 MB
  • T-16 (434cdb79e98994ec0e273959c9b1d8809dd86971): 360 MB
  • T-15 (c89d81a5d64cdd73e84d7ad8c8cdb9abed990d40): 360 MB
  • T-14 (0550e604582265caa5f949c9f0fa96b984ead581): 360 MB
  • T-13 (f1c4d1017acba380048c06efa98b51b967f763d2): 360 MB
  • T-12 (50b3483efa03203859ff49583e3c91c90b1999f2): 360 MB
  • T-11 (df33dd0c14c14dce32b34c6b9bc5b5897970075d): 360 MB
  • T-10 (a41323f4f8827c228664de9ea38607b4c80efc09): 360 MB
  • T-9 (b2b0faa4a66cdc0d6bcbe51ef5ebed1dd8936efd): 360 MB
  • T-8 (7d6566953ae6fb3c04992fcd84e204ffe452750e): 360 MB
  • T-7 (1c8968d5ebb50f7fc781b92e37fc3aa3e29f3b33): 360 MB
  • T-6 (40b1cf9b45e78d07817829323320ea8a90c476e4): 360 MB
  • T-5 (39eb031d75436074bf109732847f4ecc995fe061): 360 MB
  • T-4 (8720854eb1efc6c0c6e3c3a54bb4709035c21756): 360 MB
  • T-3 (7bb0322fd71469e1d258ee573e376ff946c506f0): 360 MB
  • T-2 (4e5eb1a12915fad63a433d1b6eb7d7d549473d88): 360 MB
  • T-1 (3d7a4e1b6fd82546d9fa9ff6b90ba58be09f8221): 360 MB
  • T (current commit): 364 MB

github-actions[bot] avatar Jan 28 '22 11:01 github-actions[bot]

CI tests are currently failing. I am wondering if maybe the new tests setup will help with this?

ehmicky avatar Feb 03 '22 18:02 ehmicky

Hi @lukasholzer, I left a small comment.

Also in order to trigger a release we'll need to merge this as fix or feat.

erezrokah avatar Feb 04 '22 11:02 erezrokah

This PR currently has a merge conflict. Please resolve this and then re-add the automerge label.

kodiakhq[bot] avatar Feb 04 '22 15:02 kodiakhq[bot]

Always great to see more things migrating to ESM! Has this PR fallen under the radar?

janosh avatar Mar 03 '22 07:03 janosh

@janosh sadly I had to put it on the side due to a shift of resources and priorities but If you want to continue feel free to!

I would love to see this effort going further!

lukasholzer avatar Mar 03 '22 07:03 lukasholzer

I'm not familiar with the code base so I could only take over if it's minor stuff. What's left to do beside merge conflict resolution and addressing the comment by @erezrokah?

janosh avatar Mar 03 '22 07:03 janosh

@janosh that should be all - having passing checks (e2e tests and unit tests) should provide the confidence

lukasholzer avatar Mar 03 '22 11:03 lukasholzer

Basically we try to split it from top to bottom to migrate small parts for small parts as you can import commonjs in esm.

But vice verca is way more complicate through dynamic imports we can go from top to bottom and move the files to .mjs that import some commonjs.

The downside is that we have to move named imports then to default imports and destruct it later but that is all.

lukasholzer avatar Mar 03 '22 11:03 lukasholzer

Closing as a lot of this is now already in the main branch

danez avatar Dec 06 '22 16:12 danez