Previously, React or other JSX runtimes threw rather hard to read errors
when a component was undefined (because it wasn’t imported, passed, or
provided), essentially only pointing to *something* missing.
Now we throw proper errors when a component is missing at runtime,
including what exact component (or object) is undefined.
In addition, this adds a `development` option, which defaults to
`false` but can be configured explicitly or turned on with
`NODE_ENV=development`.
When it’s `true`, the exact place that references the missing component
or object, and which file did that, is included in the error message.
Related-to: mdx-js/mdx#1775.
Backports: wooorm/xdm@62e6f30.
`@mdx-js/mdx` can now evaluate MDX with any runtime, supporting async plugins,
and returning exported values.
This also removes `dtslint` from dev-dependencies.
* Import xdm’s core into `@mdx-js/mdx`
* Tons of fixes and updates and a couiple of changes that will be
tested and documented later
* Use ESM
* Add JSDoc based types
* Use ESM
* Add JSDoc based types (and improve the types a bunch)
* Rewrite to use modern Vue features such as reactive provide/inject
and fragments
* Remove `mdx` export, which is no longer needed
* Use `xdm` for a second
* Use ESM
* Add JSDoc based types (and improve the types a bunch)
* Mark `MDXContext` and `withMDXComponents` exports as deprecated
(they still work)
* Remove `mdx` export, which is no longer needed
* Use `xdm` for a second
* Use ESM (with CJS wrapper, which is a requirement for webpack currently)
* Add JSDoc based types
* Use webpack 5
* Add preact, vue tests, which it now supports
* Switch to xdm for second — will switch back to `@mdx-js/mdx` when that’s migrated
* yarn is having problems hoisting dependencies
* workspaces are built into npm now
* GHA + npm have some fancy caching mechanisms
Reviewed-by: Christian Murphy <christian.murphy.42@gmail.com>
Related-to: GH-1015.
* uses xdm for now, will switch to mdx-js/mdx when it has the features
* rsc is the future
* extremely optimized implementation, rich metadata, sitemap, rss feed
* improved playground(s)
* no framework, which makes sure we don’t favor one company over another
* currently a lot of new direct dependencies and custom code, which will
presumably become less so when RSC hits mainstream as either someone
else will build stuff that does things like this, or perhaps I will
externalize it.
Create React App is the most looked at resource by users here on GitHub.
But it’s suggesting an old, unmaintained, and buggy way to use MDX.
This instead updates the guide to use our maintained projects, without
having to eject from CRA.
As CRA itself is an ever-changing “init” tool, which can support MDX by
following a couple steps, I don’t think it’s wise to have an example in
the project: we want folks to do `npx create-react-app ...`, not clone
our custom example.
Not having CRA checked in also makes for a faster `yarn install`.
Perhaps developing our own [CRA
template](https://create-react-app.dev/docs/custom-templates) might be
nice for the future, but for now I’ve kept it at an up to date and
working guide.
Related to GH-1015.
Related to GH-1388.
Closes GH-365.
Closes GH-589.
Closes GH-1422.
Reviewed-by: Christian Murphy <christian.murphy.42@gmail.com>
* Update `react`, `react-dom`
* Clean Next, Razzle, Vue examples
* Update parcel example, parcel plugin, run tests
* Prefer `.mdx` extension over `.md`
* This does not yet touch CRA
* It’s impossible to get Gatsby working in our workspace (they fork MDX but resolve from their dependency on old MDX)
* I can’t get webpack 5 working either
Related to GH-1292.
Closes GH-1415.
Reviewed-by: Christian Murphy <christian.murphy.42@gmail.com>
This updates the dependencies and dev-dependencies in `packages/`.
Unfortunately, either updating to webpack 5 or updating to react 17 crash the
webpack loader with a react error, with an [invalid hook call
warning](https://reactjs.org/warnings/invalid-hook-call-warning.html) for
`useMDXComponents`:
<dafdf6d70a/packages/react/src/context.js (L15)>
Which might have to do with the magic of shortcodes (#1385), or something else,
I have no clue.
Furthermore, this loosens package dependencies instead of locking them,
which relates to GH-865, GH-1015, and GH-1267.
It was a long and divided discussion before and the reason for changing now is:
While the package currently doesn’t break easily (it was mentioned that unlocking
packages might cause that), we are currently *locked* on security vulnerabilities.
We’re not getting any patches, and MDX isn’t released that frequently or
maintained that actively, so MDX users are stuck.
If folks want to lock: npm and yarn have package locks.
Closes GH-1267.
Closes GH-1375.
Closes GH-1392.
* Update readmes
* Fix code style
* Add 100% coverage to renderers, babel plugins, loaders, runtime
* Add todos inline for potentially broken things
* Fix Vue to have tests, support properties, support Vue components
* Soft deprecate `@mdx-js/util`, `@mdx-js/test-util`,
`babel-plugin-html-attributes-to-jsx`: their contents weren’t used or not
reused
* Set up tests in each package, to allow for different test methods (e.g.,
vue, remark-mdx)
* Stop locking dev-dependencies
* Move several dev-dependencies from the root `package.json` to the places
that depend on them
* Remove unused dev-dependencies
* Remove unused `yarn.lock`s in non-root
* Use `microbundle` for preact, react, and vue
* Fix installing, building, formatting, and testing
* Fix actions
Closes GH-1338.
Reviewed-by: Christian Murphy <christian.murphy.42@gmail.com>
This sets us up to modernize all of our builds by implementing microbundle on the preact package. This produces a commonjs build that is left as main because that's what people currently expect, an es build that gets used by webpack, etc under the module key, and a true es modern build that will get used conditionally by node v14 native esm when `import` is used. When `require` is used in v14, the commonjs build gets used.
* Improve export name extraction
Many different types of export syntax wasn't supported,
primarily destructuring for objects and arrays. This adds
export extraction to the import name extraction step so
we can more accurately determine what shortcodes to
generate.
* Place gatsby-plugin-mdx in the root for now, seems to not be resolving properly
* Fix linting
* Make null handling more clear
* Fix handling of null specifiers
* Move dep to proper place
* Move `remark-mdx*` packages to `remark-mdxjs`
* Rename
* Add `remark-mdx`
* Add tests
* Ignore `remark-mdx`
* Remove husky for now
* done
* Update comment syntax in the docs
* Add back all file extensions for eslint
* Remove comments for now and eslint-mdx temporarily
* Remove comments for now, add redirect to mdx-provider in docs
* Missed a merge conflict
* Fix eslint
Co-authored-by: John Otander <johnotander@gmail.com>