angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

[Feature] Create boilerplate for library

Open ritz078 opened this issue 10 years ago • 73 comments

This is a feature request.

It will be great if we can create a basic boilerplate for creating libraries for pipes, components etc. This is the time when people may be willing to create components for angular 2 but due to the lack of this, it's tough. angular-cli already has a build system in place so it will be easier to integrate it here.

For example, If making a pipe, I won't need the whole src folder. A single file and a page where I can see the preview will do. This will make it easier for a lot of people.

ritz078 avatar Aug 14 '16 20:08 ritz078

I used https://github.com/robisim74/angular-library-starter with 3 npm packages (http://npmjs.com/~orizens) thus far and it's working quite well with AOT

orizens avatar May 26 '17 12:05 orizens

Check out https://github.com/gonzofish/angular-library-set

litzebauer avatar May 26 '17 13:05 litzebauer

@benetis-bentley Not at all, i am not disrespecting any framework or anyone. We all are here because of the wonderful framework Angular and i love to use it. I was just worried, Angular should not lose its popularity because of this.

My words would have been little harsh, i apologize if i have hurt any one. (edited my previous comment as well)

I do have to say, it is getting harder than angularjs because of the fragmentation... (angular 2, angular 4), even upgrading the framework from angular 4.0.3 > 4.1.2 broke the build (I think it has nothing to do with the framework, it is problem with the CLI) It is going out of scope for this issue, so i ll leave it here.

I am just a encouraged developer looking to promote Angular.

achieverprince avatar May 29 '17 09:05 achieverprince

@achieverprince

Unfortunately I agree with you. The Angular team has not been able to create a simple framework for the community. Instead he has put more inconveniences along the way than improvements.

In my team we have made a library for Angular 2/4 and we have had many problems to support the different versions and, above all, the AOT compilation.

If a framework wants to be successful it needs the community, and it is evident that Angular 2/4 has not been built with the community in mind.

It would be well if the Angular team would participate in the reflection created in this issue and tell us their impressions.

pjpenast avatar May 30 '17 10:05 pjpenast

Perhaps the idea of what an Angular Library needs to change to better go with the flow that Angular CLI supports. My thought is that instead of attempting to create an alternative set of build tools for Angular Libraries (ex. https://github.com/gonzofish/angular-library-set), libraries could be included directly into an Angular CLI based project in the /src/app/contrib/<angular library module name> directory so that the standard Angular CLI build chain picks it up. This might get messy with dependency management but Open Source projects like Drupal were able to foster a thriving ecosystem of community contributed modules that did not have the luxury of being able to use their own specific version of some dependency.

rjcorwin avatar May 30 '17 15:05 rjcorwin

@rjsteinert I agree that creating third-party tools don't solve the problem--I created Angular Librarian when I realized using the CLI wasn't going to be possible/too cumbersome to create a library.

I'd love to incorporate what librarian and other generators have done into the CLI to perpetuate a set of standards & practices when it comes to developing Angular code.

gonzofish avatar May 30 '17 17:05 gonzofish

It's great to see so many people eager to help with this feature, however @filipesilva commented above:

I appreciate your offer but we're not yet open to contributions for this new feature :/

I think this means that Angular team is working hard on this feature. I only hope to see an update with the progress/roadmap to calm the community down a bit.

DmitryEfimenko avatar May 30 '17 17:05 DmitryEfimenko

@DmitryEfimenko I think that would be great for the community to get an update with the progress as many of us in the community have been eagerly waiting for this feature to be out.

playground avatar May 30 '17 17:05 playground

@DmitryEfimenko I doubt that, cos the priority is still "required". I think the Angular team has other major issues to deal with in their bucket.

I absolutely respect the team on prioritizing the issues (they know the actual situation) I think we shouldn't pressure them as well, but what other choice do we got.

achieverprince avatar May 30 '17 17:05 achieverprince

Thanks everyone for your comments.

We really appreciate the discussion regarding libraries, but unfortunately this will not be implemented as part of CLI 1.x. There are multiple challenges that are insurmountable with library support and the current state of the CLI. Here are a few examples (in no particular order, and non-exhaustive):

  1. Webpack does not support the kind of modules we're looking for when publishing Angular libraries (e.g. metadata.json and d.ts files).
  2. Webpack does not support (but it's on the roadmap) outputting ES6 code like we suggest for flat modules.
  3. We do not have a story yet for a real multi-application projects, which is required for developing libraries (you want a demo app, a development app and an e2e app for developing libraries).
  4. We do not have support for custom templates, and creating templates right now is particularly expensive for us.
  5. We do not have support for having multiple entry points.
  6. There's no proper serve/test/e2e, or even build stories for libraries in particular. What I mean by this is that no design has been done yet on how e.g. ng serve in a library would even work. This is a surprisingly hard problem for us because the CLI should stay as simple-to-use as possible. Same goes for ng test; our current karma config relies heavily on Webpack (see points above).

There are of course other problems that arise when building a CLI tool that supports both libraries and applications while being simple and straightforward to understand.

As for the way forward, we are currently building our Angular Development Kit and in the early design stages. We are rethinking the build story entirely and taking into account libraries from the start. Unfortunately the timeline for the DevKit is rather fuzzy, but once we have something more concrete we will share it with the community.

I'm going to lock this conversation for now, to make sure people coming into this thread see this message. I am not entirely sure this issue will live on as we move to the DevKit, but wherever news happen on library support in the CLI I will point to from this thread so people can follow.

Thanks everyone.

hansl avatar May 30 '17 18:05 hansl

Addendum: We are in the process of adding custom template support to the CLI, and with it another tool that can be used to generate just templates but outside the CLI. We will consider having a scaffold for basic library projects, but it will not be part of the Angular CLI.

hansl avatar May 30 '17 18:05 hansl

I created https://github.com/angular/angular-cli/issues/6510 to keep this thread locked, but the conversation going. Please continue the discussion over to the new issue, so that people coming here see the official answer.

hansl avatar May 30 '17 18:05 hansl

In version 6.0.0 of Angular CLI you will be able to create, test and lint libraries.

This functionality is available in the latest RCs of 6.0.0, and documentation can temporarily be found at https://github.com/angular/angular-cli/blob/master/docs/documentation/stories/create-library.md. Once 6.0.0 reaches final, the documentation will be moved to the main wiki.

filipesilva avatar May 02 '18 23:05 filipesilva