Is there a difference between exporting like this:
export const Foo ...
and this
const Foo ...
export { Foo }
Is there a difference between exporting like this:
export const Foo ...
and this
const Foo ...
export { Foo }
There is not really a difference, with the second approach you could just export a list of names:
After the
exportkeyword, you can uselet,const, andvardeclarations, as well as function or class declarations. You can also use theexport { name1, name2 }syntax to export a list of names declared elsewhere. Note thatexport {}does not export an empty object — it's a no-op declaration that exports nothing (an empty name list). - mdn web docs