packages/remark-bemjson/lib/index.js
function plugin(options) {
    options = defaultsDeep({}, options, defaults);

    this.Compiler = compiler;

    function compiler(node, file) {
        const root = node && node.type && node.type === 'root';
        const bemjson = toBemjson(node, { augment: options.augment });

        const bjsonString = options.export ? JSON.stringify(bemjson, null, 4) : '';

        if (file.extname) {
            file.extname = '.js';
        }

        if (file.stem) {
            file.stem = file.stem + '.bemjson';
        }

        file.data = bemjson;

        return root ? createExport({ type: options.exportType, name: options.exportName }, bjsonString) : bjsonString;
    }
}
function plugin(options) {
    options = defaultsDeep({}, options, defaults);

    this.Compiler = compiler;

    function compiler(node, file) {
        const root = node && node.type && node.type === 'root';
        const bemjson = toBemjson(node, { augment: options.augment });

        const bjsonString = options.export ? JSON.stringify(bemjson, null, 4) : '';

        if (file.extname) {
            file.extname = '.js';
        }

        if (file.stem) {
            file.stem = file.stem + '.bemjson';
        }

        file.data = bemjson;

        return root ? createExport({ type: options.exportType, name: options.exportName }, bjsonString) : bjsonString;
    }
}
function plugin ( options ) { options = defaultsDeep ( { } , options , defaults ) ; this . Compiler = compiler ; function compiler ( node , file ) { const root = node && node . type && node . type === 'root' ; const bemjson = toBemjson ( node , { augment : options . augment } ) ; const bjsonString = options . export ? JSON . stringify ( bemjson , null , 4 ) : '' ; if ( file . extname ) { file . extname = '.js' ; } if ( file . stem ) { file . stem = file . stem + '.bemjson' ; } file . data = bemjson ; return root ? createExport ( { type : options . exportType , name : options . exportName } , bjsonString ) : bjsonString ; } }
remark bemjson compiler plugin

@param {Object} options - plugin options
@param {ExportType} [options.exportType=commonJS] - export type.
@param {string} [options.exportName] - if export to browser requires name.
@param {Function} [options.augment] - transform callback.
remark bemjson compiler plugin