6

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 SystemJSas 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?

EDIT: 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?

2 Answers 2

7

"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>

You need those 4 .js (not .ts) files.

"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>

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.

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.

Sign up to request clarification or add additional context in comments.

11 Comments

Thanks for your answer. So basicly if i want to use typescript, i have to include the whole package, to be able to use all angular2 functions in typescript? Also as mentioned in my question, including the /ts folder in my app gives errors, as systemjs as well as rxjs, which are required are not included in the angular2 package. Is it enough to download those 2 packages or are there more needed packages?
Depends on you project needs. Those are the basic ones, if you need more stuff like the router, you have to add the router one. rxjs and systemjs are not part of angular2, angular 2 just have dependencies on them, node will detect that and download them too in node_modules/systemjs & node_modules/rxjs.
I meant npm, not node. When you do "npm install".
Okay so basicly i would just need to include the dependencies "angular2", "systemjs" and "rxjs" into my "package.json" and npm should download all these packages for me right? Also shouldn't angular-router be included in the angular2 package allready?
If you have more questions open new questions, these long comments discussions aren't as helpful to other users.
|
3

The package.json file in Angular 2 Quickstart guides contains development dependencies like concurrently,lite-server, typescript etc along with es6-shim etc for older browser compatibility.

Basic dependencies for angular 2 are

  • angular2
  • typescript
  • systemjs
  • rxjs

You can look into this Angular2 Tutorial Plunker to start a simple application. It also contains routing library.

4 Comments

Is it also possible to just download the TypeScript-Version of angular2? The whole angular2 project, as stated above, is over 30 MB bit. It also includes examples, which are not needed for a real app. Or would it even be better to download only the single files?
You can try downloading individual files and use npm local path feature. docs.npmjs.com/files/package.json#local-paths
Thanks for your help, but i still can't really see which single files are really needed. Taking a look at our current (working) Angular1 project, i can see a single Angular.js file, as well as files for modules like restangular, angular-route etc. But looking at the Angular2 files (the one downloaded over "npm install angular2"), i can't find the Angular2 counterparts.
are there angular2 counterparts of the files i mentioned above? Or is the angular2 framework splitted up into different files (like core.ts, common.ts etc.)?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.