Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(node-resolve): Add the ability to pass a function into resolveOnly #1152

Merged
merged 2 commits into from
Apr 11, 2022
Merged

feat(node-resolve): Add the ability to pass a function into resolveOnly #1152

merged 2 commits into from
Apr 11, 2022

Conversation

TotalTechGeek
Copy link
Contributor

@TotalTechGeek TotalTechGeek commented Mar 27, 2022

Rollup Plugin Name: node-resolve

This PR contains:

  • bugfix
  • feature
  • refactor
  • documentation
  • other

Are tests included?

  • yes (bugfixes and features will not be merged without tests)
  • no

Breaking Changes?

  • yes (breaking changes will not be merged unless absolutely necessary)
  • no

If yes, then include "BREAKING CHANGES:" in the first commit message body, followed by a description of what is breaking.

List any relevant issue numbers:
#1150

Description

Currently, the resolveOnly property allows you to pass in an array of strings or regular expressions to validate if a module should be bundled in.

I had a use case where I wanted to bundle in everything except for certain dependencies. (node-rdkafka, sqlite3).

I've extended the resolveOnly property to allow developers more control. With this PR, it should be possible to pass in a function into nodeResolve to override the check that takes place, thus allowing something like the following:

function forbid (...modules) {
    const set = new Set(modules)
    return module => !set.has(module)
}

nodeResolve({
    resolveOnly: forbid('sqlite3', 'node-rdkafka')
})

Sorry, something went wrong.

Verified

This commit was signed with the committer’s verified signature.
TotalTechGeek Jesse Mitchell
…ly to resolve issue #1150

Verified

This commit was signed with the committer’s verified signature.
TotalTechGeek Jesse Mitchell
Copy link
Member

@tjenkinson tjenkinson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lgtm! I think the empty array behaviour is the same but just wanted to double check

packages/node-resolve/src/index.js Show resolved Hide resolved
@shellscape
Copy link
Collaborator

thanks!

@shellscape shellscape merged commit f561ec1 into rollup:master Apr 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants