Closed jdubois closed 7 years ago
I would follow this example on the angular website:
There's other steps after of course but that would be a good start !
I think we should also consider generating a project that is compatible with angular-cli as this is the new official way to scaffold a project and run some other commands like generating new routes, linting, running tests, ...
In some way, angular-cli overlaps with yeoman.
This document does give us a lot of insights on upgrade from 1.x to 2
@gmarziou 💯 agree
I have created the client-2 sub generator in a new branch https://github.com/jhipster/generator-jhipster/tree/angular-2
we can do development in this branch until the client-2 is ready to be provided as beta option, so that we can still do pach releases of our master if required.
I have added the typescript dependencies and angular 2 dependencies in the package.json. we need to move all the bower dependencies to package.json (some might not be angular2 compatible yet and some might not be available for npm, we need to find workarounds for those)
we also need to setup gulp to process typescript here is a good tutorial http://blog.scottlogic.com/2015/12/24/creating-an-angular-2-build.html
@wmarques please proceed to change to typescript if you have time else ill do it on Monday.
Can we use broccoli ?
@sendilkumarn gulp is still the most popular and stable build and I dont see why we would want to move away from that also lot of people have put in a lot of effort to make our gulp build as stable as today so I dont think we need to jeopardize that.
@sendilkumarn btw if you are interested you can do the gulp typescript integration step, follow the link I shared above
I will give a shot to it.
Thanks @deepu105 , let's work on this branch -> for me we can release this as an "early alpha version" very soon, it doesn't do any harm as long as we warn people it's not ready
Yes we can do an Alpha, but we need atleast typescript working on the client-2 for that else it would be same as client. Ill try to move all js -> ts soon.
Thanks & Regards, Deepu
On Mon, Jun 6, 2016 at 4:39 PM, Julien Dubois notifications@github.com wrote:
Thanks @deepu105 https://github.com/deepu105 , let's work on this branch -> for me we can release this as an "early alpha version" very soon, it doesn't do any harm as long as we warn people it's not ready
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/jhipster/generator-jhipster/issues/3664#issuecomment-223899779, or mute the thread https://github.com/notifications/unsubscribe/ABDlF9aI2ddMrd3symc4aoT7UOc4EYNgks5qI9y7gaJpZM4Ipod9 .
Excellent! I had wondering about this for a little while, and had already set up an "edge" branch for myself, to play around with Angular2 and Gulp4, before being sidetracked by another project.
Typescript sounds like a natural choice since Angular 2 is built with it, and Gulp allows even the build itself to be written in typescript, in gulpfile.ts
. Or maybe ES6 would be a more widely favoured choice?
Anyway, thanks for opening this issue, looking forward to seeing how this develops.
dropping bower
we can add angular 2 dependencies via npm. I think for referencing files, we need to have either gulp task or move node_modules inside webapp
@deepu105 I won't have alot of time today sorry :( @sendilkumarn Agree, we should move the node_modules inside webapp in order to reference dependencies in our index.html file.
Here is a very minor work on using systemjs + typescript : https://github.com/wmarques/Ng2JhiSample
I just moved to TypeScript (removed IIFE + angular.controller...
lines) and added export ..
. line at the end of the file (see here). Then I imported each controller, services in app.module file. Then I load this module using SystemJS in index.html
It simply displays the home page and there is no Auth logic in it, to make it work fully I have to import all controllers etc in app.module
and I didn't have time do it.
I'm having some weird issue with the typings. on windows when i do npm i typings
i'm able to do npm run typings install
but if I add typings to package.json
and then do npm i
and when i run npm run typings install
I get error as the typings executable is not present in the node_modules/.bin
folder. @wmarques could you check this in your machine to see if this is a windows only issue?
@wmarques @sendilkumarn I already moved to ts fully and integrated systemJS. I didnt move node_modules to webapp instead I wrote a copy task in gulp to move only required files to a vendor folder. @wmarques I will see what you have done as well
@deepu105 seems to work fine on my computer. Oh yes, it's even better if gulp copy required files only ! Do you think we should split our app in little modules ?
@wmarques yes we should. we should atleast make the following modules
@deepu105 @wmarques may be we can split
@wmarques @sendilkumarn when you have time can you try to generate an app using this branch and see if what I have done is ok? It works for me but there is one weird ts error on console and a lot of repetitive logs from the language service
I tried. It does have some error. I will let you know on that
@deepu105 Ok will try to work on it once I have some time. Yep I'll try this and check if I can fix some errors :)
@sendilkumarn I guess I missed a file. Try now
oups sorry for the previous commit message. I was trying to follow your commit message convention but I didn't realize it would be picked up by github. I'll stop doing this, I'll only mention it the PR if i'll ever get to this point ;)
its ok @francisoud
can we move compiled js files outside app folder. Its confusing sometimes
@sendilkumarn ya it was confusing for me as well :( @jhipster/developers what do you think of the below?
We can have the .ts
files and .html
files in the app directory under webapps as in current branch and this will only have the source files
There will be a gulp task which is running as part of gulp serve
.ts
files as it changes to the target|build/www
directory.html
files as it changes to the target|build/www
directorynode_modules
will be copied to target|build/www/vendor
directory
We need to make target|build/www
directory as the webapp root similar to what we do for prod build so irrespective of profile we will always serve web assets from this folder either as un compressed js files or as compressed js files with sourcemaps.This is similar to what @erikkemperman wanted to do earlier for our current version but I was against it as I didnt want developers to always have a gulp serve
running. But that was for angular1, with angular2 we need to have gulp serve
running always anyway for ts file compilation so riding on the same to copy assets to target|build/www
would be ok as well. (@erikkemperman dont be mad at me, I personally still stand by by original view but I dont want to be a bottleneck here, I dont like Typescript as well but I would relax my view for the community needs this time)
second that
@deepu105 Haha, I am furious! But seriously, I completely understand your point of view, of course.
Actually I have been reading about a school of thought that says you can do most things straight from npm scripts, no need for a separate build tool with plugins, because basically all essential components (lint, transpile, minify, watch) have cli anyway, or otherwise are easily wrapped in a portable script.
I'm not sure if that will work for complex projects like this, although I think it would be interesting to see how far one gets. That would remove Deepu's objection, I suppose, because npm scripts should work everywhere. Would anyone be interested if I gave that a try, when I find some time?
Or alternatively, would anyone be interested in trying to adapt to Gulp 4? It's not yet released, but I've been contributing some little bits here and there and it seems to be finally getting there. It promises to be a real improvement over the current version, especially regarding composing tasks and error propagation.
I would be more interested in gulp4 rather than hacking npm to do all these.
Npm would work in theory and may be after some real painfull hacks it might do all what we do today but in the end that package.json would look real ugly and will scare away an average user. Of course you could write external js files and call those but then you are re inventing something similar to gulp without the speed of gulp of course.
IMO its just a hacky way without much real benefit in the end.
And writing complex builds with json, good luck with that :P On 8 Jun 2016 19:07, "Erik Kemperman" notifications@github.com wrote:
@deepu105 https://github.com/deepu105 Haha, I am furious! But seriously, I completely understand your point of view, of course.
Actually I have been reading about a school of thought that says you can do most things straight from npm scripts, no need for a separate build tool with plugins, because basically all essential components (lint, transpile, minify, watch) have cli anyway, or otherwise are easily wrapped in a portable script.
I'm not sure if that will work for complex projects like this, although I think it would be interesting to see how far one gets. That would remove Deepu's objection, I suppose, because npm scripts should work everywhere. Would anyone be interested if I gave that a try, when I find some time?
Or alternatively, would anyone be interested in trying to adapt to Gulp 4? It's not yet released, but I've been contributing some little bits here and there and it seems to be finally getting there. It promises to be a real improvement over the current version, especially regarding composing tasks and error propagation.
— You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub https://github.com/jhipster/generator-jhipster/issues/3664#issuecomment-224558241, or mute the thread https://github.com/notifications/unsubscribe/ABDlF3O-Es7aLShebifTdUOJJwMmu-r_ks5qJqKBgaJpZM4Ipod9 .
@deepu105 All true, and I originally had the same feeling about this. But now I've seen a few examples of reasonably elaborate builds, and I must say it's not nearly as bad as I expected. But yeah, probably JH is too complex.
If I have some time I might give Gulp 4 a go based off this branch, but I should probably wait a bit for things to settle slightly -- both here in this angular 2 effort and my day job.
@wmarques I have split the app to multiple modules
@sendilkumarn can you convert the admin module to angular2?
Am working on it. In between stuck with other activities. I will update
@sendilkumarn thanks. @jhipster/developers this is actually lot more work then we anticipated so we might require more hands here
@jdubois could you add @sendilkumarn to the https://github.com/orgs/jhipster/teams/hipsters group so that I can assign him to this ticket as well
I can't do it right now, but I think this has changed on Github, and you can assign tickets to anyone now.
@deepu105, I am going to start on accounts
module. Hope nobody started yet.
@deepu105 Not sure how to start at the moment. I've started looking at some components inside common
. I have rewritten the ProfileInfoService
(according to the ng2 tutorial) like this (looks fine to me, but its my first hands on ng2 and ts):
import { Injectable } from '@angular/core';
import {Http} from '@angular/http';
import 'rxjs/add/operator/toPromise';
import {ProfileInfo} from 'profileInfo.class'
@Injectable()
export class ProfileService {
private profileInfoUrl = 'api/profile-info';
constructor(private http: Http) {
}
getProfileInfo(): Promise<ProfileInfo> {
return this.http.get(this.profileInfoUrl)
.toPromise()
.then(response => {
let data = response.json().data;
ProfileInfo pi = new ProfileInfo();
pi.activeProfiles = data.activeProfiles;
pi.ribbonEnv = data.ribbonEnv;
pi.inProduction = data.activeProfiles.indexOf("prod") !== -1;
pi.swaggerDisabled = data.activeProfiles.indexOf("no-swagger") !== -1;
return pi;
})
.catch(this.handleError);
}
private handleError(error: any) {
console.error('An error occurred', error);
return Promise.reject(error.message || error);
}
}
So whats next? How to integrate that new servic and how to test it works correctly? How to we handle 3rd party dependencies that are not yet available as ng2 versions?
@atomfrede The idea now is to use the upgrade adapter to import the ng2 service and use it in an ng1 app so that we can still use the external libs. Can you commit your change. Ill try to import this into the app tomorrow. @tapas4java i guess no body has started. Cc @mraible as he might be starting something so to avoid duplicate work.
@jdubois I tried but couldn't anyways not urgent do it when you have time
@deepu105 Sure, just need to integrate into the generator
EDIT: here are my changes: https://github.com/atomfrede/generator-jhipster/commit/161ff39a1ea12226ca5500b8fd7cf6ce48b059d4
I also tried to convert the ribbon directive to an ng2 component
@atomfrede ok ill wait for you to commit into the branch. don't worry if tests fail or if app doesn't work, we can get it fixed on the way
Since there is no opposition for my proposal to move all generated js code into temp folders ill be doing that change first.
@deepu105 Should I open a PR against the angulat2 branch?
I guess you can directly commit if you want. or PR if you want the change to be reviewed.
I just added @sendilkumarn to the "hipsters" team on Github
@deepu105 agree with you, it's very confusing to have .ts, .js and even .map in same folder so we should copy them into the target
folder and keep typescript files in the src
one :+1:
@wmarques im working on that
@deepu105 I'm having some trouble when generating an NG2 app, I let the default choices, instead of the angular version, and at the end in doesn't copy any files so I just have an src
folder... But maybe it's just my computer, I'm trying to update Yeoman
EDIT : If I choose Angular1 it works. Updated Yeoman and using Node 4.4.4 still the same issue :cry:
I pushed a fix can you check now
Thanks & Regards, Deepu
On Tue, Jun 14, 2016 at 4:24 PM, William Marques notifications@github.com wrote:
@deepu105 https://github.com/deepu105 I'm having some trouble when generating an NG2 app, I let the default choices, instead of the angular version, and at the end in doesn't copy any files so I just have an src folder... But maybe it's just my computer, I'm trying to update Yeoman
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/jhipster/generator-jhipster/issues/3664#issuecomment-225812713, or mute the thread https://github.com/notifications/unsubscribe/ABDlF8gc_wduCxIu00fSb4F8-d9qXrENks5qLmU3gaJpZM4Ipod9 .
This is a global ticket listing tasks for Angular 2 support, originally coming from this thread in the dev mailing list
Edit: @jhipster/developers if you have started working on any of the item below, please edit this comment and add your name after the item. Once feature is complete please tick it off, pretty please 😄 - @deepu105
The tasks below can be edited and changed, depending on the discussions below:
client-2
instead ofclient
so that users can choose what they want -> with "client" they will stay on AngularJS 1 (and have less risk), with "client-2" they follow our migration path, and will end up with AngularJS 2 app in the end (but more work/risk for them). All work is now done on "client-2"entity-2
sub generator to use when project is usingclient-2
entity-2
sub-generatorclient
and makeclient-2
default (major version release)progress of individual module migrations
The known issues checklist has been moved to #4407 to make this thread lighter
If anyone is looking for a guide to use the angular-2 branch here it is https://github.com/jhipster/generator-jhipster/blob/angular-2/NG2-GUIDE.md