kevlened/fireway

Need Support for ES6 Module -> (Error [ERR_REQUIRE_ESM]: require() of ES Module)

wyyr opened this issue · 0 comments

wyyr commented

Hey, I'm done searching for firestore migration, and just found this great tools. But seems only support for CommonJS.

Can I use ES6 module import ? because I faced this error when i'm using ES6 Module import.

Screenshot 2023-11-22 203555

v0.0.1__foods.js

import * as fs from 'fs';
import * as path from 'path';

async function migrate({ firestore, FieldValue }) {
  const foods = JSON.parse(fs.readFileSync(path.resolve('src/seeds/foods.json')));

  foods.forEach(async (item) => {
    await firestore.collection('foods').doc(item.id).set(item);
  });
}

export default migrate;