Closed ljharb closed 8 years ago
The promise is resolved with the module namespace (2.1.1, step 8.c.iv of
the current draft), i.e. x
will be the same as in
import * as x from 'path'
You can get the same behaviour as foo
and bar
with x.default
and
x.bar
, respectively.
Or by destructuring if you don’t require the live binding:
import('path').then(({default: foo, bar}) => { /* … */ })
It's the namespace object, so there's a bar
and a default
. It's equivalent of the imperative import * as path from 'path'
.
edit: @Ltrlg literally beat me by a second! :)
Seems like this has been answered.
Thanks for clarifying!
Any chance somebody can provide a link to "2.1.1, step 8.c.iv of the current draft"? I'm looking for a link to use for https://github.com/webpack/webpack.js.org/pull/1109.
Let's say I have a module that can be imported like so:
How can I use
import()
to get both foo and bar? In the following code: