unjs / unbuild

📦 A unified JavaScript build system
MIT License
2.37k stars 92 forks source link

rollup.dts.compilerOptions cannot work with declaration #428

Open gweesin opened 3 months ago

gweesin commented 3 months ago

Environment

node v18.19.1 pnpm v9.7.1

Reproduction

git clone git@github.com:gweesin/unbuild-issue.git

cd unbuild-issue

pnpm i

pnpm build

Describe the bug

run the reproduction, you can see dist/tsup/index.type.d.ts and dist/unbuild/index.type.d.ts

on tsup, the compilerOptions parameter is valid like this:

interface InterfaceA {
}
interface InterfaceB {
}

type TypeC = InterfaceA | InterfaceB;

export type { TypeC };

on unbuild, the compilerOptions parameter is invalid like this:

import { InterfaceA, InterfaceB } from '@/demo';
export type TypeC = InterfaceA | InterfaceB;

the build.config.ts file:

import {defineBuildConfig} from 'unbuild'

export default defineBuildConfig({
    entries: [
        {
            builder: 'mkdist',
            input: './types/',
            outDir: './dist/unbuild',
        }
    ],
    declaration: true,
    clean: true,
    rollup: {
        dts: {
            compilerOptions: {
                noEmitOnError: false,
                strict: false,
                alwaysStrict: false,
                skipLibCheck: true,
                skipDefaultLibCheck: true,
                paths: {
                    '@/*': ['./src/*'],
                }
            }
        }
    }
})

Additional context

No response

Logs

No response

gweesin commented 2 months ago

While path mapping functions correctly in rollup-plugin-dts, I'm facing an issue with unbuild where it fails to resolve paths, even though the configuration matches the test case at:

https://github.com/Swatinem/rollup-plugin-dts/blob/9d11bbabc597f1226b320e316507e138900ea7d7/tests/testcases/custom-tsconfig/tsconfig.build.json#L5