wooorm / xdm

Just a *really* good MDX compiler. No runtime. With esbuild, Rollup, and webpack plugins
http://wooorm.com/xdm/
MIT License
595 stars 18 forks source link

Fix `MDXContent` to allow missing props #83

Closed mike-mcdonald closed 3 years ago

mike-mcdonald commented 3 years ago

Adjusts MDXContent function output to allow undefined props as a parameter without throwing a TypeError.

Closes #82

wooorm commented 3 years ago

Sweet, thanks for working on this!

I think it would be better to solve it in the argument list: MDXContent(props = {}). Reasoning is that it’s documented that props is an object in one example of the readme: https://github.com/wooorm/xdm#mdx-content.

Also, could you update the example in the readme following “The actual output of running node example.js is:”?

There are also two errors in the tests on CI. the babel one looks a bit flakey (I’ll check if that’s still the case), but the error message might need to be changed?

wooorm commented 3 years ago

ps. run npm test locally to test your changes! And you can use ASTExplorer to figure out what the AST is for certain JS code

wooorm commented 3 years ago

Rebasing your PR against main should solve the weird babel error

wooorm commented 3 years ago

The other error was related due to a change in Node 16.9. Updates the tests to fix that as well.

mike-mcdonald commented 3 years ago

@wooorm Sounds like a plan. I'll adjust the fix to provide a default value for the props parameter and work on the test errors.

mike-mcdonald commented 3 years ago

@wooorm I've updated my branch with your changes to main and am able to run npm run test locally with no failures now!

wooorm commented 3 years ago

Thanks, released!