Skip to content

Commit bb8e37e

Browse files
committed
If JSX compilation fails, retry it without source map generation. Closes #89
1 parent eff1c2b commit bb8e37e

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

src/React/Resources/shims.js

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,24 @@ function ReactNET_transform(input, harmony, stripTypes) {
5353

5454
function ReactNET_transform_sourcemap(input, harmony, stripTypes) {
5555
try {
56-
var result = global.JSXTransformer.transform(input, {
57-
harmony: !!harmony,
58-
stripTypes: !!stripTypes,
59-
sourceMap: true
60-
});
56+
var result;
57+
try {
58+
// First try to compile and generate a source map
59+
result = global.JSXTransformer.transform(input, {
60+
harmony: !!harmony,
61+
stripTypes: !!stripTypes,
62+
sourceMap: true
63+
});
64+
} catch (ex) {
65+
// It's possible an exception was thrown during the source map generation, and the
66+
// transform might actually work without a source map.
67+
result = global.JSXTransformer.transform(input, {
68+
harmony: !!harmony,
69+
stripTypes: !!stripTypes,
70+
sourceMap: false
71+
});
72+
}
73+
6174
if (!result.sourceMap) {
6275
return JSON.stringify({
6376
code: result.code,

0 commit comments

Comments
 (0)