Skip to content

[@rollup/plugin-node-resolve]: Should not consider node modules with trailing slash as built-in. #1211

@philfontaine

Description

@philfontaine

Expected Behavior

node modules with trailing slash should not be resolved as built-in, as explained in this comment nodejs/readable-stream#391 (comment)

I can't find the supporting docs to confirm that's how modules with forward slash should be resolved, but it seems to be this way since it breaks when it's required from the rollup bundle.

In my use case, I have a bunch of libs that depend on readable-stream@3 which contains require('string_decoder/').

Actual Behavior

The plugin thinks it's built-in because the is-builtin-module module returns true, so it does not resolve it.

image

Additional Information

To reproduce on the repo:

  1. yarn build
  2. node dist/index.js

To fix:

Seems like it just needs an endsWith('/') check on the module name to confirm that it's not built-in.

This maybe should be fixed upstream on the is-builtin-module package?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions