Javascript - Exporting an Imported Binding


To re-export a binding that you imported into the module, use an export statement:

import { message } from "./moduleFile.js"; 
// some javascript code 
export message; 

Here, we imported the binding message from moduleFile.js and again exported the same binding.

You can do this in one statement like this,

export { multiply } from "./moduleFile.js"; 

You can re-export everything using the wildcard '*' like in the following example:

export * from "./moduleFile.js"; 

Here, everything from moduleFile.js is exported out of the current module, including the default value.

Related Topic