Angular CLI is probably always going to be faster as it stands today. We think we offer a good compromise. 2 seconds vs 3 seconds is not worth fretting over in my opinion. Both are pretty fast. We’ll keep trying to get faster but for now there are more pressing issues to attend to.
The Angular CLI is not without it’s own host of issues. In some ways, we think we’re ahead of them. In other ways, we’re playing catch up. I’m confident we’ll get where we need to be.
@pivalig, Sorry, that isn’t really enough to work off of. Can you try to track the issue down and if it’s an issue with the build process itself vs the code/library can you file an issue here?
I mentioned the Angular CLI just for reference, as speed will vary on different machines. 3 secs is not too bad, but I suspect on slower machines the difference will be more significant.
I think there’s actually another thing that makes the webpack-dev-server nicer to work with: as soon as you save a file you see in the devtools console [WDS] App updated. Recompiling...
It’s a small detail but it does helps with the “perceived speed” because you know straight away that the change has been detected, even if it’s going to take a bit longer before it reloads the page. Without that you just wait there thinking “is it doing anything?”.
I was having various issues trying to use Webpack with Ionic and Angular, especially when it came to caching/refreshing files and HMR. Luckily, I stumbled across this github repo: https://github.com/qdouble/angular-webpack2-starter. (This is not AngularClass.) This repo demonstrates quite a lot and does it really well. I got HMR, lazy loading, and AOT (with and without Angular Universal) all setup in a day. And that included integrating it all with Ionic. While I’m not using the Ionic CLI directly, I am using some of the scripts from ionic-app-scrpts.
I figured this repo may have some some ideas that could help you out so thought I’d share. It also uses some libraries that I haven’t had any experience with yet, like Yarn and NGRX (specifically the ‘store’). So, if you like trying new things, this repo should do the trick.
Hey Dan, thanks for driving this one home. As a early adopter of RC0/1 I had my share of trouble with rollup and dependencies which worked with ionic beta. now with app-scripts@beta these tend to work as expected!
I now tried the latest beta 2 of webpack support and I have the problem that ionic serve creates for every .ts file in my src folder one .js and one .js.map file, in the same folder which is quite annoying. Is there a way to make it save these files in a separate folder?
Edit: Another problem: When running ionic-app-scripts build --dev, the program outputs “build dev finished” and does nothing afterwards.
can you please provide minimal project template for the external library that can be used with the latest app scripts to demonstrate reusable libraries work? Optionally could you explain how this example could be made working with app scripts (webpack)? https://github.com/DenisVuyka/ionic2-issue
For last 3 weeks since migrating from beta 11 I’m desperately trying to get at least any ‘empty’ project working with RC.x tools with no luck.
It should not save the .js and .js.map files to the src folder. It should save them to the .tmp folder. Are you doing something unique there? Are you overriding the .tmp directory per the docs?
I see that it uses webpack now, not rollup. Upon startup (ionic serve) the browser error is “Uncaught Error: Unexpected value ‘SamplesModule’ imported by the module ‘AppModule’”.
All I do is ‘npm install’ my demo library, and change app.module.ts
Is SamplesModule an NgModule export? Can you review the docs on Angular Modules and confirm? Admittedly, it is complicated. There are javascript/typescript classes which are JS modules, and then there are NgModules which are a separate thing.
So i switched to webpack and i am back to life, from 25 seconds ts updates to now only 4-6 seconds. This is bearable but 25 seconds was a pain to wait. Thanks ionic team.
This project works with angular 2 projects without any problem. The only problem I have is running it with Ionic.
So far I’ve been trying to get it working for a month now without any responses here, on github and twitter. You guys just keep disappearing when asked about guidelines for shared libraries.
I would be more than happy if you provide any other basic template that works fine with whatever configuration and bundler you prefer this week.
I’m sorry that’s been your experience. We are all very busy so sometimes we lose track of this. Since we allowed Webpack support, most third party libraries are just working without issue. In general, just make any library that works in the web and it should be fine. Commonjs, Typescript, whatever. If it is an NgModule library (which most aren’t), then it needs to be pre-compiled with NGC and include the .metadata.json files.
I will check out your project and give some feedback. It looks fine at first glance. I am not sure why it wouldn’t work with Ionic but I will dig in now.
Thanks Dan, much appreciated. Even a small gist with package.json and absolute minimum to get it working would be more than enough. I just need anything to migrate code to and keep working.
I was unable to build your library out of the box due to it not depending on @angular/compiler-cli. I added an entry for @angular/compiler-cli@0.6.2 since that is what ionic-angular is set up to use. I’m not sure if that makes a difference or not.
Your library looks like it is set-up correctly from a distribution perspective. You’re shipping esm modules (es2015 module headers, es5 body content). I did not do the bundling as that step didn’t work either, but I doubt you want to do that to get started anyway.
I think the part that you’re missing is how to import the module in a separate project.
See the code we wrote here
to provide the import in the NgModule in Ionic apps.
I don’t have time to do a deeper dive right now. I will try to make some time in the next week to create starter projects for both regular modern libs (Typescript + esm) and then an angular NgModule lib as well. Sound fair? In general, any code that can run with ngc in an Angular project can be run in an Ionic project. Using the angular-cli and utilizing ngc may be a good path to troubleshoot since it takes Ionic out of the equation.