Skip to content

pathFilter (or some new API) should support implementations of exports #253

@SimenB

Description

@SimenB

In lieu of this module supporting exports out of the box, it would be awesome if consumers could use its existing capabilities (packageFilter, pathFilter etc.) to implement support for exports on the consumer side.

I have experimented a bit with this, and from what I can tell there are 2 issues:

  1. resolve adds index if a directory is specified (
    return loadAsFileSync(path.join(x, '/index'));
    ). This can potentially cause issues in the case index is not specified by the user as changing it to . (which is what a directory means in exports) is not necessarily a safe operation. Not sure how to mitigate this in a way that's backwards compatible.
  2. I tried to use pathFilter which works great for require('some-module/thing'), but it doesn't work for require('./some-thing') from within a module. Relative imports within a module isn't restricted by exports, but pathFilter cannot know if the resolution request is for a relative file or not. A solution here is maybe to include a flag saying if it's relative within the package or not?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions