在具有 SystemJS 和 TypeScript 的 Angular2 Cli 应用程序中使用 PouchDB

Using PouchDB in an Angular2 Cli Application with SystemJS and TypeScript

过去两天我在 GitHub 和 Stack Overflow 上搜索了数十个问题和答案。我还没有找到解决方案。希望这里有人可以帮助我!

我已经让 PouchDB 在开发模式下工作,使用 ng serveng build,但是,当我尝试构建生产环境时,使用 ng build --prod,它遇到错误:

...

Error: Unable to calculate canonical name to bundle file:///home/josiah/Projects/www/projectname/vendor/pouchdb/dist/pouchdb.js. Ensure that this module sits within the baseURL or a wildcard path config.

...

我当前生成的 Angular2 Cli system-config.ts 包含:

const map: any = {
  'pouchdb': './vendor/pouchdb/dist/',
};

const packages: any = {
   "pouchdb": {
      main: "pouchdb",
      defaultExtension: "js"
   }
};

angular-cli-build.json中我添加了'pouchdb/dist/*.+(js|js.map)',

我在我的项目中使用 PouchDB 导入:import * as PouchDB from 'pouchdb';

欢迎任何想法或建议!谢谢!

删除./,像这样:

const map: any = {
  'pouchdb': 'vendor/pouchdb/dist/',
};

https://github.com/delasteve who pointed this out to me on https://gitter.im/angular/angular-cli 呐喊。