parseFileSync

external fun parseFileSync(filepath: String, options: String): String

external native method. recommend using parseSync(filepath: String, options: ParserConfig): Program

swc#parseFileSync

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
}

fun parseFileSync(filepath: String, options: ParserConfig): Program

parse js file to AST Tree

swc#parseFileSync

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
}