amark / gun

An open source cybersecurity protocol for syncing decentralized graph data.
https://gun.eco/docs
Other
18.03k stars 1.16k forks source link

VM811:2762 crbug/1173575, non-JS module files deprecated. #1261

Closed bitdom8 closed 2 years ago

bitdom8 commented 2 years ago

Come from MongoDB as it's prod ready but not mature enough. Had to format my VPN to use it again mongoDB and file system crashed. I couldn't export all json files with dump function.

After all happy to find GunJS however the instructions are very hard. Website is not userfriendly and also gunjs sometimes works sometimes not because of lack of updates info on the website: https://gun.eco/docs/Vite

How can I make it work please?

bitdom8 commented 2 years ago

Thanks @amark . This was because Sveltekit uses Vite built and we need to import as such:


<script lang="ts">

let txt: any

import { onMount } from 'svelte/internal';
// import Gun from 'gun'
// don't do the above

let gun
onMount(async () => {
  gun = (await import('$src/stores/initGun')).gun;

if (gun) {
  // console.log("gun here", gun.get('textbitfinicontry38479234'))
  gun.get('textbitfinicontry).once((node, id) => {console.log(node)} )
  gun.get('textbitfinicontry').once((node) => { // Retrieve the text value on startup
      // console.log(node)
      if(node == undefined) {
        gun.get('textbitfinicontry').put({textbitfinicontry: "Write the text here"})
      } else {
        console.log("Found Node")
        txt = node.textbitfinicontry
      }
    })

    gun.get('textbitfinicontry').on((node) => { // Is called whenever text is updated
      console.log("Receiving Update", node)
      // console.log(node)
      txt = node.textbitfinicontry
    })
} else {
  console.log("gunn oammo")
}

})

  const updateText = (event) => {
    console.log("Updating Text")
    console.log(event.target.value)
    gun.get('textbitfinicontry38479234').put({textbitfinicontry38479234: event.target.value}) // Edit the value in our db
    // txt = event.target.value
  }
</script>

<textarea value={txt} on:change={updateText}/>

GUNDB gunjs has more advantages over MongoDB as MongoDB is linux based and when Linux stalls can't fix it easily. You need to hammer Linux as Win95 issues. It's so much popular on stackoverflow while traditional databases has many errors.

JSON becomes BSON on mongodb, it's not a big deal

amark commented 2 years ago

Yeah, bundlers/compilers all do very weird things - often times it is not GUN's fault (as in, gun.js runs fine in a browser from a script tag) but I still want it to work well with other frameworks: But you need to find someone who knows these/other frameworks, I have no clue (nor can/could I be proficient in all of them).

Seems like you got it fixed?

Please re-open if not - tho, please fix the title... it seems like you just pasted your app's error, it has no reference of a gun line number error.