Given
const anInstance = new Plugin({ a: 'path' })
Is it possible to retrieve the arguments passed to the instance?
anInstance./* some method */ === [{ a: 'path' }]
// or
someWrapper(anInstance) === [{ a: 'path' }]
Constraints:
- You are not allowed to modify the internal workings of
Plugin
: consider it as an external dependency. Plugin
can accept multiple arguments of any type.You cannot store the initial arguments in an external variable like this:
const config = { a: 'path' } const anInstance = new Plugin(config)
Context: My goal is to test a webpack plugin configuration. For instance:
module.exports = {
plugins: [
new wepback.DllPlugin({
name: '[name]',
path: path.join(buildDir, '[name].json'),
})
]
}
I aim to verify the configuration provided to DllPlugin. The third restriction is in place to avoid exporting the configuration for each plugin solely for the purpose of testing.
If there's no straightforward way to accomplish my initial objective, I may have to resort to exporting those configurations as I currently see no alternative means of accessing them.