Skip to content

Generated directive won't work in prod #2294

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

Closed
1 task done
dhaazen opened this issue Oct 13, 2016 · 7 comments
Closed
1 task done

Generated directive won't work in prod #2294

dhaazen opened this issue Oct 13, 2016 · 7 comments
Assignees
Labels

Comments

@dhaazen
Copy link

dhaazen commented Oct 13, 2016

  • I understand that GitHub issues are not for tech support, but for questions specific to this generator, bug reports, and feature requests.
Item Version
generator-angular-fullstack 4.1.0
Node 4.4.5
npm 3.10.5
Operating System OS X
etc etc
Item Answer
Transpiler Babel
Markup HTML
CSS CSS
Router ngRoute
Client Tests Mocha
DB SQL
Auth N
etc etc

When generating a directive and including html the generated code uses:

      templateUrl: 'app/myDirective/myDirective.html',

which when bundled breaks because the path doesn't exist.

This can be resolved by simply changing the line to

      template: require('./myDirective.html'), 
@Awk34 Awk34 added the bug label Oct 13, 2016
@Awk34 Awk34 self-assigned this Oct 13, 2016
@dhaazen
Copy link
Author

dhaazen commented Oct 14, 2016

Hey @Awk34, Did you want me to try to go through the process of just submitting these as pull requests for small changes like this or..? Just because I was about to open another small bug for the generated directive.spec which would be only a couple liner. But I'm not sure how much red tape is involved in trying to contribute to the project. I looked through the guidelines and it seemed pretty strict on making commits. Let me know. Thanks.

@Awk34
Copy link
Member

Awk34 commented Oct 14, 2016

@dhaazen go ahead. This would be a PR against generator-ng-component though.

The main thing is try to conform to our commit message guidelines, like so:

fix(directive): fix template definition for webpack

We enforce this because it allows us to automatically extract a lot of data from these messages

@dhaazen
Copy link
Author

dhaazen commented Oct 14, 2016

Thanks @Awk34 I looked into it and in the generator-ng-component directive has an if else checking for 'filters.webpack'

      <%_ if(filters.webpack) { -%>
      template: require('./<%=name%>.<%=templateExt%>'),
      <%_ } else { -%>
      templateUrl: '<%= htmlUrl %>',
      <%_ } -%>

I can see the filters are added when an new project is created using the generator-angular-fullstack does anyone else use generator-ng-component that wouldn't be using webpack? because if it needs to have that use case then we would need to set the 'filters.webpack' variable in this project. Otherwise remove the if else and stick with the webpack version of the template. Let me know which way you'd like me to go with it.

@Awk34
Copy link
Member

Awk34 commented Oct 14, 2016

I'm not sure if anyone else uses that repo anymore. Anyhow, once the project is fully moved over to Angular 2, We'll have another subgenerator specific to Angular 2 components/etc.

If you look here, you'll see that we're adding the webpack filter to the ng-component config, so I wonder what's getting messed up here...

@dhaazen
Copy link
Author

dhaazen commented Oct 17, 2016

Hey, Figured it out. It didn't account for filters being an array it expected it to be an object. Changed it the:

 <%_ if(filters.webpack) { -%>

to

 <%_ if(filters.indexOf('webpack') > -1) { -%>

And now it works fine. I submitted a pull request to the other project.

Cheers,
Dale

@Awk34
Copy link
Member

Awk34 commented Oct 17, 2016

@Awk34
Copy link
Member

Awk34 commented Oct 17, 2016

#2300

@Awk34 Awk34 closed this as completed Oct 17, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants