Pizzicato
Pizzicato

Reputation: 1621

Complex Angular element (web component) or Angular Library

I need to code a module that would be reused for our different apps, and it requires to use routing, forms, tabs... Does it make sense to make a web component using Angular elements or it would be a better idea to create a library for that?

All of our current apps that would require this module are made in Angular and our company wants to keep using Angular for our web apps, but, who knows if in the future we'll use React or other JS library or framework...

Edit: The module is only for internal use, not for the client. It would include functionality for CRUD operations on different resources that all of our apps have in common (types, languages, statuses...). Each of these would be represented in a tab, so, for example, in the languages tab you'll see a table with pagination showing all languages entries, and you could create new languages filling a form, edit languages and delete them.

Upvotes: 1

Views: 955

Answers (1)

dannybucks
dannybucks

Reputation: 2365

I guess there is more than one answer to this question and you have to decide what to do at the end. From my experience I would recommend to make a normal Angular library, not a web component. This are the reasons:

1) It is just less work and as your company sets on Angular and has no plans to change that I would definitely keep things easy / avoid the extra work.

2) Deployment is most likely getting more complicated when using a independent web component.

3) The chance that you implement something Angular specific by mistake that can't be used in other framework without additional work is high and would make it impossible to actually re-use your library for other frameworks anyways.

4) You say it is a complicated module. In a library you can easily split that into several components / services. Although you can do that in a independent web component too, it's always additional work.

5) And finally: Should your company decide to use another framework than Angular, this would be a huge step as you more or less rewrite everything! If you do such a step, it's always smart to re-thing approaches, user experiences and all of that. And this would most likely leads to the decision, that your web component either has to be heavily refactored, also should no longer use Angular or is deprecated.

So for me it seems like you won't have a benefit from your additional work if you create a independent web component. However: If you find a real benefit from creating a independent web component, one that someone (your boss or customer) is willing to pay for, then you should choose that option.

Upvotes: 4

Related Questions