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

Commit 8425e9f

Browse files
committed
fix(loader): don't rely on internal APIs
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
1 parent 94764ee commit 8425e9f

File tree

4 files changed

+11
-2
lines changed

4 files changed

+11
-2
lines changed

angularFiles.js

+1
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ angularFiles = {
6666
],
6767

6868
'angularLoader': [
69+
'src/minErr.js',
6970
'src/loader.js'
7071
],
7172

src/loader.js

+7
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
function setupModuleLoader(window) {
1212

1313
var $injectorMinErr = minErr('$injector');
14+
var ngMinErr = minErr('ng');
1415

1516
function ensure(obj, name, factory) {
1617
return obj[name] || (obj[name] = factory());
@@ -71,6 +72,12 @@ function setupModuleLoader(window) {
7172
* @returns {module} new module with the {@link angular.Module} api.
7273
*/
7374
return function module(name, requires, configFn) {
75+
var assertNotHasOwnProperty = function(name, context) {
76+
if (name === 'hasOwnProperty') {
77+
throw ngMinErr('badname', 'hasOwnProperty is not a valid {0} name', context);
78+
}
79+
};
80+
7481
assertNotHasOwnProperty(name, 'module');
7582
if (requires && modules.hasOwnProperty(name)) {
7683
modules[name] = null;

src/loader.prefix

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
* License: MIT
55
*/
66
'use strict';
7-
(
7+
(function() {

src/loader.suffix

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
)(window);
1+
setupModuleLoader(window);
2+
})(window);
23

34
/**
45
* Closure compiler type information

0 commit comments

Comments
 (0)