How to use the pkg.babel function in pkg

To help you get started, we’ve selected a few pkg examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github wxajs / wxa / packages / wxa-compiler-babel / src / index.js View on Github external
// default match file path.
        this.test = /\.js$|\.wxs$/;

        this.current = cwd;
        // get configuration from .babelrc, package.json or wxa.config.js
        // find .babelrc first then babel.config.js
        let babelrc = path.join(this.current, '.babelrc');
        let babeljs = path.join(this.current, 'babel.config.js');
        let pkg = path.join(this.current, 'package.json');

        if (fs.existsSync(babelrc)) {
            this.configs = JSON.parse(fs.readFileSync(babelrc, 'utf-8'));
        } else if (fs.existsSync(babeljs)){
            this.configs = require(babeljs);
        } else if (fs.existsSync(pkg)){
            this.configs = require(pkg).babel;
        } 

        // setup default babel config
        this.configs = this.configs || configs || {};
        // process ignore to compat babel6
        if (
            typeof this.configs.ignore === 'string' || 
            this.configs.ignore instanceof RegExp
        ) {
            this.configs.ignore = [this.configs.ignore];
        } else if ( 
            this.configs.ignore && 
            !Array.isArray(this.configs.ignore)
        ) {
            throw new Error(`babel 配置 ignore 必须为Array类型`);
        } else {