Switch from `require` to `define`

To get the JS modules to load properly. I don't know why this is necessary, but
the tests break without it.