Skip to content

Reworks Twoslasher instance creation#103

Merged
Adammatthiesen merged 12 commits into
mainfrom
adam/cleanup-and-fixes
Mar 14, 2026
Merged

Reworks Twoslasher instance creation#103
Adammatthiesen merged 12 commits into
mainfrom
adam/cleanup-and-fixes

Conversation

@Adammatthiesen

@Adammatthiesen Adammatthiesen commented Mar 11, 2026

Copy link
Copy Markdown
Member

This pull request addresses several improvements and bug fixes for the expressive-code-twoslash package, focusing on Twoslasher instance creation, dependency configuration, and memory management documentation. The most significant changes involve refactoring Twoslasher instance handling for better caching and reliability, updating dependency bundling configurations, and enhancing documentation for users encountering memory issues.

Twoslasher instance creation and caching improvements

  • Refactored Twoslasher instance creation to use async thunks, enabling proper caching and lazy loading of Twoslash, Vue, and ESLint instances via dedicated helper functions (getBaseTwoslasher, getVueTwoslasher, getEslintTwoslasher). This fixes issues with Twoslasher instance creation and ensures robust error handling for missing dependencies. [1] [2] [3] [4] [5] [6]
  • Updated the plugin to use a singleton TwoslasherMap for storing Twoslasher functions, improving instance reuse and performance. [1] [2]

Dependency bundling configuration

  • Changed tsdown.config.ts files in @ec-ts/twoslash and css-js-gen packages to use deps.onlyAllowBundle for specifying bundled dependencies, replacing the previous inlineOnly approach. [1] [2]

Documentation and usability enhancements

  • Added a section to the installation.mdx documentation explaining potential memory issues when using Astro, including recommendations for adjusting the lib option and increasing Node.js memory limits.

Plugin initialization and resource management

  • Introduced singletons for tsLibDirectory, includesMap, and the Expressive Code Engine instance to ensure consistent resource usage across plugin invocations. [1] [2] [3]
  • Simplified plugin code by removing redundant cache and file system map creation in the Twoslash preprocessing logic. [1] [2]

Type improvements

  • Added and exported the new TwoslasherThunk type for improved type safety and clarity in Twoslasher function signatures. [1] [2]

These changes collectively improve reliability, maintainability, and user experience for the expressive-code-twoslash package.

@changeset-bot

changeset-bot Bot commented Mar 11, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 621ffaf

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
expressive-code-twoslash Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@htg-1-studiocms-cloud

htg-1-studiocms-cloud Bot commented Mar 11, 2026

Copy link
Copy Markdown

Dokploy Preview Deployment

Name Status Preview Updated (UTC)
Expressive-Code-Twoslash Docs ✅ Done Preview URL 2026-03-13T06:37:38.531Z

@pkg-pr-new

pkg-pr-new Bot commented Mar 11, 2026

Copy link
Copy Markdown
npm i https://pkg.pr.new/expressive-code-twoslash@103

commit: f1d9e32

@apollo-git-bot

apollo-git-bot Bot commented Mar 11, 2026

Copy link
Copy Markdown
Contributor

Allure Report Summary

Name Duration Stats New Flaky Retry Report
css-js-gen Tests 23ms Passed tests 37 94 0 0
@ec-ts/twoslash Tests 29s 828ms Passed tests 29 94 0 0
@ec-ts/twoslash-vue Tests 6s 12ms Passed tests 7 94 0 0
@ec-ts/vfs Tests 9s 281ms Passed tests 21 94 0 0

@github-actions github-actions Bot added twoslash expressive-code-twoslash docs labels Mar 13, 2026
@Adammatthiesen Adammatthiesen changed the title [WIP] Reworks Twoslasher instance creation Reworks Twoslasher instance creation Mar 13, 2026
@Adammatthiesen Adammatthiesen marked this pull request as ready for review March 13, 2026 07:18
@Adammatthiesen Adammatthiesen requested a review from a team as a code owner March 13, 2026 07:18
@Adammatthiesen Adammatthiesen merged commit 3ddf10f into main Mar 14, 2026
10 checks passed
@Adammatthiesen Adammatthiesen deleted the adam/cleanup-and-fixes branch March 14, 2026 02:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Chore: Tweak tsdown configs for changes in 0.21.0 ESLint dependency is now required Running large docs causing memory overload in latest version

3 participants