lib/transpiler.js
function transpile( sourceCode, sourceName, minify ) {
    try {
        const
            sourceFileName = Path.basename( sourceName ),
            ast = parseToAST( sourceCode ),
            transfo = Babel.transformSync( sourceCode, buildOptions( sourceFileName, minify ) ),
            // transfo = Babel.transformFromAstSync( ast, OPTIONS ),
            transpiledCode = transfo.code;

        return {
            code: `${transpiledCode}\n//# sourceMappingURL=${sourceFileName}.map`,
            zip: transpiledCode,
            map: transfo.map,
            ast
        };
    } catch ( ex ) {
        console.warn( "================================================================================" );
        console.warn( sourceCode );
        console.warn( "================================================================================" );
        Fatal.fire( `Babel parsing error in ${sourceName}:\n${ex}`, sourceName );
    }
    return null;
}
function transpile( sourceCode, sourceName, minify ) {
    try {
        const
            sourceFileName = Path.basename( sourceName ),
            ast = parseToAST( sourceCode ),
            transfo = Babel.transformSync( sourceCode, buildOptions( sourceFileName, minify ) ),
            // transfo = Babel.transformFromAstSync( ast, OPTIONS ),
            transpiledCode = transfo.code;

        return {
            code: `${transpiledCode}\n//# sourceMappingURL=${sourceFileName}.map`,
            zip: transpiledCode,
            map: transfo.map,
            ast
        };
    } catch ( ex ) {
        console.warn( "================================================================================" );
        console.warn( sourceCode );
        console.warn( "================================================================================" );
        Fatal.fire( `Babel parsing error in ${sourceName}:\n${ex}`, sourceName );
    }
    return null;
}
function transpile ( sourceCode , sourceName , minify ) { try { const sourceFileName = Path . basename ( sourceName ) , ast = parseToAST ( sourceCode ) , transfo = Babel . transformSync ( sourceCode , buildOptions ( sourceFileName , minify ) ) , // transfo = Babel.transformFromAstSync( ast, OPTIONS ), transpiledCode = transfo . code ; return { code : ` ${ transpiledCode } \n ${ sourceFileName } ` , zip : transpiledCode , map : transfo . map , ast } ; } catch ( ex ) { console . warn ( "================================================================================" ) ; console . warn ( sourceCode ) ; console . warn ( "================================================================================" ) ; Fatal . fire ( ` ${ sourceName } \n ${ ex } ` , sourceName ) ; } return null ; }
Transpile code into Javascript equivalent that can be read on currently supported browsers.
@param {string} sourceCode - Code in cutting edge Javascript.
@param {string} sourceName - Name of the file.
@param {boolean} minify - Default `false`.
@returns {object} The transpiled code and its source map.
__code__: code compatible with currently supported browsers.
__map__: source map.
Transpile code into Javascript equivalent that can be read on currently supported browsers .