Skip to content

t.templateLiteral does not automatically populate cooked from raw, no helpers available for conversion #9242

@coreyfarrell

Description

@coreyfarrell

Bug Report

Current Behavior
t.templateLiteral({raw}, tail) does not contain a cooked value.

Input Code
cfware/babel-plugin-template-html-minifier@aa91d8c

My babel plugin uses the raw value of quasi elements. Babel does not provide any helper to convert between raw and cooked values for templateElement. Per cfware/babel-plugin-template-html-minifier#10 lack of cooked creates a problem when transpiling for IE11 (I will post an update if I get a minimal reproduction repo).

Expected behavior/code
A way to create a templateElement when only cooked or raw is known should be possible.

Babel Configuration (.babelrc, package.json, cli command)
I don't have the specific babelrc, I will provide once I get an update from the reporter of the bug on my plugin.

Environment

  • Babel version(s): ^7.0.0
  • Node/npm version: node 10.14.2, npm 6.4.1
  • OS: Fedora 28
  • Monorepo: no
  • How you are using Babel: webpack

Possible Solution
t.templateElement could automatically populate cooked from raw, or raw from cooked if only one option is provided. Alternatively a helper function to convert between raw and cooked would be helpful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    outdatedA closed issue/PR that is archived due to age. Recommended to make a new issuepkg: types

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions