Created
June 16, 2017 13:40
-
-
Save kimniche/0c695b23b13d68017e4c5354b08259c9 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| // https://github.com/tc39/proposal-dynamic-import | |
| // http://2ality.com/2017/01/import-operator.html#loading-code-on-demand | |
| /** | |
| CURRENT STATE | |
| - top-level, not conditional, not able to be used in event handler, | |
| - not dynamic due, fixed module specifier (./dir/someModule) | |
| **/ | |
| import * as someModule from './dir/someModule.js' | |
| /** | |
| PROPOSAL | |
| - parameter can be any expression whose result can be coerced to a string (runtime-determined template strings) | |
| - function style, returns a promise | |
| - promise resolves after fetching, instantiating, and evaluating all of the module's dependencies & module itself | |
| - works for both scripts and modules | |
| - stage 3/candidate of tc39 process | |
| **/ | |
| const moduleSpecifier = './dir/someModule.js' | |
| import(moduleSpecifier) | |
| .then(someModule => someModule.foo()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment