loading...
Cover image for Angular's NgModule System needs one simple change

Angular's NgModule System needs one simple change

jwp profile image John Peters Updated on ・1 min read

When the Javascript module system was codified, it was an immediate blow to the Angular NgModule system.

Indeed if we are creating Angular libraries and look at the compiled distribution folder output, all the NgModules collapse. They all point to just one or more Javascript index.js files like this:

//One or more exports
✔️ export * from filename.js

There is nothing more simple than one or more export statements in an index.js file that define a known ECMA module. Need more than one module for separation of concerns? Just create another index.js file in another folder.

The ngModule system is legacy and just needs to be changed. Some may argue in favor of it, for them the feature should stay as is. For others, that prefer the other way, a simple option should be allowed for every new Component, Directive, Service etc. Instead of specifying an NgModule we should be able to pick an index.js file.

I opened a ticket to Angular on the subject and see other's have too.

JWP2020 Allow Index.ts files in NgModule System.

Discussion

pic
Editor guide