If we specify a default export:
export class Foo {}
export default Foo;
then we can omit curly braces during import (as noted in this answer):
import { Foo } from "foo"; // becomes:
import Foo from "foo";
That's fine, but is there any non-stylistic reason to prefer one over the other in particular cases? For example, is there some convention, or is one incompatible with certain tools, or does one have a different meaning?
(Based on this discussion and others, my understanding is that export default might have arisen as a way of handling the export of a single, primary object (like $), which is now handled by import * as foo from "foo". Also, it seems the default import syntax does not enforce consistent naming (import fooAlias from "foo"), while the standard import import { fooAlias } from "foo" would be a compilation error unless the alias was explicit (Foo as fooAlias). Apart from that, I haven't been able to find much information on when I should use one over the other.)
import * as $ from "jquery";would not work - you want$to be a function not a namespace object.import { $ } from "jquery"be any different? When would I use one over the other? Isexport defaultever required at all?default, soimport { default as $ } from 'jquery'is equivalent toimport $ from 'jquery'.import { jQuery as $ } …), and you need to remember the name of the export - and repeat it, as it will be the same everywhere. No, default exports are nowhere required, they're just a convienience.