@dapplets/unicode-escape-webpack-plugin

中文文档
0.1.1发布于 2025/01/14MITCommonJS零依赖近 30 天下载 5.7万

Escape Unicode characters in webpack

原始使用文档
文档目录11 节
  1. Features
  2. Installation
  3. Usage
  4. Example: Basic Configuration
  5. Example: Custom File Types
  6. How It Works
  7. Input Example
  8. Output Example
  9. Options
  10. Contributing
  11. License

Unicode Escape Plugin for Webpack

@dapplets/unicode-escape-webpack-plugin is a simple Webpack plugin that escapes all Unicode characters in your JavaScript files. This is useful for ensuring compatibility with environments that do not support certain Unicode characters natively.

Features

  • Escapes all Unicode characters (\u007f and above) in .js files.
  • Configurable to target specific file types or extensions.
  • Lightweight and easy to use.

Installation

Install the package via npm:

npm install -D @dapplets/unicode-escape-webpack-plugin

Usage

Add the plugin to your Webpack configuration file:

Example: Basic Configuration

javascript

Copy code

const UnicodeEscapePlugin = require("@dapplets/unicode-escape-webpack-plugin");

module.exports = {
  mode: "production", // or 'development'
  entry: "./src/index.js",
  output: {
    filename: "bundle.js",
    path: __dirname + "/dist",
  },
  plugins: [
    new UnicodeEscapePlugin({
      test: /\.js$/, // Process only `.js` files (default)
    }),
  ],
};

Example: Custom File Types

You can customize the test option to target other file types:

javascript

Copy code

new UnicodeEscapePlugin({
  test: /\.(js|jsx|ts|tsx)$/, // Escape Unicode in JavaScript and TypeScript files
});

How It Works

The plugin hooks into Webpack's build process and processes the specified files during the emit phase. It escapes Unicode characters using the \uXXXX format for all characters with a Unicode code point of \u007f or higher.

Input Example

javascript

Copy code

const example = "Unicode: é, ☃, 🐱";

Output Example

javascript

Copy code

const example = "Unicode: \\u00e9, \\u2603, \\ud83d\\udc31";

Options

OptionTypeDefaultDescription
testRegExp/\.js$/A regular expression to match files for processing.

Contributing

Contributions are welcome! If you encounter any issues or have feature requests, feel free to open an issue or submit a pull request on GitHub.

License

This project is licensed under the MIT License.

版本与发布记录

@dapplets/unicode-escape-webpack-plugin 共发布 2 个版本,首次发布于 2025/01/14;过去 12 个月发布了 0 个版本。

版本发布日期距今
0.1.1latest2025/01/141.8 年前
0.1.02025/01/141.8 年前

关于 @dapplets/unicode-escape-webpack-plugin 的常见问题

@dapplets/unicode-escape-webpack-plugin 是什么?

Escape Unicode characters in webpack

如何安装 @dapplets/unicode-escape-webpack-plugin?

在项目目录运行 npm install @dapplets/unicode-escape-webpack-plugin,或使用 pnpm add / yarn add / bun add。

@dapplets/unicode-escape-webpack-plugin 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/dapplets__unicode-escape-webpack-plugin 是否存在。

@dapplets/unicode-escape-webpack-plugin 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@dapplets/unicode-escape-webpack-plugin 可以商用吗?

@dapplets/unicode-escape-webpack-plugin 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@dapplets/unicode-escape-webpack-plugin 的下载量有多少?

根据 npm 官方下载统计,@dapplets/unicode-escape-webpack-plugin 在 2026/10/12 – 2026/11/10 这 30 天内被下载 56,609 次,日均约 1,887 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@dapplets/unicode-escape-webpack-plugin 还在维护吗?

最新版本 0.1.1 发布于 2025/01/14(1.8 年前);至今共发布 2 个版本,其中过去 12 个月发布了 0 个;首次发布于 2025/01/14。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。