Skip to content

Commit

Permalink
Determined api
Browse files Browse the repository at this point in the history
  • Loading branch information
kdy1 committed May 3, 2021
1 parent 4f3cf4b commit f55f107
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
16 changes: 16 additions & 0 deletions node-swc/src/babel.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { Options, ParseOptions } from './types';

export type BabelifyOptions = {
/**
* If it's not specified, transforms will not be applied.
*
* The parser config should be provided via this property when transformations are enabled.
*/
transforms: Options
} | {

/**
* Option for the parser.
*/
parser: ParseOptions
};
18 changes: 18 additions & 0 deletions node-swc/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import {
export * from "./types";
import { BundleInput, compileBundleOptions } from "./spack";
import { loadBinding } from "@node-rs/helper";
import * as babel from '@babel/types';
import { BabelifyOptions } from './babel';

const bindings = loadBinding(__dirname, "swc", "@swc/core")

Expand All @@ -29,6 +31,22 @@ export function plugins(ps: Plugin[]): Plugin {
}

export class Compiler {
/**
* Parse source code as a babel ast.
*
* @param src Source code
* @param options
*/
babelify(src: string, options?: BabelifyOptions): Promise<babel.Program>;
babelify(src: Module, options?: BabelifyOptions): Promise<babel.Program>;
babelify(input: string | Module, options?: BabelifyOptions): Promise<babel.Program> {
}

babelifySync(src: string, options?: BabelifyOptions): babel.Program;
babelifySync(src: Module, options?: BabelifyOptions): babel.Program;
babelifySync(input: string | Module, options?: BabelifyOptions): babel.Program {
}

parse(
src: string,
options: ParseOptions & { isModule: false }
Expand Down

0 comments on commit f55f107

Please sign in to comment.