Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Comments are parsed #79

Open
vavasilev opened this issue Dec 27, 2016 · 6 comments
Open

Comments are parsed #79

vavasilev opened this issue Dec 27, 2016 · 6 comments

Comments

@vavasilev
Copy link

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 {
...
}

@ChrisProlls
Copy link

ChrisProlls commented Jun 8, 2017

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

@dherges
Copy link

dherges commented Jun 8, 2017

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
Copy link

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
Copy link
Owner

ludohenin commented Dec 16, 2017

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

@ChrisProlls
Copy link

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

@dherges
Copy link

dherges commented Dec 20, 2017

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants