{"id":2870,"date":"2014-03-03T03:44:01","date_gmt":"2014-03-03T03:44:01","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/03\/requirejsjs-amduglifyjsr-jsview-the-original-page-collection-of-common-programming-errors\/"},"modified":"2014-03-03T03:44:01","modified_gmt":"2014-03-03T03:44:01","slug":"requirejsjs-amduglifyjsr-jsview-the-original-page-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/03\/requirejsjs-amduglifyjsr-jsview-the-original-page-collection-of-common-programming-errors\/","title":{"rendered":"requirejs,js-amd,uglifyjs,r.jsView the original page-Collection of common programming errors"},"content":{"rendered":"<h3>UnKnown Error<\/h3>\n<ul>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/0952b219674743e4d2bf396eb12032dc?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nkeithjgrant<br \/>\nrequirejs minify web-deployment 2014-2-14 12:33:23<br \/>\nI&#8217;ve got some paths configured in require-config.js as follows:var require = {baseUrl: &#8216;\/javascript&#8217;,paths: {&#8216;jquery&#8217;: &#8216;jquery\/jquery-1.8.1.min&#8217;\/\/ etc. &#8212; several paths to vendor files here}, }I am trying to get the optimization working for deployment. The docs say I should have a build.js that looks something like this:({baseUrl: &#8216;javascript&#8217;,paths: {&#8216;jquery&#8217;: &#8216;jquery\/jquery-1.8.1.min&#8217;},name: &#8216;main&#8217;,out: &#8216;main-build.js&#8217; })Is there a way to have the optimizer read my config file instead of (or i<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/708eed1b644bddaa3b636c9348af2610?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\ngremo<br \/>\nnode.js module requirejs amd commonjs 2014-2-14 12:12:00<br \/>\nI&#8217;m a lot confused about CommonJS, AMD and RequireJS. Even after reading a lot.I know that CommonJS (previously ServerJS) is a group for defining some JavaScript specifications (i.e. modules) when the language is used outside the browser. CommonJS modules specification has some implementation like Node.js or RingoJS, right?What&#8217;s the relation between CommonJS, Asynchronous module definition (AMD) and RequireJS? Is RequireJS an implementation of CommonJS module definition? If yes, what&#8217;s AMD then<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/c09aacd08730773ebed79dc6532a9987?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nAhmed Nuaman<br \/>\ncoffeescript requirejs gruntjs grunt 2014-2-13 12:36:38<br \/>\nI have a project written in CoffeeScript that uses AngularJS. My vendor dependancies are installed using Bower and my file structure is like this:- assets- js- app- model- *.coffee- factory- *.coffee&#8230;- app.coffee- config.coffee- routes.cofeee- vendor- angular- lodash&#8230;- distWhat I&#8217;m trying to do is the following:I&#8217;m trying to work out how I can use RequireJS&#8217;s r.js to optimise my app files so that I essentially get a concatenated file all ordered nice (so vendor dependancies, my config and ro<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/3b1a3c7eb11abd99439c5b1b4b50b37f?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nmadth3<br \/>\njavascript jquery requirejs browser-cache 2014-2-13 9:20:31<br \/>\nI&#8217;m using RequireJS (the jQuery version) and I want to append GET parameters to my scripts to prevent unwanted caching. I&#8217;m using the urlArgs parameter, as suggested in the docs. This is my app-build.js file: ({appDir: &#8220;..\/&#8221;,baseUrl: &#8220;scripts\/&#8221;,urlArgs: &#8220;cache=v2&#8221;,&#8230;Then I build the project as follows: $ node ..\/..\/r.js -o app.build.jsThe output in app-build directory now contains both require-jquery.js, which is the same file as previously, and require-jquery.js?cache=v2, which is blank.The in<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/88c75dd7980a58990017d7b24d507d86?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nNPehrsson<br \/>\njavascript requirejs 2014-2-12 9:14:58<br \/>\nIm thinking of an html5\/js mobile app, and I need to store the state of the application. I&#8217;m figuring to use RequireJS, and RequireJs does hold the instances and scripts loaded into memory at runtime.Does RequireJs have any hook where I can just ask RequireJs for all stored instances? And also, can I somehow tell RequireJs here are all your stored instances?<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/76676180aea6681d69779993e870ce0e?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nEd .<br \/>\njavascript maven requirejs web-component 2014-2-11 11:21:04<br \/>\nI&#8217;m looking to layout the structure of our new web components and am currently not sure I&#8217;ve found a tool that&#8217;ll do all of what we ideally want, or comes very close, but it seems like it&#8217;d be a fairly common thing to want to do nowadays.We have a web application that is running Java server-side, while client side we use JavaScript heavily and SASS, amongst other things. We are looking to re-sturcture some of our codebase and component-ize certain aspects of our dynamic page content.For example,<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/8cb695c8a26166533a799689d4c36caa?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nnull_radix<br \/>\njavascript requirejs amd r.js 2014-2-9 6:35:38<br \/>\nI have the following. require([ &#8216;a&#8217;, &#8216;b&#8217; ], function() { if(x){require([ &#8216;c&#8217;, &#8216;d&#8217; ], function( ) {});} });c will always be loaded with d. Is there anyway to make the optimizer optimize c and d so that they will load as one file?EDIT:Also im using r.js as the optimizer. And the modules for my build script look something like this.modules: [{name: &#8220;main&#8221;,},{name: &#8220;c&#8221;,include: [&#8220;d&#8221;]} ] This will include d in c, but both c and d are still loaded at runtime.<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/e2490b7d243a543476a29904931dc66b?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nIziFortune<br \/>\njavascript requirejs 2014-2-3 19:59:11<br \/>\nI&#8217;m getting this error when the optimizer is launched by grunt (I&#8217;m using yeoman backbone-generator )Running &#8220;requirejs:dist&#8221; (requirejs) taskError: ReferenceError: window is not definedI&#8217;m using requirejs and the plugin i18n. This is my main.jsrequire.config({\/\/locale: &#8220;en&#8221;,shim: {underscore: {exports: &#8216;_&#8217;},backbone: {deps: [&#8216;underscore&#8217;,&#8217;jquery&#8217;],exports: &#8216;Backbone&#8217;},&#8217;jquery-notify&#8217;: {deps: [&#8216;jquery&#8217;]},swiper: {deps: [&#8216;jquery&#8217;],exports: &#8216;Swiper&#8217;},bstrapcollapse: {deps: [&#8216;jquery&#8217;,&#8217;bstraptransit<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/4c0cf9d5bfde491833d0f8895020b882?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nyokks<br \/>\nnode.js cordova requirejs handlebars.js handlebars 2014-2-1 14:53:13<br \/>\ni am using handlebars pre-compiler for compiling handlebar templates using the commandhandlebars *.tpl -f *.jsi am using handlebar.runtime-v1.1.2.js for using pre-compiled handlebar templates.When is execute the compiled template with the following codeHandlebars.template(&#8216;****&#8217;);am getting an errorUncaught Error: Template was precompiled with an older version of Handlebars than the current runtime. Please update your precompiler to a newer version (&gt;= 1.0.0) or downgrade your runtime to an o<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/97a6c2dad6d35933c21268723367c3c1?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nbcmcfc<br \/>\njavascript requirejs gruntjs 2014-1-31 16:42:08<br \/>\nI&#8217;m precompiling Handlebars templates and loading them through Requirejs. Grunt creates a build and does all the precompiling and whatnot.Next step is to use Handlebars Runtime instead of the full Handlebars script.In the RequireJS config, the path to Handlebars is set:js\/src\/config.js:require.config({\/\/&#8230;paths: { handlebars: &#8216;lib\/handlebars&#8217; }\/\/&#8230; });For a particular Grunt task, I wish to include an option that will change this path to handlebars.runtime, so that when the whole thing is compr<\/li>\n<\/ul>\n<ul>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/c87afc2dd0b48e5a4e0c5dc1d664ce2b?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nMerc<br \/>\ndojo dijit js-amd 2013-11-11 1:09:20<br \/>\nThis took me a while. A long while. I battled two problems at once (circular dependencies, fixed with refactoring, and this problem). To get this problem into a JSFiddle required a LOT of work&#8230; but I think it was worth it. So:http:\/\/jsfiddle.net\/EVbTL\/3\/I define three widgets:r.AppMainScreen &#8212; This is the main app&#8217;s widget. Easy: just a bunch of tabs, and a button which contains a simple button, which goes:\/\/ SUbmit form this.form.onSubmit = function(e){e.preventDefault();console.log(&#8220;HERE&#8221;);<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/5b5c1c8d2cd9e9b370e30c5a1d09fbce?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nPeter<br \/>\nrequirejs amd js-amd r.js almond 2013-11-6 21:31:34<br \/>\nIn my grunt.js file I&#8217;ve gotrequirejs: {dist: {options: {almond: true,wrap: true,modules: [{name: &#8216;main&#8217;}],mainConfigFile: &#8220;src\/js\/main.js&#8221;,baseUrl: &#8220;src\/js&#8221;,dir: &#8220;tmp\/js&#8221;,inlineText: true,preserveLicenseComments: false}} }Running grunt requirejs:dist populates the tmp\/js directory with some minified files &#8211; among others a big main.js file (everything seems to be bundled in this file as expected) &#8211; however when I want to include this file like so&lt;script type=&#8221;text\/javascript&#8221; src=&#8221;tmp\/main.js<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/74ed58457a9b1cb04f854ae5ca531ca5?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nCam<br \/>\njavascript requirejs amd js-amd 2013-11-2 21:44:47<br \/>\nI&#8217;m getting an Uncaught TypeError when i refresh the page, my js\/app\/main.js file can&#8217;t call the method update() on js\/app\/utilities\/resize.js.Error outputUncaught TypeError: Object function U(n){return n&amp;&amp;typeof n==&#8221;object&#8221;&amp;&amp;!me(n)&amp;&amp;ne. call(n,&#8221;__wrapped__&#8221;)?W(n)} has no method &#8216;update&#8217;I haven&#8217;t managed to isolate\/replicate the issue into a simplified working example unfortunately. But you can click on the js files within the folder tree below for gists.index.html js \/ a<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/57abd59dd9f19b6f9cbd6a7ca7319896?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nJim Rubenstein<br \/>\njavascript highcharts requirejs js-amd 2013-10-20 6:57:23<br \/>\nI&#8217;m attempting to load the Highcharts library using a shim in RequireJS. However, when Highcharts loads, it throws an exception because it can&#8217;t access the jQuery methods it depends on.The require config looks like so:require.config({baseUrl: &#8220;js&#8221;,shim: {&#8216;libs\/highcharts\/highcharts.src.js&#8217;: {deps: [&#8216;jquery&#8217;],exports: function(jQuery){this.HighchartsAdapter = jQuery;return this.Highcharts;}}} });The exception that is thrown is:Uncaught TypeError: undefined is not a functionand is in regards to t<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/aab7f54273423e7f6445e773909d391c?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nvoidstate<br \/>\njavascript dojo requirejs js-amd 2013-9-17 7:36:26<br \/>\nIs it possible to use require within a define block?I am trying to load the facebook JS API but need to wrap it in a require with a different context because I don&#8217;t want the whole application to stop loading if Facebook is blocked by a firewall.The problem I have is how to return the module from within the nested require() call.My code looks something like this:define( [ &#8216;require&#8217; ], function( require ) {var fbRequire = require( { context: &#8216;fb&#8217;,waitSeconds: 3} );fbRequire.onError = function(){<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/678c7ee0f57988f895fe47057eef817c?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nRichard<br \/>\njavascript requirejs amd js-amd 2013-9-16 18:54:47<br \/>\nI am already using RequireJS to load jQuery and other plugins, as follows: var dependencies = [&#8220;order!jquery&#8221;, &#8220;order!plugins\/jquery.typewatch&#8221;, &#8220;order!plugins\/jquery.csv-0.71.min&#8221;, &#8220;plugins\/jquery.zclip.min&#8221;]; require(dependencies, function($) {\/\/ jQuery code goes here });This works fine. I now want to use RequireJS to load a text file, so I&#8217;ve downloaded the RequireJS text plugin, and amended my code:var dependencies = [&#8220;order!jquery&#8221;, &#8220;order!plugins\/jquery.typewatch&#8221;, &#8220;order!plugins\/jquery.<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/a222a3df37c7fb1f88712ff44a50bf9f?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nDavid Given<br \/>\njavascript js-amd 2013-9-13 23:23:32<br \/>\nI am trying to write a reasonably chunky client side web app using Javascript and jQuery. In order to organise my code, I read up on Javascript module systems and decided to go with AMD modules. Currently I&#8217;m using curl.js as my module loader, but I&#8217;m not particularly wedded to that.Unfortunately I&#8217;ve now run up against an issue where two of my modules need to be mutually dependent. I was expecting it to Just Work &#8212; but what actually happens is that loading the app just seems to stall half-way<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/2f786b1ad349a30e02802ae61b4518fc?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nDan D.<br \/>\nrequirejs js-amd 2013-9-9 18:20:42<br \/>\nI&#8217;m successfully loading jQuery (when setting require.config)&#8230;\/\/ For details see: \/\/ http:\/\/groups.google.com\/group\/requirejs\/browse_thread\/thread\/e7532b7e3013bc62\/1e5ca8a89b276de6?show_docid=1e5ca8a89b276de6 require.config({ paths : { &#8216;jquery&#8217; : &#8216;Utils\/jquery&#8217; } });I have a github repo with the entire set-up here: https:\/\/github.com\/Integralist\/RequireJs-ExampleMy issue is that when I try to run the build script: https:\/\/github.com\/Integralist\/RequireJs-Example\/blob\/master\/Assets\/Scripts\/ap<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/i.stack.imgur.com\/iKis5.jpg?s=32&amp;g=1\" \/><br \/>\nPanu Haaramo<br \/>\ndojo lotus-domino js-amd 2013-9-5 21:55:14<br \/>\nWhen I put this on my Form (not XPage):&lt;script src=&#8221;\/xsp\/.ibmxspres\/dojoroot\/dojo.js&#8221; data-dojo-config=&#8221;async: true, parseOnLoad: true&#8221;&gt;&lt;\/script&gt; calls like this:require([&#8220;dojox\/validate\/web&#8221;], function(validate) {validate.isEmailAddress(someAddress); });fail with error (this error is from Opera 12.15):Unhandled Error: Undefined variable: requireI checked with Chrome network panel that dojo.js is loaded and tried also with IE10.If I use:&lt;script src=&#8221;\/\/ajax.googleapis.com\/ajax\/libs<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/14be33dcb144726ea0d8d6b15c682168?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nSoundstep<br \/>\njavascript node.js commonjs javascript-namespaces js-amd 2013-9-5 6:07:07<br \/>\nI&#8217;m trying to write a javascript module that I can load:normally in a browser (script tag) in a browser using requirejs (AMD) in node.jsI got it almost right I believe, but I&#8217;m not sure the way it should work in node.js as I didn&#8217;t use it much.The goal:create a namespace that contains stuff adding methods\/properties to that namespace from other javascript filesMore specifically, I would like to create a namespace named &#8220;myns&#8221;:a &#8220;myns-before.js&#8221; would add a &#8220;before&#8221; property a &#8220;myns.js&#8221; would add<\/li>\n<\/ul>\n<ul>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/57ed1491a844ed59227c11ed96386f9d?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nMrLipman<br \/>\nrequirejs js-amd uglifyjs r.js 2013-9-1 22:16:18<br \/>\nI&#8217;m using r.js to optimize\/uglify my JavaScript code which is using RequireJS.One of my modules is a polyfill module:define(function(){if (!Array.prototype.filter){ \/* &#8230; *\/ }var isPolyfillNeeded = function () { \/* &#8230; *\/ }if (isPolyfillNeeded()) {\/* polyfill implementation *\/} });The module causes parsing error thrown from r.js when trying to uglify it, saying:Tracing dependencies for: ..\/scripts\/main-app Error: Parse error using UglifyJS for file: C:\/&#8230;\/polyfill.js Unexpected character &#8216;?&#8217;<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/b1d4fa5c84335ee6b6b5304927151a56?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nEdward Samson<br \/>\njavascript requirejs google-closure-compiler uglifyjs 2013-8-26 18:05:26<br \/>\nI&#8217;m using the RequireJS Optimizer on a project of mine and, by default, it uses UglifyJS. However, I was encountering an error (&#8216;anim&#8217; is undefined) when running on IE and Opera. Switching to the Closure Compiler with no other configuration change, just sticking to defaults, makes the problem go away.How can I get an effective diff of the optimized output these two tools produce?I don&#8217;t mean to compare the capabilities of the two, either way is fine with me, but this may help point out a bug in<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/93003bf760643e95fa03935f3d3322db?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nTetaxa<br \/>\njavascript uglifyjs 2013-8-25 6:31:15<br \/>\nI have code similar to this:(function (global) {var MyObject = function (arg1, arg2) {this.publicVar = arg1;this._internalVar = arg2;};MyObject.prototype = {publicFunc: function (param) {return param + this._internalVar;}};global.MyObject = MyObject; }(window));Can I somehow get UgilfyJS to mangle _internalVar because it is not intended to be used outside of this scope? I know it can be done with closure compiler using advanced compression etc but I&#8217;m using anvil to build and uglifyjs to minify.<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/35fc5853be2c9206609f1483b83b5808?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nEvan<br \/>\njavascript npm minify concat uglifyjs 2013-8-24 7:49:13<br \/>\nSo I installed npm using npm install uglify-jsI run a command which is:cat file1.js file2.js .. fileN.js | uglifyjs -o files.min.jsand I get this error:WARN: ERROR: Unexpected token eof \u00abundefined\u00bb, expected punc \u00ab,\u00bb [-:630,15]\/usr\/local\/lib\/node_modules\/uglify-js\/lib\/parse.js:199throw new JS_Parse_Error(message, line, col, pos);^ Errorat new JS_Parse_Error (\/usr\/local\/lib\/node_modules\/uglify-js\/lib\/parse.js:185:18)at js_error (\/usr\/local\/lib\/node_modules\/uglify-js\/lib\/parse.js:199:11)at croak (<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/i.stack.imgur.com\/qiYgm.jpg?s=32&amp;g=1\" \/><br \/>\nNULL<br \/>\njavascript uglifyjs 2013-8-20 10:19:04<br \/>\nI was looking at the output of some stuff from UglifyJS and happened across some code like the following:var a = 0; var b = function () {return function () {a++;}(), &#8216;Hello, World&#8217; }();After running that code a is 1 and b is the string Hello, World!.At first glance it appears that b will be undefined since it looks like the result of a function with no return value is being returned, but that is followed by a comma and a string literal.Why does this work? And why doesn&#8217;t UglifyJS just execute th<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/142dbbce38e59d6b5e452ca6fcf725ef?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nAndrew<br \/>\njavascript parsing uglifyjs 2013-8-9 13:09:26<br \/>\nI want to use the UglifyJS parser to check if any identifiers in a piece of code are used when they are not guaranteed to be defined.Example:\/\/ Should raise an error since myfunc and myvar have not been defined, but works var ast = jsp.parse(&#8216;myfunc(myvar);&#8217;);I realise that myfunc and myvar are not necessarily undefined (since they could exist in scope) but I want to know when they possibly might be undefined.echo &#8220;myfunc(myvar);&#8221; | uglifyjs happily returns myfunc(myvar); and I can&#8217;t find any op<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/c73ce5262b9e6b101fc9ff30df46a970?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nJeff<br \/>\njavascript node.js coffeescript uglifyjs 2013-8-8 17:47:46<br \/>\nI just installed Uglify.js and tried to use it to rebuild CoffeeScript, but keep getting this error. This happens when I type &#8220;cake build:browser&#8221; in the CoffeeScript directory. (I want to try my hand at modifying the CoffeeScript language.)My Uglify.js was cloned from GitHub and the symbolic link was created in .node_libraries. Uglify is installed correctly, confirmed since it runs properly in Node and through the command line. So maybe this is a CoffeeScript problem.Help?\/Users\/myuser\/proje<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/d73b77cf416b434e5bb20a5a83a5d666?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nDennis Burton<br \/>\njavascript uglifyjs 2013-8-6 11:18:16<br \/>\nThe first file that I am passing to uglifyjs declares some namespaces likewindow.MyNamespace = {}when uglifyjs sees this line it complains that window is not defined. Is there a way to have uglifyjs ignore undefined symbols? I have tried using the &#8211;no-dead-code option<\/li>\n<\/ul>\n<ul>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/8cb695c8a26166533a799689d4c36caa?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nnull_radix<br \/>\njavascript requirejs amd r.js 2014-2-9 6:35:38<br \/>\nI have the following. require([ &#8216;a&#8217;, &#8216;b&#8217; ], function() { if(x){require([ &#8216;c&#8217;, &#8216;d&#8217; ], function( ) {});} });c will always be loaded with d. Is there anyway to make the optimizer optimize c and d so that they will load as one file?EDIT:Also im using r.js as the optimizer. And the modules for my build script look something like this.modules: [{name: &#8220;main&#8221;,},{name: &#8220;c&#8221;,include: [&#8220;d&#8221;]} ] This will include d in c, but both c and d are still loaded at runtime.<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/a6a7a48f628d26356e376e0095fb35d5?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nNik<br \/>\njavascript backbone.js requirejs r.js 2014-1-18 5:11:53<br \/>\nScenario: Framework used are backbone and require. I have a main.js which have several dependencies on util, model and view js, which are again inter-dependent. There are cyclic dependencies also. This main.js has been compiled into a single file using requirejs optimizer.Problem: How to override certain views and models at runtime? (I have a single compiled version of main, so i am not talking about excluding the js for models or views at compile time).At compile time i don&#8217;t know whether the m<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/cb6c40f1350c41ac73e7e0c24aea5b93?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nLouis<br \/>\njavascript requirejs runtime-error bundling-and-minification r.js 2013-11-26 14:25:24<br \/>\nI bundle all my JS assets into one minified uglified file via r.js (part of requirejs).If any unhandled errors occur on the browser, I use raygun (like Airbrake) to report it back to me. The only problem is the line number I get in my error message, refers to the bundled minified file. Which doesn&#8217;t help much.Is there a way to correctly map the line number of my single minified and uglified bundled asset, into the individual JS file with the correct line number?<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/5b5c1c8d2cd9e9b370e30c5a1d09fbce?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nPeter<br \/>\nrequirejs amd js-amd r.js almond 2013-11-6 21:31:34<br \/>\nIn my grunt.js file I&#8217;ve gotrequirejs: {dist: {options: {almond: true,wrap: true,modules: [{name: &#8216;main&#8217;}],mainConfigFile: &#8220;src\/js\/main.js&#8221;,baseUrl: &#8220;src\/js&#8221;,dir: &#8220;tmp\/js&#8221;,inlineText: true,preserveLicenseComments: false}} }Running grunt requirejs:dist populates the tmp\/js directory with some minified files &#8211; among others a big main.js file (everything seems to be bundled in this file as expected) &#8211; however when I want to include this file like so&lt;script type=&#8221;text\/javascript&#8221; src=&#8221;tmp\/main.js<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/4e826bf3987d32933fd7359797c009bc?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nAlexander Klimetschek<br \/>\nrequirejs r.js 2013-9-19 16:50:50<br \/>\nI am trying to integrate the r.js optimizer on the server side (Apache Sling) and face one problem: when resolving modules it always looks them up under the output directory (dir), not from within the source directory (baseUrl or appDir), doesn&#8217;t find them and thus fails.\/project\/build.js({name: &#8220;modules\/main&#8221;,dir: &#8220;\/target&#8221;,baseUrl: &#8220;\/sources&#8221; })If you wonder, the root path \/ is inside the server&#8217;s JCR repository, not a file system. Also I simplified the example a bit (hopefully without conceal<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/7c1ff10d3a5a1e5e8cf16f3d7a1c2f62?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nToddish<br \/>\nbackbone.js requirejs r.js 2013-9-18 8:49:16<br \/>\nWhen I run the r.js optimizer over my Backbone.js app, I get this error:Uncaught TypeError: undefined is not a functionIt appears in the middle of the Backbone.js section of the output.I removed bits of code until I found out what was causing it, and it seems to be when I call Backbone.history.start();.I&#8217;ve created a simple app to replicate the bug, which I&#8217;ve posted below. Basically, it creates a route and &#8216;console.log&#8217;s &#8216;home&#8217;. It works fine when not optimized.To optimize the app, I use:node r<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/f7ffa8a69bff0f4a013ab775752d2756?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nDJ Forth<br \/>\nrequirejs ruby-on-rails-4 r.js 2013-9-8 22:00:59<br \/>\nI am using Require.js in a rails 4 application. However in the production environment I&#8217;d like to compile into 1 file and use almond. Now obviously require.js recommends r.js, which even has a coffeescript plugin for it, but would mean running it outside of rails manually. There is the requirejs-rails gem, but this seems to have not been updated for a while and doesn&#8217;t have rails4 support. There is a couple of forked version but I get an error when I try to use them:`user_config=&#8217;: undefined<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/57ed1491a844ed59227c11ed96386f9d?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nMrLipman<br \/>\nrequirejs js-amd uglifyjs r.js 2013-9-1 22:16:18<br \/>\nI&#8217;m using r.js to optimize\/uglify my JavaScript code which is using RequireJS.One of my modules is a polyfill module:define(function(){if (!Array.prototype.filter){ \/* &#8230; *\/ }var isPolyfillNeeded = function () { \/* &#8230; *\/ }if (isPolyfillNeeded()) {\/* polyfill implementation *\/} });The module causes parsing error thrown from r.js when trying to uglify it, saying:Tracing dependencies for: ..\/scripts\/main-app Error: Parse error using UglifyJS for file: C:\/&#8230;\/polyfill.js Unexpected character &#8216;?&#8217;<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/c2f58a337a2d264ce6e380794d63fb6e?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nDan Ramos<br \/>\njavascript requirejs grunt r.js 2013-8-21 14:10:08<br \/>\nI&#8217;m able to successfully compile my JS modules via Grunt&#8217;s requirejs task, but I&#8217;m getting undefined with any shim scripts. Here is my configrequirejs.config({&#8220;baseUrl&#8221;: &#8220;..\/..\/..\/components\/&#8221;,&#8221;paths&#8221;: {&#8220;less&#8221;: &#8220;less.js\/dist\/less-1.3.3&#8243;,&#8221;datepicker&#8221;: &#8220;jquery-ui\/ui\/jquery.ui.datepicker&#8221;,&#8221;jquery&#8221;: &#8220;jquery\/jquery&#8221;,&#8221;jqueryui&#8221;: &#8220;jquery-ui\/ui\/jquery-ui&#8221;,&#8221;spectrum&#8221;: &#8220;spectrum\/spectrum&#8221;,&#8221;class&#8221;: &#8220;class\/class&#8221;,&#8221;underscore&#8221;: &#8220;underscore-amd\/underscore&#8221;,&#8221;d3&#8243;: &#8220;d3\/d3&#8243;,&#8221;nv&#8221;: &#8220;nvd3\/nv.d3&#8243;,&#8221;dataTables&#8221;: &#8220;data<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/fe7f2c030846844c6ffd78c8dc099f7e?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nGeoff<br \/>\noptimization requirejs r.js 2013-8-7 10:17:43<br \/>\nI might be missing something here (it could be a RTFM).I am trying to use the requirejs optimizer to optimize a file and require it. but the value always comes back undefined. I created the most simple test.My module (Models\/Test.js):define(function () {return &#8220;from module&#8221;; });My module after I run r.js: (Models\/Test-built.js):define(&#8216;MODELS\/Test&#8217;,[],function () {return &#8220;from module&#8221;; });When I include the original in a page:&lt;script&gt;require([&#8216;Models\/Test&#8217;], function (item) {console.log(i<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>UnKnown Error keithjgrant requirejs minify web-deployment 2014-2-14 12:33:23 I&#8217;ve got some paths configured in require-config.js as follows:var require = {baseUrl: &#8216;\/javascript&#8217;,paths: {&#8216;jquery&#8217;: &#8216;jquery\/jquery-1.8.1.min&#8217;\/\/ etc. &#8212; several paths to vendor files here}, }I am trying to get the optimization working for deployment. The docs say I should have a build.js that looks something like this:({baseUrl: &#8216;javascript&#8217;,paths: [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-2870","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/2870","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=2870"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/2870\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=2870"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=2870"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=2870"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}