Skip to content

Consider removing support for "default.js" directory lookups #15

@guybedford

Description

@guybedford

I really like that this proposal includes removing the file extension checks, as this will help get closer to code that works in browsers as well.

In line with this, it might be worth considering removing directory index support as well, although only for the "default.js" directory index.

The "default.js" would still be supported as the fallback package main though.

This way there is a forwards compatibility path to deprecating directory indexes entirely.

It would still allow CommonJS fallbacks (import "./x" -> "/x/index.js") allowing a gradual upgrade path of converting some package modules into ES modules while still supporting loading local CommonJS files.

The dual-mode subpath loads (import "pkg/x" v require("pkg/x")) can then need to be handled by import "pkg/x.js" and require('pkg/x.cjs.js') being distinct (or x.mjs and x.js).

@zenparsing would you be open to considering something along these lines? Can send a PR if you think it might be a worthwhile direction.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions