-
Notifications
You must be signed in to change notification settings - Fork 70
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
Does not work - produced paths for require are incorrect. #20
Comments
It's not angular2-template-loader which is complaining it's webpack. i have post an answer on your question on stackoverflow you can find explanation there. |
The alternative you give me is as follows:
If this is my choice, then I will just use require myself and I do not need this loader. |
@jorawarsingh is correct, your path can simply be expressed as I mean, the whole point of this loader is to not have angular try and make hundreds of requests to access your templates at runtime, so avoiding using their non-cannonical resolution strategy is a given. Also you could create a custom resolver plugin to emulate this behavior instead when a request is being called for |
I would also be more than happy to merge a PR that adds a loader option called |
Angular2 expects I think it is wrong. This loader carries angular2 in its name. For me it means it should use "angular resolution" by default. I.e. rewrite |
No also, this is the relative path strategy for the angular AoT compiler as well. See angular/angular#8953 for more information. Like I said, I'm more than happy to accept a PR for an added feature. Candidly speaking maintaining webpack, working on the angular-cli is more of a priority right now, than edge cases. I hope you can understand. |
I do understand. Thank you for your work and effort. |
Can someone tell me how to resolve this? I agree that i do not see why i should have to change all my templateUrls when using this loader should really do it for me? What happens if later on down the line i do not want to use this loader, i will have to go all through my code and change the templateUrls |
Has someone found a fix for this yet? |
Anyone found a solution for this? spent days with no luck. Any input will be appreciated. |
Please, observe the following TypeScript file:
And it works fine before I use angular2-template-loader. When I am trying to use the latter and run webpack it fails with the following message:
(there are more errors like that for other components, I replaced them with an ellipsis)
The loader converts the aforementioned source into:
And now it fails.
As I understand, the reason is that require works off the current directory, whereas the templateUrl is relative to the root. So, './app/app.component.html' is correct when taken relative to the root, but wrong when relative to the current location.
It is worth noting, that I do not use require anywhere in the source code, only the ES6 import statement, which is also relative to the current location. It is only the Angular2 templateUrl and styleUrls that are relative to the root.
Anyway, I must be doing something wrong, because nobody seems to have my problem. But what am I doing wrong?
The file name is src/client/app/app.component.ts. The source code directory structure is:
The webpack configuration is:
webpack.config.js
module.exports = require('./config/webpack.dev.js');
./config/webpack.dev.js
./config/webpack.common.js
The text was updated successfully, but these errors were encountered: