Skip to content

perf(bundle): isolate MDX parser from the default Markdown entry - #149

Merged
luojiyin1987 merged 1 commit into
masterfrom
perf/isolate-mdx-entry
Oct 25, 2026
Merged

luojiyin1987 merged 1 commit into
masterfrom
perf/isolate-mdx-entry

Conversation

@luojiyin1987

Copy link
Copy Markdown
Contributor

Experiment

Move synchronous MDX parsing to @lint-md/parser/mdx.
Keep Markdown parsing in the default entry.
Build separate CommonJS, ESM, and type bundles.

Measurements

The baseline is commit 22b995f.
Node 24.15.0 ran nine fresh processes per case with about 16 KiB of input.
Values are medians.

Metric Baseline Split entry
Default CJS bundle 484,137 B 194,515 B
Default CJS gzip 143,556 B 59,141 B
Default CJS load 14.44 ms 7.85 ms
Default CJS load heap 2.06 MB 1.00 MB
Default ESM load 16.17 ms 9.05 ms
Cold MDX CJS load 14.61 ms 14.21 ms
MDX CJS load after default 0.08 ms 12.42 ms
MDX CJS load heap after default 0.01 MB 1.93 MB

The four split bundles total 1,356,173 B.
The two baseline bundles total 967,924 B.
The split adds 388,249 B of uncompressed JavaScript files.

The benchmark commands and full results are in docs/mdx-entry-experiment.md.

Tradeoffs

Default imports load less code and use less heap.
MDX imports gain no clear cold load improvement.
Existing MDX imports need a new path.
Both entries contain separate error class instances.
This change needs a major release or a migration plan before adoption.

Verification

  • pnpm run build
  • pnpm run lint
  • pnpm run test (2024 tests pass)
  • Package tests cover both entry paths and both module formats.
  • The default esbuild input graph contains no MDX parser modules.

No sensitive data was changed or shared.

Move synchronous MDX parsing to the mdx subpath.

Build separate runtime and type bundles for both entries.

Measure bundle size, cold load, heap use, and MDX load cost.

Keep this change experimental because MDX imports must change.
@luojiyin1987
luojiyin1987 marked this pull request as ready for review October 25, 2026 23:13
@luojiyin1987
luojiyin1987 merged commit 55ef687 into master Oct 25, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant