{"id":25553,"library":"ethical-utility-babel-directory-transpiler","title":"ethical-utility-babel-directory-transpiler","description":"A utility for transpiling entire directories with Babel, part of the Ethical web framework. Currently at version 0.0.0 and still in pre-release. It provides a simple API to transpile all files in a directory using Babel configuration, handling recursive directory traversal and output mirroring. Different from standalone Babel CLI in that it's designed as a programmatic utility within the Ethical ecosystem, with promise-based API and tight integration with Ethical's file system utilities.","status":"active","version":"0.0.0","language":"javascript","source_language":"en","source_url":"https://github.com/Ethically/ethical-utility-babel-directory-transpiler","tags":["javascript"],"install":[{"cmd":"npm install ethical-utility-babel-directory-transpiler","lang":"bash","label":"npm"},{"cmd":"yarn add ethical-utility-babel-directory-transpiler","lang":"bash","label":"yarn"},{"cmd":"pnpm add ethical-utility-babel-directory-transpiler","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"The module exports a named function. No default export.","wrong":"const transpileDirectory = require('ethical-utility-babel-directory-transpiler').transpileDirectory","symbol":"transpileDirectory","correct":"import { transpileDirectory } from 'ethical-utility-babel-directory-transpiler'"},{"note":"Default import is not supported; must use named import.","wrong":"const transpileDirectory = require('ethical-utility-babel-directory-transpiler')","symbol":"transpileDirectory","correct":"import transpileDirectory from 'ethical-utility-babel-directory-transpiler'"},{"note":"This class is also exported.","wrong":"const EthicalBabelDirectoryTranspiler = require('ethical-utility-babel-directory-transpiler').EthicalBabelDirectoryTranspiler","symbol":"EthicalBabelDirectoryTranspiler","correct":"import { EthicalBabelDirectoryTranspiler } from 'ethical-utility-babel-directory-transpiler'"}],"quickstart":{"code":"import { transpileDirectory } from 'ethical-utility-babel-directory-transpiler';\n\nasync function build() {\n  try {\n    const result = await transpileDirectory({\n      source: './src',\n      output: './dist',\n      babelOptions: {\n        presets: ['@babel/preset-env'],\n        plugins: ['@babel/plugin-transform-arrow-functions']\n      },\n      extensions: ['.js', '.jsx'],\n      verbose: false\n    });\n    console.log(`Transpiled ${result.count} files`);\n  } catch (error) {\n    console.error('Transpilation failed:', error);\n  }\n}\n\nbuild();","lang":"typescript","description":"Shows how to transpile all JavaScript files from a source directory to an output directory with Babel presets and plugins."},"warnings":[{"fix":"Pin to exact version and test upgrades carefully.","message":"The package is in pre-release (v0.0.0); API may change without notice.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Use @babel/preset-env for Babel 7, or babel-preset-env for Babel 6.","message":"Babel 6 and 7 presets/plugins are incompatible; ensure you pass options compatible with your installed Babel version.","severity":"breaking","affected_versions":">=0.0.0"},{"fix":"Set extensions: ['.js', '.ts'] when transpiling TypeScript files (but note Babel will strip types only if preset-typescript is used).","message":"The 'extensions' option defaults to ['.js']; if you use TypeScript, you must explicitly include '.ts'.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Monitor the repository for updates.","message":"The 'babelOptions' configuration may be renamed in future versions; currently undocumented.","severity":"deprecated","affected_versions":">=0.0.0"},{"fix":"Manually remove or clean the output directory before each build.","message":"Output directory is not cleaned before transpilation; files from previous runs remain.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"npm install @babel/core","cause":"Babel peer dependency not installed","error":"Error: Cannot find module '@babel/core'"},{"fix":"Use import { transpileDirectory } from 'ethical-utility-babel-directory-transpiler'","cause":"Default import used instead of named import","error":"TypeError: transpileDirectory is not a function"},{"fix":"Add required presets/plugins, e.g., @babel/preset-env for modern JS","cause":"Babel preset/plugin not compatible with source code","error":"Error: Unexpected token: punc (.)"},{"fix":"Ensure the source directory exists before calling transpileDirectory","cause":"Source directory does not exist","error":"Error: ENOENT: no such file or directory, scandir './src'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}