kevlened / fireway

A schema migration tool for firestore
MIT License
277 stars 41 forks source link

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

Open wyyr opened 9 months ago

wyyr commented 9 months ago

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;