|
15 | 15 | * [What is this?](#what-is-this) |
16 | 16 | * [When to use this](#when-to-use-this) |
17 | 17 | * [Install](#install) |
| 18 | + * [Replacing the official package](#replacing-the-official-package) |
| 19 | + * [Standard Installation](#standard-installation) |
18 | 20 | * [Use](#use) |
19 | 21 | * [API](#api) |
20 | 22 | * [`math(options?)`](#mathoptions) |
@@ -59,6 +61,56 @@ making it easier to transform content by abstracting these internals away. |
59 | 61 |
|
60 | 62 | ## Install |
61 | 63 |
|
| 64 | +### Replacing the official package |
| 65 | + |
| 66 | +If you are using another tool (such as `remark-math`) that depends on the original `micromark-extension-math`, you will need to tell your build tool or package manager to use this package (`micromark-extension-cfm-math`) instead. |
| 67 | + |
| 68 | +#### With Vite |
| 69 | + |
| 70 | +In your `vite.config.js` (or `vite.config.ts`), you can use the `resolve.alias` option: |
| 71 | + |
| 72 | +```js |
| 73 | +import { defineConfig } from 'vite' |
| 74 | + |
| 75 | +export default defineConfig({ |
| 76 | + // ... |
| 77 | + resolve: { |
| 78 | + alias: { |
| 79 | + 'micromark-extension-math': 'micromark-extension-cfm-math' |
| 80 | + } |
| 81 | + } |
| 82 | +}) |
| 83 | +``` |
| 84 | + |
| 85 | +#### With Package Manager Overrides |
| 86 | + |
| 87 | +A more robust method is to use the overrides feature of your package manager. This forces the dependency resolution to always use your preferred version, regardless of how deep it is in the dependency tree. |
| 88 | + |
| 89 | +* **For npm (v8.3.0+):** add this to your `package.json`: |
| 90 | + ```json |
| 91 | + "overrides": { |
| 92 | + "micromark-extension-math": "npm:micromark-extension-cfm-math@^3" |
| 93 | + } |
| 94 | + ``` |
| 95 | +* **For pnpm:** add this to your `package.json`: |
| 96 | + ```json |
| 97 | + "pnpm": { |
| 98 | + "overrides": { |
| 99 | + "micromark-extension-math": "npm:micromark-extension-cfm-math@^3" |
| 100 | + } |
| 101 | + } |
| 102 | + ``` |
| 103 | +* **For Yarn (v1 Classic and v2+ Modern):** add this to your `package.json`: |
| 104 | + ```json |
| 105 | + "resolutions": { |
| 106 | + "micromark-extension-math": "npm:micromark-extension-cfm-math@^3" |
| 107 | + } |
| 108 | + ``` |
| 109 | + |
| 110 | +After adding this, delete your `node_modules` directory and lock file (`package-lock.json`, `pnpm-lock.yaml`, or `yarn.lock`), and run install again. |
| 111 | + |
| 112 | +### Standard Installation |
| 113 | + |
62 | 114 | This package is [ESM only][esm]. |
63 | 115 | In Node.js (version 16+), install with [npm][]: |
64 | 116 |
|
|
0 commit comments