Skip to content

Commit

Permalink
docs: prefer subexport imports for the future
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Sep 16, 2024
1 parent a560bcc commit f137c45
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
8 changes: 5 additions & 3 deletions docs/guide/regex-engines.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ Shiki come with two built-in engines:
This is the default engine that uses the compiled Oniguruma WebAssembly. The most accurate and robust engine.

```ts
import { createHighlighter, createWasmOnigEngine } from 'shiki'
import { createHighlighter } from 'shiki'
import { createWasmOnigEngine } from 'shiki/engine/oniguruma'

const shiki = await createShiki({
themes: ['nord'],
Expand All @@ -44,8 +45,9 @@ This feature is experimental and may change without following semver.

This experimental engine uses JavaScript's native RegExp. As TextMate grammars' regular expressions are in Oniguruma flavor that might contains syntaxes that are not supported by JavaScript's RegExp, we use [`oniguruma-to-js`](https://github.com/antfu/oniguruma-to-js) to lowering the syntaxes and try to make them compatible with JavaScript's RegExp.

```ts {3,8}
import { createHighlighter, createJavaScriptRegexEngine } from 'shiki'
```ts {2,4,9}
import { createHighlighter } from 'shiki'
import { createJavaScriptRegexEngine } from 'shiki/engine/javascript'

const jsEngine = createJavaScriptRegexEngine()

Expand Down
6 changes: 4 additions & 2 deletions docs/guide/sync-usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ The `await createHighlighter()` and `highlighter.codeToHtml()` are already the e
In some extreme cases that you need to run Shiki completely synchronously, since v1.16, we provide a synchronous version of the core API. You can use `createHighlighterCoreSync` to create a highlighter instance synchronously.

```ts
import { createHighlighterCoreSync, createJavaScriptRegexEngine } from 'shiki/core'
import { createHighlighterCoreSync } from 'shiki/core'
import { createJavaScriptRegexEngine } from 'shiki/engine/javascript'
import js from 'shiki/langs/javascript.mjs'
import nord from 'shiki/themes/nord.mjs'

Expand All @@ -23,7 +24,8 @@ When doing so, it requires all `themes` and `langs` to be provide as plain objec
The [Oniguruma Engine](/guide/regex-engines#oniguruma-engine) can only be created asynchronously, so you need to resolve the engine promise before creating the sync highlighter.

```ts
import { createHighlighterCoreSync, createWasmOnigEngine } from 'shiki/core'
import { createHighlighterCoreSync } from 'shiki/core'
import { createWasmOnigEngine } from 'shiki/engine/oniguruma'
import js from 'shiki/langs/javascript.mjs'
import nord from 'shiki/themes/nord.mjs'

Expand Down
2 changes: 1 addition & 1 deletion packages/engine-javascript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"bugs": "https://github.com/shikijs/shiki/issues",
"keywords": [
"shiki",
"@shikijs/transformers"
"shiki-engine"
],
"sideEffects": false,
"exports": {
Expand Down
6 changes: 4 additions & 2 deletions packages/engine-oniguruma/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@shikijs/engine-oniguruma",
"type": "module",
"version": "1.17.6",
"description": "Engine for Shiki using JavaScript's native RegExp",
"description": "Engine for Shiki using Oniguruma RegExp engine in WebAssembly",
"author": "Anthony Fu <[email protected]>",
"license": "MIT",
"homepage": "https://github.com/shikijs/shiki#readme",
Expand All @@ -13,7 +13,9 @@
},
"bugs": "https://github.com/shikijs/shiki/issues",
"keywords": [
"shiki"
"shiki",
"shiki-engine",
"oniguruma"
],
"sideEffects": false,
"exports": {
Expand Down

0 comments on commit f137c45

Please sign in to comment.