LumisDocs
Migrate

JavaScript custom languages

Update integrations that supplied their own parser and queries through the JavaScript-only language API.

The JavaScript-only API for combining a custom parser with caller-supplied queries was removed. If your integration used it, a language definition cannot be carried over unchanged.

Use a published language package

Install the language's package and import the language it exports. The package supplies the parser and its matching queries together:

npm install @lumis-sh/wasm-json
import { createHighlighter } from '@lumis-sh/lumis';
import json from '@lumis-sh/wasm-json';

const highlighter = await createHighlighter({ languages: [json] });

Use the language catalog to find a supported language, and see Where parsers come from.

languages.withWasm() still attaches a package to a language, for code that imports the package as a namespace. It does not accept replacement queries or turn an arbitrary grammar into a Lumis language.

Unpublished grammars

There is no supported replacement for supplying a grammar and queries that Lumis does not publish. If your application needs that capability, changing the byte resolver is not enough to upgrade it. A cross-runtime API with a package-shaped input is planned, but is not available.

On this page