Elao / node-module-assets-gulp

Handle your project's assets with style ! (and gulp)
http://elao.github.io/node-module-assets-gulp
0 stars 0 forks source link

Production built JS is not compatible with Angular #7

Closed lwiesel closed 8 years ago

lwiesel commented 9 years ago

Issue Type: Bug Report

Lib Version: 0.3.*

Lib Configuration:

var
    gulp   = require('gulp'),
    del    = require('del'),
    assets = require('elao-assets-gulp');

/************************/
/* Assets Configuration */
/************************/

assets.config({
    autoprefixer: {
        browsers: ['> 1%', 'last 2 versions', 'Firefox ESR', 'Opera 12.1']
    },
    assets: {
        vendors: {
            src: 'components'
        }
    }
});

/*********/
/* Tasks */
/*********/

gulp.task('default', ['js', 'sass', 'css', 'images', 'fonts', 'swf', 'files']);
gulp.task('watch',   ['watch:js', 'watch:sass', 'watch:css', 'watch:images', 'watch:files']);
gulp.task('clean',   function(cb) {
    del(assets.getDest() + '/*', cb);
});

Environment: Unix

Summary: Angular Js built in prod mode is not valid. In dev mode everything is OK though.

Steps To Reproduce:

Install angular:

npm install angular

Build the following file:

// main.js

(function () {
    'use strict';

    var angular = require('angular');
}());

with the following command:

gulp js

Expected Results:

Angular loaded without error when page is loaded.

Actual Results:

Here is the error I got in my browser console:

Uncaught Error: [$injector:modulerr] Failed to instantiate module app due to:
Error: [$injector:unpr] Unknown provider: e
http://errors.angularjs.org/1.4.5/$injector/unpr?p0=e

_I suspect uglify for being responsible._

nervo commented 9 years ago

Could you try to exclude angular from browserify parsing, and tell me ?

Just add it right there: https://github.com/Elao/node-module-assets-gulp/blob/master/tasks/js.js#L20

lwiesel commented 9 years ago

Just tried it. I changed noparse: ['jquery'] to noparse: ['jquery', 'angular'].

I get the exact same result...

lwiesel commented 9 years ago

I tried to comment the lines linked to uglify : https://github.com/Elao/node-module-assets-gulp/blob/master/tasks/js.js#L32-L35

It compiles without error.