Does Angular Assign Itself To `window.angular` Globally, When Loaded As CommonJS Module?
I'm importing Angular 1.4 in my entry point module of Webpack build as a CommonJS module (i.e. with var angular = require('angular');), but somehow it becomes available in global n
Solution 1:
Angular is strongly tied to global variables, as well as a bunch of other legacy libraries that didn't have a chance to become available as full-grown CJS/UMD modules at some point (and Angular still isn't, as of v1.5.2).
var
...
angular = window.angular || (window.angular = {})
is equal to
if (!window.angular)
window.angular = {};
var
...
angular = window.angular;
The former is several bytes smaller and a couple of dans hackier.
Post a Comment for "Does Angular Assign Itself To `window.angular` Globally, When Loaded As CommonJS Module?"