Skip to content

Commit

Permalink
define root in strict mode for browsers
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielRuf committed Aug 28, 2017
1 parent f3f0f07 commit f43a331
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions templates/returnExportsGlobal.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
--}}

(function (root, factory) {
if (root === undefined && window !== undefined) root = window;
if (typeof define === 'function' && define.amd) {
{{! AMD. Register as an anonymous module. }}
define({{#if amdModuleId}}'{{amdModuleId}}', {{/if}}[{{{amdDependencies.wrapped}}}], function ({{dependencies}}) {
Expand Down
1 change: 1 addition & 0 deletions templates/umd.hbs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
(function (root, factory) {
if (root === undefined && window !== undefined) root = window;
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module unless amdModuleId is set
define({{#if amdModuleId}}'{{amdModuleId}}', {{/if}}[{{{amdDependencies.wrapped}}}], function ({{{amdDependencies.params}}}) {
Expand Down
3 changes: 2 additions & 1 deletion templates/unit.hbs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{{! UMD template that can be useful to wrap standalone CommonJS/Node modules}}
(function(root, factory) {
if(typeof module === 'object' && module.exports) {
if (root === undefined && window !== undefined) root = window;
if (typeof module === 'object' && module.exports) {
module.exports = factory({{#if cjsDependencies.wrapped}}{{{cjsDependencies.wrapped}}}, {{/if}}require, exports, module);
}
else if(typeof define === 'function' && define.amd) {
Expand Down

0 comments on commit f43a331

Please sign in to comment.