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

[TypeScript] Module resolution doesn't work in rollup.config.ts when using modern project settings #1662

Open
jdharrisnz opened this issue Jan 10, 2024 · 3 comments

Comments

@jdharrisnz
Copy link

Expected Behavior

Compile as usual. Use npm run bug in my repl to see what happens.

Actual Behavior

Produces errors when compiling:

npx rollup --config rollup.config.ts --configPlugin typescript
loaded rollup.config.ts with warnings
(!) Plugin typescript: @rollup/plugin-typescript TS2349: This expression is not callable.
  Type 'typeof import("/home/runner/rollup-plugin-repro-typescript-import/node_modules/@rollup/plugin-typescript/types/index")' has no call signatures.

Additional Information

Key ingredients are:

  • "type": "module" in package.json
  • "moduleResolution": "NodeNext" or "Node16" in tsconfig.json
  • A rollup config file written in ESM format and TypeScript

The workaround is to use a JavaScript config file, so this is really the smallest of inconveniences, but it's something to fix nonetheless.

@07akioni
Copy link

Same issue encountered.

@thisisanto
Copy link

Alternatively

// @ts-expect-error see https://github.com/rollup/plugins/issues/1662
commonjs(),

Which again isn't nice, but allows you to keep using a TS config file.

@Arnesfield
Copy link

Might be off-topic, but here is another workaround to keep the typings:

// rollup.config.ts
import _eslint from '@rollup/plugin-eslint';
import _typescript from '@rollup/plugin-typescript';

// NOTE: remove once import errors are fixed for their respective packages
const eslint = _eslint as unknown as typeof _eslint.default;
const typescript = _typescript as unknown as typeof _typescript.default;

// ...
export default {
  // ...
  plugins: [eslint(), typescript()]
};

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

4 participants