parse File Sync
external native method. recommend using parseSync(filepath: String, options: ParserConfig): Program
you could use this method only when the overhead method was broken
Return
ast tree json string
Parameters
filepath
filepath to source code
options
options json string. see dev.yidafu.swc.generated.ParserConfig.
Throws
Samples
import dev.yidafu.swc.*
import dev.yidafu.swc.generated.*
import dev.yidafu.swc.generated.dsl.*
fun main() {
//sampleStart
SwcNative().parseFileSync(
"path/to/js/code.js",
"""{"syntax":"ecmascript"}"""
)
//sampleEnd
}parse js file to AST Tree
Return
ast tree node
Parameters
filepath
filepath to source code
options
parse options
Throws
Samples
import dev.yidafu.swc.*
import dev.yidafu.swc.generated.*
import dev.yidafu.swc.generated.dsl.*
fun main() {
//sampleStart
SwcNative().parseFileSync(
"path/to/js/code.js",
esParseOptions {
dynamicImport = true
}
)
//sampleEnd
}