privatenumber / tsx

⚡️ TypeScript Execute | The easiest way to run TypeScript in Node.js
https://tsx.is
MIT License
8.61k stars 132 forks source link

Reproduction with node-postgres of "Cannot import named export from a typescript file in a workspace package if entry is using es modules and other package is not." #593

Closed saltman424 closed 2 weeks ago

saltman424 commented 2 weeks ago

Acknowledgements

Minimal reproduction URL

https://stackblitz.com/edit/stackblitz-starters-g6pt9g?file=index.mts

Problem & expected behavior (under 200 words)

Reproduced https://github.com/privatenumber/tsx/issues/38 with node-postgres

Bugs are expected to be fixed by those affected by it

Compensating engineering work will speed up resolution and support the project

privatenumber commented 2 weeks ago

Thanks for providing the repro—it helps a lot with understanding what you did.

I've never used node-postgres before so I assumed the package was node-postgres.

The pg package doesn't do named exports in a statically analyzable way, so it's hitting the same limitation in Node as with lodash (this isn't a tsx issue or limitation).

You can either file an issue with pg to make imports statically analyzable or with Node to improve their static analysis.