File tree Expand file tree Collapse file tree 4 files changed +10
-7
lines changed
Expand file tree Collapse file tree 4 files changed +10
-7
lines changed Original file line number Diff line number Diff line change 11#!/usr/bin/env node
22
3- var transform = require ( 'babel-core' ) . transform ;
3+ var transform = require ( 'babel-core' ) . transformFromAst ;
44
55var argv = require ( 'yargs' )
66 . usage ( 'Usage: sjs [options] files ...' )
Original file line number Diff line number Diff line change 4646 "shift-js" : " ^0.2.1" ,
4747 "shift-parser" : " ^4.1.0" ,
4848 "shift-reducer" : " ^3.0.2" ,
49- "shift-spidermonkey-converter" : " ^1.0.0 " ,
49+ "shift-spidermonkey-converter" : " gabejohnson/shift-spidermonkey-converter-js#babel " ,
5050 "transit-js" : " ^0.8.846" ,
5151 "yargs" : " ^4.3.2"
5252 },
Original file line number Diff line number Diff line change @@ -18,6 +18,8 @@ import { unwrap } from './macro-context';
1818
1919import { replaceTemplate } from './template-processor' ;
2020
21+ import { toSpiderMonkey as toBabel } from 'shift-spidermonkey-converter' ;
22+
2123// indirect eval so in the global scope
2224let geval = eval ;
2325
@@ -83,8 +85,8 @@ function loadForCompiletime(expr, context) {
8385 // let result = transform.fromAst(wrapForCompiletime(estree, sandboxKeys));
8486
8587 // let result = babel.transform(wrapForCompiletime(estree, sandboxKeys));
86- let gen = codegen ( parsed , new FormattedCodeGen ) ;
87- let result = context . transform ( gen , {
88+ // let gen = codegen(parsed, new FormattedCodeGen);
89+ let result = context . transform ( toBabel ( parsed ) , {
8890 babelrc : true ,
8991 filename : context . filename
9092 } ) ;
Original file line number Diff line number Diff line change @@ -10,6 +10,8 @@ import { Scope, freshScope } from "./scope";
1010
1111import BindingMap from "./binding-map.js" ;
1212
13+ import { toSpiderMonkey as toBabel } from 'shift-spidermonkey-converter' ;
14+
1315import Term from "./terms" ;
1416import { Modules } from './modules' ;
1517
@@ -43,9 +45,8 @@ export function parse(source, options = {}) {
4345
4446export function compile ( source , options = { } ) {
4547 let ast = parse ( source , options ) ;
46- let gen = codegen ( ast , new FormattedCodeGen ( ) ) ;
47- return options . transform && ( ! options . noBabel ) ? options . transform ( gen , {
48+ return options . transform && ( ! options . noBabel ) ? options . transform ( toBabel ( ast ) , {
4849 babelrc : true ,
4950 filename : options . filename
50- } ) : { code : gen } ;
51+ } ) : { code : codegen ( ast , new FormattedCodeGen ( ) ) } ;
5152}
You can’t perform that action at this time.
0 commit comments