Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

Commit

Permalink
update(build): modifies the build process to generate better Closure …
Browse files Browse the repository at this point in the history
…code

I removed all `(function () {})()` wrappers from JS files as well as "use strict", and added a step to insert them during build.  This is because Closure does not play nicely with these wrappers.

I also updated the method used to insert Closure setter lines.
  • Loading branch information
Robert Messerle committed Apr 22, 2015
1 parent 58f2c48 commit 977a495
Show file tree
Hide file tree
Showing 49 changed files with 1,927 additions and 2,141 deletions.
4 changes: 2 additions & 2 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,12 @@ var buildModes = {
useBower: false
},
'demos': {
transform: gutil.noop,
transform: utils.addJsWrapper,
outputDir: path.join(config.outputDir, 'demos') + path.sep,
useBower: false
},
'default': {
transform: gutil.noop,
transform: utils.addJsWrapper,
outputDir: path.join(config.outputDir, 'modules/js') + path.sep,
useBower: true
}
Expand Down
20 changes: 6 additions & 14 deletions scripts/gulp-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,21 +172,17 @@ exports.addClosurePrefixes = function() {
return through2.obj(function(file, enc, next) {
var moduleInfo = getModuleInfo(file.contents);
if (moduleInfo.module) {

var closureModuleName = moduleNameToClosureName(moduleInfo.module);
var provide = 'goog.provide(\'' + closureModuleName + '\');';
var requires = (moduleInfo.dependencies || []).sort().map(function(dep) {
return dep.indexOf(moduleInfo.module) === 0 ? '' : 'goog.require(\'' + moduleNameToClosureName(dep) + '\');';
}).join('\n');

var contents = file.contents.toString();

// Assign the module to the provided Closure namespace:
contents = contents.replace('angular.module', closureModuleName + ' = angular.module');

file.contents = new Buffer(
provide + '\n' + requires + '\n' + contents
);
file.contents = new Buffer([
'goog.provide(\'' + closureModuleName + '\');',
requires,
file.contents.toString(),
closureModuleName + '= angular.module(' + moduleInfo.module + ');'
].join('\n'));
}
this.push(file);
next();
Expand All @@ -196,17 +192,13 @@ exports.addClosurePrefixes = function() {
exports.buildModuleBower = function(name, version) {
return through2.obj(function(file, enc, next) {
this.push(file);


var moduleInfo = getModuleInfo(file.contents);
if (moduleInfo.module) {
var bowerDeps = {};

(moduleInfo.dependencies || []).forEach(function(dep) {
var convertedName = 'angular-material-' + dep.split('.').pop();
bowerDeps[convertedName] = version;
});

var bowerContents = JSON.stringify({
name: 'angular-material-' + name,
version: version,
Expand Down
25 changes: 11 additions & 14 deletions src/components/autocomplete/autocomplete.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
(function () {
'use strict';
/**
* @ngdoc module
* @name material.components.autocomplete
*/
/*
* @see js folder for autocomplete implementation
*/
angular.module('material.components.autocomplete', [
'material.core',
'material.components.icon'
]);
})();
/**
* @ngdoc module
* @name material.components.autocomplete
*/
/*
* @see js folder for autocomplete implementation
*/
angular.module('material.components.autocomplete', [
'material.core',
'material.components.icon'
]);
Loading

1 comment on commit 977a495

@wesalvaro
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Please sign in to comment.