packages/okam-build/lib/processor/helper/init-babel.js
function initBabelProcessorOptions(file, processorOpts, buildManager) {
    processorOpts = Object.assign(
        {}, buildManager.babelConfig, processorOpts
    );

    // init plugins
    let plugins = normalizeBabelPlugins(processorOpts.plugins, file, buildManager);

    // init app/page/component transform plugin
    let configInitHandler = initConfigInfo.bind(
        null, buildManager, 'config', file
    );
    let appBaseClass = buildManager.getOutputAppBaseClass();
    let pluginOpts = {
        appType: buildManager.appType,
        config: configInitHandler
    };
    let filterOptions = buildManager.getFilterTransformOptions();
    let enableMixinSupport = buildManager.isEnableMixinSupport();
    let {api, framework, localPolyfill, polyfill} = buildManager.buildConf;
    let getInitOptions = buildManager.getAppBaseClassInitOptions.bind(
        buildManager, file
    );
    if (file.isEntryScript) {
        Object.assign(pluginOpts, {
            framework,
            registerApi: api,
            baseClass: appBaseClass && appBaseClass.app
        });
        // polyfill using local variable is prior to global polyfill
        localPolyfill || (pluginOpts.polyfill = polyfill);
        pluginOpts.getInitOptions = getInitOptions;
        plugins.push([
            programPlugins.app,
            pluginOpts
        ]);
    }
    else if (file.isPageScript) {
        Object.assign(pluginOpts, {
            enableMixinSupport,
            filterOptions,
            tplRefs: file.tplRefs,
            baseClass: appBaseClass && appBaseClass.page,
            getInitOptions
        });
        plugins.push([programPlugins.page, pluginOpts]);
    }
    else if (file.isComponentScript) {
        Object.assign(pluginOpts, {
            enableMixinSupport,
            filterOptions,
            tplRefs: file.tplRefs,
            baseClass: appBaseClass && appBaseClass.component,
            getInitOptions
        });
        plugins.push([programPlugins.component, pluginOpts]);
    }
    else if (file.isBehavior) {
        plugins.push([programPlugins.behavior, pluginOpts]);
    }

    // init local polyfill plugins
    if (localPolyfill && !file.compiled) {
        initLocalPolyfillPlugins(localPolyfill, plugins);
    }

    processorOpts.plugins = plugins;

    return processorOpts;
}
function initBabelProcessorOptions(file, processorOpts, buildManager) {
    processorOpts = Object.assign(
        {}, buildManager.babelConfig, processorOpts
    );

    // init plugins
    let plugins = normalizeBabelPlugins(processorOpts.plugins, file, buildManager);

    // init app/page/component transform plugin
    let configInitHandler = initConfigInfo.bind(
        null, buildManager, 'config', file
    );
    let appBaseClass = buildManager.getOutputAppBaseClass();
    let pluginOpts = {
        appType: buildManager.appType,
        config: configInitHandler
    };
    let filterOptions = buildManager.getFilterTransformOptions();
    let enableMixinSupport = buildManager.isEnableMixinSupport();
    let {api, framework, localPolyfill, polyfill} = buildManager.buildConf;
    let getInitOptions = buildManager.getAppBaseClassInitOptions.bind(
        buildManager, file
    );
    if (file.isEntryScript) {
        Object.assign(pluginOpts, {
            framework,
            registerApi: api,
            baseClass: appBaseClass && appBaseClass.app
        });
        // polyfill using local variable is prior to global polyfill
        localPolyfill || (pluginOpts.polyfill = polyfill);
        pluginOpts.getInitOptions = getInitOptions;
        plugins.push([
            programPlugins.app,
            pluginOpts
        ]);
    }
    else if (file.isPageScript) {
        Object.assign(pluginOpts, {
            enableMixinSupport,
            filterOptions,
            tplRefs: file.tplRefs,
            baseClass: appBaseClass && appBaseClass.page,
            getInitOptions
        });
        plugins.push([programPlugins.page, pluginOpts]);
    }
    else if (file.isComponentScript) {
        Object.assign(pluginOpts, {
            enableMixinSupport,
            filterOptions,
            tplRefs: file.tplRefs,
            baseClass: appBaseClass && appBaseClass.component,
            getInitOptions
        });
        plugins.push([programPlugins.component, pluginOpts]);
    }
    else if (file.isBehavior) {
        plugins.push([programPlugins.behavior, pluginOpts]);
    }

    // init local polyfill plugins
    if (localPolyfill && !file.compiled) {
        initLocalPolyfillPlugins(localPolyfill, plugins);
    }

    processorOpts.plugins = plugins;

    return processorOpts;
}
function initBabelProcessorOptions ( file , processorOpts , buildManager ) { processorOpts = Object . assign ( { } , buildManager . babelConfig , processorOpts ) ; // init plugins let plugins = normalizeBabelPlugins ( processorOpts . plugins , file , buildManager ) ; // init app/page/component transform plugin let configInitHandler = initConfigInfo . bind ( null , buildManager , 'config' , file ) ; let appBaseClass = buildManager . getOutputAppBaseClass ( ) ; let pluginOpts = { appType : buildManager . appType , config : configInitHandler } ; let filterOptions = buildManager . getFilterTransformOptions ( ) ; let enableMixinSupport = buildManager . isEnableMixinSupport ( ) ; let { api , framework , localPolyfill , polyfill } = buildManager . buildConf ; let getInitOptions = buildManager . getAppBaseClassInitOptions . bind ( buildManager , file ) ; if ( file . isEntryScript ) { Object . assign ( pluginOpts , { framework , registerApi : api , baseClass : appBaseClass && appBaseClass . app } ) ; // polyfill using local variable is prior to global polyfill localPolyfill || ( pluginOpts . polyfill = polyfill ) ; pluginOpts . getInitOptions = getInitOptions ; plugins . push ( [ programPlugins . app , pluginOpts ] ) ; } else if ( file . isPageScript ) { Object . assign ( pluginOpts , { enableMixinSupport , filterOptions , tplRefs : file . tplRefs , baseClass : appBaseClass && appBaseClass . page , getInitOptions } ) ; plugins . push ( [ programPlugins . page , pluginOpts ] ) ; } else if ( file . isComponentScript ) { Object . assign ( pluginOpts , { enableMixinSupport , filterOptions , tplRefs : file . tplRefs , baseClass : appBaseClass && appBaseClass . component , getInitOptions } ) ; plugins . push ( [ programPlugins . component , pluginOpts ] ) ; } else if ( file . isBehavior ) { plugins . push ( [ programPlugins . behavior , pluginOpts ] ) ; } // init local polyfill plugins if ( localPolyfill && ! file . compiled ) { initLocalPolyfillPlugins ( localPolyfill , plugins ) ; } processorOpts . plugins = plugins ; return processorOpts ; }
Initialize babel processor options

@param {Object} file the file to process
@param {Object} processorOpts the processor options
@param {BuildManager} buildManager the build manager
@return {Object}
Initialize babel processor options