TypeScript configuration for Rollup

381 Views Asked by At

I'm using Rollup with Typescript with the following configuration:

{
    "compilerOptions": {
        "target": "ESNext"
    }
}

This causes problems with importing plugins. For example, when I import the node-resolve plugin using:

import resolve from '@rollup/plugin-node-resolve';

I am given the error:

Cannot find module '@rollup/plugin-node-resolve'. Did you mean to set the 'moduleResolution' option to 'nodenext', or to add aliases to the 'paths' option?

I then added the following line to my tsconfig.json under compilerOptions:

"moduleResolution": "NodeNext"

This allows me to successfully import the plugins, however if I try an use the plugin with resolve() I am given the following error (import path trimmed):

This expression is not callable. Type 'typeof import(".../node_modules/@rollup/plugin-node-resolve/types/index")' has no call signatures.

The only way I have found of solving this is by setting moduleResolution to Node, however this is not recommended. What is causing this problem and what is the best way to solve it without resorting to using Node for moduleResolution?

0

There are 0 best solutions below