-
-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support loose (invalid) JavaScript #267
Comments
Maybe https://github.com/acornjs/acorn/tree/master/acorn-loose/ would be of interest? |
the micromark utils do a low an acorn instance to be passed, so that might also indeed allow the loose version? Worth to check, but might not be strong enough |
I think import {Parser} from 'acorn'
import {LooseParser} from 'acorn-loose'
import jsx from 'acorn-jsx'
import remarkMdx from 'remark-mdx'
import remarkParse from 'remark-parse'
import {unified} from 'unified'
// const parser = Parser.extend(jsx())
const parser = LooseParser.extend(jsx())
const processor = unified().use(remarkParse).use(remarkMdx, {acorn: parser})
const mdx = `
import { Button } from './button.js'
Click the button
<Button>Click me!</Button>
`
console.dir(processor.parse(mdx)) Also worth considering is |
Initial checklist
Problem
While typing, code is often invalid. Various IntelliSense features typically work on invalid code. TypeScript supports this, but acorn does not. Currently invalid syntax is caught, but IntelliSense doesn’t work. We need to find a way to deal with invalid syntax.
Solution
Needs investigation
Alternatives
🤷
The text was updated successfully, but these errors were encountered: