Closed joshgachnang closed 7 months ago
Hey @joshgachnang, I was able to find a fix to your problem!
This project uses ts-node to read the TS code and parse out certain type information from the Mongoose schemas. Turns out ts-node does not play well with ESNext, see here: https://github.com/TypeStrong/ts-node/issues/922#issuecomment-673155000.
As a fix, you can add the following to your tsconfig.json file:
"ts-node": {
"compilerOptions": {
"module": "commonjs"
}
}
I tested this on your example repo and it solved the issue.
That being said, I'd rather not require users to need to change their tsconfig.json files anytime they want to use ESNext, so ill be pushing a fix shortly which should handle this from my end, so feel free to wait for that as well
Fixed in v9.2.13!
@francescov1 you are amazing, thank you! I'll try this out tomorrow!
Hello! First off thank you for the awesome package. We've been using it for a couple years and it's been wonderful.
We've just started migrating our repo to ESM. We keep running into packages that only support ESM, so we started the conversion. The last remaining thing is I can't get mongoose-tsgen to work with ESM. Any ideas?
I made an example repo here: https://github.com/joshgachnang/tsgen-esm
Running via npx, I get:
So I tried running it from my own script (mongooseTSGen.ts copied into the example repo), and get a little more info:
Any thoughts here?