File tree Expand file tree Collapse file tree 4 files changed +83
-483
lines changed Expand file tree Collapse file tree 4 files changed +83
-483
lines changed Original file line number Diff line number Diff line change 28
28
"default" : " ./dist/components.cjs.js"
29
29
}
30
30
},
31
+ "browser" : {
32
+ "./dist/index.esm.js" : " ./dist/index.browser.mjs"
33
+ },
31
34
"scripts" : {
32
35
"dev" : " next" ,
33
36
"build" : " rollup -c rollup.config.js" ,
50
53
"devDependencies" : {
51
54
"@mdx-js/mdx" : " ^2.0.0" ,
52
55
"@rollup/plugin-json" : " ^4.1.0" ,
56
+ "@rollup/plugin-replace" : " ^4.0.0" ,
53
57
"@types/diff" : " ^5.0.2" ,
54
58
"@types/node" : " ^17.0.21" ,
55
59
"@types/node-fetch" : " ^2.6.1" ,
Original file line number Diff line number Diff line change @@ -7,6 +7,8 @@ import typescript from "rollup-plugin-typescript2"
7
7
import path from "path"
8
8
import json from "@rollup/plugin-json"
9
9
import del from "rollup-plugin-delete"
10
+ import replace from "@rollup/plugin-replace"
11
+ // import { terser } from "rollup-plugin-terser"
10
12
11
13
export default function makeConfig ( commandOptions ) {
12
14
return [
@@ -46,6 +48,35 @@ export default function makeConfig(commandOptions) {
46
48
} ) ,
47
49
] ,
48
50
} ,
51
+ // for the browser esm we need to replace shiki with shiki/dist/shiki.browser.mjs
52
+ // https://github.com/shikijs/shiki/issues/131#issuecomment-1094281851
53
+ {
54
+ input : `src/index.tsx` ,
55
+ output : [
56
+ {
57
+ file : `./dist/index.browser.mjs` ,
58
+ format : "es" ,
59
+ } ,
60
+ ] ,
61
+ // external: ["react"],
62
+ plugins : [
63
+ replace ( {
64
+ delimiters : [ "" , "" ] ,
65
+ values : {
66
+ '"shiki"' : JSON . stringify (
67
+ "shiki/dist/index.browser.mjs"
68
+ ) ,
69
+ } ,
70
+ } ) ,
71
+ json ( { compact : true } ) ,
72
+ typescript ( {
73
+ tsconfigOverride : {
74
+ compilerOptions : { jsx : "react" } ,
75
+ } ,
76
+ } ) ,
77
+ // terser(),
78
+ ] ,
79
+ } ,
49
80
{
50
81
input : `src/components.tsx` ,
51
82
output : [
Original file line number Diff line number Diff line change @@ -33,6 +33,7 @@ export async function highlight({
33
33
}
34
34
}
35
35
if ( highlighterPromise === null ) {
36
+ // TODO add version
36
37
setCDN ( "https://unpkg.com/shiki/" )
37
38
highlighterPromise = getHighlighter ( {
38
39
theme : theme as IShikiTheme ,
You can’t perform that action at this time.
0 commit comments