How to use @svgr/hast-util-to-babel-ast - 1 common examples

To help you get started, we’ve selected a few @svgr/hast-util-to-babel-ast 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 gregberge / svgr / packages / plugin-jsx / src / index.js View on Github external
export default function jsxPlugin(code, config, state) {
  const filePath = state.filePath || 'unknown'
  const hastTree = parse(code)

  const babelTree = hastToBabelAst(hastTree)

  const { code: generatedCode } = transformFromAstSync(babelTree, code, {
    caller: {
      name: 'svgr',
    presets: [
      createConfigItem([svgrBabelPreset, { ...config, state }], {
        type: 'preset',
    filename: filePath,
    babelrc: false,
    configFile: false,
    code: true,
    ast: false,
    inputSourceMap: false,


Transform HAST to Babel AST (JSX)

Latest version published 11 months ago

Package Health Score

76 / 100
Full package analysis

Popular @svgr/hast-util-to-babel-ast functions