Uglify JS Unexpected token operator <<->>, expected punc <<: >>

Bachan-user3143666 picture Bachan-user3143666 · Jan 18, 2014 · Viewed 20.1k times · Source

When i try to uglify and concat using Grunt uglify js in the follwing line ,

ember-data: 'ember'

uglification fails. How to let uglifyjs skip checking for <<->>?

grunt config :

module.exports = function(grunt){
grunt.initConfig({
    pkg : grunt.file.readJSON('package.json'),
    concat : {
        options : {
            seperator :  ';'
        },
        dist : {
            src : ['js/*.js'],
            dest : 'output.min.js'
        }
    },
    uglify : {
        options : {
            banner : '/*! <%=grunt.template.today("dd-mm-yyyy")%> */\n'
        },
        dist : {
            files : {
                'dist/output.min.js' : ['<%= concat.dist.dest%>']
            }
        }
    },


});
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-concat');

grunt.registerTask('default', ['concat', 'uglify']);

}

and my config.js is

require.config({
baseUrl: 'js',
shim: {
    ember: {
        deps: ['handlebars', 'jquery'],
        exports: 'Ember'
    },
    ember-data: 'ember',
    bootstrap: 'jquery',
    handlebars: ['Handlebars']
},
paths: {
    'App': '\js\application\app',
    'models': '',
    'views': '',
    'controllers': '',
    'templates': '',

    /*LIBRARIES*/
    'jquery': '\libs\jquery\jquery',
    'handlebars': '\libs\handlebars\handebars-1.1.2',
    'ember': '\libs\ember\ember-1.2.0',
    'ember-data' : '\libs\ember\ember-data'
    'bootstrap': '\libs\bootstrap\bootstrap.min.js',

    /*REQUIRE JS PLUGINS*/
    'text': '\libs\require\require plugins\text',
    'hbs': '\libs\require\require plugins\hbs',
    'domReady': '\libs\require\require plugins\domReady'
},
hbs: {
    disableI18n: true,
    templateExtension: 'hbs'
},

'App',
'store',
'router'    

});

Thanks

Answer

Mangled Deutz picture Mangled Deutz · Jan 18, 2014

This is not an uglify issue.

This part of your JavaScript file is simply invalid:

shim: {
ember: {
    deps: ['handlebars', 'jquery'],
    exports: 'Ember'
},
ember-data: 'ember',
bootstrap: 'jquery',
handlebars: ['Handlebars']
},

You need to change ember-data: 'ember' to 'ember-data': 'ember'. Mind the quotes!