ludohenin / gulp-inline-ng2-template

Gulp plugin to inline HTML and CSS into Angular 2 component decorators
MIT License
126 stars 26 forks source link

Comments are parsed #79

Open vavasilev opened 7 years ago

vavasilev commented 7 years ago

Hello,

I have a typescript file with comment, which gives example how it should be used. In the example I have provided @Component template definition. When running the template definition it tells me it can not find the file that was mentioned in templateUrl. As this is just an example, it is normal that this file does not exist. I think the plug-in should not attempt to parse code inside comments.

Example:

/**

ChrisProlls commented 7 years ago

Any news about that ? I need this issue to be fixed for an Angular packaging plugin.

dherges commented 7 years ago

I mean, guys, the news is that it's all regex ... if someone has an idea how, feel free!

The code in question, that breaks the builds, is for example: https://github.com/angular/angular/blob/b10029c18b11dc40577e1dfd86d2edfbbee16bad/packages/animations/src/animation_metadata.ts#L257-L273

ChrisProlls commented 7 years ago

Yeah it seems not so difficult, but as you may see if you search deep in this repository, there is no activity on this repository anymore, PR are not merged since January ! And I searched from another plugin to do this, but there are not maintened anymore ... We are searching for a workaround now, maybe publish all sources (it's an intern NPM package) until tha Angular team release a proper way to publish NPM package. It's too bad, your plugin seems very nice !

ludohenin commented 6 years ago

I'm back online, please make a PR if you have a solution //cc @dherges @ChrisProlls

ChrisProlls commented 6 years ago

Hi @ludohenin, We figured this issue by using the standard Angular CLI process. Thanks for your contribution !

dherges commented 6 years ago

A more robust solution is to parse the TypeScript AST (instead of regex) to extract templateUrl and stylesUrls properties, similar to https://github.com/dherges/ng-packagr/blob/7135c42/src/lib/util/ts-transformers.ts#L4-L31

See also TheLarkInn/angular2-template-loader#54 ans TheLarkInn/angular2-template-loader#70