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

Support functions in plugins array #251

Open
jdalton opened this issue Oct 24, 2020 · 0 comments
Open

Support functions in plugins array #251

jdalton opened this issue Oct 24, 2020 · 0 comments

Comments

@jdalton
Copy link

jdalton commented Oct 24, 2020

Newer versions of '@rollup/plugin-node-resolve' don't export a traditional default module.exports = pluginFunc any more so the pattern of require(pluginId) doesn't work. Instead it has a .default property on its export. It would be nice to be able to support plugins like '@rollup/plugin-node-resolve' without resorting to a custom plugin wrapper. Maybe it could be solved by allowing a function to be passed:

import { nodeResolve } from '@rollup/plugin-node-resolve'
// ...
plugins: [nodeResolve]

or by checking for the .default property but that might be brittle. Maybe:

let plugin = require(id);
if (typeof plugin !== 'function' && typeof plugin.default === 'function') {
  plugin = plugin.default;
}
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

No branches or pull requests

1 participant