ezolenko / rollup-plugin-typescript2

Rollup plugin for typescript with compiler errors.
MIT License
819 stars 71 forks source link

Retrieve plugin config from rollup config file? #461

Closed YonatanKra closed 1 year ago

YonatanKra commented 1 year ago

I'm using a 3rd party library that generates the config for me like this:

module.exports = function setVividRollupConfig(config) {
   const rpt2 = config.plugins.find(plugin => plugin.name === 'rpt2');
}

I want to use the plugin, but change only one option. Do I need to recreate the plugin? Or is there a way to change only one property in the configuration? Thanks!

agilgur5 commented 1 year ago

This is a question for the library you mention or Rollup, not rpt2 as it is not specific to rpt2 (this question applies to any plugin or configuration).

That being said, having maintained a wrapper library in the past (I was the longest solo maintainer of TSDX), I can tell you the answer to that is no. Plugins are functions and plugin config is a function argument. You cannot retrieve an argument of a function from outside of it or without a reference.

As such, if you are the maintainer of such a wrapper library and allow such overrides, it may make sense to export each plugin's config so that users can do plugin config merging. See also https://github.com/formium/tsdx/issues/635