-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathworkers.imba
56 lines (40 loc) · 1.04 KB
/
workers.imba
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
###
Script for compiling imba and imba1 files inside workers using
workerpool.
###
import {compile} from 'dist/../compiler.imba.js'
import imba1 from 'dist/../scripts/bootstrap.compiler.js'
const workerpool = require('workerpool')
const id = Math.random!
def compile_imba code, options
let out = {id: options.sourceId}
let res = null
try
res = compile(code,options)
catch e
console.log "ERROR COMPILING IMBA",e,options.sourcePath
res = {}
for item in res.diagnostics
item.lineText = item.#lineText
if res.warnings
out.warnings = res.warnings
if res.errors
out.errors = res.errors
let js = res.js
# clean up the trims now
out.js = js
out.css = res.css
return out
def compile_imba1 code,options
options.target = 'web' if options.target == 'browser'
let out = {id: options.sourceId, warnings: [], errors: []}
let res = imba1.compile(code,options)
let js = res.js
if js.indexOf('$_ =') > 0
js = "var $_;\n{js}"
out.js = js
return out
workerpool.worker(
compile_imba: compile_imba
compile_imba1: compile_imba1
)