-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNextJavascript.js
45 lines (36 loc) · 961 Bytes
/
NextJavascript.js
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
var Babel
var runtime= global.regeneratorRuntime= require("./runtime")
var transpiledLine = exports.transpiledLineComment= "\n// kawi converted. Preserve this line, Kawi transpiler will not reprocess if this line found"
var Next= exports.default= function(){}
Next.prototype.transpile= function(source, options){
if(source.indexOf(transpiledLine) >= 0){
return {
code: source
}
}
if(!Babel)
Babel = require("./babel")
if (!options) {
options = {
presets: ['es2015','es2016','es2017'],
sourceMaps: true,
comments: false
}
}
var result= Babel.transform(source, options)
if(result.code){
result.code += transpiledLine
if(result.code.trim().startsWith("#!")){
// remove that line
result.code= result.code.split(/\r\n|\r|\n/g)
result.code.shift()
result.code= result.code.join("\n")
}
}
return result
}
exports.Next= Next
exports.transpile= function(a,b){
var next= new Next()
return next.transpile(a,b)
}