socket.io-client/socket.io.js Does not get loaded in build
- [x] 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 | 3.8.0 |
| Node | 4.6.2 |
| npm | 4.0.3 |
| Operating System | Ubuntu 16 |
| Item | Option |
|---|---|
| Transpiler | Babel / TypeScript |
| Markup | HTML / Pug |
| CSS | CSS / LESS / SCSS / Stylus |
| Router | ngRoute / ui-router |
| Client Tests | Jasmine / Mocha |
| DB | MongoDB / SQL |
| Auth | Y / N |
On a fresh scaffold of version 3.8, on a gulp serve:dist Chrome Console will show "ReferenceError: io is not defined(…)". I have isolated this to be socket.io-client/socket.io.js not loading (line 62 in index.html). The following seems to work for now, but does not compile the js into the vendor.js.
Change this in index.js:
<!-- endbower -->
<script src="socket.io-client/socket.io.js"></script>
<!-- endbuild -->
TO
<!-- endbower -->
<!-- endbuild -->
<script src="socket.io-client/socket.io.js"></script>
And remark out the following line in app.js
serveClient: config.env !== 'production',
I would also like to note similar prior issues #766 and #2497
which version of socket.io do you have installed?
Default version installed is "[email protected]" from "socket.io-client": "^1.3.5"
It's worth clarifying that gulp serve works fine without this change. The problem only occurs on a build.
try changing <script src="socket.io-client/socket.io.js"></script> to <script src="socket.io-client/dist/socket.io.js"></script>
That does seem to work, and does appear to compile the socket.io.js into the vendor.js. Better solution than mine. Thank you.
@Awk34 After a bit of using this, I see a new bug introduced. While this fixes the build it breaks my development environment. I'm now getting the io not defined error on a gulp serve
I have found what I believe to be an event better solution:
bower install socket-io-client --save
This will reveal a bug in the gulpfile which adds the js file as the following( client is removed):
<script src="bower_components/socket-io-/socket.io.js"></script>
To remedy this, on line 445 of the gulpfile.babel.js change this:
ignorePath: clientPath
to
ignorePath: './'+clientPath
Which will finally result in:
<script src="bower_components/socket-io-client/socket.io.js"></script>
Remove all other references in the index.html to socket.io-client
Would love to have this added into the master @Awk34 Would you like a PR?
@mattxgreen go for it
The PR would have to be made against the v3 branch, as the master branch contains code for the 4.x.x versions