Open mmis1000 opened 3 years ago
Good question!
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:
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)