PHP 8.2.30
Preview: transformer-macro.js Size: 1.65 KB
/home/byroehnu/easepaybiz.easetack.com/node_modules/@emotion/babel-plugin/src/utils/transformer-macro.js

import { createMacro } from 'babel-plugin-macros'

/*
type Transformer = Function
*/

export function createTransformerMacro(
  transformers /*: { [key: string]: Transformer | [Transformer, Object] } */,
  { importSource } /*: { importSource: string } */
) {
  let macro = createMacro(
    ({ path, source, references, state, babel, isEmotionCall }) => {
      if (!path) {
        path = state.file.scope.path
          .get('body')
          .find(p => p.isImportDeclaration() && p.node.source.value === source)
      }

      if (/\/macro$/.test(source)) {
        path
          .get('source')
          .replaceWith(
            babel.types.stringLiteral(source.replace(/\/macro$/, ''))
          )
      }

      if (!isEmotionCall) {
        state.emotionSourceMap = true
      }
      Object.keys(references).forEach(importSpecifierName => {
        if (transformers[importSpecifierName]) {
          references[importSpecifierName].reverse().forEach(reference => {
            let options
            let transformer
            if (Array.isArray(transformers[importSpecifierName])) {
              transformer = transformers[importSpecifierName][0]
              options = transformers[importSpecifierName][1]
            } else {
              transformer = transformers[importSpecifierName]
              options = {}
            }
            transformer({
              state,
              babel,
              path,
              importSource,
              importSpecifierName,
              options,
              reference
            })
          })
        }
      })
      return { keepImports: true }
    }
  )
  macro.transformers = transformers
  return macro
}

Directory Contents

Dirs: 0 × Files: 14

Name Size Perms Modified Actions
127 B lr--r--r-- 2026-03-14 01:49:07
Edit Download
750 B lrw-r--r-- 2026-03-05 00:19:55
Edit Download
373 B lrw-r--r-- 2026-03-05 00:19:55
Edit Download
2.79 KB lrw-r--r-- 2026-03-05 00:19:59
Edit Download
1.49 KB lrw-r--r-- 2026-03-05 00:20:00
Edit Download
537 B lrw-r--r-- 2026-03-05 00:20:02
Edit Download
4.62 KB lrw-r--r-- 2026-03-05 00:20:02
Edit Download
3.91 KB lrw-r--r-- 2026-03-05 00:20:04
Edit Download
1.26 KB lrw-r--r-- 2026-03-05 00:20:05
Edit Download
1.07 KB lrw-r--r-- 2026-03-05 00:20:06
Edit Download
1.90 KB lrw-r--r-- 2026-03-05 00:20:08
Edit Download
4.21 KB lrw-r--r-- 2026-03-05 00:20:09
Edit Download
1.65 KB lrw-r--r-- 2026-03-05 00:20:09
Edit Download
2.28 KB lrw-r--r-- 2026-03-05 00:20:09
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).