mdx-artifacts 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -1
- package/dist/lib/cli/vite-artifact.js +23 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -47,7 +47,19 @@ Astro is intentionally not part of the core yet. It can become a later adapter f
|
|
|
47
47
|
Install in a project that should build local artifacts:
|
|
48
48
|
|
|
49
49
|
```bash
|
|
50
|
-
pnpm add mdx-artifacts
|
|
50
|
+
pnpm add -D mdx-artifacts
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
In a pnpm workspace root, make the workspace-root install explicit:
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
pnpm add -Dw mdx-artifacts
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
React and React DOM are peer dependencies. Modern package managers usually install them automatically for this dev-tool workflow. If peer dependency auto-install is disabled in your project, install them explicitly:
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
pnpm add -D mdx-artifacts react react-dom
|
|
51
63
|
```
|
|
52
64
|
|
|
53
65
|
Initialize a workspace:
|
|
@@ -179,14 +179,32 @@ async function resolveReactEntryPath() {
|
|
|
179
179
|
}
|
|
180
180
|
function resolveReactAliases(projectRoot) {
|
|
181
181
|
const projectRequire = createRequire(path.join(projectRoot, "package.json"));
|
|
182
|
+
const packageRequire = createRequire(import.meta.url);
|
|
182
183
|
return [
|
|
183
|
-
{ find: /^react$/, replacement: projectRequire
|
|
184
|
-
{
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
184
|
+
{ find: /^react$/, replacement: resolveFromProjectOrPackage(projectRequire, packageRequire, "react") },
|
|
185
|
+
{
|
|
186
|
+
find: /^react\/jsx-runtime$/,
|
|
187
|
+
replacement: resolveFromProjectOrPackage(projectRequire, packageRequire, "react/jsx-runtime")
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
find: /^react\/jsx-dev-runtime$/,
|
|
191
|
+
replacement: resolveFromProjectOrPackage(projectRequire, packageRequire, "react/jsx-dev-runtime")
|
|
192
|
+
},
|
|
193
|
+
{ find: /^react-dom$/, replacement: resolveFromProjectOrPackage(projectRequire, packageRequire, "react-dom") },
|
|
194
|
+
{
|
|
195
|
+
find: /^react-dom\/client$/,
|
|
196
|
+
replacement: resolveFromProjectOrPackage(projectRequire, packageRequire, "react-dom/client")
|
|
197
|
+
}
|
|
188
198
|
];
|
|
189
199
|
}
|
|
200
|
+
function resolveFromProjectOrPackage(projectRequire, packageRequire, specifier) {
|
|
201
|
+
try {
|
|
202
|
+
return projectRequire.resolve(specifier);
|
|
203
|
+
}
|
|
204
|
+
catch {
|
|
205
|
+
return packageRequire.resolve(specifier);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
190
208
|
export async function startDevServer(project) {
|
|
191
209
|
const server = await createServer(project.config);
|
|
192
210
|
await server.listen();
|