Code Monkey home page Code Monkey logo

Comments (8)

farreldarian avatar farreldarian commented on June 11, 2024 1

@daniel-nagy @hilja I just patched the import logic to determine based on the project's moduleResolution, let me know if it's not working

It breaks on my repo πŸ˜…

I couldn't find any better approach, so I just provide the config to override

from prisma-generator-drizzle.

hilja avatar hilja commented on June 11, 2024

Ah, this won't work drizzle-team/drizzle-orm#849 I ran the generator yesterday evening and didn't try to migrate until this morning and noticed it can't find the tables.

from prisma-generator-drizzle.

hilja avatar hilja commented on June 11, 2024

This is the way:

"scripts": {
  "generate": "NODE_OPTIONS='--import tsx' drizzle-kit generate:pg"
}

A bit off-topic but, is the following supposed to work?

export default defineConfig({
  schema: './drizzle/schema/schema.ts',
})

It can't find any tables from the schema.ts, but glob works fine :)

export default defineConfig({
  schema: './drizzle/schema/*',
})

from prisma-generator-drizzle.

farreldarian avatar farreldarian commented on June 11, 2024

@hilja do you mind making a repository where I can reproduce the issue?

So far I'm importing the generated models in a next.js project (using the tsconfig created from create-next-app) and a simple ts project works fine

from prisma-generator-drizzle.

hilja avatar hilja commented on June 11, 2024

Here's a quick repro:

The app I was testing with is loosely based on the epic stack https://github.com/epicweb-dev/epic-stack

So I hacked up prisma-generator-drizzle in there https://github.com/hilja/drizzle-test. Note that the app won't actually work because I used postgres (epic-stack is sqlite). But the generator should.

Setup:

git clone [email protected]:hilja/drizzle-test.git
cd drizzle-test
npm i
npm prisma generate

After generating the drizzle schema, the imports in prisma/drizzle/schema should error: Relative import paths need explicit file extensions in ECMAScript imports when '--moduleResolution' is 'node16' or 'nodenext'. Adding .ts or .js manually fixes it.

And when trying to drizzle-kit generate:pg with npm run generate, it can’t find any tables:

0 tables

No schema changes, nothing to migrate 😴

from prisma-generator-drizzle.

daniel-nagy avatar daniel-nagy commented on June 11, 2024

I have the same issue. To make things easy I believe this library could just always add the .js extension to the import path. I believe that would work in all cases but I could be wrong.

from prisma-generator-drizzle.

daniel-nagy avatar daniel-nagy commented on June 11, 2024

I just opened a PR to add the js extension. @hilja as a temporary workaround you can use my fork by installing it from a git URL.

yarn add daniel-nagy/prisma-generator-drizzle#js-ext-pkg

from prisma-generator-drizzle.

farreldarian avatar farreldarian commented on June 11, 2024

@daniel-nagy @hilja I just patched the import logic to determine based on the project's moduleResolution, let me know if it's not working

from prisma-generator-drizzle.

Related Issues (11)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.