rollup / plugins

🍣 The one-stop shop for official Rollup plugins
MIT License
3.63k stars 585 forks source link

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

Open e965 opened 1 year ago

e965 commented 1 year ago

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
PBK-B commented 10 months ago

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

e965 commented 10 months ago

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

PBK-B commented 10 months ago

@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.