Skip to content

Commit 1badd18

Browse files
committed
First stage for adding goog.provide/require style dependencies.
Add goog.provide / goog.require style dependencies and use closurebuilder.py to concat the script together. The goal for this commit is: - to have the smallest diff for the generated build/angular.js. - Be a fairly mechanical change to make a review easier since it touched a whole bunch of files.
1 parent faad845 commit 1badd18

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+508
-6
lines changed

Rakefile

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
require 'tempfile'
12
require 'yaml'
23
include FileUtils
34

@@ -60,9 +61,10 @@ end
6061

6162
desc 'Concat AngularJS files'
6263
task :concat => :init do
64+
angularjs_temp = closure_builder(files['angularSrc'])
6365
concat_file('angular.js', [
6466
'src/angular.prefix',
65-
files['angularSrc'],
67+
angularjs_temp,
6668
'src/angular.suffix',
6769
], gen_css('css/angular.css', true))
6870

@@ -306,6 +308,21 @@ def closure_compile(filename)
306308
end
307309

308310

311+
def closure_builder(deps)
312+
tempfile = Tempfile.new('angular-').path
313+
puts "Invoking closure_builder.py --output_file=#{tempfile} ..."
314+
sh "./lib/closure-library/closure/bin/build/closurebuilder.py" +
315+
" --root=./lib/closure-library/closure" +
316+
" --namespace=angular" +
317+
" --output_mode=script" +
318+
" --output_file=#{tempfile}" +
319+
" " + deps.flatten.join(" ")
320+
rewrite_file(tempfile) do |content| fixup_concat_contents(content)
321+
return tempfile
322+
end
323+
end
324+
325+
309326
def concat_file(filename, deps, footer='')
310327
puts "Creating #{filename} ..."
311328
File.open(path_to(filename), 'w') do |f|
@@ -316,9 +333,8 @@ def concat_file(filename, deps, footer='')
316333
gsub('"NG_VERSION_MAJOR"', NG_VERSION.major).
317334
gsub('"NG_VERSION_MINOR"', NG_VERSION.minor).
318335
gsub('"NG_VERSION_DOT"', NG_VERSION.dot).
319-
gsub('"NG_VERSION_CODENAME"', NG_VERSION.codename).
320-
gsub(/^\s*['"]use strict['"];?\s*$/, ''). # remove all file-specific strict mode flags
321-
sub(/\(function\([^)]*\)\s*\{/, "\\0\n'use strict';") # add single strict mode flag
336+
gsub('"NG_VERSION_CODENAME"', NG_VERSION.codename)
337+
content = fixup_concat_contents(content)
322338

323339
f.write(content)
324340
f.write(footer)
@@ -331,13 +347,22 @@ def concat_module(name, files, footer='')
331347
end
332348

333349

350+
def fixup_concat_contents(content)
351+
return content.
352+
gsub(/^\s*goog\.(require|provide)\(.*$/, ''). # remove all goog.require / goog.provide directives
353+
gsub(/^\s*['"]use strict['"];?\s*$/, ''). # remove all file-specific strict mode flags
354+
sub(/\n\/\/ BEGIN_FILE: goog\/base.js\n.*\n\/\/ END_FILE: goog\/base.js/m, "") # remove goog\/base.js
355+
sub(/\(function\([^)]*\)\s*\{/, "\\0\n'use strict';") # add single strict mode flag
356+
end
357+
358+
334359
def rewrite_file(filename)
335360
File.open(filename, File::RDWR) do |f|
336361
content = f.read
337362

338363
content = yield content
339364

340-
raise "File rewrite failed - No content!" unless content
365+
raise "File rewrite failed - No content! (file: #{filename}" unless content
341366

342367
f.truncate 0
343368
f.rewind

angularFiles.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ angularFiles = {
88

99
'src/auto/injector.js',
1010

11+
'src/_all.js',
12+
'src/ng/_all.js',
1113
'src/ng/anchorScroll.js',
1214
'src/ng/browser.js',
1315
'src/ng/cacheFactory.js',
@@ -31,11 +33,13 @@ angularFiles = {
3133
'src/ng/timeout.js',
3234

3335
'src/ng/filter.js',
36+
'src/ng/filter/_all.js',
3437
'src/ng/filter/filter.js',
3538
'src/ng/filter/filters.js',
3639
'src/ng/filter/limitTo.js',
3740
'src/ng/filter/orderBy.js',
3841

42+
'src/ng/directive/_all.js',
3943
'src/ng/directive/directives.js',
4044
'src/ng/directive/a.js',
4145
'src/ng/directive/booleanAttrs.js',
@@ -63,8 +67,11 @@ angularFiles = {
6367
],
6468

6569
'angularSrcModules': [
70+
'src/ngCookies/_all.js',
6671
'src/ngCookies/cookies.js',
72+
'src/ngResource/_all.js',
6773
'src/ngResource/resource.js',
74+
'src/ngSanitize/_all.js',
6875
'src/ngSanitize/sanitize.js',
6976
'src/ngSanitize/directive/ngBindHtml.js',
7077
'src/ngSanitize/filter/linky.js',
@@ -74,6 +81,7 @@ angularFiles = {
7481
],
7582

7683
'angularScenario': [
84+
'src/ngScenario/_all.js',
7785
'src/ngScenario/Scenario.js',
7886
'src/ngScenario/Application.js',
7987
'src/ngScenario/Describe.js',
@@ -114,6 +122,7 @@ angularFiles = {
114122
'lib/jasmine-jstd-adapter/JasmineAdapter.js',
115123
'lib/jquery/jquery.js',
116124
'test/jquery_remove.js',
125+
'lib/closure-library/closure/goog/base.js',
117126
'@angularSrc',
118127
'src/publishExternalApis.js',
119128
'@angularSrcModules',

src/Angular.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
'use strict';
22

3+
goog.provide('angular.Angular');
4+
35
////////////////////////////////////
46

57
/**

src/AngularPublic.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
'use strict';
22

3+
goog.provide('angular.AngularPublic');
4+
5+
goog.require('angular.loader');
6+
37
/**
48
* @ngdoc property
59
* @name angular.version

src/_all.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
'use strict';
2+
3+
/**
4+
* Bundles all of AngularJS. Requires all individual packages and provides the
5+
* "angular" namespace.
6+
*/
7+
8+
goog.provide('angular');
9+
10+
goog.require('angular.Angular');
11+
goog.require('angular.loader');
12+
goog.require('angular.AngularPublic');
13+
goog.require('angular.jqLite');
14+
goog.require('angular.apis');
15+
goog.require('angular.core');

src/apis.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
'use strict';
22

3+
goog.provide('angular.apis');
4+
5+
goog.require('angular.jqLite');
36

47
/**
58
* Computes a hash of an 'obj'.

src/auto/_all.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
'use strict';
3+
4+
/**
5+
* Provides the namespace angular.auto by requiring all of
6+
* angular.auto.*.
7+
*/
8+
9+
goog.provide('angular.auto');
10+
11+
goog.require('angular.auto.injector');

src/auto/injector.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
'use strict';
22

3+
goog.provide('angular.auto.injector');
4+
5+
goog.require('angular.apis');
6+
37
/**
48
* @ngdoc function
59
* @name angular.injector

src/jqLite.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
'use strict';
22

3+
goog.provide('angular.jqLite');
4+
5+
goog.require('angular.AngularPublic');
6+
37
//////////////////////////////////
48
//JQLite
59
//////////////////////////////////

src/loader.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
'use strict';
22

3+
goog.provide('angular.loader');
4+
5+
goog.require('angular.Angular');
6+
37
/**
48
* @ngdoc interface
59
* @name angular.Module

src/ng/_all.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
2+
'use strict';
3+
4+
/**
5+
* Provides the namespace angular.core by requiring all of
6+
* angular.core.*.
7+
*/
8+
9+
goog.provide('angular.core');
10+
11+
goog.require('angular.core.$browser');
12+
goog.require('angular.core.$compile');
13+
goog.require('angular.core.$controller');
14+
goog.require('angular.core.$document');
15+
goog.require('angular.core.$exceptionHandler');
16+
goog.require('angular.core.$filter');
17+
goog.require('angular.core.$http');
18+
goog.require('angular.core.$interpolate');
19+
goog.require('angular.core.$locale');
20+
goog.require('angular.core.$location');
21+
goog.require('angular.core.$log');
22+
goog.require('angular.core.$parse');
23+
goog.require('angular.core.$q');
24+
goog.require('angular.core.$rootScope');
25+
goog.require('angular.core.$route');
26+
goog.require('angular.core.$routeParams');
27+
goog.require('angular.core.$sniffer');
28+
goog.require('angular.core.$timeout');
29+
goog.require('angular.core.$window');
30+
goog.require('angular.core.directive');
31+
goog.require('angular.core.filter');

src/ng/anchorScroll.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
goog.provide('angular.core.$anchorScroll');
2+
3+
goog.require('angular.auto.injector');
4+
15
/**
26
* @ngdoc function
37
* @name ng.$anchorScroll

src/ng/browser.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
'use strict';
22

3+
goog.provide('angular.core.$browser');
4+
5+
goog.require('angular.core.$anchorScroll');
6+
37
/**
48
* ! This is a private undocumented service !
59
*

src/ng/cacheFactory.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
goog.provide('angular.core.$cacheFactory');
2+
3+
goog.require('angular.core.$browser');
4+
15
/**
26
* @ngdoc object
37
* @name ng.$cacheFactory

src/ng/compile.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
'use strict';
22

3+
goog.provide('angular.core.$compile');
4+
5+
goog.require('angular.core.$cacheFactory');
6+
37
/* ! VARIABLE/FUNCTION NAMING CONVENTIONS THAT APPLY TO THIS FILE!
48
*
59
* DOM-related variables:

src/ng/controller.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
'use strict';
22

3+
goog.provide('angular.core.$controller');
4+
5+
goog.require('angular.core.$compile');
6+
37
/**
48
* @ngdoc object
59
* @name ng.$controllerProvider

src/ng/directive/_all.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
2+
'use strict';
3+
4+
/**
5+
* Provides the namespace angular.core.directive by requiring all of
6+
* angular.core.directive.*.
7+
*/
8+
9+
goog.provide('angular.core.directive');
10+
11+
goog.require('angular.core.directive.a');
12+
goog.require('angular.core.directive.booleanAttrs');
13+
goog.require('angular.core.directive.directives');
14+
goog.require('angular.core.directive.form');
15+
goog.require('angular.core.directive.input');
16+
goog.require('angular.core.directive.ngBind');
17+
goog.require('angular.core.directive.ngClass');
18+
goog.require('angular.core.directive.ngCloak');
19+
goog.require('angular.core.directive.ngController');
20+
goog.require('angular.core.directive.ngCsp');
21+
goog.require('angular.core.directive.ngEventDirs');
22+
goog.require('angular.core.directive.ngInclude');
23+
goog.require('angular.core.directive.ngInit');
24+
goog.require('angular.core.directive.ngNonBindable');
25+
goog.require('angular.core.directive.ngPluralize');
26+
goog.require('angular.core.directive.ngRepeat');
27+
goog.require('angular.core.directive.ngShowHide');
28+
goog.require('angular.core.directive.ngStyle');
29+
goog.require('angular.core.directive.ngSwitch');
30+
goog.require('angular.core.directive.ngTransclude');
31+
goog.require('angular.core.directive.ngView');
32+
goog.require('angular.core.directive.script');
33+
goog.require('angular.core.directive.select');
34+
goog.require('angular.core.directive.style');

src/ng/directive/a.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
'use strict';
22

3+
goog.provide('angular.core.directive.a');
4+
5+
goog.require('angular.core.directive.directives');
6+
37
/**
48
* @ngdoc directive
59
* @name ng.directive:a

src/ng/directive/booleanAttrs.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
'use strict';
22

3+
goog.provide('angular.core.directive.booleanAttrs');
4+
5+
goog.require('angular.core.directive.a');
6+
37
/**
48
* @ngdoc directive
59
* @name ng.directive:ngHref

src/ng/directive/directives.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
'use strict';
22

3+
goog.provide('angular.core.directive.directives');
4+
5+
goog.require('angular.core.filter.orderBy');
6+
37
function ngDirective(directive) {
48
if (isFunction(directive)) {
59
directive = {

src/ng/directive/form.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
'use strict';
22

3+
goog.provide('angular.core.directive.form');
4+
5+
goog.require('angular.core.directive.booleanAttrs');
36

47
var nullFormCtrl = {
58
$addControl: noop,

src/ng/directive/input.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
'use strict';
22

3+
goog.provide('angular.core.directive.input');
4+
5+
goog.require('angular.core.directive.form');
6+
37
var URL_REGEXP = /^(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?$/;
48
var EMAIL_REGEXP = /^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/;
59
var NUMBER_REGEXP = /^\s*(\-|\+)?(\d+|(\d*(\.\d*)))\s*$/;

src/ng/directive/ngBind.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
'use strict';
22

3+
goog.provide('angular.core.directive.ngBind');
4+
5+
goog.require('angular.core.directive.input');
6+
37
/**
48
* @ngdoc directive
59
* @name ng.directive:ngBind

src/ng/directive/ngClass.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
'use strict';
22

3+
goog.provide('angular.core.directive.ngClass');
4+
5+
goog.require('angular.core.directive.ngBind');
6+
37
function classDirective(name, selector) {
48
name = 'ngClass' + name;
59
return ngDirective(function(scope, element, attr) {

0 commit comments

Comments
 (0)