When I import Angular 1.4 in my Webpack build entry point module as a CommonJS module using
var angular = require("angular");
, it somehow ends up being accessible in the global namespace of the browser (as window.angular
).
Upon examining the source code of Angular 1.4, I came across the following snippet:
(function(window, document, undefined) {'use strict';
...
var
msie,
jqLite,
jQuery,
slice = [].slice,
splice = [].splice,
push = [].push,
toString = Object.prototype.toString,
getPrototypeOf = Object.getPrototypeOf,
ngMinErr = minErr('ng'),
/** @name angular */
angular = window.angular || (window.angular = {}),
angularModule,
uid = 0;
To clarify, does this line:
angular = window.angular || (window.angular = {})
mean that upon requiring Angular, it checks if the global angular object exists and creates it if not, potentially causing a side effect?