Recover from incomplete ESM using acorn-loose#528
Recover from incomplete ESM using acorn-loose#528jp-knj wants to merge 2 commits intomdx-js:mainfrom
Conversation
|
|
Hi! It seems you removed the template which we require. Here are our templates (pick the one you want to use and click *raw* to see its source): I won’t send you any further notifications about this, but I’ll keep on updating this comment, and hide it when done! Thanks, |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #528 +/- ##
==========================================
+ Coverage 92.43% 92.47% +0.04%
==========================================
Files 13 13
Lines 1982 1994 +12
==========================================
+ Hits 1832 1844 +12
Misses 150 150 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Initial checklist
Description of changes
Closes #267
Problem
When users type incomplete ESM (e.g.
export const x =orimport { } from) in an MDX file, the strict acorn parser fails and the language service loses all IntelliSense — completions, diagnostics, and hover information disappear for the entire file until the syntax is corrected.This is a poor editing experience because ESM is always incomplete while the user is actively typing it.
Approach
Introduce a "hybrid acorn" strategy that uses
acorn-loosefor ESM parsing and the strictacornparser (with JSX) for expressionsLong-term perspective
This is a minimal, low-risk first step. Possible future improvements include working with
micromark-extension-mdxjs-esmto support pluggable error recovery, reducing the need for patching at the language-service level.