Skip to content

resolve #58

@AbhiPrasad

Description

@AbhiPrasad

We can replace resolve with built-ins starting Node 8.9.0 and above.

It pulls in a bunch of deps, and doesn’t support exports field and custom conditions (which is very common in modern JS apps).

image

For CJS you can use require.resolve. ESM is more tricky, you prob need https://www.npmjs.com/package/resolve.exports, but there is import.meta.resolve that was introduced with Node 20.6.0

Here's an example PR I opened up with rollup that does the ESM thing: rollup/plugins#1742 (I may have to change this to make it work with ESM, need more testing)

Here's an example PR (that tbh should be merged in to require-in-the-middle) that does the CJS port: nodejs/require-in-the-middle#25

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