Skip to content

Commit b020cb8

Browse files
authored
Fix ReferenceError for module.exports in browser environment (sugarlabs#4229)
1 parent 9a9088d commit b020cb8

14 files changed

+126
-99
lines changed

js/js-export/API/DictBlocksAPI.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,6 @@ class DictBlocksAPI {
5151
return this.runCommand("getValue", [args[1], args[0], this.turIndex]);
5252
}
5353
}
54-
55-
module.exports = DictBlocksAPI;
54+
if (typeof module !== 'undefined' && module.exports) {
55+
module.exports = DictBlocksAPI;
56+
}

js/js-export/API/DrumBlocksAPI.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,6 @@ class DrumBlocksAPI {
5151
return this.runCommand("playNoise", [args[0], this.turIndex]);
5252
}
5353
}
54-
module.exports=DrumBlocksAPI;
54+
if (typeof module !== 'undefined' && module.exports) {
55+
module.exports=DrumBlocksAPI;
56+
}

js/js-export/API/GraphicsBlocksAPI.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,4 +86,6 @@ class GraphicsBlocksAPI {
8686
return this.runCommand("doScrollXY", [args[0], args[1]]);
8787
}
8888
}
89-
module.exports = GraphicsBlocksAPI;
89+
if (typeof module !== 'undefined' && module.exports) {
90+
module.exports = GraphicsBlocksAPI;
91+
}

js/js-export/API/IntervalsBlocksAPI.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,6 @@ class IntervalsBlocksAPI {
5858
return this.runCommand("setTemperament", [args[0], args[1], args[2]]);
5959
}
6060
}
61-
module.exports = IntervalsBlocksAPI;
61+
if (typeof module !== 'undefined' && module.exports) {
62+
module.exports = IntervalsBlocksAPI;
63+
}

js/js-export/API/MeterBlocksAPI.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ class MeterBlocksAPI {
7474
return Singer.MeterActions.getNotesPlayed(args[0], this.turIndex);
7575
}
7676
}
77+
if (typeof module !== 'undefined' && module.exports) {
78+
module.exports = MeterBlocksAPI;
79+
}
7780

78-
79-
module.exports = MeterBlocksAPI;

js/js-export/API/OrnamentBlocksAPI.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,6 @@ class OrnamentBlocksAPI {
4848
return this.ENDFLOWCOMMAND;
4949
}
5050
}
51-
module.exports = OrnamentBlocksAPI;
51+
if (typeof module !== 'undefined' && module.exports) {
52+
module.exports = OrnamentBlocksAPI;
53+
}

js/js-export/API/PenBlocksAPI.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,4 +99,6 @@ class PenBlocksAPI {
9999
return this.runCommand("doSetFont", [args[0]]);
100100
}
101101
}
102-
module.exports = PenBlocksAPI;
102+
if (typeof module !== 'undefined' && module.exports) {
103+
module.exports = PenBlocksAPI;
104+
}

js/js-export/API/PitchBlocksAPI.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,4 +179,6 @@ class PitchBlocksAPI {
179179
return Singer.PitchActions.numToPitch(args[0], "octave", this.turIndex);
180180
}
181181
}
182-
module.exports = PitchBlocksAPI;
182+
if (typeof module !== 'undefined' && module.exports) {
183+
module.exports = PitchBlocksAPI;
184+
}

js/js-export/API/RhythmBlocksAPI.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,4 +113,6 @@ class RhythmBlocksAPI {
113113
return this.ENDFLOWCOMMAND;
114114
}
115115
}
116-
module.exports=RhythmBlocksAPI;
116+
if (typeof module !== 'undefined' && module.exports) {
117+
module.exports=RhythmBlocksAPI;
118+
}

js/js-export/API/ToneBlocksAPI.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,4 +129,6 @@ class ToneBlocksAPI {
129129
return this.ENDFLOWCOMMAND;
130130
}
131131
}
132-
module.exports = ToneBlocksAPI;
132+
if (typeof module !== 'undefined' && module.exports) {
133+
module.exports = ToneBlocksAPI;
134+
}

0 commit comments

Comments
 (0)