问题描述
我想先从Angular2测试工作,但我面对关于所需要的库的几个问题。结果
我使用Eclipse和它的。结果
另外,我使用 SystemJS
作为模块加载。结果
我的问题是,如果我Angular2使用安装NPM安装angular2
它加载了整个角项目,包括 CommonJS的
- 版本, ES6
-Version和打字稿
-Version。这导致了30 MB的大文件夹,几乎2000个文件,但我只需要在打字稿
-Version(还有一些100文件),没有例子。结果
此外,进口 / TS
在的Eclipse
-folder给我的错误,从rxjs的模块不存在(rxjs /主题......)。所以我想我必须下载该项目了。结果
使用的package.json
在, NPM安装
下载超过80MB(几乎10000个文件),而且我相信,我并不需要所有这些文件。结果
所以,我想知道,这是真的 Angular2
所需的文件和如何下载呢?结果
我应该创建自己的的package.json
- 文件?还是有更简单的方法?
I would like to start working with the Angular2 Beta, but I am facing a few problems regarding the required libraries.
I am using Eclipse and it's TypeScript Plugin.
Also, I am using SystemJS
as module loader.
My problem is that if I install Angular2 using npm install angular2
it loads the whole Angular-Project, including the CommonJS
-Version, ES6
-Version and the TypeScript
-Version. This results in a over 30 MB big folder with almost 2000 files, though I only need the TypeScript
-Version (still a few 100 files), without examples.
Also, importing the /ts
-folder in Eclipse
gives me errors, that the modules from "rxjs" do not exist ("rxjs/Subject"...). So i guess i have to download that project too.
Using the package.json
used in the 5 Min Quickstart, npm install
downloads over 80MB (almost 10000 files), and I am sure, I don't need all those files.
So i would like to know, which files are really needed by Angular2
and how can i download them?
Should i create my own package.json
-File? Or is there a even simpler way?
编辑:
纵观我们的(工作)角1.X项目,我可以看到一个 angular.js
文件,以及为不同的模块文件(如restangular.js ,角route.js等),共约10个文件。结果
什么现在我寻找的是这些文件的angular2对口。结果
做那些同行存在吗?我在哪里可以找到他们?
Taking a look at our (working) Angular 1.X Project, i can see a single angular.js
file, as well as files for the different modules (like restangular.js, angular-route.js etc.), in total about 10 files.
What i am now looking for is an angular2 counterpart of those files.
Do those counterparts exist? Where can i find them?
推荐答案
那现在我寻找的是这些文件的angular2对口:
"What i am now looking for is an angular2 counterpart of those files":
<!-- 1. Load libraries -->
<script src="node_modules/angular2/bundles/angular2-polyfills.js"></script>
<script src="node_modules/systemjs/dist/system.src.js"></script>
<script src="node_modules/rxjs/bundles/Rx.js"></script>
<script src="node_modules/angular2/bundles/angular2.dev.js"></script>
您需要的4 .js文件(不.TS)文件。
You need those 4 .js (not .ts) files.
我在哪里可以找到他们呢?
他们得到了与NPM下载。你可以把那些4,并删除一切。您也可以从CDN得到它们,或者手动下载。
"Where can i find them?"They got downloaded with npm. You can keep those 4 and delete everything else. You can also get them from a CDN, or download them manually.
<!-- 1. Load libraries -->
<script src="https://rawgithub.com/systemjs/systemjs/0.19.6/dist/system.js"></script>
<script src="https://code.angularjs.org/tools/typescript.js"></script>
<script src="https://code.angularjs.org/2.0.0-beta.0/angular2-polyfills.js"></script>
<script src="https://code.angularjs.org/2.0.0-beta.0/Rx.js"></script>
<script src="https://code.angularjs.org/2.0.0-beta.0/angular2.dev.js"></script>
但是。这些已经被编译JavaScript文件,他们会为你工作,如果你写JS使用你的应用程序,但现在90%以上的scarse文档,你会发现约2角是打字稿,为了与打字稿你会工作需要角2的源文件,这就是你所得到的全包。
HOWEVER. These are already compiled javascript files, and they'll work for you if you write your app using JS, but right now 90% of the scarse documentation you will find about Angular 2 is on typescript and in order to work with typescript you'll need the source files of Angular 2 which is the whole package you are getting.
我的建议,如果你正在做它在打字稿:不要担心所有这些文件得到下载的,他们是为了发展,你的身材不neccesarily一部分。您只能包括我告诉你,在你构建的那些,这将让你真正的应用程序小。另外你不要以为所有的这些文件添加到git的回购或者您正在使用瓦特/电子回购的想法是,你有混帐忽略整个node_modules文件夹,您只需提交的package.json文件,将工作对于其他开发人员,以便他们跑NPM安装和他们得到的所有依赖自己。因此,所有的这些文件只是为了在开发机器,你不必担心他们让你应用程式过大的原因,他们不会是你的应用程序的一部分。
My suggestion if you are doing it in typescript: Don't worry about all those files getting downloaded, they are meant for development, not neccesarily part of your build. You can only include the ones I told you in your build and that will keep you real app small. Also you are not suppose to add all those files into the git repo or w/e repo you are using, the idea is that you have git ignore the whole "node_modules" folder and you only commit the package.json file, which will work for other developers so they run npm install and they get all the dependencies themselves. So all those files are only meant to be in dev machines, you don't have to worry about them making you app too big cause they won't be part of your app.
这篇关于角2所需的库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!