Skip to content

[Bug?] Index file import not being transformed correctly #159

Closed
@SammyWhamy

Description

@SammyWhamy

I have this settings in my tsconfig:

"paths": {
  "@util": ["util/index.js"]
}

But when I import { } from "@util";
It emits this code: import { } from "../util";
If I instead rename the file to something else, e.g. barrel, it emits this: import { } from "../util/barrel";

The problem is, node can resolve neither of these. And as I specify that @util should be rewritten to util/index.js I expect it to keep the index.js part, without this my import simply doesn't function.

I can't really tell if this is intended behavior or not, but I think emitting the full path (including index.js) should always be a safe option if it is specified as such in the paths option.

I know I could instead do "@util/*": ["util/*"]
And then import { } from "@util/index.js";
But it'd be even better if I can have it emit the index.js for me as well.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions