Issue with autoLoadMode, modeURL and browserify



I’m using CM 5.1.0 and browserify.

I can require CM modules just fine, e.g.


however, I'm trying to do autoloading of modes based on file extention and I cannot work out what the modeURL should be. I'ver tried:

not setting it (so it defaults to `../mode/$N/$N.js`
relative to the code that calls `autoLoadMode`
relative to the browserify `bundle.js`

and any other path I can think of, but I still get '`cannot find module`'.
Any help greatly appreciated.


Browserify does not provide a working require on the client side, so I don’t think you can expect it to work for dynamic mode loading.


I’m also having this problem.

What I think may be the cause is that when using browserify it shims a require to load modules from a bundle for the browser. This has a strange interaction in loadmode.js where we switch based on the env where it thinks that it is in cjs, but what we really want to do is try to load the mode from the bundle using browserify’s shimed cjs require first, and if that fails to fall back to loading it through the cdn url.

I’ll try and get a patch together at some point.