@exodus/i18n-babel-webpack

中文文档
1.1.5发布于 2026/10/14MIT近 30 天下载 1.2万

i18n webpack-loader & babel plugins

原始使用文档
文档目录4 节
  1. Build tooling
  2. plugin-transform-t
  3. plugin-inline-po
  4. webpack-loader

@exodus/i18n-babel-webpack

Contains i18n related babel plugin & webpack loader

Babel & webpack-loader has commonjs requirements, so that this package is extracted from i18n to keep it in cjs

Build tooling

plugin-transform-t

The babel plugin plugin-transform-t is responsible for transforming invocations of <T> and t to a format that supplies the required props/params to the underlying component/function. In the simplest case this looks as follows:

<T>Test</T> // becomes <T id={"Test"} />

Things get more complicated when interpolation comes into play. For more information on what gets transformed how, please refer to the tests.

To use the plugin, simply reference it in your babel config:

// babel.config.js

/** @type {import('@babel/core').ConfigAPI} */
module.exports = {
  presets: [createBabelConfig()],
  plugins: [
    ...expandPaths([
      ['@babel/plugin-proposal-decorators', { legacy: true }],
      '@exodus/i18n/babel/plugin-transform-t',
    ]),
  ],
}

plugin-inline-po

This plugin is optional and only to be used in projects that don't use webpack. It inlines .po file contents as object whenever it encounters a require statement for a .po file. The disadvantage of this approach is that it adds all languages to the bundle and therefore prevents lazy loading.

To use it, simply add @exodus/i18n/babel/plugin-inline-po to your babel.config.js plugins.

webpack-loader

The preferred way of enabling support for .po files is using the webpack-loader that ships with this package. To use it, add the following to your webpack config's module rules:

const rules = [
  {
    test: /\.po$/,
    exclude: /node_modules/,
    use: path.resolve(__dirname, 'src/node_modules/@exodus/i18n/webpack-loader/index.js'),
  },
]

版本与发布记录

@exodus/i18n-babel-webpack 共发布 7 个版本,首次发布于 2024/11/02;过去 12 个月发布了 2 个版本。

版本发布日期距今
1.1.5latest2026/10/141 个月前
1.1.42025/12/0511 个月前
1.1.32025/02/211.7 年前
1.1.22025/02/101.8 年前
1.1.12025/01/311.8 年前
1.1.02024/12/051.9 年前

关于 @exodus/i18n-babel-webpack 的常见问题

@exodus/i18n-babel-webpack 是什么?

i18n webpack-loader & babel plugins

如何安装 @exodus/i18n-babel-webpack?

在项目目录运行 npm install @exodus/i18n-babel-webpack,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@babel/core(^7.0.0)、@babel/types(^7.0.0)、@babel/traverse(^7.0.0)、@babel/generator(^7.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@exodus/i18n-babel-webpack 支持 TypeScript 吗?

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

@exodus/i18n-babel-webpack 可以商用吗?

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

@exodus/i18n-babel-webpack 的下载量有多少?

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

@exodus/i18n-babel-webpack 还在维护吗?

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