gdad-s-river Well, unless you are in the leagues of Kyle Simpson, Douglas Crockford (I'm not referring to their intellectual prowess, but to the fact that these guys are insanely, pedantically obsessed about the tiny details of the language :)... you do it the piecemeal way. Meaning, picking up on whatever you need whenever you need it.
For example, with your question we just search the spec for the word imports and with a little dig in, we happen at a section dedicated to it; where we can see all the different ways and forms of writing import statements, and the corresponding rules/grammar of the language, in Backus-Naur Form.
Also, blog articles like these (speaking in the context of your question) β 2ality.com/2014/09/es6-modules-final.html β help a lot!
Sai Kishore Komanduri
Engineering an eGovernance Product | Hashnode Alumnus | I love pixel art
The difference is subtle. According to ES6 grammar, the
ModuleSpecifier("./components/Home"in your example) has to be aStringLiteralat compile time. This is so its structure can be statically analyzed; for static checking, optimization, etc...In other words, the "type" information of
ModuleSpecifiercannot depend on runtime information; which is what is happening (and the reason it fails) in the second example where you are using only anIdentifierName(stringVar).