Registry / devops / typstx

typstx

JSON →
library0.0.1-beta.1jsnpmunverified

A pre-release (v0.0.1-beta.1) Typst MDX compiler that transforms Typst markup into JSX, integrating with rehype and the MDX ecosystem. It allows using Typst syntax alongside JSX components in MDX documents, with a compiler that can be used programmatically. Not yet stable; APIs may change. Differentiated from @mdx-js/mdx by supporting Typst instead of Markdown.

npm install typstx
INSTALL
IMPORT
SIG · TYPSTX
T
typstx
devopsjavascriptv0.0.1-beta.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

compile
import { compile } from 'typstx'
const { compile } = require('typstx')
ESM-only package; requires Node.js 16+
compileSync
import { compileSync } from 'typstx'
Synchronous variant; useful for server-side rendering without await
default
import typstx from 'typstx'
import { default as typstx } from 'typstx'
No default export exported; do not use default import

Compiles a Typst file to JSX using the asynchronous compile function, demonstrating basic usage.

import fs from 'node:fs/promises'; import { compile } from 'typstx'; const file = await fs.readFile('example.typ'); const compiled = await compile(file); console.log(String(compiled)); // Outputs: compiled JSX code
Debug
Known issues
deprecatedtypstx versions prior to 1.0.0 are unstable and may undergo breaking changes.
fix
Lock version to 0.0.1-beta.1 and expect future updates to break compatibility.
affects: <1.0.0
gotchaPackage is ESM-only. CommonJS require() will fail.
fix
Use import syntax or switch to Node >=16
affects: >=0.0.0
gotchaNo default export. Import named exports only.
fix
Use named imports like import { compile } from 'typstx'
affects: >=0.0.0
breakingExpected but undocumented: compile returns a VFile object, not a string. Call String() to get code.
fix
Use String(result) or result.toString()
affects: >=0.0.0
Errors
Common errors & fixes
TypeError: typstx__WEBPACK_IMPORTED_MODULE_0__.compile is not a function
Attempting to use default import instead of named import.
fix
Change import to import { compile } from 'typstx'
Error [ERR_REQUIRE_ESM]: require() of ES Module /path/node_modules/typstx/index.js from /path/script.js not supported.
Using CommonJS require() with ESM-only package.
fix
Convert to ES module (type: module in package.json) or use dynamic import.
Cannot find module 'typstx' or its corresponding type declarations.
Package has no TypeScript type declarations yet (v0.0.1-beta.1).
fix
Add declare module 'typstx'; in a .d.ts file or use @ts-ignore.
Upgrade
Version history
0.0.1-beta.1latest on npm
Audit
Dependencies
@mdx-js/mdxrequiredCore MDX compiler for parsing and transformation, typstx builds on top of it
rehypeoptionalNeeded for HTML processing; typstx likely uses rehype plugins
Agent activity
8 hits · last 30 days
node
8
Resources
packagetypstx
typstx — npm install typstx · libregistry