plugins icon indicating copy to clipboard operation
plugins copied to clipboard

[typescript] Plugin does not convert native nodejs imports in d.ts files

Open e965 opened this issue 2 years ago • 3 comments

  • Rollup Plugin Name: @rollup/plugin-typescript
  • Rollup Plugin Version: 11.1.4
  • Rollup Version: 3.29.3
  • Operating System (or Browser): Windows 11
  • Node Version: v18.18.0
  • Link to reproduction: https://stackblitz.com/edit/rollup-repro-zaitva?file=dist%2Fmain.d.ts

Expected Behavior

Correct paths in .d.ts files (like in .js files)

Actual Behavior

The files contain the imports as they appear in the source files

Additional Information

package.json:

{
  ...
  "imports": {
    "#src*": {
      "default": [
        "./src/*",
        "./src/*.ts",
        "./src/*.tsx",
        "./src/*/index.ts",
        "./src/*/index.tsx"
      ]
    }
  },
  ...
}

src/main.ts:

import { testValue } from '#src/test';
export { testValue };

dist/main.js

export { testValue } from './test.js';

dist/main.d.ts

import { testValue } from '#src/test';
export { testValue };
//# sourceMappingURL=main.d.ts.map

e965 avatar Sep 29 '23 09:09 e965

I have the same problem. do you have any ideas at present? cc @shellscape

PBK-B avatar Nov 29 '23 12:11 PBK-B

@PBK-B Unfortunately, I still had to move the import declaration to paths in tsconfig, and use a rollup plugin based on tsc-alias.

e965 avatar Nov 30 '23 02:11 e965

@PBK-B Unfortunately, I still had to move the import declaration to paths in tsconfig, and use a rollup plugin based on tsc-alias.

@e965 Thank you. I also adopted the same solution yesterday and used tsc-alias to deal with it. If I have time, I can look at the code and maybe analyze the reason.

PBK-B avatar Nov 30 '23 05:11 PBK-B