Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize Babel output a little bit #1656

Merged
merged 11 commits into from
Jan 5, 2020
Prev Previous commit
Next Next commit
appendExpressionToArguments -> appendStringReturningExpressionToArgum…
…ents
  • Loading branch information
Andarist committed Jan 1, 2020
commit 3b72c553a8298c49baa2be476173f5043040549d
6 changes: 5 additions & 1 deletion packages/babel-plugin-emotion/src/utils/arguments.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
// @flow
import { isTaggedTemplateExpressionTranspiledByTypeScript } from './checks'

export const appendExpressionToArguments = (t: *, path: *, expression: *) => {
export const appendStringReturningExpressionToArguments = (
t: *,
path: *,
expression: *
) => {
let lastIndex = path.node.arguments.length - 1
let last = path.node.arguments[lastIndex]
if (t.isStringLiteral(last)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { getExpressionsFromTemplateLiteral } from './minify'
import { getLabelFromPath } from './label'
import { getSourceMap } from './source-maps'
import { simplifyObject } from './object-to-string'
import { appendExpressionToArguments } from './arguments'
import { appendStringReturningExpressionToArguments } from './arguments'
import { appendStringToArguments, joinStringLiterals } from './strings'

const CSS_OBJECT_STRINGIFIED_ERROR =
Expand Down Expand Up @@ -142,7 +142,7 @@ export let transformExpressionWithStyles = ({
t.stringLiteral(''),
t.stringLiteral(labelString)
)
appendExpressionToArguments(t, path, labelConditional)
appendStringReturningExpressionToArguments(t, path, labelConditional)
break
}
case 'always':
Expand All @@ -157,7 +157,7 @@ export let transformExpressionWithStyles = ({
t.stringLiteral(''),
t.stringLiteral(sourceMap)
)
appendExpressionToArguments(t, path, sourceMapConditional)
appendStringReturningExpressionToArguments(t, path, sourceMapConditional)
}

return { node: undefined, isPure }
Expand Down