If fauna-schema-migrate init is run in a project which has already indicated that it is using esmodules (by setting "type": "module" in the nearest package.json file), the resulting default .fauna-migrate.js file will be treated as an esmodule by the node runtime.
Since the generated file uses commonjs modules, this causes an immediate runtime error.
By changing the file extension to .cjs, we're telling the node runtime to expect commonjs modules in this file regardless of whether the parent project is using esmodules.
An alternative approach would be to match the parent project's module system in the generated code.
If
fauna-schema-migrate init
is run in a project which has already indicated that it is using esmodules (by setting"type": "module"
in the nearestpackage.json
file), the resulting default.fauna-migrate.js
file will be treated as an esmodule by the node runtime.Since the generated file uses commonjs modules, this causes an immediate runtime error.
By changing the file extension to
.cjs
, we're telling the node runtime to expect commonjs modules in this file regardless of whether the parent project is using esmodules.An alternative approach would be to match the parent project's module system in the generated code.