Lokijs in RC0

I used Lokijs in my application and i managed to import both lokijs and loki-cordova-fs-adapter, but on ionic server i got such messages:
[19:12:20] rollup: Treating ‘fs’ as external dependency
[19:12:24] rollup: No name was provided for external module ‘fs’ in options.globals – guessing ‘fs’

In browser:
main.dev.js:3 Uncaught ReferenceError: fs is not defined

I tried different solutions from rollup issues, but nothing helped:

Maybe some one know how to solve this issue?

1 Like

I had the same problem and could not solve it.
As an “dirty” workaround, i commented out the “fs” require in the lokijs.js file as i anyway use the indexed adapter. That works perfect for now :slight_smile:

I also tried this workaround, but i dont like it. Maybe we will get some solution from Ionic or Rollup team in future versions.

Same problem here but, with sockJS

[09:33:39]  rollup: No name was provided for external module 'events' in options.globals – guessing 'events'
[09:33:39]  rollup: No name was provided for external module 'stream' in options.globals – guessing 'stream'

I don’t know lockJS but the error seems familiar with angularfire. I’ve configured rollup.config.js according to this blog post: Getting Started with Ionic 2 RC0, Firebase 3 + AngularFire 2

  plugins: [
    ngTemplate(),
    commonjs({
        include: [
        'node_modules/rxjs/**',
        'node_modules/firebase/**',
        'node_modules/angularfire2/**'
        ],
        namedExports: {
        'node_modules/firebase/firebase.js': ['initializeApp', 'auth', 'database'],
        'node_modules/angularfire2/node_modules/firebase/firebase-browser.js': ['initializeApp', 'auth', 'database']
        }
    }),
...

Maybe it’s worth a try and see what happens. Good luck!

No, it didn’t work for me :frowning:

same here :confused: any updates on this? Where exactly did you comment out the fs declaration? Thanks in advance!

I commented out ‘fs’ declaration on line #1141 (function LokiFsAdapter) in file src/lokijs.js

thanks for that quick response. it seems that the fs adapter might be a on a own module in the future, see https://github.com/techfort/LokiJS/issues/449