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
The semantic of x::ext:name( seems incompatible with tree shaking after transpile if the the import and x::ext:name( got trasnpiled individually.
import * as ext from 'someOtherModule'
ExtInvoke(ext, 'name', x, args)
There is no way for any tool chain after it to realize that only ext.name is used instead of the whole ext.
Although the transpiler is still possible to do it if they are transformed at same time
(by just assume ext[SymbolExtension] do not exist because it is a module and emit different output)
The text was updated successfully, but these errors were encountered:
Actually tree shaking is one of the important use cases of this proposal.
First, ad-hoc extension methods and accessors are very friendly to tree shaking, it could solve size issue of many libraries (could be splitted into core and some extensions).
There could be a import ::{x, y, z} from 'module' syntax to import extension methods and declare x, y, z as ad-hoc extension methods/accessors in current module. This syntax is not included in the README just because it's not the core part of this proposal and could be separate to a follow-on proposal. I will improve the document to cover that soon.
Second, for x::ext:name, the behavior is delegated by ext. I would expect there will be three types in practice:
customized extension: by definition it can't and no need to apply tree shaking;
fine-grained static extension: the methods/accessors in it are highly related and sharing code, which means tree shaking can do little for it;
coarse-grained static extension: just a namespace, normally is re-exports of many fine-grained static extension. As u said, we need tools do static analysis and transform it to fine-grained static extensions. It would look like babel-plugin-lodash, but in a more general way.
The semantic of
x::ext:name(
seems incompatible with tree shaking after transpile if the theimport
andx::ext:name(
got trasnpiled individually.There is no way for any tool chain after it to realize that only
ext.name
is used instead of the wholeext
.Although the transpiler is still possible to do it if they are transformed at same time
(by just assume
ext[SymbolExtension]
do not exist because it is a module and emit different output)The text was updated successfully, but these errors were encountered: