Open H01001000 opened 8 months ago
Hi @H01001000 Thanks for your contribution
I also added some missing conditions to add the ".js" or "index.js"
p.s. suggest add eslint or prettier
Its already part of the project. I've added to CI checks now.
I was unable to run the example that you have created, its working for you?
I also don't quite understand the advantage of this approach (esm) as opposed to the approach that the old example already used. Could you help me clarify this so I can add it to the readme?
@Cauen can try to use ts-node --esm?
not really are there advantage esm vs cjs (you can read more googling), but if for example if some deps are in esm (e.g. node-fetch) you must use esm instead cjs, otherwise you can't import them node throw error
@Cauen can try to use ts-node --esm?
Not working but... I think the ideal would be for the "inputs-simple-sqlite-esm" example not to work without the new "esm" support configuration. Exactly as was your case, right?
not really are there advantage esm vs cjs
I'm just confused because I've always used ESM in my projects and I've never had the limitation of inserting ".js" extensions in imports
@Cauen cuz it works for me
Are you sure you putting "type": module in package.json, and tsconfig compile to es module, without those you are still using commonjs, cuz from what i look tsconfig you use will compile esm to cjs
Are you sure you putting "type": module in package.json, and tsconfig compile to es module, without those you are still using commonjs, cuz from what i look tsconfig you use will compile esm to cjs
@H01001000 I'm referring to the example you created in the project
For that I mean your other project
As it currently stands, does it work for you?
@Cauen see if this work, i suspect the only diff my env and your is im install using yarn
@H01001000 I'm using Yarn too, even with 4.0 from your change its not working
Same error:
Unknown file extension ".ts" for /home/caue/projects/personal/prisma-generator-pothos-codegen/examples/inputs-simple-sqlite-esm/src/server.ts
@Cauen could you use node --loader ts-node/esm
instead of ts-node
I'm thinking another reason could be I'm still using node 18 instead of 20
🚀 node --loader ts-node/esm src/server.ts
works
But the example project runs even without the need to use this new functionality Could you update this example to make this new functionality necessary? (As your use case)
I believe you use the build process and use node without ts-node, right?
@H01001000
This PR makes generated files use module imports (with .js ext and refactor import directory to import directory/index), making the generated file be used in an esm environment
close #63
p.s. suggest add eslint or prettier