Spaces:
Sleeping
Sleeping
pythonic-rag-FastAPIReact / frontend /node_modules /@emotion /babel-plugin /src /utils /transformer-macro.js
Download frontend/node_modules/@emotion/babel-plugin/src/utils/transformer-macro.js from sepidnes/pythonic-rag-FastAPIReact: direct link, hf CLI and curl.
- Browser
- Download file 1.69 kB
-
https://huggingface.co/spaces/sepidnes/pythonic-rag-FastAPIReact/resolve/c9f908872ebbec3c4fa1392419c0f6cd3750ddb3/frontend/node_modules/%40emotion/babel-plugin/src/utils/transformer-macro.js
- Command line
-
hf download hf://spaces/sepidnes/pythonic-rag-FastAPIReact@c9f908872ebbec3c4fa1392419c0f6cd3750ddb3/frontend/node_modules/@emotion/babel-plugin/src/utils/transformer-macro.js
-
curl -L -o transformer-macro.js https://huggingface.co/spaces/sepidnes/pythonic-rag-FastAPIReact/resolve/c9f908872ebbec3c4fa1392419c0f6cd3750ddb3/frontend/node_modules/%40emotion/babel-plugin/src/utils/transformer-macro.js
1.69 kB
| 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 | |
| } | |