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

Commit

Permalink
fix(loader): don't rely on internal APIs
Browse files Browse the repository at this point in the history
This significantly increases the size of the loader:
- minified: 1031bytes -> 1509bytes (+46%)
- minified + gzip: 593bytes -> 810bytes (+36%)

I'm not entirely sold on the idea of shipping minErr with the loade. With the current state, the angular-loader behavior is completely broken - this is just a quick fix, we can revisit this change in the future.


Closes #4437
Closes #4874
  • Loading branch information
vojtajina committed Nov 14, 2013
1 parent 94764ee commit 8425e9f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions angularFiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ angularFiles = {
],

'angularLoader': [
'src/minErr.js',
'src/loader.js'
],

Expand Down
7 changes: 7 additions & 0 deletions src/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
function setupModuleLoader(window) {

var $injectorMinErr = minErr('$injector');
var ngMinErr = minErr('ng');

function ensure(obj, name, factory) {
return obj[name] || (obj[name] = factory());
Expand Down Expand Up @@ -71,6 +72,12 @@ function setupModuleLoader(window) {
* @returns {module} new module with the {@link angular.Module} api.
*/
return function module(name, requires, configFn) {
var assertNotHasOwnProperty = function(name, context) {
if (name === 'hasOwnProperty') {
throw ngMinErr('badname', 'hasOwnProperty is not a valid {0} name', context);
}
};

assertNotHasOwnProperty(name, 'module');
if (requires && modules.hasOwnProperty(name)) {
modules[name] = null;
Expand Down
2 changes: 1 addition & 1 deletion src/loader.prefix
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
* License: MIT
*/
'use strict';
(
(function() {
3 changes: 2 additions & 1 deletion src/loader.suffix
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
)(window);
setupModuleLoader(window);
})(window);

/**
* Closure compiler type information
Expand Down

0 comments on commit 8425e9f

Please sign in to comment.