add extensions to import specifier in dts files #1144
-
I'm shipping a dual package using the config like import { defineConfig } from '@rslib/core'
import type { LibConfig } from '@rslib/core';
export default defineConfig({
lib: (['esm', 'cjs'] as const).map<LibConfig>(format => ({
format,
bundle: true,
syntax: 'es2022',
dts: {
bundle: false,
},
outBase: 'src',
})),
source: {
tsconfigPath: './tsconfig.json',
},
output: {
cleanDistPath: true,
sourceMap: true,
target: 'node',
}
}) with package.json in {
"types": "module"
} and tsonfig in {
"compilerOptions": {
"module": "esnext"
"moduleResolution": "bundler"
}
} Found extensions is not be added according to the format // foo.d.cts
export interface Foo {}
// index.d.cts
import { Foo } from './foo'
// not import { Foo } from './foo.cjs' which causes a issue when consuming the package with tsconfig(>=5.8) with {
"compilerOptions": {
"module": "nodenext"
"moduleResolution": "nodenext"
}
} nodejs forces extensions for esm, so when tsc tries to resolve There are several answers for this issue I can do buy myself:
But is there any offically solutions from rslib? thx |
Beta Was this translation helpful? Give feedback.
Answered by
Timeless0911
Aug 2, 2025
Replies: 1 comment 3 replies
-
Set redirect.dts.extension to |
Beta Was this translation helpful? Give feedback.
3 replies
Answer selected by
YiCChi
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Set redirect.dts.extension to
true
.