Matyas
Matyas

Reputation: 41

How to prevent babel.js from encoding string to unicode?

I have a simple function:

const showUTF8Text = text => `Funkcja wyświetla tekst: ${text}`;

and after transpile it with babel I receive:

var showUTF8Text = function showUTF8Text(text) {
  return "Funkcja wy\uFFFDwietla tekst: " + text;
};

how to prevent babel from encoding to keep the original string?

Upvotes: 1

Views: 429

Answers (1)

Lera Rosalene
Lera Rosalene

Reputation: 119

As suggested here: https://github.com/babel/babel/issues/9804#issuecomment-480075309
Add this to your babel config:

"generatorOpts": {
  "jsescOption": {
    "minimal": true
  }
}

More info about this jsesc option on their README: https://github.com/mathiasbynens/jsesc#minimal

Upvotes: 1

Related Questions