Skip to content

Commit

Permalink
Merge pull request #18 from timeiscoffee/master
Browse files Browse the repository at this point in the history
Improve checks for module.exports support
  • Loading branch information
bebraw authored Nov 16, 2016
2 parents 595d5d6 + 5ba4422 commit b77da71
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions templates/returnExportsGlobal.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
define({{#if amdModuleId}}'{{amdModuleId}}', {{/if}}[{{{amdDependencies.wrapped}}}], function ({{dependencies}}) {
return ({{#if globalAlias}} root['{{{globalAlias}}}'] = {{/if}}factory({{dependencies}}));
});
} else if (typeof exports === 'object') {
} else if (typeof module === 'object' && module.exports) {
{{!--
Node. Does not work with strict CommonJS, but
only CommonJS-like enviroments that support module.exports,
Expand All @@ -33,7 +33,7 @@

{{! FIX FOR BROWSERIFY: Set global alias if we in browserify. }}
{{#if globalAlias}}
if(typeof window !== "undefined"){
if(typeof window !== 'undefined'){
window['{{{globalAlias}}}'] = module_exports;
}
{{/if}}
Expand Down
4 changes: 2 additions & 2 deletions templates/umd+rails.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

(function(factory) {
/* jshint undef: true */
if (typeof define === "function" && define.amd) {
if (typeof define === 'function' && define.amd) {
define({{#if amdModuleId}}'{{amdModuleId}}', {{/if}}[
{{{amdDependencies.wrapped}}}
], factory);
}
else if (typeof module !== "undefined" && module.exports) {
else if (typeof module === 'object' && module.exports) {
module.exports = factory(
{{{cjsDependencies.wrapped}}});
}
Expand Down
2 changes: 1 addition & 1 deletion templates/umd.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
define({{#if amdModuleId}}'{{amdModuleId}}', {{/if}}[{{{amdDependencies.wrapped}}}], function ({{{amdDependencies.params}}}) {
return ({{#if objectToExport}}root['{{{objectToExport}}}'] = {{/if}}factory({{{amdDependencies.params}}}));
});
} else if (typeof exports === 'object') {
} else if (typeof module === 'object' && module.exports) {
// Node. Does not work with strict CommonJS, but
// only CommonJS-like environments that support module.exports,
// like Node.
Expand Down
2 changes: 1 addition & 1 deletion templates/unit.hbs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{{! UMD template that can be useful to wrap standalone CommonJS/Node modules}}
(function(root, factory) {
if(typeof exports === 'object') {
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 b77da71

Please sign in to comment.