How to use the @codesandbox/common/lib/utils/is-babel-7.isBabel7 function in @codesandbox/common

To help you get started, we’ve selected a few @codesandbox/common 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 codesandbox / codesandbox-client / packages / app / src / sandbox / compile.ts View on Github external
const preinstalledDependencies =
    sandpackConfig.preInstalledDependencies == null
      ? PREINSTALLED_DEPENDENCIES
      : sandpackConfig.preInstalledDependencies;

  if (templateDefinition.name === 'reason') {
    returnedDependencies = {
      ...returnedDependencies,
      '@jaredly/bs-core': '3.0.0-alpha.2',
      '@jaredly/reason-react': '0.3.4',
    };
  }

  // Always include this, because most sandboxes need this with babel6 and the
  // packager will only include the package.json for it.
  if (isBabel7(d, devDependencies)) {
    returnedDependencies['@babel/runtime'] =
      returnedDependencies['@babel/runtime'] || '7.3.1';
  } else {
    returnedDependencies['babel-runtime'] =
      returnedDependencies['babel-runtime'] || '6.26.0';
  }

  // This is used for cache busting
  returnedDependencies.csbbust = '1.0.0';

  preinstalledDependencies.forEach(dep => {
    if (returnedDependencies[dep]) {
      delete returnedDependencies[dep];
    }
  });
github codesandbox / codesandbox-client / packages / app / src / sandbox / compile.ts View on Github external
const preinstalledDependencies =
    sandpackConfig.preInstalledDependencies == null
      ? PREINSTALLED_DEPENDENCIES
      : sandpackConfig.preInstalledDependencies;

  if (templateDefinition.name === 'reason') {
    returnedDependencies = {
      ...returnedDependencies,
      '@jaredly/bs-core': '3.0.0-alpha.2',
      '@jaredly/reason-react': '0.3.4',
    };
  }

  // Always include this, because most sandboxes need this with babel6 and the
  // packager will only include the package.json for it.
  if (isBabel7(d, devDependencies)) {
    returnedDependencies['@babel/runtime'] =
      returnedDependencies['@babel/runtime'] || '7.3.1';
  } else {
    returnedDependencies['babel-runtime'] =
      returnedDependencies['babel-runtime'] || '6.26.0';
  }

  // This is used for cache busting
  returnedDependencies.csbbust = '1.0.0';

  preinstalledDependencies.forEach(dep => {
    if (returnedDependencies[dep]) {
      delete returnedDependencies[dep];
    }
  });
github codesandbox / codesandbox-client / packages / app / src / sandbox / eval / transpilers / babel / index.ts View on Github external
const loaderOptions = loaderContext.options || {};

      const dependencies =
        (configs.package &&
          configs.package.parsed &&
          configs.package.parsed.dependencies) ||
        {};

      const devDependencies =
        (configs.package &&
          configs.package.parsed &&
          configs.package.parsed.devDependencies) ||
        {};

      const isV7 =
        loaderContext.options.isV7 || isBabel7(dependencies, devDependencies);

      const hasMacros = Object.keys(dependencies).some(d =>
        d.includes('macro')
      );

      const babelConfig = getBabelConfig(
        foundConfig || (loaderOptions as any).config,
        loaderOptions,
        path,
        isV7
      );

      this.queueTask(
        {
          code,
          config: babelConfig,
github codesandbox / codesandbox-client / packages / app / src / sandbox / eval / presets / create-react-app / index.js View on Github external
setup: manager => {
        const { configurations } = manager;

        if (
          isBabel7(
            configurations &&
              configurations.package &&
              configurations.package.parsed &&
              configurations.package.parsed.dependencies,

            configurations &&
              configurations.package &&
              configurations.package.parsed &&
              configurations.package.parsed.devDependencies
          ) &&
          !v2Initialized
        ) {
          const babelOptions = {
            isV7: true,
            compileNodeModulesWithEnv: true,
            config: {
github codesandbox / codesandbox-client / packages / app / src / sandbox / eval / transpilers / babel / index.ts View on Github external
const loaderOptions = loaderContext.options || {};

      const dependencies =
        (configs.package &&
          configs.package.parsed &&
          configs.package.parsed.dependencies) ||
        {};

      const devDependencies =
        (configs.package &&
          configs.package.parsed &&
          configs.package.parsed.devDependencies) ||
        {};

      const isV7 =
        loaderContext.options.isV7 || isBabel7(dependencies, devDependencies);

      const hasMacros = Object.keys(dependencies).some(
        d => d.indexOf('macro') > -1
      );

      const babelConfig = getBabelConfig(
        foundConfig || (loaderOptions as any).config,
        loaderOptions,
        path,
        isV7
      );

      this.queueTask(
        {
          code,
          config: babelConfig,