gulp-inline-ng2-template
gulp-inline-ng2-template copied to clipboard
Comments are parsed
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:
/**
-
- 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 { ... }
Any news about that ? I need this issue to be fixed for an Angular packaging plugin.
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
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 !
I'm back online, please make a PR if you have a solution //cc @dherges @ChrisProlls
Hi @ludohenin, We figured this issue by using the standard Angular CLI process. Thanks for your contribution !
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