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 2828 "default" : " ./dist/components.cjs.js"
2929 }
3030 },
31+ "browser" : {
32+ "./dist/index.esm.js" : " ./dist/index.browser.mjs"
33+ },
3134 "scripts" : {
3235 "dev" : " next" ,
3336 "build" : " rollup -c rollup.config.js" ,
5053 "devDependencies" : {
5154 "@mdx-js/mdx" : " ^2.0.0" ,
5255 "@rollup/plugin-json" : " ^4.1.0" ,
56+ "@rollup/plugin-replace" : " ^4.0.0" ,
5357 "@types/diff" : " ^5.0.2" ,
5458 "@types/node" : " ^17.0.21" ,
5559 "@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"
77import path from "path"
88import json from "@rollup/plugin-json"
99import del from "rollup-plugin-delete"
10+ import replace from "@rollup/plugin-replace"
11+ // import { terser } from "rollup-plugin-terser"
1012
1113export default function makeConfig ( commandOptions ) {
1214 return [
@@ -46,6 +48,35 @@ export default function makeConfig(commandOptions) {
4648 } ) ,
4749 ] ,
4850 } ,
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+ } ,
4980 {
5081 input : `src/components.tsx` ,
5182 output : [
Original file line number Diff line number Diff line change @@ -33,6 +33,7 @@ export async function highlight({
3333 }
3434 }
3535 if ( highlighterPromise === null ) {
36+ // TODO add version
3637 setCDN ( "https://unpkg.com/shiki/" )
3738 highlighterPromise = getHighlighter ( {
3839 theme : theme as IShikiTheme ,
You can’t perform that action at this time.
0 commit comments