-
-
Notifications
You must be signed in to change notification settings - Fork 40
WebPack'd bundle.js file can't seem to figure out how to load the main /app.component.html #10
Comments
I think you can solve your problems by following what I have done here #11. It's not the definitive solution but it is the best available right now.. |
@ntrp actually thanks for the input -- I have two other ways (just haven't had time to try either) I believe would fix this, but I posted the bug because this is a serious issue for anyone doing any ng code and using webpack. |
The major problem is that you can't have the same codebase for standard build and webpack unless you use only inline templates.. |
@ntrp -- Actually I believe either of the two fixes that I have come up with (still haven't needed to try either) would easily allow everything to work with both inline and external templates all automatically for all types of projects. So I don't honestly believe this issue will actually block @NathanWalker 's project. Nathan was going to try something else first -- he is the guru at ng2, me I just pretend to know what I'm doing. :-D I'd rather let him try and fix his issue if he can, because then he can probably incorporate it into his cool ns-ng2 seed, so that others can benefit. |
The latest release of nativescript-dev-webpack (0.2.x) takes care of the templateUrl/template (or bundled vs. non-bundled) problem by using the ng-tools AoT loader. With that you can have a |
This seems to be an issue between Angular2, webpack and the project -- part of the issue is WebPack/ng2 ---
Side note: I love how /app.component.html is trying to load /app.component.html
The issue is that webpack does some url rewriting; the original app.component.js file has:
The bundle.js has:
templateURL: '/app.component.html'
This obviously messes things up; as when this gets to the http/xhr function the "/" causes it to try and load the file from the main root folder of the device.
Now related to this issue is that webpack doesn't rewrite the urls properly for the other sub-components either.
This project has a "components/name/name.js" folder. In this folder it has the same declaration as the app.component:
templateUrl: 'name.component.html'
However, in this case the bundle.js has:
templateUrl: 'name.component.html'
Notice it didn't add the "/" which is good on one hand, but notice what it didn't add? It didn't bother to add that this file is actually located in the "components/name" folder. So when xhr tried to read it -- it fails since it things it is in the root of the app folder.
So basically all components fail to load, making the bundled app worthless..
One side note: even thought the app bundled up all the JS in the "app" folder (and subfolders) and is using them from the bundle.js; the actual deployed app on the emulator appears to have all the .js from the app and the app sub folders also deployed. Shouldn't these also be excluded since they are in the bundle.js
The text was updated successfully, but these errors were encountered: