Skip to content

Commit 3a16449

Browse files
committed
Fix
1 parent 8f971c5 commit 3a16449

4 files changed

Lines changed: 9 additions & 7 deletions

File tree

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ tsconfig.json
1616
# end managed by sku
1717

1818
dist-storybook/
19-
src/private/Prism.cjs
19+
src/private/Prism.ts

.prettierignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ tsconfig.json
1212
# end managed by sku
1313

1414
dist-storybook/
15-
src/Private/Prism.cjs
15+
src/Private/Prism.ts
1616
lib/

prism.mjs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ import fs from 'node:fs/promises';
22
import path from 'node:path';
33
import { fileURLToPath } from 'node:url';
44

5-
const header = `const { Prism, themes } = require('prism-react-renderer'); /* eslint-disable */`;
6-
const footer = `module.exports = { Prism, themes };`;
5+
const header = `// @ts-nocheck
6+
import { Prism, themes } from 'prism-react-renderer';
7+
const prismInstance = Prism; /* eslint-disable */`;
8+
const footer = `export { prismInstance as Prism, themes };`;
79

810
// Also see src/private/prismUtils.ts for language names
911
const languages = [
@@ -27,13 +29,13 @@ const languageDefinitions = await Promise.all(
2729
),
2830
'utf8',
2931
);
30-
return `// Language: ${language}\n\n${definition}\n\n`;
32+
return `// Language: ${language}\n\n(function(Prism) {\n${definition}\n})(prismInstance);\n\n`;
3133
}),
3234
);
3335

3436
const content = [header, ...languageDefinitions, footer].join('\n');
3537

3638
await fs.writeFile(
37-
path.join(import.meta.dirname, 'src/private/Prism.cjs'),
39+
path.join(import.meta.dirname, 'src/private/Prism.ts'),
3840
content,
3941
);

src/components/CodeContainer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Box, Stack } from 'braid-design-system';
22
import { Highlight, type Token } from 'prism-react-renderer';
33

4-
import { Prism } from '../private/Prism.cjs';
4+
import { Prism } from '../private/Prism';
55
import { codeThemes } from '../private/codeThemes';
66

77
import { useCodeTheme } from './CodeThemeProvider';

0 commit comments

Comments
 (0)