How to use the @emotion/babel-utils.appendStringToExpressions function in @emotion/babel-utils

To help you get started, we’ve selected a few @emotion/babel-utils 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 emotion-js / next / packages / babel-plugin-core / src / styled-macro.js View on Github external
)
        ])
      }
      if (t.isCallExpression(reference.parentPath.parentPath)) {
        if (state.emotionSourceMap) {
          if (
            !sourceMap &&
            reference.parentPath.parentPath.node.loc !== undefined
          ) {
            sourceMap = getSourceMap(
              reference.parentPath.parentPath.node.loc.start,
              state
            )
          }

          appendStringToExpressions(
            reference.parentPath.parentPath.node.arguments,
            sourceMap,
            t
          )
        }
      }
    })
  }
github emotion-js / next / packages / babel-plugin-core / src / css-macro.js View on Github external
if (t.isCallExpression(path)) {
    const label = getLabelFromPath(path, t)

    let isPure = true

    path.get('arguments').forEach(node => {
      if (!node.isPure()) {
        isPure = false
      }
      if (t.isObjectExpression(node)) {
        node.replaceWith(simplifyObject(node.node, t))
      }
    })
    if (label) {
      appendStringToExpressions(path.node.arguments, `label:${label};`, t)
    }

    if (state.emotionSourceMap) {
      if (!sourceMap && path.node.loc !== undefined) {
        sourceMap = getSourceMap(path.node.loc.start, state)
      }
      appendStringToExpressions(path.node.arguments, sourceMap, t)
    }

    path.node.arguments = joinStringLiterals(path.node.arguments, t)

    if (
      path.node.arguments.length === 1 &&
      t.isStringLiteral(path.node.arguments[0])
    ) {
      let cssString = path.node.arguments[0].value
github emotion-js / next / packages / babel-plugin-core / src / css-macro.js View on Github external
if (!node.isPure()) {
        isPure = false
      }
      if (t.isObjectExpression(node)) {
        node.replaceWith(simplifyObject(node.node, t))
      }
    })
    if (label) {
      appendStringToExpressions(path.node.arguments, `label:${label};`, t)
    }

    if (state.emotionSourceMap) {
      if (!sourceMap && path.node.loc !== undefined) {
        sourceMap = getSourceMap(path.node.loc.start, state)
      }
      appendStringToExpressions(path.node.arguments, sourceMap, t)
    }

    path.node.arguments = joinStringLiterals(path.node.arguments, t)

    if (
      path.node.arguments.length === 1 &&
      t.isStringLiteral(path.node.arguments[0])
    ) {
      let cssString = path.node.arguments[0].value
      let res = css(cssString)

      path.replaceWith(
        t.objectExpression([
          t.objectProperty(t.identifier('name'), t.stringLiteral(res.name)),
          t.objectProperty(t.identifier('styles'), t.stringLiteral(res.styles))
        ])