drizzle-team / drizzle-team/drizzle-orm
[BUG]: package.json import alias breaks
- Dominant language
- TypeScript
- Stars
- 35.8k
- Forks
- 1.6k
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 4
Description
### Report hasn't been filed before.
- [x] I have verified that the bug I'm about to report hasn't been filed before.
### What version of `drizzle-orm` are you using?
1.0.0-rc.4
### What version of `drizzle-kit` are you using?
1.0.0-rc.4
### Other packages
_No response_
### Describe the Bug
I don't know if this worked in the past, but using the new `@sveltejs/kit@3.0.0-next.11` packages, they force you to use the package.json imports alias.
```json
{
...,
"imports": {
"#lib/*": "./src/lib/*"
}
}
```
drizzle-orm seems to not have issues with it, but drizzle-kit generate breaks and gets the path wrong.
The error message:
```
Error Cannot find module '/home/{user}/{org}/src/lib/server/db/schema/schema'
Require stack:
- /home/{user}/{org}/{project}/src/lib/server/db/schema/data/source.ts
[ELIFECYCLE] Command failed with exit code 1.
```
schema.ts
```ts
import { pgSchema } from 'drizzle-orm/pg-core';
export const data = pgSchema('data');
```
source.ts <- drizzle-kit generate error
```ts
import { data } from '#lib/server/db/schema';
import { boolean, text, timestamp, uuid } from 'drizzle-orm/pg-core';
export const source = data.table('source', {
id: uuid().primaryKey().defaultRandom(),
...
}
```
source.ts <- drizzle-kit generate success
```ts
import { data } from '../schema';
import { boolean, text, timestamp, uuid } from 'drizzle-orm/pg-core';
export const source = data.table('source', {
id: uuid().primaryKey().defaultRandom(),
...
}
Contributor guide
Research direction
Start by reproducing `drizzle-kit generate` with the `package.json` `#lib/*` import in `source.ts`, then compare it with the relative import and inspect how the path is resolved. The work is done when generation resolves the alias to `src/lib/server/db/schema` without the reported module-not-found error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- nodejs, postgresql, typescript
- Domain
- cli, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100