Closed georgeben closed 2 years ago
Never worked on an open-source project, but happy to do if someone explains the process. Just raise a PR?
Non-breaking fix anyway is: migrationsDir.js
async loadMigration(fileName) {
const configContent = await config.read();
const { useES6 } = configContent;
const migrationsDir = await resolveMigrationsDirPath();
if (useES6) {
return import(path.join(migrationsDir, fileName));
}
return require(path.join(migrationsDir, fileName)); // eslint-disable-line
},
New config option:
useES6
This allows me to write in ES6 format:
import { Settings } from '../src/models/settings';
const up = async (_db, _client) => {
await Settings()
.updateOne({}, {
inboundCallsAcceptedFrom: '08:00',
inboundCallsAcceptedTo: '21:00',
inboundCallsAcceptedTimezone: 'Australia/Sydney',
});
};
export {
up,
};
Would second this request. Would like to implement migrate-mongo on my project but I cannot export the config setup because of ES6 incompatibility. If there's anything I'm missing, please let me know.
Thanks
ESM is finally here! Upgrade to migrate-mongo >= 9.0.0, and see the README for details.
i have to use type: module in package.json. is there any other workaround?
Is your feature request related to a problem? Please describe. I can't import modules into my
migrate-mongo-config.js
using ES6 imports, which is unfortunate because the whole codebase is written using ES6 module importsDescribe the solution you'd like This library should support ES6+ syntax