guybedford / ecmascript-modules-mode

ECMAScript Modules esm boundary proposal for Node.js
0 stars 0 forks source link

Default entry point? #5

Open GeoffreyBooth opened 5 years ago

GeoffreyBooth commented 5 years ago

What if a user’s entire package.json is just { "mode": "esm" }? Does the package have an implied "main" or default entry point, like how CommonJS defaults to index.js if "main" isn’t defined?

I assume we’re not providing a default, and basically it’s on the user to define an entry point if they expect their package to be importable. (Not all packages need to be importable, for example a user’s project that is never intended to be imported by something else, such as something generated via create-react-app.)

guybedford commented 5 years ago

I assume we’re not providing a default, and basically it’s on the user to define an entry point if they expect their package to be importable.

Exactly, it would just throw for no main found.

guybedford commented 5 years ago

(Unless we want to define a default behaviour for ESM?)

GeoffreyBooth commented 5 years ago

No, because a) we'd need to choose between index.mjs and index.js, and b) the idea of a default like that feels like the default folder root of CommonJS that we're not continuing in ESM.