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

reduce ambient imports and drop maxNodeModuleJsDepth #9373

Merged
merged 26 commits into from
May 20, 2024
Merged

Conversation

turadg
Copy link
Member

@turadg turadg commented May 15, 2024

refs: #6512

Description

  • further improves recent TypeScript best practices doc
  • turns the zoe/exported.js into a .d.ts so it can be used in triple-slash references
  • adopts that and stops the runtime imports of zoe/exported (progress on End runtime imports of types modules #6512)
  • remove the maxNodeModuleJsDepth now that the types resolve without
  • burns down imports so there are no inter-package runtime imports of typedefs. (leaving just a bit for End runtime imports of types modules #6512)

I put commit checkpoints of type coverage to guard against any regression, though I took them out again when merging

Security Considerations

Scaling Considerations

Documentation Considerations

Testing Considerations

Upgrade Considerations

Copy link

cloudflare-workers-and-pages bot commented May 15, 2024

Deploying agoric-sdk with  Cloudflare Pages  Cloudflare Pages

Latest commit: 8573fad
Status: ✅  Deploy successful!
Preview URL: https://6417c264.agoric-sdk.pages.dev
Branch Preview URL: https://ta-no-ts-search.agoric-sdk.pages.dev

View logs

@turadg turadg force-pushed the ta/use-.ts branch 2 times, most recently from a925bba to d371cb3 Compare May 16, 2024 16:31
Base automatically changed from ta/use-.ts to master May 16, 2024 18:18
@turadg turadg changed the title drop maxNodeModuleJsDepth reduce ambient imports and drop maxNodeModuleJsDepth May 17, 2024
@turadg turadg requested review from mhofman and dckc May 17, 2024 19:22
Copy link
Member

@dckc dckc left a comment

Choose a reason for hiding this comment

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

good stuff so far...

@@ -2,7 +2,6 @@ import chalk from 'chalk';
import { makePspawn } from './helpers.js';

/// <reference types="@endo/captp/src/types.js" />
/// <reference types="@agoric/swingset-vat/exported.js" />
Copy link
Member

Choose a reason for hiding this comment

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

removing that file seems like a breaking change

for example, consider a dapp that imports it.

comment belongs on the deleted file, but I don't see how to do that.

Copy link
Member Author

Choose a reason for hiding this comment

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

true. in practice we know all the code that relies on it:
https://github.com/search?q=org%3AAgoric+swingset-vat%2Fexported&type=code

https://github.com/Agoric/dapp-pegasus/blob/f3b8f0400e9921a7497b08385d2b3aa609829182/api/deploy.js#L9

that looks ok to me to drop but if you want a BREAKING CHANGE commit I'm game. the package hasn't hit version 1 yet so it won't be a major version bump

Copy link
Member

Choose a reason for hiding this comment

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

In order to accommodate 3rd party developers, yes, I think a BREAKING CHANGE commit is worthwhile.

For example:

https://github.com/Kryha/KREAd/blob/c5c5d9e4b7cc370b0adfadc407ee7199c2064c98/agoric/contract/src/kreadKit.js#L43

Copy link
Member Author

@turadg turadg May 20, 2024

Choose a reason for hiding this comment

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

None of the exported.js imported in that repo have been removed https://github.com/search?q=repo%3AKryha%2FKREAd%20exported&type=code

But a few have and I it'll be faster to do this than convince you otherwise ;-) I'll amend the commit message before I merge. I do wish we didn't have to modify commit history in order to note such things

Copy link
Member

Choose a reason for hiding this comment

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

oh. I misread this PR as deleting @agoric/zoe/exported.js.

Comment on lines -28 to +26
* @property {Installation} installation
* @property {import('./zoeService/utils.js').Installation<any>} installation
Copy link
Member

Choose a reason for hiding this comment

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

I'd like to understand the motivation for this change better.

Copy link
Member Author

Choose a reason for hiding this comment

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

the Installation it was referencing before is available only ambiently. That one was just an alias for what's here

packages/zoe/src/types-ambient.js Outdated Show resolved Hide resolved
Comment on lines -4 to +3
// XXX ambient types runtime imports until https://github.com/Agoric/agoric-sdk/issues/6512
import '@agoric/zoe/exported.js';
import '@agoric/zoe/src/contracts/exported.js';
/// <reference types="@agoric/zoe/exported" />
Copy link
Member

Choose a reason for hiding this comment

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

👏

I'm curious about the impact on bundle sizes for these contracts.

Copy link
Member Author

@turadg turadg May 17, 2024

Choose a reason for hiding this comment

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

before

    22135 bundle-econCommitteeCharter-js-meta.json
  1166313 bundle-econCommitteeCharter.js
    28423 bundle-fluxAggregatorKit-js-meta.json
  1534301 bundle-fluxAggregatorKit.js
    28121 bundle-psm-js-meta.json
  1496517 bundle-psm.js

after

    20614 bundle-econCommitteeCharter-js-meta.json
  1105853 bundle-econCommitteeCharter.js
    26868 bundle-fluxAggregatorKit-js-meta.json
  1474173 bundle-fluxAggregatorKit.js
    26566 bundle-psm-js-meta.json
  1435797 bundle-psm.js
bundle abs drop rel drop
psm 60,720 4.1%
fluxAggregatorKit 98,504 60,128 3.9%
econCommitteeCharter 60,460 5.2%

Copy link
Member Author

Choose a reason for hiding this comment

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

at 2844e7c

  1104273 bundle-econCommitteeCharter.js
  1472593 bundle-fluxAggregatorKit.js
  1434213 bundle-psm.js
bundle abs drop rel drop
econCommitteeCharter 62,040 5.3%
fluxAggregatorKit 61,708 4.0%
psm 60,720 4.0%

@@ -1,7 +1,7 @@
// @jessie-check

// XXX ambient types runtime imports until https://github.com/Agoric/agoric-sdk/issues/6512
import '@agoric/zoe/exported.js';
Copy link
Member

Choose a reason for hiding this comment

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

prune the XXX comment too?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll do that. Any other requested changes? I'm putting this in to R4R since all the tests are passing. (I don't know what's up with the Cloudflare build but it works for me locally)

@turadg turadg marked this pull request as ready for review May 17, 2024 20:44
@turadg turadg requested a review from dckc May 17, 2024 23:25
Copy link
Member

@mhofman mhofman left a comment

Choose a reason for hiding this comment

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

Looks like a nice cleanup, and I'm surprised we can simply use an exported.d.ts files that does imports of .js files which do the actual ambient side effects.

import '@agoric/zoe/exported.js';
/// <reference path="./types.js" />
/// <reference types="@agoric/zoe/exported" />
/// <reference path="./types-ambient.js" />
Copy link
Member

Choose a reason for hiding this comment

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

I'm confused, I thought you couldn't reference .js files?

Copy link
Member Author

Choose a reason for hiding this comment

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

for reference types, but path works.

Copy link
Member

Choose a reason for hiding this comment

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

How does this file work in the first place? I don't see it referenced anywhere

Copy link
Member Author

Choose a reason for hiding this comment

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

hm, yeah, some cruft. I'll remove

import '@agoric/ertp/exported.js';
import '@agoric/store/exported.js';
import '@agoric/swingset-vat/exported.js';
// Dummy file for .d.ts twin to declare ambients
Copy link
Member

Choose a reason for hiding this comment

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

That seems like a cheap trick, what's the drawback of doing that everywhere?

Copy link
Member Author

Choose a reason for hiding this comment

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

Do you mean carrying out the best practice written here? https://github.com/Agoric/agoric-sdk/blob/master/docs/typescript.md#dts-modules

Or something more specific? If it's about exported.js, I'd like to move away from that pattern altogether. Zoe is just recalcitrant

@turadg turadg requested a review from mhofman May 18, 2024 14:41
Copy link
Member

@dckc dckc left a comment

Choose a reason for hiding this comment

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

ok... I think I get it now.

Though #6512 doesn't seem to be scheduled, I presume addressing it is worth the potential release branch complications. cc @gibson042 @mhofman

I'd be more comfortable if the schedule for releasing from master (#9252) were more clear. Again, I presume this progress is worth any downsides. cc @ivanlei

@turadg turadg added the automerge:rebase Automatically rebase updates, then merge label May 20, 2024
@mergify mergify bot merged commit 980ff41 into master May 20, 2024
63 checks passed
@mergify mergify bot deleted the ta/no-ts-search branch May 20, 2024 20:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge:rebase Automatically rebase updates, then merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants