endo icon indicating copy to clipboard operation
endo copied to clipboard

support .ts in bundle-source

Open turadg opened this issue 1 year ago • 2 comments

What is the Problem Being Solved?

TypeScript is very popular and the JsDoc syntax for it has many limitations compared to .ts. (Some described in https://github.com/Agoric/agoric-sdk/issues/5760)

A developer who wants to write in .ts can transpile before bundling with Endo, but that increases work, room for error, and the transformation chain to audit.

Description of the Design

bundle-source would bundle .ts files directly by transparently transforming them to .js using something like @swc/wasm-typescript used in Node's new .ts support.

Security Considerations

Transforming code can make it harder to audit the bundled code. But conversely, type annotations can mislead in an audit.

Given the complexities of audits and the trade-offs with runtime constraints, solving auditing will require purpose-built tooling: https://github.com/endojs/endo/issues/1656

Scaling Considerations

Test Plan

Compatibility Considerations

Upgrade Considerations

turadg avatar Aug 17 '24 14:08 turadg

Striping TS types and purely replacing with whitespace may cause semantic JS difference, and some cases need special handling. Any mechanism that support TS in bundle source need to correctly handle these cases and not change the runtime semantics.

Some pointers:

mhofman avatar Aug 19 '24 18:08 mhofman

Pure ESM has so many advantages... just being able to do <script type="module" src="..."></script> with an import map... TS destroys nice ESM and also makes code unreadable. Simple one liner JS functions that are easy to document with JSDoc become type monsters where you can't even differ between real code and type sugar any longer without starring at ASCII soup for 5 minutes.

For what? The beginning of the end.

kungfooman avatar Aug 20 '24 07:08 kungfooman

This in TS 5.7 might help,

  • https://github.com/microsoft/TypeScript/issues/59597

And this may be a better option than the WASM:

  • https://bloomberg.github.io/ts-blank-space/

turadg avatar Sep 27 '24 15:09 turadg