Angular2 2.0.x和Rx 5 beta.12捆绑包 [英] Angular2 2.0.x and Rx 5 beta.12 bundle

查看:90
本文介绍了Angular2 2.0.x和Rx 5 beta.12捆绑包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在更新项目的依赖关系,该项目使用Angular2 npm软件包,因此也使用了RxJ.我将更新到2.0.2稳定的angular版本,具体取决于Rx5 beta.12. 对于我的Web应用程序,我仅部署Rx.min.js捆绑包,并在index.html文件中使用脚本标签加载它.这种方法在使用Rx umd捆绑软件之前可以很好地工作,但是同时会引起错误,因为在我看来,RxJ的贡献者为了一个通用捆绑软件而放弃了不同的捆绑软件版本.即Rx.js,而不是Rx.umd.js,等等.

I am currently updating the dependencies of my project which uses the Angular2 npm packages and therefore RxJs as well. I am updating to the 2.0.2 stable release of angular which depends on Rx5 beta.12. For my web application i only deploy the Rx.min.js bundle and load it with a script tag in my index.html file. That approach worked perfectly before with the Rx umd bundle, but causes errors meanwhile, since it appears to me that the contributors of RxJs dropped the different bundle versions for the sake of one common bundle file. i.e. Rx.js instead of Rx.umd.js and so on.

我正在使用SystemJs模块加载器,如果不执行其他步骤,则RxJs Framework的任何符号都将发生这些错误:

I am using SystemJs module loader and if i do no additional steps these errors will occur with any symbol of the RxJs Framework:

GET http://localhost:8080/rxjs/Subject.js 404 (Not Found)

我认识到Rx现在是全局定义的(window.Rx),并且包含所有必要的内容.因此,我尝试通过像这样的smth在SystemJs中手动定义这些符号:

I recognized that Rx is now globally defined (window.Rx) and contains all the necessary stuff. So i tried to define those symbols in SystemJs manually by doing smth like this:

function defineGlobalModule( parentModuleName, simpleName, moduleValue ) {
  var fqModuleName = parentModuleName + simpleName;
  System.amdDefine( fqModuleName, ["require", "exports"], function (require, exports) {
       "use strict";
       exports[ simpleName ] = moduleValue;
  }); 

  if( typeof moduleValue === "object" )
     for( var key in moduleValue )
       defineGlobalModule( fqModuleName + "/", key, moduleValue[ key ] )
}

defineGlobalModule( "", "rxjs", global.Rx );

这使得'rxjs/Subject'样式的导入再次起作用.但是现在我得到了很多这样的错误:

That made the 'rxjs/Subject' style imports work again. But now i get lots of errors like this:

GET http://localhost:8080/rxjs/operator/toPromise.js 404 (Not Found)
GET http://localhost:8080/rxjs/observable/fromPromise.js 404 (Not Found)

例如,这些文件是通过angularforms.umd.js捆绑包导入的.

These files are imported by the angular forms.umd.js bundle for example.

在导入Rx.js 捆绑包而不部署node_module本身的情况下,Angular2 2.0.x的最新技术水平是什么?我需要捆绑版!我使用的是Rx.js捆绑包的umd版本,在此之前似乎已经不存在了.

What is the state of the art for Angular2 2.0.x when it comes to importing the Rx.js bundle without deploying the node_module itself. I need the bundled version! I was using the umd version of the Rx.js bundle before which seems not to exist anymore.

推荐答案

我也许正是用Angular2rxjs@5.0.0-beta.12做了您要找的东西,它们现在以globals的形式分发,而umd软件包是可能不再受支持了(就像您说的那样):

I did maybe exactly what you're looking for with Angular2 and rxjs@5.0.0-beta.12 which is now distributed as globals and the umd package is probably not supported any more (just as you said):

观看现场演示: https://plnkr.co/edit/z4gg2XBoQDgYXev0Csuq

基本上,我刚刚更新了SystemJS配置:

Basically, I just updated my SystemJS config:

paths: {
  'rxjs*': 'https://unpkg.com/@reactivex/rxjs@5.0.0-beta.12/dist/global/Rx.js'
},

然后我从map列表中删除了rxjs.现在,它会加载一个Rx.js文件.

Then I removed rxjs from map list. Now it loads a single Rx.js file.

这篇关于Angular2 2.0.x和Rx 5 beta.12捆绑包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆