Skip to content

[api-extractor] Some relative path imports of local files are not resolved anymore since 7.49.0 #5126

@cdauth

Description

@cdauth

Summary

I am using vite-plugin-dts with rollupTypes: true to create a rollup of the type declarations. After upgrading, I am experiencing some errors. After narrowing down the problem, it seems like this is a regression that was introduced with api-extractor 7.49.0. With 7.48.1 the problem does not occur anymore.

With api-extractor 7.49.0, the resulting bundle contains imports like this:

import { CRUValidatorForDeclaration as CRUValidatorForDeclaration_2 } from './cru.js';

The file cru.js is part of my package and its contents should be embedded in the bundle, which worked correctly with 7.48.1. The path ./cru.js does not lead anywhere, since that file does not exist in the output folder where the bundle is saved. The relative path is simply preserved from how it is specified in the source file.

Repro steps

I have copied the relevant package to this repository. To create a build, run yarn install and then yarn build. This will generate the bundle as dist/facilmap-types.d.ts.

The repository uses api-extractor 7.48.1, so the generated bundle does not have the problem described. To reproduce the problem, change the api-extractor resolution in package.json to 7.49.0 and run yarn install and yarn build again.

To investigate the declaration files that the bundle is generated from, set rollupTypes to false in vite.config.ts and run yarn build. This will generate the raw declaration files under dist.

Details

Standard questions

Please answer these questions to help us investigate your issue more quickly:

Question Answer
@microsoft/api-extractor version? 7.48.1 (working), 7.49.0 (broken)
Operating system? Arch Linux
API Extractor scenario? rollup (.d.ts)
Would you consider contributing a PR? No, I don’t have the expertise
TypeScript compiler version? 5.7.3 (I believe api-extractor is using 5.4.2)
Node.js version (node -v)? 23.4.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Closed

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions