Skip to content

maherma-adg/db-migrate-plugin-es6cjs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

db-migrate plugin for accept .cjs files

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published