Skip to content

socket.io-client/socket.io.js Does not get loaded in build #2524

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

Open
1 task done
mattxgreen opened this issue Mar 21, 2017 · 9 comments
Open
1 task done

socket.io-client/socket.io.js Does not get loaded in build #2524

mattxgreen opened this issue Mar 21, 2017 · 9 comments

Comments

@mattxgreen
Copy link

mattxgreen commented Mar 21, 2017

  • 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

@Awk34
Copy link
Member

Awk34 commented Mar 21, 2017

which version of socket.io do you have installed?

@mattxgreen
Copy link
Author

Default version installed is "[email protected]" from "socket.io-client": "^1.3.5"

@mattxgreen
Copy link
Author

It's worth clarifying that gulp serve works fine without this change. The problem only occurs on a build.

@Awk34
Copy link
Member

Awk34 commented Mar 21, 2017

try changing <script src="socket.io-client/socket.io.js"></script> to <script src="socket.io-client/dist/socket.io.js"></script>

@mattxgreen
Copy link
Author

That does seem to work, and does appear to compile the socket.io.js into the vendor.js. Better solution than mine. Thank you.

@mattxgreen
Copy link
Author

@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

@mattxgreen
Copy link
Author

mattxgreen commented Mar 23, 2017

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?

@Awk34
Copy link
Member

Awk34 commented Mar 23, 2017

@mattxgreen go for it

@Awk34
Copy link
Member

Awk34 commented Mar 23, 2017

The PR would have to be made against the v3 branch, as the master branch contains code for the 4.x.x versions

mattxgreen pushed a commit to mattxgreen/generator-angular-fullstack that referenced this issue Mar 23, 2017
Adds socket-io-client to bower
Fixes issue with gulp wiredep removing the string 'client' from added packages with the word 'client' in it's name
Closes angular-fullstack#2524
@mattxgreen mattxgreen mentioned this issue Mar 23, 2017
3 tasks
Awk34 added a commit that referenced this issue Mar 24, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants