News for hackers. Stuff that matters.
Re:NPM and NodeJS should do more to make ES Modules easy to use by eyelidlessness on Thursday June 20, 2024 @10:49AM (#40739362)
I tend to agree, but I’ve found it mostly doesn’t matter as I stopped typing import statements almost altogether. I type a reference to the thing I want to import, in the place I want to use it, choose a suggestion from the editor, and let the editor write the import statement as a side effect. It only doesn’t work when dealing with aliases, and even then only when something isn’t cached yet.
Re:NPM and NodeJS should do more to make ES Modules easy to use by eddd-ddde on Thursday June 20, 2024 @12:49PM (#40740721)
You can type the real name, import it with autocomplete, then rename the symbol (f2), which creates the alias.
Re:NPM and NodeJS should do more to make ES Modules easy to use by eyelidlessness on Thursday June 20, 2024 @02:44PM (#40741849)
I should’ve been more clear that I meant import specifier aliases. Eg in TypeScript, this is often determined by `paths` in tsconfig.json. It may also be controlled by `imports` in package.json, or any number of other tools and configs.
Re:NPM and NodeJS should do more to make ES Modules easy to use by paulddraper on Thursday June 20, 2024 @02:35PM (#40741757)
That doesn't work so well for default or wildcard imports.

(I'd argue that default + wildcard imports are bad, but ESM went out of its way to have them :shrug:)

Re:NPM and NodeJS should do more to make ES Modules easy to use by eyelidlessness on Thursday June 20, 2024 @02:45PM (#40741864)
It works okay for defaults IME, and yeah I generally avoid both but especially namespace (wildcard) imports.