Upgrading Xblocks for Ironwood

TL;DR

Some (at least one) vendor/customer sites upgrading from Gingko to Ironwood are finding XBlock code no longer working with some of their libraries using require/define wrappers. This can be accounted for by the change to how XBlocks are loaded with the Ironwood release, and can be fixed by removing the define/require wrappers in favor of importing files to update the window context, and relying on the pre-existing configuration to provide a number of modules at the global level.

Details/Background

McKinsey updated from Gingko to Ironwood release and noticed that their scorm xblock stopped responding as expected.

Specifically, they had a library attempting to add functionality to jquery selectors for file upload, which was attempting to use the local requireJS define interface to load jquery.

In the dev and production environments, this simplifies to roughly:

Unfortunately, that syntax doesn’t seem to work anymore in Ironwood release (specifically within xblocks), and calls to the define function available in the window are swallowed.

Luckily, jquery, along with a number of other libraries, are included at the global window-level. So we were able to simply remove the first clause of the if-statement, causing it to fall back to the window’s jQuery reference.

Posting this because it is possible other such isolated xblock instances may need the same update in order to work in the ironwood release.