asciidisco / grunt-requirejs

RequireJs (r.js) plugin for grunt.js
https://github.com/asciidisco/grunt-requirejs
MIT License
298 stars 76 forks source link

"Module ID almond has a source path that is the same as the output path" #87

Open aelaguiz opened 10 years ago

aelaguiz commented 10 years ago

Error: Error: Module ID 'almond' has a source path that is same as output path: /Users/aelaguiz/workspace/cratejoy/node_modules/grunt-requirejs/node_modules/almond/almond.j

module.exports = function(grunt) {
  grunt.initConfig({
    requirejs: {
        compile: {
            options: {
                appDir: './www',
                baseUrl: './js',
                dir: './build/www',
                wrap: true,
                almond: true,

                "paths": {
                    "jquery": "bower_components/jquery/jquery.min",
                    "jquery-cookie": "bower_components/jquery-cookie/jquery.cookie",
                    "text": "bower_components/requirejs-text/text",
                    "dropzone": "bower_components/dropzone/downloads/dropzone-amd-module.min",
                    "mustache": "bower_components/mustache/mustache",
                    "stache": "bower_components/requirejs-mustache/stache",
                    "bootstrap": "bower_components/bootstrap/dist/js/bootstrap.min",
                    "bootstrap-calendar": "libs/bootstrap/bootstrap.calendar",
                    "bootstrap-switch": "libs/bootstrap/bootstrap-switch",
                    "backbone-modelbinder": "bower_components/backbone.modelbinder/Backbone.ModelBinder",
                    "backbone": "bower_components/backbone-amd/backbone",
                    "underscore": "bower_components/underscore-amd/underscore-min",
                    "less": "bower_components/less/dist/less-1.5.1.min",
                    "picker": "bower_components/pickadate/lib/picker",
                    "picker.date": "bower_components/pickadate/lib/picker.date",
                    "backgrid": "libs/backgrid/lib/backgrid",
                    "backgrid-selectall": "libs/backgrid/lib/extensions/select-all/backgrid-select-all",
                    "backbone-pageable": "bower_components/backbone-pageable/lib/backbone-pageable",
                    "backgrid-paginator": "libs/backgrid-paginator/backgrid-paginator",
                    "backgrid-filter": "libs/backgrid/lib/extensions/filter/backgrid-filter",
                    "lunr": "bower_components/lunr.js/lunr",
                    "parsley": "libs/parsleyjs.larkio/parsley",
                    "accounting": "bower_components/accounting/accounting",
                    "tempus": "bower_components/tempus/min/tempus.min",
                    "messenger": "bower_components/messenger/build/js/messenger",
                    "resumablejs": "bower_components/resumablejs/resumable",
                    "aviary": "empty:",
                    "jquery.sortable": "bower_components/html5sortable/jquery.sortable",
                    "jquery.cookie": "bower_components/jquery-cookie/jquery.cookie",
                    "bootbox": "bower_components/bootbox/bootbox",
                    "jquery.simplemodal": "bower_components/ericmmartin.simplemodal/src/jquery.simplemodal",
                    "stripe": "empty:",
                    "fineuploader": "libs/fineuploader/custom.fineuploader-4.1.0",
                    "fuelux": "bower_components/fuelux/dist",
                    "typeahead": "libs/typeahead.js/dist/typeahead",

                    "css": "bower_components/codemirror/mode/css/css",
                    "xml": "bower_components/codemirror/mode/xml/xml",
                    "javascript": "bower_components/codemirror/mode/javascript/javascript",
                    "htmlmixed": "bower_components/codemirror/mode/htmlmixed/htmlmixed",
                    "htmlembedded": "bower_components/codemirror/mode/htmlembedded/htmlembedded",
                    "codemirror": "bower_components/codemirror/lib/codemirror",

                    "tplbox": "libs/tplbox/tplbox",

                    "console-shim": "bower_components/console-shim/console-shim-min"
                },

                "shim": {
                    "aviary": {
                        exports: "Aviary"
                    },
                    "jquery": {
                        exports: "jquery"
                    },
                    "messenger": {
                        exports: "Messenger",
                    },
                    "tempus": {
                        exports: "tempus",
                    },
                    "accounting": {
                        exports: "accounting"
                    },
                    "lunr": {
                        exports: "lunr",
                    },
                    "codemirror": {
                        exports: "CodeMirror"
                    },
                    "css": {
                        "deps": ['codemirror']
                    },
                    "xml": {
                        "deps": ['css']
                    },
                    "javascript": {
                        "deps": ['xml']
                    },
                    "htmlmixed": {
                        "deps": ['javascript', 'xml', 'css', 'codemirror']
                    },
                    "htmlembedded": {
                        "deps": ['htmlmixed']
                    },
                    "stripe": {
                        exports: "stripe"
                    },
                    "parsley": ["jquery"],
                    "picker.date": ["picker"],
                    "bootstrap": ["jquery", "less"],
                    "bootstrap-calendar": ["jquery"],
                    "bootstrap-switch": ["jquery"],
                    "bootbox": {
                        deps: ["bootstrap"],
                        exports: "bootbox"
                    }
                },

                "deps": ["console-shim"],

                modules: [
                    {
                        name: 'vendor/mains/dashboard_main',
                        include: ["vendor/pages/dashboard_page"]
                    },
                    {
                        name: 'store/mains/standard_main',
                        include: ["store/pages/standard_page"]
                    }
                ],

                optimize: 'none',
                preserveLicenseComments: false,
                generateSourceMaps: false
            }
        }
    }
     }

  });

  grunt.loadNpmTasks('grunt-requirejs');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-contrib-copy');
  grunt.loadNpmTasks('grunt-contrib-less');
  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.registerTask('default', ['requirejs']);
};
aelaguiz commented 10 years ago

Looks like this commit on r.js broke it:

014dd9da

25827   
25828                               //If buildPath and sourcePath are the same, throw since this
25829                               //would result in modifying source. This condition can happen
25830                               //with some more tricky paths: config and appDir/baseUrl
25831                               //setting, which is a sign of incorrect config.
25832                               if (module._buildPath === module._sourcePath) {
25833                                   throw new Error('Module ID \'' + module.name  +
25834                                                   '\' has a source path that is same as output path: ' +
25835                                                   module._sourcePath +
25836                                                   '. Stopping, config is malformed.');
25837                               }
25838   
asciidisco commented 10 years ago

Thanks for heads up. I do have a lot on my schedule atm., I will try to analyse the issue soon; but it might take some time until a fix could be ready. I´ll notice you when I found something.

aelaguiz commented 10 years ago

Just setting the version of r.js to a couple versions back fixed it. Works in the short term for me.

Darksoulsong commented 10 years ago

I've got the same issue and things worked out when I changed the modules names to the alias given on the path config, rather than the module path, for example:

modules: [
    {name: "app"}
]

... instead of:

modules: [
    {name: "scripts/app.js"}
]

The downside is that everything must have an alias to actually work.

dotnetwise commented 9 years ago

This still seems to be an issue on 2.1.16 Bummer!

dotnetwise commented 9 years ago

We explicitely want that, since we always build to a new fresh folder, hence the first step is to copy the source code in there, and then explicitly want it to be overwritten!