简体   繁体   中英

Bundling pouchDB js library in Aurelia v1 app using requirejs

I'm facing errors while bundling the pouchDB js library in an Aurelia v1 app using the built-in requirejs bundler\/module loader.

  1. <\/li><\/ol>
    <\/li><\/ol>
     cd test au run --env dev --port 9000 --watch<\/code><\/pre>

    The minimal aurelia app successfully shows up at localhost:9000

    1. <\/li><\/ol>
      <\/li><\/ol>
      import PouchDB from "pouchdb-browser"; export class App { message = 'Hello World!'; constructor() { this.db = new PouchDB("test"); } }<\/code><\/pre>

      As soon as the pouchDB class is imported in the project, the Aurelia bundler kicks-in and re-bundles all the added dependencies without throwing errors

       I also tried to install individual pouchDB packages (pouchdb-core, pouchdb-adapter-idb) instead of the preset package (pouchdb-browser) but I'm still getting the same error.

      Can someone please help?

I had used pouchdb-browser with Aurelia v1, it had worked previously, although I have not tried it recently. However, I did have to add the following to main.js to get it to work:

//to make pouchdb-browser work
import process from 'process';
  window.process = process;
  import {Buffer} from 'buffer';
  window.Buffer = Buffer;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM