How to use the umi-core/lib/registerBabel function in umi-core

To help you get started, we’ve selected a few umi-core 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 umijs / umi / packages / umi / src / isUmiUIEnable.js View on Github external
export default function(cwd) {
  registerBabel(cwd);
  const config = getUserConfig({ cwd });

  if (config.ssr) return false;

  if (process.env.BIGFISH_COMPAT) {
    if (config.appType !== 'console') return false;
    if (config.deployMode === 'chair') return false;
  }

  const pkgFile = join(cwd, 'package.json');
  const pkg = existsSync(pkgFile) ? JSON.parse(readFileSync(pkgFile, 'utf-8')) : {};

  // disable if react is lower than 16
  const reactVersion = getDep(pkg, 'react');
  if (reactVersion) {
    const reactPkgFile = join(cwd, 'node_modules', 'react', 'package.json');