Last active
September 4, 2019 18:13
-
-
Save dherman/b15badb4afffa75230a8 to your computer and use it in GitHub Desktop.
using new.target-style syntax for providing metadata and relative dynamic import to modules
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// import default export | |
import.default("Spinner").then(Spinner => { | |
widget.appendChild(new Spinner(...)) | |
}); | |
// import namespace object | |
import.namespace("fs").then(fs => { | |
fs.readFile(...) | |
}); | |
// import local metadata | |
import.metadata.filename | |
import.metadata.address |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// import default export | |
import.default(["Spinner", "Slider", "Gallery"]).then([Spinner, Slider, Gallery] => { | |
... | |
}); | |
// vs | |
Promise.all(["Spinner", "Slider", "Gallery"].map(import.default)).then([Spinner, Slider, Gallery] => { | |
... | |
}); | |
// import namespace object | |
import.namespace(["fs", "util", "collections"]).then([fs, util, collections] = { | |
... | |
}); | |
// vs | |
Promise.all(["fs", "util", "collections"].map(import.namespace)).then([fs, util, collections] => { | |
... | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment