Ability to specify import kind/name
Right now, imports are hardcoded as import * from './x', which generates a lot of boilerplate if there's only one export.
Particularly if you only have a default export, you get something like:
var __exports = {};
__export(__exports, {
default: () => __default
});
var __default = 'export goes here';
while it could just be:
var x = 'export goes here';
which is the behavior you get with import x from './x'.
Additionally, I'm using this in conjunction with esbuild-plugin-yaml, which generates even more overhead because every "export" essentially gets repeated. While this is not a common case, it does illustrate the problem rather well.
You could argue that esbuild should figure this out, but I think the plugin can also do a better job at understanding exports, be it with some help from the programmer.
One option would be to embed some config in the import glob:
import justTheDefaultExports from './stuff/*.js#default'
import foosAndBars from './named/*.js#foo,bar'
or the config could be prefixed instead of suffixed. Alternatively, this could be a good case for (nonstandard) import assertions, but I imagine that would take more parsing.
Just spitballing though. WDYT?
I've implemented this in my own take on this plugin: https://www.npmjs.com/package/esbuild-plugin-import-pattern