jmdobry / angular-cache

angular-cache is a very useful replacement for the Angular 1 $cacheFactory.
http://jmdobry.github.io/angular-cache
MIT License
1.39k stars 156 forks source link

Build error using Gulp: Unexpected token #219

Closed arjenfvellinga closed 8 years ago

arjenfvellinga commented 8 years ago

When I try to use your Angular library in our project we get an error using it. During concatenation and minification, gulp-uglify throws following error:

Error (gulp-uglify): [...]/frontend/vendor/angular/angular-cache/angular-cache.js: Unexpected token: operator (<)

Do you have an idea what is wrong?

jmdobry commented 8 years ago

How about you share your gulp config? And show how you're using angular-cache in your code?

arjenfvellinga commented 8 years ago

This is our complete gulp config file: https://github.com/HelloLily/hellolily/blob/develop/gulpfile.js

I think this is the relevant part (line 224):

gulp.task('vendor-js', [], function() {
    return gulp.src(config.vendor.js.src)
        .pipe(ifElse(!isProduction, function() {
            return sourcemaps.init();
        }))

        .pipe(cached('vendor-js'))
        .pipe(ifElse(isProduction, uglify))
        .pipe(remember('vendor-js'))

        .pipe(concat(config.vendor.js.fileName))
        .pipe(ifElse(!isProduction, function() {
            return sourcemaps.write('.');
        }))
        .pipe(gulp.dest(config.vendor.buildDir))
        .pipe(ifElse(isWatcher, size))
        .pipe(ifElse(isWatcher, livereload));
});

with config.vendor.js.src (line 75) being:

    vendor: {
        buildDir: 'lily/static/vendor/',
        js: {
            src: [
                'frontend/vendor/**/*jquery.min.js',
                'frontend/vendor/**/*angular.js',
                'frontend/vendor/**/*.js',
                '!frontend/vendor/**/angular-mocks.js',
                '!frontend/vendor/metronic/assets/global/plugins/ie-fixes/**/*.js',  // IE fixes
            ],

The angular-cache.js file is placed in frontend/vendor/angular/angular-cache/ (not commited yet)

The gulp-uglify error is given when issuing the (our) gulp build command, so actually before even using you library in code.

jmdobry commented 8 years ago

And what's the exact angular-cache.js file you're using? Where did you get it? Does gulp not give a more useful stack trace? No line number?

arjenfvellinga commented 8 years ago

I got it from https://github.com/jmdobry/angular-cache/tree/master/dist , stable version 4.5.0.

But I now see I made a mistake (and never gonna make again...), right clicking the link saves a html file named .js instead of the raw js file. So I got the wrong file, sorry for the inconvenience.