diff --git a/docs/api.html b/docs/api.html index 7e3027b97..15ff66091 100644 --- a/docs/api.html +++ b/docs/api.html @@ -33,9 +33,8 @@

RequireJS API

  • Loader Plugins§§ 5-5.4
  • @@ -51,32 +50,20 @@

    § 1.1

    -

    If you just want to load some JavaScript files, use the require() API. If there is already a require() in the page, you can use requirejs() to access the RequireJS API for loading scripts.

    +

    RequireJS takes a different approach to script loading that traditional <script> tags. Its goal is to encourage modular code. While it can also run fast and optimize well, the primary goal is to encourage modular code. As part of that, it encourages using module IDs instead of URLs for script tags.

    -

    Here is a simple example of calling require():

    +

    RequireJS loads all code relative to a baseUrl. The baseUrl is normally set to the same directory as the script used in a data-main attribute for the top level script to load for a page. The data-main attribute is a special attribute that require.js will check to start script loading. This example will end up with a baseUrl of scripts:

    -
    <script src="scripts/require.js"></script>
    -<script>
    -    require(["some/module", "a.js", "b.js"], function(someModule) {
    -        //This function will be called when all the dependencies
    -        //listed above are loaded. Note that this function could
    -        //be called before the page is loaded.
    -        //This callback is optional.
    -    });
    -</script>
    +
    <--This sets the baseUrl to the "scripts" directory-->
    +<script data-main="scripts/main.js" src="scripts/require.js"></script>
     
    -

    The dependencies above, ["some/module", "a.js", "b.js"], will be loaded via script tags that have the following src values:

    - - +

    Or, baseUrl can be set manually via the RequireJS config. If there is no explicit config and data-main is not used, then the default baseUrl is the directory that contains the HTML page running RequireJS.

    -

    RequireJS normally uses the baseUrl and paths configuration to convert names like "some/module" into a file path.

    +

    RequireJS also assumes by default that all dependencies are scripts, so it does not expect to see a trailing ".js" suffix on module IDs. RequireJS will automatically add it when translating the module ID to a path. With the paths config, you can set +up locations of a group of scripts. All of these capabilities allow you to use smaller strings for scripts as compared to traditional <script> tags.

    -

    However, if the dependency name has one of the following properties, it is treated as a regular file path, like something that was passed to a <script src=""> tag:

    +

    There may be times when you do want to reference a script directly and not conform to the "baseUrl + paths" rules for finding it. If a module ID has one of the following characterstics, the ID will not be passed through the "baseUrl + paths" configuration, and just be treated like a regular URL that is relative to the document:

    -

    See the Configuration Options section for information on changing the lookup paths used for dependencies.

    +

    In general though, it is best to use the baseUrl and "paths" config to set paths for module IDs. By doing so, it gives you more flexibility in renaming and configuring the paths to different locations for optimization builds.

    -

    While you can use require() inside a script tag in an HTML file, it is strongly encouraged to place the work in a file that is loaded by RequireJS. This allows for easier optimization via the optimization tool, and there is a shorthand that can be used in the HTML for this pattern. The above example would be structured like this:

    +

    Similarly, to avoid a bunch of configuration, it is best to avoid deep folder hierarchies for scripts, and instead either keep all the scripts in baseUrl, or if you want to separate your library/vendor-supplied code form your app code, use a directory layout like this:

    -
    <script data-main="scripts/main" src="scripts/require.js"></script>
    -
    + + +

    in index.html:

    -The path rules used for data-main changed in RequireJS 0.23. Before that version, data-main="main" for the above example. +
    <script data-main="js/app.js" src="js/require.js"></script>
    -

    The data-main attribute tells RequireJS to take the value of the data-main attribute and treat it like a require([]) call. So, in this case, it would load scripts/main.js, and that file should have the top-level require call:

    +

    and in main.js:

    -
    //Inside scripts/main.js
    -require(["some/module", "a.js", "b.js"], function(someModule) {
    -    //...
    +
    requirejs.config({
    +    //By default load any module IDs from js/lib
    +    baseUrl: 'js/lib',
    +    //except, if the module ID starts with "app",
    +    //load it from the js/app directory. paths
    +    //config is relative to the baseUrl, and
    +    //never includes a ".js" extension since
    +    //the paths config could be for a directory.
    +    paths: {
    +        app: '../app'
    +    }
     });
    -
    -

    The directory that contains the data-main script also then becomes the root URL value (or baseUrl in the RequireJS terms) to find other scripts that use the module naming scheme, the scheme that does not end a ".js" extension. In this example "some/module" is using the module naming scheme, where "a.js" and "b.js" are not.

    +// Start the main app logic. +requirejs(['jquery', 'canvas', 'app/sub'], +function ($, canvas, sub) { + //jQuery, canvas and the app/sub module are all + //loaded and can be used here now. +}); +
    -

    Since data-main was used, and main.js is in the scripts directory, the baseUrl for RequireJS becomes the scripts directory. The "some/module" script would map to a path relative to the scripts directory. So it would be found at scripts/some/module.js.

    +

    Notice as part of that example, vendor libraries like jQuery did not have their version numbers in their file names. It is recommended to store that version info in a separate text file if you want to track it, or if you use a tool like volo, it will stamp the package.json with the version information but keep the file on disk as "jquery.js". This allows you to have the very minimal configuration instead of having to put an entry in the "paths" config for each library. For instance, configure "jquery" to be "jquery-1.7.2".

    -

    Note how this is different from the first example where "some/module" was found at some/module.js. If data-main is not used and an explicit baseUrl value is not passed in the RequireJS configuration, then then the default baseUrl is the directory containing the HTML page that loads RequireJS.

    +

    Ideally the scripts you load will be modules that are defined by calling define(). However, you may need to use some traditional/legacy "browser globals" scripts that do not express their dependencies via define(). For those, you can use the shim config. To properly express their dependencies.

    -

    Script names that are just regular paths ending in ".js", start with a "/" or have a protocol in them are always mapped relative to the HTML page instead of relative to baseUrl, just like HTML <script> src="" values. You can use the "module naming scheme" even if the script does not define a module, it is just means the path will be relative to baseUrl in that case.

    +

    If you do not express the dependencies, you will likely get loading errors since RequireJS loads scripts asynchronously and out of order for speed.

    Define a Module @@ -414,8 +434,7 @@

    paths: { "some": "some/v1.0" }, - waitSeconds: 15, - locale: "fr-fr" + waitSeconds: 15 }); require( ["some/module", "my/module", "a.js", "b.js"], function(someModule, myModule) { @@ -451,43 +470,97 @@

    Supported configuration options:

    -

    baseUrl: the root path to use for all module lookups. So in the above example, "my/module"'s script tag will have a src="/another/path/my/module.js". baseUrl is not used when loading plain .js files, those strings are used as-is, so a.js and b.js will be loaded from the same directory as the HTML page that contains the above snippet.

    +

    baseUrl: the root path to use for all module lookups. So in the above example, "my/module"'s script tag will have a src="/another/path/my/module.js". baseUrl is not used when loading plain .js files, those strings are used as-is, so a.js and b.js will be loaded from the same directory as the HTML page that contains the above snippet.

    If no baseUrl is explicitly set in the configuration, the default value will be the location of the HTML page that loads require.js. If a data-main attribute is used, that path will become the baseUrl.

    The baseUrl can be a URL on a different domain as the page that will load require.js. RequireJS script loading works across domains. The only restriction is on text content loaded by text! plugins: those paths should be on the same domain as the page, at least during development. The optimization tool will inline text! plugin resources so after using the optimization tool, you can use resources that reference text! plugin resources from another domain.

    -

    paths: path mappings for module names not found directly under baseUrl. The path settings are assumed to be relative to baseUrl, unless the paths setting starts with a "/" or has a URL protocol in it ("like http:"). In those cases, the path is determined relative to baseUrl. Using the above sample config, "some/module"'s script tag will be src="/another/path/some/v1.0/module.js". The path that is used for a module name should not include the .js extension, since the path mapping could be for a directory. The path mapping code will automatically add the .js extension when mapping the module name to a path.

    +

    paths: path mappings for module names not found directly under baseUrl. The path settings are assumed to be relative to baseUrl, unless the paths setting starts with a "/" or has a URL protocol in it ("like http:"). In those cases, the path is determined relative to baseUrl. Using the above sample config, "some/module"'s script tag will be src="/another/path/some/v1.0/module.js". The path that is used for a module name should not include the .js extension, since the path mapping could be for a directory. The path mapping code will automatically add the .js extension when mapping the module name to a path.

    + +

    shim: Configure the dependencies and exports for older, traditional "browser globals" scripts that do not use define() to declare the dependencies and set a module value. Example:

    + + +
    requirejs.config({
    +    shim: {
    +        'backbone': {
    +            //These script dependencies should be loaded before loading
    +            //backbone.js
    +            deps: ['underscore', 'jquery'],
    +            //Once loaded, use the global 'Backbone' as the
    +            //module value.
    +            exports: 'Backbone'
    +        },
    +        'foo': {
    +            deps: ['bar'],
    +            //A function can be used to generate the exported value.
    +            //"this" for the function will be the global object.
    +            //The dependencies will be passed in as function arguments.
    +            exports: function (bar) {
    +                //Using a function allows you to call noConflict for libraries
    +                //that support it. However, be aware that plugins for those
    +                //libraries may still want a global.
    +                return this.Foo.noConflict();
    +            }
    +        }
    +    }
    +});
    +
    + +

    For "modules" that are just jQuery or Backbone plugins that do not need to export +any module value, the shim config can just be an array of dependencies:

    + +
    requirejs.config({
    +    shim: {
    +        'jquery.colorize': ['jquery'],
    +        'jquery.scroll': ['jquery'],
    +        'backbone.layoutmanager': ['backbone']
    +    }
    +});
    +
    -

    packages: configures loading modules from CommonJS packages. See the packages topic for more information.

    +

    Note however if you want to get 404 load detection in IE so that you can use paths fallbacks or errbacks, then a string exports value should be given so the loader can check if the scripts actually loaded:

    + +
    requirejs.config({
    +    shim: {
    +        'jquery.colorize': {
    +            deps: ['jquery'],
    +            exports: 'jQuery.fn.colorize'
    +        },
    +        'jquery.scroll': {
    +            deps: ['jquery'],
    +            exports: 'jQuery.fn.colorize'
    +        },
    +        'backbone.layoutmanager': {
    +            deps: ['backbone']
    +            exports: 'Backbone.LayoutManager'
    +        }
    +    }
    +});
    +
    -

    waitSeconds: The number of seconds to wait before giving up on loading a script. The default is 7 seconds.

    +

    packages: configures loading modules from CommonJS packages. See the packages topic for more information.

    -

    locale: The locale to use for loading i18n bundles. By default navigator.language or navigator.userLanguage will be used. The proper syntax for specifying a locale is using lowercase and separating values by dashes, for instance: "fr-fr-paris" or "en-us".

    +

    waitSeconds: The number of seconds to wait before giving up on loading a script. The default is 7 seconds.

    -

    context: A name to give to a loading context. This allows require.js to load multiple versions of modules in a page, as long as each top-level require call specifies a unique context string. To use it correctly, see the Multiversion Support section.

    +

    context: A name to give to a loading context. This allows require.js to load multiple versions of modules in a page, as long as each top-level require call specifies a unique context string. To use it correctly, see the Multiversion Support section.

    -

    deps: An array of dependencies to load. Useful when require is defined as a config object before require.js is loaded, and you want to specify dependencies to load as soon as require() is defined.

    +

    deps: An array of dependencies to load. Useful when require is defined as a config object before require.js is loaded, and you want to specify dependencies to load as soon as require() is defined.

    -

    callback: A function to pass to require that should be require after deps have been loaded. Useful when require is defined as a config object before require.js is loaded, and you want to specify a function to require after the configuration's deps array has been loaded.

    +

    callback: A function to pass to require that should be require after deps have been loaded. Useful when require is defined as a config object before require.js is loaded, and you want to specify a function to require after the configuration's deps array has been loaded.

    -

    priority: An array of module/file names to load immediately, before tracing down any other dependencies. This allows you to set up a small set of files that are downloaded in parallel that contain most of the modules and their dependencies already built in. More information is in the Optimization FAQ, Priority Downloads.Note: resources loaded by loader plugins (like 'text!template.html') cannot be specified in the priority array: the priority mechanism only works with regular JavaScript resources.

    +

    priority: An array of module/file names to load immediately, before tracing down any other dependencies. This allows you to set up a small set of files that are downloaded in parallel that contain most of the modules and their dependencies already built in. More information is in the Optimization FAQ, Priority Downloads.Note: resources loaded by loader plugins (like 'text!template.html') cannot be specified in the priority array: the priority mechanism only works with regular JavaScript resources.

    -

    xhtml: If set to true, document.createElementNS() will be used to create script elements.

    +

    xhtml: If set to true, document.createElementNS() will be used to create script elements.

    -

    urlArgs: Extra query string arguments appended to URLs that RequireJS uses to fetch resources. Most useful to cache bust when the browser or server is not configured correctly. Example cache bust setting for urlArgs:

    +

    urlArgs: Extra query string arguments appended to URLs that RequireJS uses to fetch resources. Most useful to cache bust when the browser or server is not configured correctly. Example cache bust setting for urlArgs:

    urlArgs: "bust=" +  (new Date()).getTime()
     

    During development it can be useful to use this, however be sure to remove it before deploying your code.

    -

    jQuery: (RequireJS 0.25.0+) specify an exact version match for the version of jQuery that should be allowed to register as the 'jquery' dependency. This is useful in environments where multiple jQuery files could be loaded but you want -to be sure to get the right version of jQuery for your loading context. Normally you do not need to set this if you are only loading one version of jQuery in a page. However, if you use third party libraries that may also load jQuery, it is best to set this option.

    - -

    scriptType: (RequireJS 1.0.4+) specify the value for the type="" attribute used for script tags inserted into the document by RequireJS. Default is "text/javascript". To use Firefox's JavaScript 1.8 features, use "text/javascript;version=1.8".

    - -

    catchError: (RequireJS 0.26.0+) Normally, errors evaluating define() factory functions are not caught, to allow easy debugging during development. However, for some scenarios and production deployments, it is useful to have the errors caught. By specifying catchError.define = true, the errors will be caught and passed to requirejs.onError(). Normally requirejs.onError() throws the error, but you can override the definition of requirejs.onError() to do something different.

    +

    scriptType: Specify the value for the type="" attribute used for script tags inserted into the document by RequireJS. Default is "text/javascript". To use Firefox's JavaScript 1.8 features, use "text/javascript;version=1.8".

    @@ -709,8 +782,14 @@

    Handling Errors

    -

    If you want errors that occur as part of calling the define() factory function to create a module export value, you can set catchError to true, and any errors from running the factory function will be passed to -requirejs.onError().

    +

    If you want errors that occur as part of calling the define() factory function to create a module export value, you can pass an errback to the require call that will load it:

    + +
    require(['moduleThatMayError'], function (mod) {
    +    //loaded OK
    +}, function (err) {
    +    //error loading or evaluating it.
    +});
    +
    @@ -757,27 +836,7 @@

    Specify a Text File Dependencythe RequireJS optimizer will inline any text! references with the actual text file contents into the modules, so after a build, the modules that have text! dependencies can be used from other domains.

    -

    Load Scripts in a Specific Order§ 5.2

    - -

    Normally RequireJS loads and evaluates scripts in an undetermined order. However, there are some traditional scripts that depend on being loaded in a specific order. For those cases you can use the order plugin. Download the plugin and put it in the same directory as your app's main JS file. Example usage:

    - -
    require(["order!one.js", "order!two.js", "order!three.js"], function () {
    -    //This callback is called after the three scripts finish loading.
    -});
    -
    - -

    Scripts loaded by the order plugin will be fetched asynchronously, but evaluated in the order they are passed to require, so it should still perform better than using script tags in the head of an HTML document.

    - -

    The order plugin is best used with traditional scripts. It is not needed for scripts that use define() to define modules. It is possible to mix and match "order!" dependencies with regular dependencies, but only the "order!" ones will be evaluated in relative order to each other.

    - -

    Notes:

    -
      -
    • The order! plugin only works with JavaScript files that are cacheable by the browser. If the JS file has headers that do not allow the browser to cache the file, then the order of scripts will not be maintained.
    • -
    • Do not use the order! plugin to load other plugin-loaded resources. For instance. 'order!cs!my/coffescript/module' is not recommended. You will get errors in some versions of IE and WebKit. This is due to the workarounds the order plugin needs to do for those browsers to ensure ordered execution.
    • -
    - - -

    Page Load Event Support/DOM Ready§ 5.3

    +

    Page Load Event Support/DOM Ready§ 5.2

    It is possible when using RequireJS to load scripts quickly enough that they complete before the DOM is ready. Any work that tries to interact with the DOM should wait for the DOM to be ready. For modern browsers, this is done by waiting for the DOMContentLoaded event.

    @@ -809,23 +868,7 @@

    Page Load Event Support/DOM ReadyNote: If the document takes a while to load (maybe it is a very large document, or has HTML script tags loading large JS files that block DOM completion until they are done), using domReady as a loader plugin may result in a RequireJS "timeout" error. If this a problem either increase the waitSeconds configuration, or just use domReady as a module and call domReady() inside the require() callback.

    -

    DOM Ready with implicit dependencies: If you are working on a project that does not use require() and define() to explicitly indicate dependencies in all scripts, you many notice some errors when waiting for the DOM to be ready then executing code that depends on those implicit dependencies.

    - -

    The best fix is to wrap all scripts in explicit define() calls that specify all the direct dependencies. However, if that is not an option, you can call a special method on the domReady plugin to wait for all scripts to load and the DOM to be ready:

    - -
    require(['domReady'], function (domReady) {
    -  domReady.withResources(function () {
    -    //This function is called once the DOM is ready,
    -    //and all modules/plugin resources that RequireJS is loading
    -    //finish loading.
    -  }):
    -});
    -
    - -

    You should avoid using this function, and instead be very explicit about the dependencies in each file. -However, as an intermediate patch to get a project working with RequireJS, it can be useful.

    - -

    Define an I18N Bundle§ 5.4

    +

    Define an I18N Bundle§ 5.3

    Once your web app gets to a certain size and popularity, localizing the strings in the interface and providing other locale-specific information becomes more useful. However, it can be cumbersome to work out a scheme that scales well for supporting multiple locales.

    @@ -888,7 +931,18 @@

    Define an I18N BundleConfiguration options section).

    +

    RequireJS will use the browser's navigator.language or navigator.userLanguage property to determine what locale values to use for my/nls/colors, so your app does not have to change. If you prefer to set the locale, you can use the module config to pass the locale to the plugin:

    + +
    requirejs.config({
    +    config: {
    +        //Set the config for the i18n
    +        //module ID
    +        i18n: {
    +            locale: 'fr-fr'
    +        }
    +    }
    +});
    +

    Note that RequireJS will always use a lowercase version of the locale, to avoid case issues, so all of the directories and files on disk for i18n bundles should use lowercase locales.

    diff --git a/docs/download.html b/docs/download.html index 0c2ade8be..f32eb15fd 100644 --- a/docs/download.html +++ b/docs/download.html @@ -11,9 +11,8 @@

    Download RequireJS

  • Release Notes§ 3
  • @@ -36,9 +35,9 @@

    -Sample RequireJS 1.0.8 + jQuery 1.7.2 project +Sample RequireJS 2.0.0 + jQuery 1.7.2 project -Download +Download

    A zip file containing a sample project that uses jQuery and RequireJS.

    @@ -86,17 +85,6 @@

    logic until the DOM is ready for querying/modification.

    -
    -

    -order - -Minified -With Comments -

    -

    Load script in the order specified in the dependency array. Useful for existing scripts that have implied dependencies instead of calling define() to create modular code.

    -
    - -

    cs (CoffeeScript) @@ -212,163 +200,4 @@

    1.0.1

  • r.js 1.0.1 changes
  • -

    1.0.0

    - -

    Same as RequireJS 0.27.1 release, with some document updates and a -small fix to the optimizer's regular expression for converting CommonJS modules to AMD.

    - -

    0.27.1

    - -

    RequireJS 1.0 release candidate. Small bugfixes for 0.27.0:

    - -
      -
    • define(id, function () {}) where the function has require('') dependencies will now be scanned - for dependencies. Allows for smaller universal module adapters.
    • -
    • Loader plugin that depends on a different plugin's loaded resource works as it did in 0.26.0.
    • -
    • Optimizer: update UglifyJS to 1.1.
    • -
    • Optimizer: semicolons are inserted between files if concatenating would cause errors.
    • -
    • Optimizer: always strip BOM files on all platforms when file transforms/concatenations are done.
    • -
    • Optimizer: allow override of modules used in optimizer. Example.
    • -
    • Optimizer: allow copying of .directories via build config option.
    • -
    • Optimizer: Resolving paths for .js dependencies might fail if an appDir was not part of the config.
    • -
    - - -

    0.27.0

    - -

    RequireJS 1.0 release candidate.

    - -
      -
    • require.ready() has been removed. In its place, use the domReady plugin. - This allows better interoperability with other AMD loaders and better separation of concerns.
    • -
    • A new wrap config option for the optimizer is available, - for wrapping built code in a function. Allows for better API hiding and tiny builds with the - almond API shim.
    • -
    • The order plugin is improved for IE.
    • -
    • Loader plugins can now have dependencies and they will work in the optimizer, as long as the - dependencies work in the optimizer environment (Node, Rhino).
    • -
    • The namespace config option for the optimizer is more robust.
    • -
    • Removed require.def(), use define() instead.
    • -
    • Removed module.setExports, use module.exports instead.
    • -
    - -

    0.26.0

    - -
      -
    • npm install requirejs to allow require("requirejs"). This allows you to: - - This is now the recommended path for using RequireJS in Node. More information on - the Use with Node page.
    • - -
    • UglifyJS in the minifier is updated to 1.0.6. The upside: now - has() branch trimming now works with - the default minifier.
    • - -
    • Fixes for running under Node on Windows using the native node.exe builds that are now available - in the Node 0.5.x series. Now there is less of a need to use Java to drive the RequireJS - Optimizer!
    • - -
    • Configuration is now done via a require.config({}) call, to get in line with - the amdjs require API. - The old require({}) method works on the global require() - for backwards compatibility, but the suggested API going forward is require.config({}). - The API doc has been updated to show proper usage. - -
    • There is a namespace option now for builds, - to allow moving require() and define() - calls under a different namespace. This allows you to build an optimized file that uses - RequireJS but does not interfere with any other AMD loader on the page, and you can make - sure only your modules are loaded in that namespaced object.
    • - -
    • The default error behavior when a define() factory function throws an error is - to not catch it. The catching done in 0.25.0 made it more difficult to debug. However, - there are some situations where catching the errors is preferred. Setting the config - value catchError.define = true will switch to catching the errors - and allow processing via require.onError()
    • - -
    • Closure Compiler in the optimizer was updated. As a result, the code - to invoke Closure Compiler changed, and will likely only work with the latest - Closure Compiler release. You can grab a version known to work with - the optimizer in the optimizer's lib/closure directory.
    • - -
    • There is now a pragmasOnSave build option, which is used in the - require-cs CoffeeScript loader plugin build profile - to strip out the - CoffeeScript compiler after a build. The end result: tiny build layers - of converted CoffeeScript code.
    • -
    - -

    0.25.0

    - -

    The awesome part: the optimizer is now just one JS file! It also doubles as a bootstrap script that supports the full capability of AMD modules and loader plugins in Node and in Rhino.

    - -

    To use the optimizer, pass the "-o" option to r.js:

    - -
        node r.js -o app.build.js
    - -

    To run your AMD-based project via the adapter (assuming server.js is your top-level AMD module):

    - -
        node r.js server.js
    - -

    There is more information about running AMD modules in Node. The optimizer docs have been updated to the new optimizer syntax, and the r.js script has its own project now, to allow releases that are decoupled from require.js.

    - -

    Other highlights:

    - -
    • The loader plugin API changed to allow plugins to create cross-domain-accessible resources. The main use case: you use the text plugin to dynamically load text resources, but you want to deploy those scripts to a CDN. See the text plugin's implementation of writeFile() as an example. -
    • There is now a global requirejs() function object that is the same as the old global require() function object. This should allow RequireJS to work better in environments like Mozilla Chromeless, which already have a built-in require() function that does not have full AMD/loader plugin capabilities. -
    • It is now possible to specify the precise version of jQuery to allow in a RequireJS context. This is useful if you know of other scripts that load different versions of jQuery on a page.
    - -

    Some changes in the name of compatibility with other AMD module loaders and Node:

    - - -
    • The "lib" directory configuration in package support was removed. It was always very awkward to support, and Node no longer supports it, so it was enough justification to remove it.
    • Relative module IDs are now relative to the related module ID, not the related module ID path.
    • includeRequire in the optimizer config was removed, Use a paths config to include require.js instead. See the Optimization docs for more details.
    - -

    A small change to the context-specific require() passed to a loader plugin's load() call: require.isDefined() is now require.defined() and there is require. specified().

    - -

    0.24.0

    - -
      -
    • Support for IE 9. It has a non-conformant script loading behavior that necessitated the change. It would be ideal if IE 9 would change the behavior to be conformant.
    • -
    • Changes to jQuery integration: -
        -
      • jQuery 1.5.1 included in sample project.
      • -
      • No more bundled RequireJS and jQuery file. RequireJS includes special code to detect jQuery as a module, so the combined file is not necessary, and this approach makes it easier to swap in new versions of jQuery as they are released. (Changed on April 1, 2011 back to the old integrated sample)
      • -
      • Because of that change, the jQuery sample project uses the new priority: config approach. (Changed on April 1, 2011 back to the old integrated sample)
      • -
      -
    • allplugins-require.js has been removed. Plugins are no longer bundled with require.js or in the sample jQuery project. There are separate download links to the existing plugins on the download page. Special treatment of these plugins has also been removed from the require.js source, so those plugins behave like any other loader plugin.
    • -
    • There is now a CoffeScript plugin. It makes it easy to code in CoffeeScript in the browser, it can participate in the optimizer optimizations, and it works in Node and Rhino. This is the best way to do cross-environment, modular CoffeeScript.
    • -
    • Bug fixes.
    • -
    - -

    0.23.0

    - -
      -
    • Calculation of baseUrl changed. This affects the jQuery Sample project, which has been updated in this release. Instead of baseUrl defaulting to the directory containing require.js, it now defaults to the HTML page's directory. If data-main is used, then the directory used in that attribute becomes the baseUrl. Explicitly setting baseUrl in the configuration overrides the aforementioned defaults.
    • -
    • The RequireJS optimizer now uses Node by default. So, build.sh/.bat are now Node-based. Java/Rhino is still supported via the buildj.sh/.bat scripts.
    • -
    • UglifyJS is now the default minifier for the optimizer, since it works both in Node and in Rhino. However, UglifyJS does not do if/else dead code removal, so the has() optimization is not that great when using UglifyJS. Hopefully this will change in a future version of UglifyJS. If you want the full has() optimization, Closure Compiler can still be used, either by using buildj.sh to use Java/Rhino to do the optimization work, or by running Closure Compiler yourself after the optimizer runs.
    • -
    • The behavior of the Node adapter, r.js has changed. It now assumes that any module found via the RequireJS config uses define() to define modules. If a module is not found via the RequireJS path config, r.js uses Node's native require() function and its pathing rules -to find the module. This allows the most compatible use of npm-installed modules. However it means you should not include RequireJS configuration for npm-installed modules/packages.
    • -
    • The r.js adapter now works in Node and Rhino.
    • -
    • The config option, baseUrlMatch has been removed, since the data-main baseUrl rule mentioned above removes the need for it.
    • -
    • Some important fixes around loader plugins: a fix to allow multiple modules to use the same plugin resources as a common dependency, and to allow loader plugins that use a define() function callback to work in the optimizer.
    • -
    • A fix for the use of jQuery's readyWait capability when jQuery is detected and used as a module.
    • -
    • Some directory shuffling related to making the rhino and node adapters the same for use in command line tools and in the r.js adapter.
    • -
    - -

    0.22.0

    - -
    diff --git a/docs/jquery.html b/docs/jquery.html index 1f039a6b6..ed1b55828 100644 --- a/docs/jquery.html +++ b/docs/jquery.html @@ -157,11 +157,9 @@

    Some options:

    diff --git a/docs/plugins.html b/docs/plugins.html index 7f61b60cf..69d03a266 100644 --- a/docs/plugins.html +++ b/docs/plugins.html @@ -59,8 +59,6 @@

    }); -

    Note that before 0.24.0, the text!, i18n! and order! plugins were "special" in that you only need to use a name like "text" to refer to it, but the actual module name was "require/text". This was done to support old code that was authored before the Plugin API was fully fleshed out. That magic module name transformation is no longer done in 0.24.0 and greater.

    -
    diff --git a/docs/start.html b/docs/start.html index 435719e8d..1e33faf8e 100644 --- a/docs/start.html +++ b/docs/start.html @@ -84,8 +84,6 @@

    </html> -The path rules used for data-main changed in RequireJS 0.23. Before that version, data-main="main" for the above example. -

    Inside of main.js, you can use require() to load any other scripts you need to run:

    require(["helper/util"], function(util) {
    @@ -96,7 +94,9 @@ 

    });

    -

    That is it! Check out the API docs to learn more about require() and define().

    +

    That will load the helper/util.js script. To get full advantage of RequireJS, +see the API docs to learn more about defining and using +modules.

    diff --git a/tasks.txt b/tasks.txt index 359977df1..b7f68f0f8 100644 --- a/tasks.txt +++ b/tasks.txt @@ -3,10 +3,6 @@ Release Notes Things to mention about 1.1/TODOC: ---------- -- requirejs.undef() -- packagePaths removed -- jquery check only for holdReady jquerys that explicitly call define(). - Implementation notes -------- @@ -16,42 +12,21 @@ they are loaded in between anon define call scripts, since onload on scripts do not fire immediately after script execution, the wrong names can be associated with scripts. -1.1 items? --------------- -- support shim exports: 'jQuery.fn.plugin'? -- remove special jquery detection, only do it for define() calls. -- check bug list - robust handling for anon modules loaded outside loader. -- baseUrl and name optional in optimizer? r.js -o include=a,b out=foo.js -- globals: config to help underscore case? -- remove packagePaths config. - Just remove packages config altogether, suggest volojs for making adapter modules. -> Allow 'module': '' and 'module/': '' config instead of packages config. -- allow error handler either per context, or per top-level require call. -- allow define(function(require, exports, module, define)) where that local define - only defines modules visible to the current module, to help with builds of projects - that wrap up all of their defines in a file but still want it usuable to other - modules? -- !removing priority config -- !Remove resourcesReady and jQuery callback holding DOC updates: - Talk about paths and baseUrl first, - Teach how to fail, how to debug first. +- Put in link to the 1.0.8 docs. - remove require() references, focus on doing data-main and define() instead. -- local require.isBrowser (any other props?) removed. requirejs.isBrowser still available. -- domReady.withResources removed, no more loader done messages? jquery hooks removed too. -- catchError.define removed, now just pass localized error handler. - Update api.html#errors to mention new local errors, requireType, requireModules. - plugins: load.error(). Once called, there is no resetting from it, no undef. - module.config() - shim: use, always need to use mainConfigFile. -- removed order - map config with * -- text plugin: make sure to use module.config() and update doc on how to set useXhr -- i18n plugin: make sure to use module.config() and update doc on how to set - locale, config listing on api.html - enforceDefine: true, - mention in error handling - create errors.html section for nodefine