The following is a section from MDN's reference on the JavaScript import statement (with added emphasis):
Import a single export from a module
Given an object or value named
myExportwhich has been exported from the modulemy-moduleeither implicitly (because the entire module is exported) or explicitly (using theexportstatement), this insertsmyExportinto the current scope.import {myExport} from '/modules/my-module.js';
I know what it means for an object or value to have been exported from a module explicitly (using the export statement), but how can they be exported implicitly (impliedly without using an export statement)? What does it mean for an "entire module" to be exported?
I think the wording on this statement is somewhat confusing, assuming I understand it correctly. I think what they mean by "explicitly" would be explicitly named, e.g.
export { foo };
// or others
export var foo;
export function foo(){}
export class foo {}
export { foo } from "./foo.js";
whereas implicitly would be one that is not explicitly named, like
export * from "./foo.js";
where then doing
import { foo } from "./mod.js";
would work as long as mod is re-exporting foo from the foo.js file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With