How to use find-babel-config - 7 common examples

To help you get started, we’ve selected a few find-babel-config 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 reworkjs / reworkjs / src / internals / webpack / features / babel.js View on Github external
getBabelConfig(): Object {
    // FIXME need to find a way to support other kind of babel configs.
    const { config } = findBabelConfig.sync(resolveProject('.'));

    if (config == null) {
      return { presets: ['@reworkjs/core/babel-preset'] };
    }

    return config;
  }
}
github toomuchdesign / babel-timing / src / standalone / getImports.js View on Github external
async function getImports(file, options) {
  // Even though rollup-plugin-babel can autodiscover Babel configurations,
  // here we want to use the same babel config for every module
  const babelConfig =
    options.babelConfig || findBabelConfig.sync(path.dirname(file)).file;

  // https://rollupjs.org/guide/en#rollup-rollup
  const inputOptions = {
    external: [],
    input: file,
    plugins: [
      nodeResolve({
        extensions: defaultExtensions,
        mainFields: options.resolveMainFields,
      }),
      babel({
        include: options.include,
        exclude: options.exclude,
        extensions: defaultExtensions,
        configFile: babelConfig,
      }),
github reworkjs / reworkjs / src / internals / webpack / get-babel-config.js View on Github external
export default function getBabelConfig() {
  // FIXME note: might break with Babel 7 due to new support for babelrc.js
  const { config } = findBabelConfig.sync(resolveProject('.'));

  if (config == null) {
    return getDefaultBabelConfig();
  }

  // no need to load it, babel will do it on its own.
  return null;
}
github youzan / vant / packages / vant-cli / src / compiler / compile-js.ts View on Github external
function genTempBabelConfig() {
  const { config } = findBabelConfig.sync(ROOT);
  const content = `module.exports = function (api) {
  api.cache.never();

  return ${JSON.stringify(config)}
};`;

  outputFileSync(TEMP_BABEL_CONFIG, content);
}
github trivago / melody / packages / melody-jest-transform / src / preprocessor.js View on Github external
export function getBabelConf() {
    const { config } = findBabelConfig.sync(p.cwd());

    if (!config) {
        throw new Error(
            'Couldn\'t find .babelrc or babel entry on package.json! You can specify custom config with "transformer". Please consult documentation.'
        );
    }
    return config;
}
github egoist / vue-compile / src / script-compilers / babel.ts View on Github external
export const compile = async (code: string, { filename, modern, babelrc }: ScriptCompilerContext): Promise => {
  const cwd = path.dirname(filename)
  const file =
    babelrc === false ?
      null :
      cache.get(cwd) ||
        (require('find-babel-config')(cwd).then((res: any) => res.file))

  cache.set(cwd, file)

  const config: TransformOptions = {
    filename,
    presets: [
      [
        require.resolve('../babel/preset'),
        {
          modern
        }
      ]
    ]
  }

  if (file) {

find-babel-config

Find the closest babel config based on a directory

MIT
Latest version published 9 days ago

Package Health Score

80 / 100
Full package analysis

Popular find-babel-config functions