Tree shaking and partial imports.
DylanPiercey opened this issue · 8 comments
Is this something that can be done here?
I figured something like
import('lodash', 'map').then(map => ...)
Just curious if this has been thought of.
You meant import(…
instead of Import(…
right?
@Mouvedia was on a phone, but I fixed that.
I don't really understand this issue. What bug are your reporting with the current proposal? Are you trying to create another proposal? If so this isn't the place for it.
@domenic I am merely asking if there is something synonymous with
import { map } from 'lodash'
In this proposal.
You can do import('lodash').then(ld => ld.map)
.
@domenic I am aware of that. Was just curious since obviously that doesn't support tree shaking.
From what I understand, tree-shaking is a nonstandard way of using modules supported by some ahead-of-time tooling that turns those modules into non-modules. It's not really something that informs the design of the language, but instead is something for those creating such tools to work through on their own.
@DylanPiercey to be precise here, if you have a tool that can do tree shaking on something like:
import * as foo from "foo";
foo.x('do something');
Assuming that foo exports a lot more than just x
, then it is very likely that the same tool can work the same way with import("foo")
.