Open theaccordance opened 8 years ago
Bueller?... Bueller?... Bueller?
Hi @theaccordance,
We use socket.io for logging as well as some internal processes and therefore inject it when we start the server. It is not related to the autoreload work.
There does appear to be a conflict between requirejs and socket.io, I see a patch here ( although it does not really help you @theaccordance ) https://gist.github.com/Tug/3d1c0282df796a518a5c
I ended up building out my own serve function within my project's grunt.js
workflow. Not too difficult to mimic with the exception of the proxy, but I'm using a CORS plugin to circumvent that need until I can set time aside to configure one.
I am currently experiencing the exact same issue, as soon as I include the require.js script I get the very long error.
Uncaught Error: Mismatched anonymous define() module
Any suggestions? Unfortunately I didn't get a lot out of @theaccordance's solution, I'd like to keeping using phonegap serve
if possible to test on the Phonegap developer app...
i'm having the same issue, did someone maneged to solve this, or have a work around?
I'm still using the workaround I described above. Not ideal to "recreate the wheel", but it's worked and I haven't had to deal with the mismatch error in my console logs during iterative development.
Thoughts I've had in terms of addressing the problem so I could continue using phonegap serve
:
To clarify what my workaround is:
phonegap serve
in favor of a different web server to launch my cordova project in-browser. I went with grunt-contrib-connect since I'm a grunt.js guy, there's a lot of other options available as well if you're not into grunt. My server points to the compiled browser target: my-project/platforms/browser/www
my-project/platforms/browser/www
when files are changed@theaccordance I can confirm that webpack does not suffer from this conflict, I'm now using webpack with phonegap serve
without issue.
I'm having this issue as well. Would love to see this fixed.
I'm ditching RequireJS as I plan an upgrade of our major frameworks for my client-side stack, so this will no longer be an issue for me.
Since no traction was made on this issue, I would encourage others to move away from RequireJS, should they feel this is important enough to address.
The quick trick is to comment a few lines in node_modules/socket.io-client/socket.io
:
(function webpackUniversalModuleDefinition(root, factory) {
//if(typeof exports === 'object' && typeof module === 'object')
//module.exports = factory();
//else if(typeof define === 'function' && define.amd)
//define([], factory);
//else if(typeof exports === 'object')
//exports["io"] = factory();
//else
root["io"] = factory();
})(this, function() {
return /******/ (function(modules) { // webpackBootstrap
but it's really dirty... but I don't see how we can handle this in userland especially since connect-phonegap
injects code that rely on the global variable :
<script>
(function(window) {
var socket = io(document.location.protocol + '//' + document.location.host);
//...
OS: Mac OS X 10.11.4 CLI Version: 6.0.3 Node Version: 4.3.1 Browsers: Google Chrome 50.0.2661.86 (64-bit), Chrome Canary 52.0.2718.0 canary (64-bit)
I have a phonegap app that's built with Require.JS, when I load the app into the browser using
phonegap serve
, RequireJS throws a 7.3k line-long error message about anUncaught Error: Mismatched anonymous define() module
related tosocket.io
This gist contains the error in its entirety. This happens every time the app is initialized (page refreshed), and it has a significant impact on the browser, slowing down our iterative development process.I verified that our application does not have
socket.io
as a dependency, but the library is being injected at the bottom of my page when usingphonegap serve
. Below is my source for the index file being served:But when inspecting the page in Chrome, I find that![screen shot 2016-04-27 at 2 09 16 pm](https://cloud.githubusercontent.com/assets/1813001/14869740/1d1fd432-0c9b-11e6-80b3-c53dfc0326a7.png)
socket.io
is injected at the bottom of the page:I've attempted to run
phonegap serve --no-autoreload
but that doesn't resolve the problem either.