@lovett/ui 0.0.7 → 0.0.8
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/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/code-block.tsx +12 -1
- package/src/react-syntax-highlighter-prism.d.ts +19 -0
package/package.json
CHANGED
package/src/code-block.tsx
CHANGED
|
@@ -12,7 +12,18 @@
|
|
|
12
12
|
import { useEffect, useState, type HTMLAttributes } from 'react'
|
|
13
13
|
import { Check, Copy } from 'lucide-react'
|
|
14
14
|
import { PrismLight as SyntaxHighlighter } from 'react-syntax-highlighter'
|
|
15
|
-
|
|
15
|
+
// The `/index.js` is REQUIRED and is not a style preference.
|
|
16
|
+
//
|
|
17
|
+
// `react-syntax-highlighter/dist/esm/styles/prism` is a DIRECTORY. Vite's
|
|
18
|
+
// resolver follows a directory import; **Node's ESM resolver does not**, and
|
|
19
|
+
// `tsup` externalises this specifier verbatim into `dist/index.js`. So the
|
|
20
|
+
// package built green and published, and any consumer loading it under Node ESM
|
|
21
|
+
// — vitest, most obviously — failed at IMPORT, before a single assertion ran.
|
|
22
|
+
//
|
|
23
|
+
// Reported by the studios plane against `@lovett/ui@0.0.7` and reproduced from
|
|
24
|
+
// the registry: two of three suites failed to load, not to assert. A green build
|
|
25
|
+
// and dead tests, with nothing connecting the two facts.
|
|
26
|
+
import { vscDarkPlus, oneLight } from 'react-syntax-highlighter/dist/esm/styles/prism/index.js'
|
|
16
27
|
|
|
17
28
|
import bash from 'react-syntax-highlighter/dist/esm/languages/prism/bash'
|
|
18
29
|
import css from 'react-syntax-highlighter/dist/esm/languages/prism/css'
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// Bridges a conflict between two resolvers, neither of which is wrong.
|
|
2
|
+
//
|
|
3
|
+
// `@types/react-syntax-highlighter` declares the DIRECTORY module
|
|
4
|
+
// `react-syntax-highlighter/dist/esm/styles/prism`. Node's ESM resolver refuses
|
|
5
|
+
// a directory import and needs the explicit `.../prism/index.js`. So the
|
|
6
|
+
// specifier TypeScript can type is the one Node rejects, and the specifier Node
|
|
7
|
+
// accepts is the one TypeScript cannot find — see the note in `code-block.tsx`
|
|
8
|
+
// for what that cost.
|
|
9
|
+
//
|
|
10
|
+
// This declares the file path by RE-EXPORTING the real types from the directory
|
|
11
|
+
// module, so the values stay fully typed. The alternative — a `@ts-expect-error`
|
|
12
|
+
// or an `any` import — would silence the error by discarding `oneLight` and
|
|
13
|
+
// `vscDarkPlus`'s types, which is trading a build failure for a typing hole at
|
|
14
|
+
// the one site that already proved it can ship broken.
|
|
15
|
+
//
|
|
16
|
+
// Removable when upstream's types declare the file path directly.
|
|
17
|
+
declare module 'react-syntax-highlighter/dist/esm/styles/prism/index.js' {
|
|
18
|
+
export * from 'react-syntax-highlighter/dist/esm/styles/prism';
|
|
19
|
+
}
|