I'm developing a angular project that has grown large enough to warrant 
increased modularization, so I went through the process of splitting out a 
lot of the components I use into separate libraries. These packages might 
in future be published via npm, but for the moment they are unpublished. 
For each of the packages, I used systemjs for packaging unit tests because 
it takes 5 minutes to set up and the libraries are small, but I've used 
webpack on the main library because it bundles the applications nicely. 

Now that I've got to the point that I'm integrating the libraries back into 
the main application I have a problem about what to do with the moduleId of 
the components. I tried the following hack in order to fix the problem

 
@Component({
  moduleId: typeof module.id === 'string' ? module.id :null
  ...
})
...

But I tried using the compiler-cli on one of the libraries, and it 
complains because it's not statically analyzable -- this isn't a problem at 
the moment, but I could forsee it being a problem in future when I switch 
my production code to AoT compilation. I also can't inline the styles in 
the libraries because there are sass variables that I'd like to override 
elsewhere in my application. 

I also tried running the template loader over all javascript files I've 
imported the libraries, but it unfortunately breaks the `@angular/compiler` 
module, giving an error about "Cannot find directory "./" in 
@angular/compiler/bundles".

There seems to be a problem with developing a component library in a way 
that allows the consumer to support all possible build processes, and it 
all centres around the handling of moduleId.

I don't know how libraries like @angular/material get away with it, I 
haven't tried using it (preferring bootstrap) and I can't see how the build 
process of these libraries gets around the moduleId problem.

Some help please? I would usually ask a question like this on stack 
overflow but there's a couple of similar questions already out there in the 
wild that have been gathering dust, so I decided to try the mailing list 
instead.

-- 
You received this message because you are subscribed to the Google Groups 
"Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to