【发布时间】:2016-08-12 07:30:10
【问题描述】:
所以我注意到我在 PhantomJs 中遇到了这个错误,我原以为包含了 polyfill,因为有一个 @type/whatwg-fetch。
Error: HttpClient requires a Fetch API implementation, but the current environment doesn't support it. You may need to load a polyfill such as https://github.com/github/fetch. in spec-bundle.js (line 18057)
我不确定如何在这种 webpack 情况下加载推荐的 polyfill,我需要安装什么 npm 模块?以及如何将其添加到 webpack(基于 typescript-weback 框架的 webpack)
试过了
import { Aurelia } from 'aurelia-framework';
import '../styles/styles.css';
import 'font-awesome/css/font-awesome.css';
import 'bootstrap/dist/css/bootstrap.css';
import 'bootstrap';
import * as Bluebird from 'bluebird';
import 'whatwg-fetch';
// we want font-awesome to load as soon as possible to show the fa-spinner
// comment out if you don't want a Promise polyfill (remove also from webpack.config.js)
Bluebird.config({ warnings: false });
export async function configure(aurelia: Aurelia) {
aurelia.use
.standardConfiguration()
.developmentLogging();
// Uncomment the line below to enable animation.
// aurelia.use.plugin('aurelia-animator-css');
// if the css animator is enabled, add swap-order="after" to all router-view elements
// Anyone wanting to use HTMLImports to load views, will need to install the following plugin.
// aurelia.use.plugin('aurelia-html-import-template-loader')
await aurelia.start();
aurelia.setRoot('app');
// if you would like your website to work offline (Service Worker),
// install and enable the @easy-webpack/config-offline package in webpack.config.js and uncomment the following code:
/*
const offline = await System.import('offline-plugin/runtime');
offline.install();
*/
}
这是我安装的
npm ls whatwg-fetch slave-vi
aurelia-skeleton-navigation-webpack@1.0.0 /home/xenoterracide/IdeaProjects/rpf-ui
└── whatwg-fetch@1.0.0
我可以在我的 app-bundle.js 中看到获取代码,但我仍然看到 PhantomJS 抛出上述错误
【问题讨论】:
标签: typescript phantomjs webpack aurelia