I'm reading through the ES6 import statement on the MDN docs.
I understand generally how it works, but wanting to dive deeper, I'm not understanding one aspect of the syntax.
As stated in the MDN syntax of import, these are all of the different way to import code into the current module/scope:
import defaultExport from "module-name";
import * as name from "module-name";
import { export } from "module-name";
import { export as alias } from "module-name";
import { export1 , export2 } from "module-name";
import { foo , bar } from "module-name/path/to/specific/un-exported/file";
import { export1 , export2 as alias2 , [...] } from "module-name";
import defaultExport, { export [ , [...] ] } from "module-name";
import defaultExport, * as name from "module-name";
import "module-name";
var promise = import("module-name");
What I'm trying to understand is the difference between these two lines:
import { export1 , export2 } from "module-name";
import { foo , bar } from "module-name/path/to/specific/un-exported/file";
Wouldn't both of those be exactly the same? We're not importing a default export, therefore we have to be importing named exports.
Why are they two separate syntax definitions?
And why does the second one have this:
from "module-name/path/to/specific/un-exported/file";