![]() So if using generateSourceMaps, then explicitly set preserveLicenseComments to false. The default for the optimizer is for preserveLicenseComments to be true. generateSourceMaps was introduced in version 2.1.2 of the optimizer. However, for the minifier to accurately construct a source map, the minified source cannot be modified in any way, so preserveLicenseComments is incompatible with generateSourceMaps. When the minifier is done, the comments are added to the top of the file by the r.js optimizer. Various kinds of license comments are found, pulled out of the JS source, then that modified source is passed to the minifier. In the r.js optimizer, preserveLicenseComments works as a pre- and post-processing step on a JS file. If you want to exclude that file from being included, and just need to map "dependency"įor the build (otherwise it will not build), then use the special "empty:" paths config: //Inside the build profileĬannot use preserveLicenseComments and generateSourceMaps together § 10 If you want to include this dependency in the built/optimized file, download the JS file and in theīuild profile for the optimizer, put in a paths config that points to that local file. If you are using the simplified define wrapper, make sure you have require as the first argument to the definition function: define(function (require) ) DO NOT use require('foo'), but use the async It was a top-level require call (not a require call inside a define() call) that should be using the async, callback version of require to load the code: //If this code is not in a define call, If the error message includes Use require(), then This occurs when there is a require('name') call, but the 'name' module has not been loaded yet. The fix is to make sure all module ID references use the same ID (either choose "something" or "lib/something" for all references), or use map config. One anonymous module in it, this kind of timeout error can occur. If module IDs "something" and "lib/something" are both configured to point to the same "scripts/libs/something.js" file, and something.js only has The paths config was used to set two module IDs to the same file, and that file only has one anonymous module in it.In some cases you may need to use the paths configuration to fix the URL resolution for the script. Make sure the script file is in the right place. Check the "Net" or "Network" tab in the browser's developer tools to see if there was a 404 for an URL that would map to the module name. The path configuration for a module is incorrect.Sometimes script errors do not show up in Firebug. If there is no script error in the browser's error console, and if you are using Firebug, try loading the page in another browser like Chrome or Safari. There was a script error in one of the listed modules.If the problem is the var define lint approach, use /*global define */ (no space before "global") comment style instead.If the problem is the use of loader plugins or anonymous modules but the RequireJS optimizer is not used for file bundling, use the RequireJS optimizer.If you manually code an HTML script tag, be sure it only includes named modules, and that an anonymous module that will have the same name as one of the modules in that file is not loaded.Do not manually code script tags in HTML to load scripts that have define() calls in them. Be sure to load all scripts that call define() via the RequireJS API. ![]() If you use var define at the top of your file for jshint/jslint purposes, this will cause a problem for the optimizer because it avoids parsing files that declare a define variable, since that may indicate a script that was created by a concatenation of some scripts that use a local define. The optimizer knows how to name anonymous modules correctly so that they can be combined with other modules in an optimized file. ![]() If you use the loader plugins or anonymous modules (modules that call define() with no string ID) but do not use the RequireJS optimizer to combine files together, this error can occur. If you manually code a script tag in HTML to load a script that has a few named modules, but then try to load an anonymous module that ends up having the same name as one of the named modules in the script loaded by the manually coded script tag. If you manually code a script tag in HTML to load a script with an anonymous define() call, this error can occur.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |