db-migrate-plugin-es6cjs

0.0.2 • Public • Published

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🪝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.

Dependencies (0)

    Dev Dependencies (0)

      Package Sidebar

      Install

      npm i db-migrate-plugin-es6cjs

      Weekly Downloads

      131

      Version

      0.0.2

      License

      MIT

      Unpacked Size

      3.28 kB

      Total Files

      4

      Last publish

      Collaborators

      • maherma