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

Convert from CJS only to ESM or Hybrid #1354

Closed
jmrossy opened this issue Nov 30, 2022 · 5 comments · Fixed by #3531
Closed

Convert from CJS only to ESM or Hybrid #1354

jmrossy opened this issue Nov 30, 2022 · 5 comments · Fixed by #3531

Comments

@jmrossy
Copy link
Contributor

jmrossy commented Nov 30, 2022

Restructure core dist so factories are tree-shakeable

enables tree shaking of all the ABIs, deployers, and utils that apps (like the warp UI) don't actually use. And more broadly, CJS is being deprecated.

Revamp libraries in ESM so that integrating for partners is a better experience, so that their bundlers can discard unused packages

All SDK users will pull in 850Kb of factories, 200kb of which are for Test

Screen Shot 2022-11-30 at 14 13 16

@yorhodes
Copy link
Member

yorhodes commented Dec 1, 2023

maybe deployer code should be in a different package

@jmrossy
Copy link
Contributor Author

jmrossy commented Dec 1, 2023

maybe deployer code should be in a different package

@yorhodes Yes that's a good idea, but it won't help much unless we also update the TS output module target to ESM (from commonJS). The CLI already uses the ESM, we'd want to do the same for all the others

@jmrossy
Copy link
Contributor Author

jmrossy commented Dec 5, 2023

Possibly blocked by NomicFoundation/hardhat#3385

@jmrossy jmrossy moved this to Backlog in Hyperlane Tasks Dec 5, 2023
@avious00 avious00 moved this from Backlog to Next Sprint in Hyperlane Tasks Dec 11, 2023
@avious00 avious00 changed the title Restructure core dist so factories are tree-shakeable Convert from CJS only to ESM or Hybrid Jan 9, 2024
@jmrossy jmrossy moved this from Next Sprint to Backlog in Hyperlane Tasks Jan 15, 2024
@nambrot nambrot added the sdk label Mar 1, 2024
@jmrossy
Copy link
Contributor Author

jmrossy commented Mar 7, 2024

Copied from #2553, which is closed as duplicate:

The build settings for the monorepo JS packages don't support tree-shaking, which how bundlers drop code apps don't use. Meaning every consumer of the utils/core/sdk packages will bundle every lib we use, every contract factory, and all our code into their app, even if they don't use parts of it. Currently our bundle contribution is 1.5Mb plus all our transitive lib deps. Not horrible, but problematic as we start adding libs for more protocols. To fix this we'd need to change our TS and package.json settings to produce more modern build output.
Requirements

Builds output both commonJS and ES6 module output
Package.json files are updated to properly reference the different types
The output libs work with most popular bundlers/frameworks including webpack 5, rollup, next.js, esbuild, etc.
Test projects are created to ensure the libs work and don't regress

@avious00 avious00 moved this from Backlog to Next Sprint in Hyperlane Tasks Mar 13, 2024
@jmrossy
Copy link
Contributor Author

jmrossy commented Mar 25, 2024

Semi-related: cosmos/cosmjs#904 (comment)

@jmrossy jmrossy moved this from Next Sprint to Sprint in Hyperlane Tasks Mar 27, 2024
@jmrossy jmrossy moved this from Sprint to In Review in Hyperlane Tasks Apr 4, 2024
jmrossy added a commit that referenced this issue Apr 9, 2024
### Description

- Reconfigure tsconfig and package.json for the utils, core, sdk, and helloworld packages
- Update imports to use ESM syntax
- Add patch for typechain to address [issue 898](dethcrypto/TypeChain#898)

### Drive-by changes

Improve package Readme content

### Related issues

Fixes #1354

### Backward compatibility

No: package consumers using CJS will need to modify their imports or
update to ESM. See [this popular
gist](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c#pure-esm-package)
for details.

### Testing

- [x] CI test coverage which invokes a lot of code via the CLI e2e
- [x] Manually test in Warp UI by copying packages
- [x] Publish beta packages and test in a few popular bundlers
@github-project-automation github-project-automation bot moved this from In Review to Done in Hyperlane Tasks Apr 9, 2024
yorhodes pushed a commit that referenced this issue Apr 14, 2024
### Description

- Reconfigure tsconfig and package.json for the utils, core, sdk, and helloworld packages
- Update imports to use ESM syntax
- Add patch for typechain to address [issue 898](dethcrypto/TypeChain#898)

### Drive-by changes

Improve package Readme content

### Related issues

Fixes #1354

### Backward compatibility

No: package consumers using CJS will need to modify their imports or
update to ESM. See [this popular
gist](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c#pure-esm-package)
for details.

### Testing

- [x] CI test coverage which invokes a lot of code via the CLI e2e
- [x] Manually test in Warp UI by copying packages
- [x] Publish beta packages and test in a few popular bundlers
letonchanh pushed a commit to letonchanh/hyperlane-monorepo that referenced this issue Apr 25, 2024
### Description

- Reconfigure tsconfig and package.json for the utils, core, sdk, and helloworld packages
- Update imports to use ESM syntax
- Add patch for typechain to address [issue 898](dethcrypto/TypeChain#898)

### Drive-by changes

Improve package Readme content

### Related issues

Fixes hyperlane-xyz#1354

### Backward compatibility

No: package consumers using CJS will need to modify their imports or
update to ESM. See [this popular
gist](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c#pure-esm-package)
for details.

### Testing

- [x] CI test coverage which invokes a lot of code via the CLI e2e
- [x] Manually test in Warp UI by copying packages
- [x] Publish beta packages and test in a few popular bundlers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

4 participants