Running a RequireJS/WireJS app using PhantomJS

喜夏-厌秋 提交于 2019-12-05 14:26:24

You are right, Younes. PhantomJS doesn't support Function.prototype.bind for some reason.

You can polyfill Function.prototype.bind by using either cujoJS/poly or kriskowal/es5-shim.

As mentioned in the comments to the question, the origin of this problem is the fact that PhantomJS doesn't implement 'Function.prototype.bind()' function.

As suggested by the people from PhantomJS and WireJS, the problem would be fixed using an ES5 polyfill. The implementation suggested by MDN didn't help as it is a partial implementation of the specs. The implementation included in CujoJS/PolyJS has solved my problem. Now, WireJS is happy with PhantomJS.

Hereinafter is the new version of app.js

"use strict";

require.config({
    baseUrl: ".",

    packages: [
        { name: 'wire', location: '../../../target/deps/wire-0.0.1/0.10.2', main: 'wire' },
        { name: 'when', location: '../../../target/deps/when-0.0.1/2.4.1', main: 'when' },
        { name: 'meld', location: '../../../target/deps/meld-0.0.1/1.3.0', main: 'meld' },
        { name: 'poly', location: '../../../target/deps/poly-0.0.1/0.5.2', main: 'poly' }
    ]
});

require(["poly/function", "wire!appWireContext"], function(poly, wireContext) {
    alert(wireContext.message);
});

Cheers

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!