drizzle-team / drizzle-team/drizzle-orm

[BUG]: `drizzle-kit` generate fails to resolve imports

Open
#2,455 3 comments 7 reactions 0 assignees View on GitHub
bug drizzle/kit priority
Dominant language
TypeScript
Stars
35.8k
Forks
1.6k
Avg merge
2d 7h
Merged PRs (30d)
4

Description

### What version of `drizzle-orm` are you using?

0.31.1

### What version of `drizzle-kit` are you using?

0.22.2

### Describe the Bug

Importing another table from another drizzle schema file (both are `sqliteTable()`) using
```ts
import { users as dataspaceUsers } from '../dataspace/index.js';
```
fails unless I remove the `/index.js` like:
```ts
import { users as dataspaceUsers } from '../dataspace';
```
which then works as expected when running `drizzle-kit generate`. But this breaks the schema file when being imported to be used by `drizzle-orm` normally at runtime:
```
Uncaught Error Error [ERR_UNSUPPORTED_DIR_IMPORT]: Directory import '\dist\schemas\dataspace' is not supported resolving ES modules imported from \dist\schemas\tenant\index.js
```
which is fixable by keeping the full path:
```ts
import { users as dataspaceUsers } from '../dataspace/index.js';
```

### Expected behavior

I use the
```ts
import { users as dataspaceUsers } from '../dataspace/index.js';
```
and the import resolves as expected both during `drizzle-kit` and `drizzle-orm` runtime

### Environment & setup

`drizzle-kit` is ran using `exec()` inside a node.js script that is ran in GitHub actions as part of overall project ci/cd to do automated migrations.
`drizzle-orm` using that schema is at regular runtime being used either in node.js environment or cloudflare workers environment.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.