Require JS and Minifiers
It is likely the case that at some point you will use require js async style syntax. But lots of libraries (like ace.js for instance) use the commonjs style syntax for defining their modules. This generally works fine since requirejs will statically analyze the incoming script and detect the dependencies required to actually load the scripts contents. The problem comes in when you deploy to production and minify your code, now all the places that once said:
define(function(require){
something = require("something");...
will now say:
define(function(e){x = e;...
so the incoming file will no longer match the requirements to have it's dependencies loaded. To get around this make sure to add "require" to the list of reserved words so it is not mangled on request.
Written by Gabriel Hernandez
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Requirejs
Authors
steveniseki
41.04K
gerardsans
12.17K
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#