@59naga/babel-plugin-transform-string-raw 中文文档教程

发布于 9年前 浏览 19 项目主页 更新于 3年前

babel-plugin-transform-string-raw

Installation

npm install @59naga/babel-plugin-transform-string-raw --save

String.raw 替换为 ponyfill 函数

Requirement

https://github.com/59naga/babel-plugin-transform-array-from

Installation

npm install @59naga/babel-plugin-transform-string-raw --save

Example

In

const arg1 = 'foo';
const arg2 = 'bar';
String.raw`hoge${arg1}fuga${arg2}piyo`;

Out

var _stringRaw = String.raw || function(){...};
_stringRaw`hoge${arg1}fuga${arg2}piyo`;

Usage

Via .babelrc (Recommended)

.babelrc

{
  "plugins": ["@59naga/babel-plugin-transform-string-raw"]
}

Via CLI

$ babel --plugins @59naga/babel-plugin-transform-string-raw script.js

Via Node API

require("babel-core").transform("code", {
  plugins: ["@59naga/babel-plugin-transform-string-raw"]
});

Development

要求全局

  • NodeJS v0.12.13
  • Npm v3.7.1
git clone https://github.com/59naga/babel-plugin-transform-string-raw
cd babel-plugin-transform-string-raw
npm install

npm test

License

麻省理工学院

babel-plugin-transform-string-raw

Installation

npm install @59naga/babel-plugin-transform-string-raw --save

replace String.raw with an ponyfill function.

Requirement

https://github.com/59naga/babel-plugin-transform-array-from

Installation

npm install @59naga/babel-plugin-transform-string-raw --save

Example

In

const arg1 = 'foo';
const arg2 = 'bar';
String.raw`hoge${arg1}fuga${arg2}piyo`;

Out

var _stringRaw = String.raw || function(){...};
_stringRaw`hoge${arg1}fuga${arg2}piyo`;

Usage

Via .babelrc (Recommended)

.babelrc

{
  "plugins": ["@59naga/babel-plugin-transform-string-raw"]
}

Via CLI

$ babel --plugins @59naga/babel-plugin-transform-string-raw script.js

Via Node API

require("babel-core").transform("code", {
  plugins: ["@59naga/babel-plugin-transform-string-raw"]
});

Development

Requirement global

  • NodeJS v0.12.13
  • Npm v3.7.1
git clone https://github.com/59naga/babel-plugin-transform-string-raw
cd babel-plugin-transform-string-raw
npm install

npm test

License

MIT

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文