Closed dirk-ecker closed 3 years ago
Hey, I may add native ESM as part of 1.0, but for now, you can get around this by using a ley.config.cjs
file inside your project, and then passing that value/path to the --config
flag.
All your commands will start with this: ley --config ley.config.cjs
. If you add the flag as part of your "migrate" npm-script, then you don't have to worry about typing it every time:
{
"scripts": {
"migrate": "ley --config ley.config.cjs"
}
}
$ yarn migrate up
I think your migration files will also need to be .cjs
extension, which is fine since ley
just reads everything inside the --dir
value ("migrations"
by default).
Thank you for the hint to rename to .cjs. In the end renaming to .mjs works.
I am currently developing an application in nodejs using modules that means my package.json contains a
"type": "module",
and so I have to import and export everything.
Hey, ley is a great idea and module I want to use.
Using it gaves me an error because it tries to require my ley.config.js that should be module. I could manage to support it by modifying util.js using import instead of require:
and adjustment to postgres.js by using this config
My problem is, I do not know to differentiate between import and require during execution. How could we do this and would this be a good extension for ley?