@babel/plugin-transform-json-strings

json-strings - 图1info

This plugin is included in @babel/preset-env, in ES2019

Examples

In

JavaScript

  1. const ex = "before
after";
  2. // ^ There's a U+2028 char between 'before' and 'after'

Out

JavaScript

  1. const ex = "before\u2028after";
  2. // ^ There's a U+2028 char between 'before' and 'after'

Installation

  • npm
  • Yarn
  • pnpm
  1. npm install --save-dev @babel/plugin-transform-json-strings
  1. yarn add --dev @babel/plugin-transform-json-strings
  1. pnpm add --save-dev @babel/plugin-transform-json-strings

Usage

babel.config.json

  1. {
  2. "plugins": ["@babel/plugin-transform-json-strings"]
  3. }

Via CLI

Shell

  1. babel --plugins @babel/plugin-transform-json-strings script.js

Via Node API

JavaScript

  1. require("@babel/core").transformSync("code", {
  2. plugins: ["@babel/plugin-transform-json-strings"],
  3. });

References