You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Endo is often bundled for use in runtime environments that constrain bundle size. Sometimes these bundles exceed the limits (e.g. Agoric/agoric-sdk#9900).
A significant source of bytes is comments. If comment could be stripped at the discretion of the builder of the bundle, that would reduce the size significantly.
E.g. in a recent contract bundle the patternMatchers.js file was 59KB. That’s a little less than the raw 62KB of the source in Endo
but still quite a lot more than it would be without comments. Terser with defaults drops it to 19KB. If we cut Endo dep size to 1/3 or even 2/3 we’d buy a lot more time on bundle size limits.
Description of the Design
Provide an option to the bundle-source command to turn comments to whitespace.
It should preserve line numbers so that stack traces in runtime match up with the original source code. However it does not need to preserve character positions per line.
Unlike conventional minifiers, it should not perform any alterations to the actual code,
Provide an option to the bundle-source command to turn comments to whitespace.
Quick note that striping comments requires in some case to insert a semi colon to preserve the semantics of ASI. It's not always purely replacing with whitespace.
My intention is to replace the interior of comments: erase all characters before newlines, replace all characters on the final line with spaces, preserve all newlines. That covers @gibson042’s subtle case of comments containing newlines serving as newlines for ASI.
What is the Problem Being Solved?
Endo is often bundled for use in runtime environments that constrain bundle size. Sometimes these bundles exceed the limits (e.g. Agoric/agoric-sdk#9900).
A significant source of bytes is comments. If comment could be stripped at the discretion of the builder of the bundle, that would reduce the size significantly.
E.g. in a recent contract bundle the
patternMatchers.js
file was 59KB. That’s a little less than the raw 62KB of the source in Endobut still quite a lot more than it would be without comments. Terser with defaults drops it to 19KB. If we cut Endo dep size to 1/3 or even 2/3 we’d buy a lot more time on bundle size limits.
Description of the Design
Provide an option to the
bundle-source
command to turn comments to whitespace.It should preserve line numbers so that stack traces in runtime match up with the original source code. However it does not need to preserve character positions per line.
Unlike conventional minifiers, it should not perform any alterations to the actual code,
While implementing this, it may be helpful to consider how one would extend it to
Security Considerations
Stripping comments can make it harder to audit the bundled code. But conversely, comments can mislead in an audit.
Given the complexities of audits and the trade-offs with runtime constraints, solving auditing will require purpose-built tooling: #1656
Scaling Considerations
Test Plan
Compatibility Considerations
Upgrade Considerations
The text was updated successfully, but these errors were encountered: