gonzofish / angular-librarian

An Angular 2+ scaffolding setup for creating libraries
https://www.npmjs.com/package/angular-librarian
MIT License
91 stars 9 forks source link

referenced templateUrl styleUrls not working, inline works #52

Closed kferstl closed 7 years ago

kferstl commented 7 years ago

Referenced files for template and styles do not work with out-of-the-box configuration. I just ran npm run start using windows with node v8.1.3, i also tried 6.9 LTS without success.

I debugged it a bit and found that the Angular Compiler does not properly read the @Component metadata. It does read the "selector" property but it reads "templateUrl" as an empty string instead of the actual value. Changing to inline-templates is a possible workarround but i'd prefer separate files as it is easier to manage scss files etc.

I'd be happy to provide further info & assistance if you'd like to tackle this issue!

Great work for the library so far! I was hoping somebody builds a tool like this one day for a looong time :-)

gonzofish commented 7 years ago

I haven't had this issue so far...can I see some code? I've been using librarian day-to-day and I only use templateUrl & styleUrls

gonzofish commented 7 years ago

And thanks for the compliments, always nice to hear kind words

kferstl commented 7 years ago

i created a little repository with the bricked code :-)

https://github.com/kferstl/angular-librarian-test

what i did:

image

image

gonzofish commented 7 years ago

Ok, I'll check out your repo and see what goes--I'm on node 6.9.5 right now myself and it's been working

gonzofish commented 7 years ago

I'm almost 100% sure, after running some local tests, that running ncu -u -a is what caused the problems. The package.json that is scaffolded out by angular-librarian is setup somewhat specifically--even changing something like @types/jasmine can cause error messages.

My assumption from issues in the past was that updating angular2-template-loader past 0.6.0 is causing the problems. So, in your project, I did roll back that to 0.6.0 you'll and it worked. So if you do that, it should work!

Let me know if it does (and close the issue if it worked).

kferstl commented 7 years ago

downgrading to angular2-template-loader v 0.6.0 causes the loader to load the actual content of the template appended to the URL. So it now actually resolves the file but it tries to load the content as an URL then. Strange behaviour ;) using the angular router, with a simple template just containing the therefor results in the following request:

http://localhost:9000/%3Crouter-outlet%3E%3C/router-outlet%3E

gonzofish commented 7 years ago

wait so you're using the Angular router, too?

gonzofish commented 7 years ago

Anymore details on this @kferstl? I was hoping to help you out here, if you're ok, though, let me know so I can close this up!