Skip to navigation

@mdx-js/esbuild

MDX 的 esbuild 插件。

¥esbuild plugin for MDX.

内容

¥Contents

这是什么?

¥What is this?

该软件包是一个支持 MDX 的 esbuild 插件。

¥This package is an esbuild plugin to support MDX.

我什么时候应该使用这个?

¥When should I use this?

如果你使用 esbuild(或其他使用 esbuild 的工具),此集成非常有用。

¥This integration is useful if you’re using esbuild (or another tool that uses esbuild).

如果你想评估 MDX 代码,则可以使用更底层的编译器 (@mdx-js/mdx)。为了支持非标准的 JSX 运行时(例如 Vue),也可以使用 @mdx-js/mdx,或者我们的 webpack 加载器(@mdx-js/loader)或 Rollup 插件(@mdx-js/rollup)。

¥If you want to evaluate MDX code then the lower-level compiler (@mdx-js/mdx) can be used. to support nonstandard JSX runtime (such as Vue), @mdx-js/mdx can also be used, or our webpack loader (@mdx-js/loader) or Rollup plugin (@mdx-js/rollup).

安装

¥Install

这个包是 仅限 ESM。在 Node.js(版本 16+)中,使用 npm 安装:

¥This package is ESM only. In Node.js (version 16+), install with npm:

Shell
npm install @mdx-js/esbuild

使用

¥Use

使用 esbuild API 执行类似的操作:

¥Do something like this with the esbuild API:

TypeScript
import mdx from '@mdx-js/esbuild'
import esbuild from 'esbuild'

await esbuild.build({
  // Replace `index.js` with your entry point that imports MDX files:
  entryPoints: ['index.js'],
  format: 'esm',
  outfile: 'output.js',
  plugins: [mdx({/* jsxImportSource: …, otherOptions… */})]
})

API

该包不导出任何标识符。默认导出为 mdx

¥This package exports no identifiers. The default export is mdx.

mdx(options?)

创建一个 esbuild 插件来将 MDX 编译为 JS。

¥Create an esbuild plugin to compile MDX to JS.

esbuild 负责将现代 JavaScript 功能转换为可以在任何你想要的地方使用的语法。对于其他集成,你可能需要使用 Babel 来实现此目的,但对于 esbuild 则不需要。有关更多信息,请参阅 esbuild 的文档。

¥esbuild takes care of turning modern JavaScript features into syntax that works wherever you want it to. With other integrations you might need to use Babel for this, but with esbuild that’s not needed. See esbuild’s docs for more info.

参数

¥Parameters

  • optionsOptions,可选) - 配置

    ¥options (Options, optional) — configuration

返回

¥Returns

ESBuild 插件(Pluginesbuild)。

¥ESBuild plugin (Plugin from esbuild).

Options

配置(TypeScript 类型)。

¥Configuration (TypeScript type).

选项与 CompileOptions@mdx-js/mdx 相同。

¥Options are the same as CompileOptions from @mdx-js/mdx.

类型

¥Types

该包完全采用 TypeScript 类型。它导出附加类型 Options。请参阅我们网站上的 § 类型 了解信息。

¥This package is fully typed with TypeScript. It exports the additional type Options. See § Types on our website for information.

兼容性

¥Compatibility

由统一集体维护的项目与 Node.js 的维护版本兼容。

¥Projects maintained by the unified collective are compatible with maintained versions of Node.js.

当我们削减新的主要版本时,我们会放弃对未维护的 Node.js 版本的支持。这意味着我们尝试保持当前版本 @mdx-js/esbuild@^3 与 Node.js 16 兼容。

¥When we cut a new major release, we drop support for unmaintained versions of Node. This means we try to keep the current release line, @mdx-js/esbuild@^3, compatible with Node.js 16.

安全

¥Security

请参阅我们网站上的 § 安全 了解信息。

¥See § Security on our website for information.

贡献

¥Contribute

请参阅我们网站上的 § 贡献 了解入门方法。请参阅 § 支持 了解获取帮助的方法。

¥See § Contribute on our website for ways to get started. See § Support for ways to get help.

该项目有 行为守则。通过与此存储库、组织或社区交互,你同意遵守其条款。

¥This project has a code of conduct. By interacting with this repository, organization, or community you agree to abide by its terms.

许可证

¥License

MIT © Titus Wormer

MDX 中文网 - 粤ICP备13048890号