Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESM configuration module does not work under tsx #443

Open
rla opened this issue Dec 27, 2023 · 0 comments
Open

ESM configuration module does not work under tsx #443

rla opened this issue Dec 27, 2023 · 0 comments

Comments

@rla
Copy link

rla commented Dec 27, 2023

ESM configuration module does not work under tsx. tsx is runner for TypeScript code.

This happens because migrate-mongo uses exception to try to load ESM-based configuration module:

if (e.code === 'ERR_REQUIRE_ESM') {

but tsx swallows these exceptions as described in its README:
https://github.com/privatenumber/tsx/tree/9c000f04f3381ccd07627e11eea759753c10b839?tab=readme-ov-file#about

I think it's tsx issue but leaving this here since I was not able to file the issue on the tsx tracker. Workaround is to not rely on a configuration file but use config.set: https://github.com/seppevs/migrate-mongo/tree/3753b2bc52436d06482efc8442d10e93960b83f8?tab=readme-ov-file#configsetyourconfigobject

To enable the workaround you might also have to extract and update @types/migrate-mongo because the types are out-of-sync with this package (missing moduleSystem property).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant