mitodl / micromasters

Portal for learners and course teams to access MITx Micromasters® programs
https://mm.mit.edu
BSD 3-Clause "New" or "Revised" License
29 stars 17 forks source link

ReferenceError: jQuery is not defined #2278

Open pdpinch opened 7 years ago

pdpinch commented 7 years ago

some kind of network failure?

https://sentry.io/mit-office-of-digital-learning/micromasters/issues/190464647/

ReferenceError: jQuery is not defined
  at call (./static/js/entry/public.js:3)
...
(3 additional frame(s) were not displayed)
singingwolfboy commented 7 years ago

This problem is coming from RRSSB, the social sharing widget we're using. It depends on jQuery, and assumes that it is already loaded in the global context. It looks like RRSSB is imported in entry/public.js, while jQuery is imported (and put into the global context) in entry/style_public.js, so there's a race condition here.

@aliceriot, do you know why this was set up this way?

alicewriteswrongs commented 7 years ago

I'm not sure what the justification was, probably not wanting to import it twice or something. That shouldn't be a concern though, now that we're using webpack's CommonChunkPlugin to pull out common code.

singingwolfboy commented 7 years ago

@aliceriot Does that mean that we can import jQuery in entry/public.js to resolve the race condition, and not increase the file size? I'm not familiar with how CommonChunkPlugin works.

alicewriteswrongs commented 7 years ago

Yep, that's exactly what it means. CommonChunkPlugin looks at all of the code and finds chunks which are common to different entry points, and it pulls these out into a separate bundle. We have it set so that anything which is present in 2 or more places should be pulled out.