strues/retinajs

retinajs should not be defining "exports" if it isn't available

niedfelj opened this issue · 0 comments

A lot of scripts determine what environment they are running in based on whether exports is defined as an "object". If retinajs is running on a site and defines the exports object, other scripts think they are running in a node environment...example:

JS Cookies
Line 14
https://github.com/js-cookie/js-cookie/blob/master/src/js.cookie.js

retinajs should use a similar factory/loading mechanism in retina.min.js so that it attaches retinajs where it's needed on the globa/root/window without defining exports

;(function (factory) {
	var registeredInModuleLoader = false;
	if (typeof define === 'function' && define.amd) {
		define(factory);
		registeredInModuleLoader = true;
	}
	if (typeof exports === 'object') {
		module.exports = factory();
		registeredInModuleLoader = true;
	}
	if (!registeredInModuleLoader) {
		var OldCookies = window.Cookies;
		var api = window.Cookies = factory();
		api.noConflict = function () {
			window.Cookies = OldCookies;
			return api;
		};
	}
}(function () {