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 Support #351
ESM Support #351
Conversation
This feature looks interesting. Could you add tests please :) ? |
I added some tests and fixed some existing tests that did not work on Windows. |
Nice ! |
Great work! When do think this could be merged and released? |
try { | ||
return Promise.resolve(moduleLoader.require(configPath)); | ||
} catch (e) { | ||
if (e.code === 'ERR_REQUIRE_ESM') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nathan-knight
I observe instability here (potentially depending on the Node version used ???)
This code used to work for me, I used it some weeks ago but now for the same usage I no longer have this error code thrown by the Node's require so it seems unstable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This error only occurs on newer versions of Node that are configured to use ES modules
Co-authored-by: Antoine <73850194+Antoineeeee-tech@users.noreply.github.com>
Co-authored-by: Antoine <73850194+Antoineeeee-tech@users.noreply.github.com>
Nice, when will this be released? |
I'm available to make any remaining changes that are required. It just needs someone with write access to merge the PR if it is good to go. |
Any idea when this update will be released? Would be very useful to me :) |
I too am looking to use this but have type: "module" so I can use import in my project. This is breaking this tool as node complains: RROR: Must use import to load ES Module: C:...\migrate-mongo-config.js |
@seppevs Are there any other changes that are needed for this to be merged? |
Just ran into this issue... looks like a ready-made solution...? This would let me adopt migrate-mongo, which I'd love to be able to do! |
As a workaround, I was able to get it to work by having my migration files still be in common js with the |
Any update on the release date for this? This PR has been open since May... |
Thank you for your contribution, and sorry it took so long. I have merged your PR to the master branch, and improved the ESM support a bit further. This feature has finally landed in migrate-mongo 9.0.0! |
This resolves #248
Checklist
npm test
passes and has 100% coverageThese changes allow
migrate-mongo
to work in projects with"type": "module"
set in their package.json file without disrupting other configurations or requiring additional configuration.Config files should use
export default {
instead ofmodule.exports = {
Migrations should look like: