Skip to content

Commit

Permalink
bug fix to remove module name if requireCall === require
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Jones committed Nov 15, 2013
1 parent 97c7963 commit decb4e7
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ define("my-components", ["components/package1/index", "components/package1/index
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using [Grunt](http://gruntjs.com/).

## Release History
* 0.0.8 - Fixed a bug that added the module name to require() calls
* 0.0.7 - Added support for requireCall option
* 0.0.6 - expand the full package name
* 0.0.5
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "grunt-requirejs-bundle",
"description": "A Grunt plugin to bundle one or more AMD packages into a single define statement. This means you can just require the bundle and get all the packages loaded via requirejs.",
"version": "0.0.7",
"version": "0.0.8",
"homepage": "https://github.com/cajones/grunt-requirejs-bundle",
"author": {
"name": "Chris Jones",
Expand Down
5 changes: 3 additions & 2 deletions tasks/requirejs_bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,13 @@ module.exports = function(grunt) {

this.files.forEach(function (file) {
var baseUrl = options.baseUrl,
hasModuleName = options.moduleName && /^define$/i.test(options.requireCall),
moduleList = file.src.filter(isDirectory)
.map(enumerateInstalledPackages)
.map(expandFullPackagePath(baseUrl))
.reduce(buildAMDModuleDefinition, ''),
moduleNameDeclaration = options.moduleName ? '"'+ options.moduleName +'", ' : '',
defineStatement = options.requireCall + '(' + moduleNameDeclaration +'['+ moduleList+ ']);',
moduleNameDeclaration = hasModuleName ? '"'+ options.moduleName +'", ' : '',
defineStatement = options.requireCall + '(' + moduleNameDeclaration + '['+ moduleList+ ']);',
amdContent = options.autoGeneratedMessage + '\r\n' + defineStatement;

grunt.file.write(file.dest, amdContent);
Expand Down
2 changes: 1 addition & 1 deletion test/expected/components.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
/* This file has been automatically-generated by the grunt task requirejs-bundle; any changes to this file could be lost */
require("components", ["components/adapt-plugin1/js/index", "components/adapt-plugin2/js/main"]);
require(["components/adapt-plugin1/js/index", "components/adapt-plugin2/js/main"]);

0 comments on commit decb4e7

Please sign in to comment.