Skip to content

@babel/template tries to replace uppercase strings #8067

@djfarly

Description

@djfarly

v7 Regression

First check out: https://new.babeljs.io/docs/en/next/v7-migration.html
Also a partial upgrade tool: https://github.com/babel/babel-upgrade

Potential Commit/PR that introduced the regression
Somewhere between v6 and v7 - not quite sure though… also the cafe is closing so i don't have time to investigate further, sorry!

Describe the regression
AST generation fails for ALLCAPS strings. I think it should not. 🤔

Input Code

Reduced test case here.

var template = require("@babel/template");

const string = "var a = { a: 'NormalString', b: 'UPPERCASESTRING' };"

console.log(template.default(string)())

This throws:

Error: @babel/template placeholder "UPPERCASESTRING": Expected string substitution

Working v6 here.

var template = require("babel-template");

const string = "var a = { a: 'NormalString', b: 'UPPERCASESTRING' };"

console.log(template(string)())

This works flawlessly.

Babel Configuration (.babelrc, package.json, cli command)
none

Expected behavior/code
It should create an AST normally, taking into account that 'UPPERCASESTRING' is just a string.

Environment

  • Babel version(s): In REPL 7.0.0-beta.49
  • Node/npm version: Tested in node 9 + 10
  • OS: OSX (local) + linux/amd64 (REPL)
  • Monorepo (does not matter?)
  • How you are using Babel: babel/template directly in babel-plugin-codegen

Thanks a ton! 🎉 ❤️

Metadata

Metadata

Assignees

No one assigned

    Labels

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

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions