optimism icon indicating copy to clipboard operation
optimism copied to clipboard

feat(ci): Add esm exports to sdk

Open roninjin10 opened this issue 2 years ago • 18 comments

  • Add tsup to build esm modules for packages sdk depends on.
  • Update the package exports to include extension to reduce ambiguity
  • In general the old build is unchnaged. Typescript generates the cjs exports as before we just more explicitly target the build outputs now
  • We also build esm and include those imports. This maximizes compatibility with all build tools
  • As a bonus this will fix source maps

We should add this to all packages

image

Failing check fails on develop image

Other failing checks also fail on develop https://github.com/ethereum-optimism/optimism/pull/4848

roninjin10 avatar Feb 03 '23 18:02 roninjin10

🦋 Changeset detected

Latest commit: 935ffce7d97f5c0bc3582aff358dee6622617226

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@eth-optimism/sdk Minor
@eth-optimism/chain-mon Patch
@eth-optimism/message-relayer Patch

Not sure what this means? Click here to learn what changesets are.

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

changeset-bot[bot] avatar Feb 03 '23 18:02 changeset-bot[bot]

Current dependencies on/for this PR:

  • develop
    • PR #4839 Graphite 👈
      • PR #4846 Graphite

This comment was auto-generated by Graphite.

roninjin10 avatar Feb 03 '23 18:02 roninjin10

Perhaps we could merge this after https://github.com/ethereum-optimism/optimism/pull/4778?

tynes avatar Feb 03 '23 20:02 tynes

@tynes agreed this one is trying to fix a P0 bug for gateway but I want to look really quick on monday to see if I can do this in a simpler so this pr has less urgency to land

roninjin10 avatar Feb 04 '23 00:02 roninjin10

SDK only exports cjs and something about how we formatted the package.json makes some build tools unable to recognize it.

Trying to understand better, what does 'something' refer to in this line, can you point me to it? I am trying to understand what prevent us from using the module as a cjs in the gateway, haven't we been using it in that way till now?.

Perhaps this PR try to address different things and we could perhaps takle first the fix that is blocking deployments on the gateway (P0) and then as a follow-up to address P1s like switching to a more modern build system, source maps ecc.

@tynes what you think?

nickbalestra avatar Feb 06 '23 19:02 nickbalestra

Contracts needs to not bundle

roninjin10 avatar Feb 06 '23 20:02 roninjin10

(btw not testing locally until ci passes then I'm testing with gateway and doing some extra due dillegence. So it's expected this will fail a bunch more times

tsc still needs to emit for contracts is the next one

roninjin10 avatar Feb 06 '23 20:02 roninjin10

removed bundling we are now at the point where we are going to be ready to go soon most likely

roninjin10 avatar Feb 06 '23 20:02 roninjin10

@nickbalestra @tynes this change is additive not subtractive or changing. The old build still exists with no changes. The only difference is we are adding esm outputs

roninjin10 avatar Feb 06 '23 20:02 roninjin10

removing clean is actually a better fix to my contract bundling issue but going to keep both since the change to bundling derisks this pr a tad via making the old buildsystem unchanged instead of mostly unchanged

roninjin10 avatar Feb 06 '23 20:02 roninjin10

Trying to understand better, what does 'something' refer to in this line, can you point me to it?

@nickbalestra I can't I would have to debug to figure it out but debugging is unnecessary since just doing everything cannonical best practice way confirmed fixes the issue

roninjin10 avatar Feb 06 '23 20:02 roninjin10

I am trying to understand what prevent us from using the module as a cjs in the gateway, haven't we been using it in that way till now?.

Webpack config because create react app bloats webpack handles this issue well. A more complicated change to gateway would also be able to handle it well. Core pain we are feeling is the pain of thinking we were deployed when we weren't for many many weeks

roninjin10 avatar Feb 06 '23 20:02 roninjin10

Perhaps this PR try to address different things and we could perhaps takle first the fix that is blocking deployments on the gateway (P0) and then as a follow-up to address P1s like switching to a more modern build system, source maps ecc.

This has been my strategy from minute 1. What you are seeing here is the simplist lowest risk solution

roninjin10 avatar Feb 06 '23 20:02 roninjin10

Testing baseline what ci is passing/failing in this pr is here https://github.com/ethereum-optimism/optimism/pull/4848

roninjin10 avatar Feb 06 '23 23:02 roninjin10

This PR is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar Feb 22 '23 02:02 github-actions[bot]

Don't close as stale we really need this so source maps work and debugging the SDK can be done without spending 10 minutes putting console logs into a compiled node_modules/@eth-optimism/sdk/dist/Foo.js file

roninjin10 avatar Feb 22 '23 15:02 roninjin10

Also need this because a minority but still large chunk of users will need special build tooling to use all our packages.

roninjin10 avatar Feb 22 '23 15:02 roninjin10

Just wondering if you are planning on continuing this @roninjin10, would like to help get your code merged

tynes avatar Feb 22 '23 19:02 tynes

Hey @roninjin10! This PR has merge conflicts. Please fix them before continuing review.

mergify[bot] avatar Feb 28 '23 14:02 mergify[bot]

This PR is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar Mar 15 '23 01:03 github-actions[bot]

Hey @roninjin10! This PR has merge conflicts. Please fix them before continuing review.

mergify[bot] avatar Mar 26 '23 17:03 mergify[bot]

@tynes this has actually been ready to go in the entire time unless there are changes requested

roninjin10 avatar Mar 26 '23 18:03 roninjin10

Deploy Preview for opstack-docs canceled.

Name Link
Latest commit 935ffce7d97f5c0bc3582aff358dee6622617226
Latest deploy log https://app.netlify.com/sites/opstack-docs/deploys/64208e7a4a0c9800086687da

netlify[bot] avatar Mar 26 '23 18:03 netlify[bot]

Keeping this in draft don't trust this until I manually test everything again plus a tsup config appears to have gone missing rebasing

roninjin10 avatar Mar 26 '23 18:03 roninjin10

This PR is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar Apr 11 '23 01:04 github-actions[bot]

going to do this but to every package instead of just the ones gateway uses post bedrock

roninjin10 avatar Apr 11 '23 02:04 roninjin10