rangle / angular-ssr

Angular 4+ server-side rendering solution compatible with @angular/material, jQuery, and other libraries that touch the DOM (as well as providing a rich feature set!)
BSD 2-Clause "Simplified" License
279 stars 38 forks source link

node_modules path exclusion #44

Closed buu700 closed 7 years ago

buu700 commented 7 years ago

Not sure if you saw my comment about finding the root cause of #36, so figured I should just move it over to a new ticket.

It seems that having a node_modules accessible from the temporary rendering directory causes the error I pasted (as you noted, most likely by causing multiple instances of reflect-metadata to be loaded).

Could this be resolved simply by having ng-render add something to the effect of "exclude": ["/node_modules", "/tmp/node_modules"] to the relevant tsconfig.json?

clbond commented 7 years ago

Ahhh, that makes sense. Hmm, I am not quite sure how to solve this. Technically the way nodejs/npm is behaving is correct for your node_modules layout since you really do have duplicate implementations available (in / and /tmp etc)

buu700 commented 7 years ago

Yep, it's literally at the filesystem root. This is in a Docker image for our local development/build environment, and the node_modules were placed at the root with the intention that they would be available for any script that runs anywhere, which we hadn't expected would ever become the opposite of what we want.

If excluding /node_modules isn't possible, what about removing any duplicate modules from the tmp node_modules?

clbond commented 7 years ago

angular-ssr doesn't have any logic about how to handle node_modules. That is all built into node / npm / webpack. There's really nothing I can do about it. It is always going to search parent directories for node_modules.