play-angular-typescript.g8 icon indicating copy to clipboard operation
play-angular-typescript.g8 copied to clipboard

template3 (single js out file) doesn't work with ng2

Open golechwierowicz opened this issue 8 years ago • 7 comments

Hi, great activator!

However when doing sbt dist for production and then launching the binary file it fails with

http://localhost:9000/assets/lib/rxjs/rx.js Failed to load resource: the server responded with a status of 404 (Not Found) zone.min.js:1 Error: (SystemJS) Error: XHR error (404 Not Found) loading http://localhost:9000/assets/lib/rxjs/rx.js(…)e.invoke @ zone.min.js:1

golechwierowicz avatar Aug 30 '16 10:08 golechwierowicz

I couldn't replicate your issue. I called sbt stage and then ran the binary and the NG2 application starts just fine.

joost-de-vries avatar Aug 30 '16 18:08 joost-de-vries

Since I couldn't replicate the issue and haven't heard from your for quite a while I'm closing the issue.

joost-de-vries avatar Oct 17 '16 15:10 joost-de-vries

I know you have closed the issue, but I am having the same problem if I follow your readme.

Running: sbt stage it works, however, JS is served as more than one file.

Running: sbt stage -tsCompileMode=stage it gets the same error as @golechwierowicz :

zone.min.js:1 Error: (SystemJS) XHR error (404 Not Found) loading http://localhost:9000/assets/app/main.js(…)
e.invoke @ zone.min.js:1
n.run @ zone.min.js:1
(anonymous function) @ zone.min.js:1
e.invokeTask @ zone.min.js:1
n.runTask @ zone.min.js:1
a @ zone.min.js:1
invoke @ zone.min.js:1

avanwyk avatar Oct 17 '16 18:10 avanwyk

The template3 variant hasn't been ported to ng2 final yet. It's mostly an ng2 matter with a little bit of knowledge of Play required.

What needs to be done is that the <script/> downloads and the SystemJs config need to be updated for Angular2. What's different in the SystemJs config is that either the config shouldn't do anything about loading the app code and we should load it using a script tag. Or we should configure SystemJs to go to this single file for all app modules.

I'm pretty busy the coming weeks. A pull request is welcome.

joost-de-vries avatar Oct 19 '16 05:10 joost-de-vries

I have tried to run the single javascript file compilation. The only problem I have is that in the generated main.js there are a lot of references to Angular2 dependencies. For example, there is a line that is:

System.register("app/app/app.component", ['@angular/core'], function //... 

All those files are being requested by the browser and they are not shipped with that main.js, they still cannot be accessed because there is nothing on localhost:9000/@angular/core.

The only javascript files referenced in this index2.html are

  • angular2-polyfills.js
  • system.js
  • Rx.js
  • angular2.dev.js
  • main.js

None of them having problems loading.

I run using activator -DtsCompileMode=stage ~run

I know this template is not ported yet for this template, and I'm really sorry for bothering you with this 😓 , I just don't really know what is the missing part on this. Are dependencies not being compiled inside main.js?

I attach my main.js, I have changed the HTML System import script for:

<script>
    System.import('app/main')
        .catch(console.error.bind(console));
</script>

I don't really have any urges with this, so don't worry.

Thank you! 😃

camilosampedro avatar Nov 25 '16 20:11 camilosampedro

@joost-de-vries any updates here? I know you said you are busy, but just wanted to know if you will be looking at this anytime soon? I too am unable to get the index2 to work. I am getting 404 of angular2-polyfills.js, angualr2.dev.js files

Thanks

SadatAnwar avatar Apr 13 '17 21:04 SadatAnwar

Hi, Some updates about single js file compilation ? I'm struggling too running my app in production. Thanks

museOnSite avatar Sep 25 '17 13:09 museOnSite