0.0.2 • Published 3 years ago

db-migrate-plugin-es6cjs v0.0.2

Weekly downloads
7
License
MIT
Repository
github
Last release
3 years ago

db-migrate-plugin-es6cjs

A plugin to allow CJS migrations.

Installation

npm install db-migrate-plugin-es6cjs

Implementation Detail

The plugin hooks into the functionality of db-migrate itself. In this case it hooks into migrator:migration:hook:require.

It allow db-migrate to detect migrations with (.cjs) extensions.

Why

When you have a node project defined as ES6 modules, you got an error when try to import .js files generated by db-migrate tool.

[ERROR] AssertionError [ERR_ASSERTION]: ifError got unwanted exception: Must use import to load ES Module

and the solution proposed is:

Instead rename 20210102234349-Test.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /..../package.json.

but if you rename the file to .cjs as requested, the migration tool can't find, because the it search only for .js files.