You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, it appears that the resolveOnly property allows you to pass in an array of strings or regular expressions to validate if a plugin should be bundled in.
I had a use case where I wanted to bundle in everything except for certain dependencies. (node-rdkafka, sqlite3).
I would like to extend the resolveOnly property to allow developers more control.
This feature may already exist under another property, and if so, I apologize for the unnecessary recommendation.
Feature Proposal
While it is semi-possible to work around this by creating a complex regular expression to attempt to match everything except the given string, there are a few ways to introduce this.
Suggestion 1
I believe the best way to introduce this is to also allow resolveOnly to be a (plugin: string) => boolean function, thus allowing a developer to write something like:
By allowing the user to provide their own function, it gives them complete control to customize however they see fit.
Suggestion 2
While I believe suggestion 1 should be simple enough to implement, if you wanted to change just literally 1 type / 1 line of code, all you'd need to do is change out RegExp for { test: (plugin: string) => boolean }. I do not like this as much :)
…ly (#1152)
* feat(node-resolve): Add the ability to pass a function into resolveOnly to resolve issue #1150
* Add a missing piece of text to the readme.
Feature Use Case
Currently, it appears that the
resolveOnly
property allows you to pass in an array of strings or regular expressions to validate if a plugin should be bundled in.I had a use case where I wanted to bundle in everything except for certain dependencies. (
node-rdkafka
,sqlite3
).I would like to extend the
resolveOnly
property to allow developers more control.This feature may already exist under another property, and if so, I apologize for the unnecessary recommendation.
Feature Proposal
While it is semi-possible to work around this by creating a complex regular expression to attempt to match everything except the given string, there are a few ways to introduce this.
Suggestion 1
I believe the best way to introduce this is to also allow
resolveOnly
to be a(plugin: string) => boolean
function, thus allowing a developer to write something like:By allowing the user to provide their own function, it gives them complete control to customize however they see fit.
Suggestion 2
While I believe suggestion 1 should be simple enough to implement, if you wanted to change just literally 1 type / 1 line of code, all you'd need to do is change out
RegExp
for{ test: (plugin: string) => boolean }
. I do not like this as much :)My current workaround
In order to work around this, I ended up doing the following:
While this works for now, I know it's a hack and could break at any minute :P
If someone likes the idea, I'm 100% willing to file the MR!
The text was updated successfully, but these errors were encountered: