@lovett/ui 0.0.7 → 0.0.9
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 +14 -14
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/code-block.tsx +26 -15
- package/src/react-syntax-highlighter-prism.d.ts +34 -0
package/package.json
CHANGED
package/src/code-block.tsx
CHANGED
|
@@ -12,21 +12,32 @@
|
|
|
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
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
import
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
import
|
|
27
|
-
|
|
28
|
-
import
|
|
29
|
-
import
|
|
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'
|
|
27
|
+
|
|
28
|
+
import bash from 'react-syntax-highlighter/dist/esm/languages/prism/bash.js'
|
|
29
|
+
import css from 'react-syntax-highlighter/dist/esm/languages/prism/css.js'
|
|
30
|
+
import diff from 'react-syntax-highlighter/dist/esm/languages/prism/diff.js'
|
|
31
|
+
import javascript from 'react-syntax-highlighter/dist/esm/languages/prism/javascript.js'
|
|
32
|
+
import json from 'react-syntax-highlighter/dist/esm/languages/prism/json.js'
|
|
33
|
+
import jsx from 'react-syntax-highlighter/dist/esm/languages/prism/jsx.js'
|
|
34
|
+
import markdown from 'react-syntax-highlighter/dist/esm/languages/prism/markdown.js'
|
|
35
|
+
import markup from 'react-syntax-highlighter/dist/esm/languages/prism/markup.js'
|
|
36
|
+
import python from 'react-syntax-highlighter/dist/esm/languages/prism/python.js'
|
|
37
|
+
import sql from 'react-syntax-highlighter/dist/esm/languages/prism/sql.js'
|
|
38
|
+
import tsx from 'react-syntax-highlighter/dist/esm/languages/prism/tsx.js'
|
|
39
|
+
import typescript from 'react-syntax-highlighter/dist/esm/languages/prism/typescript.js'
|
|
40
|
+
import yaml from 'react-syntax-highlighter/dist/esm/languages/prism/yaml.js'
|
|
30
41
|
|
|
31
42
|
import { cn } from './lib/utils'
|
|
32
43
|
|
|
@@ -0,0 +1,34 @@
|
|
|
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
|
+
// ── AND THE SAME APPLIES TO THE 13 LANGUAGE IMPORTS ─────────────────────────
|
|
17
|
+
// Fixing only the styles directory shipped `0.0.8`, which failed on
|
|
18
|
+
// `.../languages/prism/bash` — a FILE imported without its extension, which
|
|
19
|
+
// Node's ESM resolver also refuses. The directory import was merely the FIRST
|
|
20
|
+
// failure, not the defect. Caught by loading the published artifact under Node
|
|
21
|
+
// rather than trusting the local build, which is the whole of PN-015.
|
|
22
|
+
//
|
|
23
|
+
// Removable when upstream's types declare the file paths directly.
|
|
24
|
+
declare module 'react-syntax-highlighter/dist/esm/styles/prism/index.js' {
|
|
25
|
+
export * from 'react-syntax-highlighter/dist/esm/styles/prism';
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
declare module 'react-syntax-highlighter/dist/esm/languages/prism/*.js' {
|
|
29
|
+
// Upstream types these as `any`-shaped syntax definitions passed straight to
|
|
30
|
+
// `registerLanguage`; the wildcard keeps that contract rather than inventing
|
|
31
|
+
// a stricter one this package cannot verify.
|
|
32
|
+
const language: unknown;
|
|
33
|
+
export default language;
|
|
34
|
+
}
|