Files
orca/config/build-plugins/markdown-parser-exports.ts
T
Neil 51530bb86c build: declare dependencies that only hoisting supplied (#30225)
* build: declare dependencies that only hoisting supplied

Under pnpm's global virtual store each package sees only its declared
dependencies. Several published packages relied on hoisting:

- jest-dom's vitest matcher augmentation could not find vitest (1645
  TS2339 errors in tc:web), and react libraries' .d.ts could not find
  @types/react, so lucide-react, dnd-kit, cmdk, sonner and others typed
  as `any`. Other .d.ts phantoms (electron, vfile, prosemirror-model,
  d3-selection, type-fest) degraded silently the same way.
- electron-vite resolves electron/package.json and the binary itself.

packageExtensions declares these, which also holds in the hoisted
layout. The markdown alias now resolves decode-named-character-reference
through mdast-util-from-markdown, the package that actually declares it.

* build: let addMissingPeerTypes supply @types/react to react peers

pnpm 12.12 links a peer's @types package next to every package that
peer-depends on it, which replaces the hand-listed @types/react peers.
The regression test now reads pnpm-workspace.yaml, so it checks every
packageExtensions entry instead of a hand-picked seven.
2026-10-18 19:54:51 -07:00

17 lines
747 B
TypeScript

import { createRequire } from 'node:module'
const require = createRequire(import.meta.url)
// Why: walk the declared dependency chain; isolated installs don't hoist decode-named-character-reference next to remark-parse.
const fromMarkdownRequire = createRequire(
createRequire(require.resolve('remark-parse')).resolve('mdast-util-from-markdown')
)
const mathRequire = createRequire(require.resolve('rehype-katex'))
// Both preview paths use DOM-free parsing so their dependencies also run in workers.
export const markdownParserAliases = {
'decode-named-character-reference': fromMarkdownRequire.resolve(
'decode-named-character-reference'
),
'hast-util-from-html-isomorphic': mathRequire.resolve('hast-util-from-html-isomorphic')
}