Skip to content

Support functions in plugins array #251

@jdalton

Description

@jdalton

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;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions