Small fix to address a regression introduced as part of #198, when we moved from require -> import.
When dynamic-importing CJS/ESM modules, export default { ... } and module.exports = ... is placed under a default key (as opposed to require where the CJS module was returned as the top level object. This meant using a .cjs config would fail when parsing the settings with:
Error: Errors occurred during settings validation:
- Setting 'connectionString': Expected a string, or for DATABASE_URL envvar to be set
- Setting 'databaseOwner': Expected a string or for user or database name to be specified in connectionString
- Setting 'shadowConnectionString': Expected `shadowConnectionString` to be a string, or for SHADOW_DATABASE_URL to be set
- The following config settings were not understood: 'default'
- Could not determine the shadow database name, please ensure shadowConnectionString includes the database name.
I explored adding regression tests to ensure this didn't happen again but it looks like jest needs some extra configuration to support dynamic import()s so I've opted for the fingers-crossed🤞 approach that we won't accidentally break this again instead. If you reckon there's a clear approach to support this in jest, happy to add as part of the PR.
Checklist
[x] My code matches the project's code style and yarn lint:fix passes.
[ ] I've added tests for the new feature, and yarn test passes.
[ ] I have detailed the new feature in the relevant documentation.
[ ] I have added this feature to 'Pending' in the RELEASE_NOTES.md file (if one exists).
[ ] If this is a breaking change I've explained why.
Description
Small fix to address a regression introduced as part of #198, when we moved from require -> import.
When dynamic-importing CJS/ESM modules,
export default { ... }
andmodule.exports = ...
is placed under adefault
key (as opposed torequire
where the CJS module was returned as the top level object. This meant using a.cjs
config would fail when parsing the settings with:I explored adding regression tests to ensure this didn't happen again but it looks like jest needs some extra configuration to support dynamic
import()
s so I've opted for the fingers-crossed🤞 approach that we won't accidentally break this again instead. If you reckon there's a clear approach to support this in jest, happy to add as part of the PR.Checklist
yarn lint:fix
passes.yarn test
passes.RELEASE_NOTES.md
file (if one exists).