In the current ECMAScript Specifications, Imports look something like this
import { Module } from "/Module.mjs";
I am not asking for a replacement for this, in fact ECMAScript's import system is one of the best ones. But many modules only have one import. Some examples of this include
import { Module } from "/Module1.mjs";
import DefaultModule from "/Module2.mjs";
import { ModuleTres as Module3 } from "/Module3.mjs";
My Solution is an import statement like Python or Java, like this
import "/Module1.mjs";
import "/Module2.mjs" as Mod2;
import "/Module2.mjs" as globalThis;
It would automatically create an object with the same name as the file name, but with some rules:
- Dashes are replaced with Underscores
- Spaces are replaced with Underscores
- Any JS Reserved word will cause an error if by itself
- Invalid Characters will cause an error
Using as will let you be able to choose what the import is called. To create a single export file, use export only instead of export or export default. For example:
export only {
property: 0,
method: (x) => x * 2 + 1
}