mrichard / generator-marionette

Yeoman marionette generator a la AMD
329 stars 72 forks source link

Grunt build fails with a Mismatched anonymous define() error #19

Closed ErikEvenson closed 11 years ago

ErikEvenson commented 11 years ago

Looks like there is a build problem related to mismatched anonymous defines. Hopefully I'm not missing something obvious this time... Ran this right after yo marionette and getting a successful "congrats" page.

$ grunt build
Running "createDefaultTemplate" task

Running "handlebars:compile" (handlebars) task
>> Destination not written because compiled files were empty.

Running "compass:dist" (compass) task
directory .tmp/styles/ 
   create .tmp/styles/main.css 

Running "useminPrepare:html" (useminPrepare) task
Going through app/index.html to update the config
Looking for build script HTML comment blocks

Found a block:
        <!-- build:js scripts/vendor/modernizr.js -->
        <script src="bower_components/modernizr/modernizr.js"></script>
        <!-- endbuild -->
Updating config with the following assets:
    - app/bower_components/modernizr/modernizr.js

Found a block:
        <!-- build:js scripts/main.js -->
        <script data-main="scripts/init" src="bower_components/requirejs/require.js"></script>
        <!-- endbuild -->
Updating config with the following assets:
    - dist/scripts/main.js

Configuration is now:

  cssmin:
  { dist: 
   { files: 
      { '<%= yeoman.dist %>/styles/main.css': 
         [ '.tmp/styles/{,*/}*.css',
           'app/styles/{,*/}*.css' ] } } }

  concat:
  { 'dist/scripts/vendor/modernizr.js': [ 'app/bower_components/modernizr/modernizr.js' ],
  'dist/scripts/main.js': [ 'dist/scripts/main.js' ] }

  uglify:
  { 'dist/scripts/vendor/modernizr.js': 'dist/scripts/vendor/modernizr.js',
  'dist/scripts/main.js': 'dist/scripts/main.js',
  'dist/bower_components/requirejs/require.js': 'app/bower_components/requirejs/require.js' }

  requirejs:
  { dist: 
   { options: 
      { baseUrl: 'app/scripts',
        optimize: 'none',
        paths: { templates: '../../.tmp/scripts/templates' },
        preserveLicenseComments: false,
        useStrict: true,
        wrap: true,
        pragmasOnSave: 
         { excludeHbsParser: true,
           excludeHbs: true,
           excludeAfterBuild: true },
        name: 'init',
        out: 'dist/scripts/main.js',
        mainConfigFile: 'app/scripts/init.js' } } }

Running "requirejs:dist" (requirejs) task
>> Error: Mismatched anonymous define() module: function (){
>>     return Handlebars;
>> }
>> http://requirejs.org/docs/errors.html#mismatch
Warning: Task "requirejs:dist" failed. Use --force to continue.

Aborted due to warnings.
rrichter commented 11 years ago

Hi Erik,

do you still have the handlebars shim in your init.js by chance?

Removing the shim worked for me:

handlebars: {
    exports: 'Handlebars'
}
ErikEvenson commented 11 years ago

That worked. Thanks.

mrichard commented 11 years ago

I removed the handlebars shim. Thanks for finding and resolving this.