`types` are wrong configed
- Rollup Plugin Name: All plugins
- Rollup Plugin Version:
16.0.1 - Rollup Version:
4.39.0 - Operating System (or Browser): macOS
- Node Version: v22.14.0
- Link to reproduction (⚠️ read below):
https://arethetypeswrong.github.io/?p=%40rollup%2Fplugin-node-resolve%4016.0.1
Expected Behavior
ESM should be has its own definition.
Actual Behavior
Import resolved to a CommonJS type declaration file, but an ESM JavaScript file.
Additional Information
We have a big project ahead with going ESM for all plugins - Node 18 is now out of LTS and 20 and 22 support clean ESM require in commonjs.
@shellscape It's about types, not runtime codes.
think about it carefully:)
think about it carefully:)
No idea what's your meaning, when using type: module + tsconfig with module: node16:
commonjs.default is required by TypeScript, but it's wrong. commonjs.default is undefined.
error TS2349: This expression is not callable.
Type 'typeof import("/Users/JounQin/Workspaces/GitHub/pkgr/node_modules/@rollup/plugin-commonjs/types/index")' has no call signatures.
107 const cjs = (sourceMap: boolean) => commonjs({ sourceMap })
I have to use the following for workaround
https://github.com/un-ts/pkgr/blob/a4acfbcab1a22236605f56c7b4355a63bc656877/packages/rollup/src/config.ts#L108
import { __importStar } from 'tslib'
const cjs = (sourceMap: boolean) =>
__importStar(commonjs).default({ sourceMap })
When we ship only esm the types will be only esm and this will self-resolve. Last I'll be commenting on this issue until the esm migration starts.
@shellscape Nope, .d.ts and .d.mts should be splitted for require and import, it's a common mistake
for TypeScript packages, I can raise a PR for them.
We're going to use tshy. Please chill.
We're going to use tshy. Please chill.
@shellscape Then why you're saying:
When we ship only esm the types will be only esm and this will self-resolve.
It doesn't required to be ESM only.
Are there any news on this thread? The issue still exists today and it does not allow to use Typescript for Rollup configs
@just-boris please show restraint in adding noise. your reply doesn't contribute anything useful. Follow the repo's activity if you wan to know what's going on in the repo. Further noise will result in the issue being locked.