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
It would be great if we could come up with some ways to enable better introspection and debuggability in prod builds for createCommand. The transform that createCommand does right now is irreversible and the choice of prod vs. dev build infects user code because the type information is thrown away in the constructor.
This leaves the decision of whether to provide a type or not to the caller. Might increase the bundle size by probably about 1kb if we do nothing else?
Compression options
If we want to sacrifice DX in the same way that we do now, but in a way that only affects library code, we can have a transform like transform-error-messages simply remove the argument in prod builds.
If a particularly optimization-focused caller really wants to conditionally throw away the type, they can already do that pretty easily with their own wrapper, a ternary at each call site, or a transform (as above).
Another compression option here would be to have something like transform-error-messages that replaces longer strings with shorter ones, e.g. ':1' and we would expect that any command that has a type starting with ':' should be found in an out-of-bundle-table (that the dev tools would ship with). If we were byte-conscious we could use a more dense encoding than decimals.
A slight modification to the above would be to change the type to type?: string | number which would let us have an out-of-bundle table and serial id transform, to save a few uncompressed bytes for each command (since numbers don't have 2 characters of syntax overhead).
Thanks for describing it. We can indeed use transform table here for built in commands (and extension would have it) and then let user to decide how to deal with custom commands on their own.
It would be great if we could come up with some ways to enable better introspection and debuggability in prod builds for
createCommand
. The transform thatcreateCommand
does right now is irreversible and the choice of prod vs. dev build infects user code because the type information is thrown away in the constructor.I suggest we change the implementation to an unconditional
return {type};
This leaves the decision of whether to provide a type or not to the caller. Might increase the bundle size by probably about 1kb if we do nothing else?
Compression options
If we want to sacrifice DX in the same way that we do now, but in a way that only affects library code, we can have a transform like
transform-error-messages
simply remove the argument in prod builds.If a particularly optimization-focused caller really wants to conditionally throw away the type, they can already do that pretty easily with their own wrapper, a ternary at each call site, or a transform (as above).
Another compression option here would be to have something like transform-error-messages that replaces longer strings with shorter ones, e.g. ':1' and we would expect that any command that has a type starting with ':' should be found in an out-of-bundle-table (that the dev tools would ship with). If we were byte-conscious we could use a more dense encoding than decimals.
A slight modification to the above would be to change the type to
type?: string | number
which would let us have an out-of-bundle table and serial id transform, to save a few uncompressed bytes for each command (since numbers don't have 2 characters of syntax overhead).RE #2942
/cc @StyleT @acywatson @thegreatercurve
The text was updated successfully, but these errors were encountered: