Skip to content

Commit 7913b42

Browse files
committed
[WIP] Fable support update
1 parent 3071ba4 commit 7913b42

File tree

6 files changed

+29
-12
lines changed

6 files changed

+29
-12
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"presets": ["babili"]
3+
}

src/netcore/Fable.Client.Browser/app.fs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ let readFileSync: System.Func<string, byte[]> = failwith "JS only"
1515
let main argv =
1616
try
1717
let source = """
18-
type BB() = member x.MMM() = 2 * 3
19-
printfn "answer: %A" (42 * BB().MMM())
18+
printfn "answer: %A" 42
2019
"""
2120
let metadataPath = "/temp/metadata/"
2221
let references = ["mscorlib";"System";"System.Core";"System.Data";"System.IO";"System.Xml";"System.Numerics"]

src/netcore/Fable.Client.Browser/demo/fableconfig.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"projFile": "project.fsx",
33
"ecma": "es2015",
44
"sourceMaps": true,
5+
"babelrc": false,
56
"rollup": {
67
"dest": "./out/bundle.js"
78
},
@@ -14,5 +15,9 @@
1415
"NO_INLINE_IL_PARSER",
1516
"TRACE",
1617
"DEBUG"
17-
]
18+
],
19+
"scripts": {
20+
"prebuild": "npm install",
21+
"postbuild": "node server"
22+
}
1823
}

src/netcore/Fable.Client.Browser/demo/index.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@
2424
<label for="option-babili"> <input id="option-babili" type="checkbox"> Minify (Babili) </label></div>
2525
</div>
2626
<div class="pull-left">
27-
<div class="form-group"><button id="fabel-compile">Compile</button></div>
27+
<div class="form-group" style="color:black">
28+
<button id="fabel-compile">Compile</button>
29+
<button id="fabel-clear">Clear</button>
30+
</div>
2831
</div>
2932
<div class="pull-right">
3033
<div class="form-group"> <strong>Fable JS v0.0.1, Babel v<span id="babel-repl-version"></span></strong></div>

src/netcore/Fable.Client.Browser/demo/repl.js

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@
227227
script.src = 'https://unpkg.com/babili-standalone@0/babili.min.js';
228228
script.onload = function() {
229229
enableCommonJSError = true;
230-
onSourceChange();
230+
//onSourceChange();
231231
};
232232
document.head.appendChild(script);
233233
isBabiliLoading = true;
@@ -253,7 +253,7 @@
253253
// Merge in defaults
254254
var defaults = {
255255
babili: false,
256-
evaluate: true,
256+
evaluate: false,
257257
lineWrap: false,
258258
presets: 'es2015,stage-2,react'
259259
};
@@ -351,7 +351,8 @@
351351
};
352352
transformed = babel.transformFromAst(ast, null, options);
353353
} catch (err) {
354-
this.printError(err.message);
354+
//this.printError(err.message);
355+
this.setOutput(err.message);
355356
throw err;
356357
}
357358

@@ -428,7 +429,7 @@
428429
var presetList = repl.options.presets.replace(/,/g, ', ');
429430
document.getElementById('babel-repl-selected-presets').innerHTML = presetList;
430431

431-
onSourceChange();
432+
//onSourceChange();
432433
}
433434

434435
function onSourceChange () {
@@ -446,8 +447,12 @@
446447
if (error) throw error;
447448
}
448449

450+
function onOutputClear() {
451+
repl.setOutput("");
452+
}
453+
449454
//repl.input.on('change', _.debounce(onSourceChange, 500));
450-
repl.$toolBar.on('change', onSourceChange);
455+
//repl.$toolBar.on('change', onSourceChange);
451456

452457
/*
453458
* Make REPL editors resizable by width
@@ -530,11 +535,12 @@
530535
getFileBlob(fileName, '/out/metadata/' + fileName);
531536
});
532537
}
533-
538+
534539
loadMetadata();
535540

536541
$('#fabel-compile').on('click', onSourceChange);
542+
$('#fabel-clear').on('click', onOutputClear);
537543

538-
initResizable('.babel-repl-resize');
544+
//initResizable('.babel-repl-resize');
539545
//onPresetChange();
540546
}(Babel, $, _, ace, window));

src/netcore/Fable.Client.Browser/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"fable": "^0.7.32"
55
},
66
"dependencies": {
7-
"fable-core": "0.7.23"
7+
"babel-preset-babili": "0.0.10",
8+
"fable-core": "^0.7.23"
89
}
910
}

0 commit comments

Comments
 (0)