@mdx-js/mdx: compact output for recmaStringify
See original GitHub issueInitial checklist
- I read the support docs
- I read the contributing guide
- I agree to follow the code of conduct
- I searched issues and couldn’t find anything (or linked relevant results below)
Problem
Out of the box, astring
generates code with proper indentation and line breaks. This seems unnecessary for MDX specifically, as the output of the compiler does not need to be human readable in most cases.
Solution
It looks like we might be able to support a more compact output using a few astring.generate
options, specifically indent
and lineEnd
(ref).
Looking at the internal recma-stringify
plugin:
const result = generate(tree, {
generator,
+ indent: '',
+ lineEnd: ' ',
comments: true,
sourceMap
})
This would result in a more compact output from MDX. We could also put this behind a flag (compact
?) if we don’t want it to be default. I’d be happy to open a PR for this if we’re open to it!
(I’m not sure if this would result in broken output, it might require further testing)
Alternatives
Consumers can try to strip out some of this after the fact, but doing it during the stringify step seems the most reliable.
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (4 by maintainers)
Top GitHub Comments
If minification or smaller output is of concern: issues & PRs to continue discussing this are welcome!
Makes sense, thanks for the insight! I’ll close this out.