gulp-inline-ng2-template icon indicating copy to clipboard operation
gulp-inline-ng2-template copied to clipboard

Comments are parsed

Open vavasilev opened this issue 7 years ago • 6 comments

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:

/**

    1. Provide a component, inheriting BaseDialog:
  • @Component({
  • selector: 'some-dialog',
  • templateUrl: 'some-dialog.html'
  • providers: [SomeService, SomeDialogController]
  • })
  • export class SomeDialog extends BaseDialog {
  • constructor(controller: SomeDialogController)
  • }

*/ export class BaseDialog extends ClosableDialog implements OnInit, OnDestroy { ... }

vavasilev avatar Dec 27 '16 16:12 vavasilev

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

ChrisProlls avatar Jun 08 '17 12:06 ChrisProlls

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

dherges avatar Jun 08 '17 15:06 dherges

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 !

ChrisProlls avatar Jun 08 '17 15:06 ChrisProlls

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

ludohenin avatar Dec 16 '17 18:12 ludohenin

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

ChrisProlls avatar Dec 19 '17 21:12 ChrisProlls

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

dherges avatar Dec 20 '17 06:12 dherges