@mdx-js/runtime
Advanced tools
Comparing version 0.16.0 to 0.16.1
{ | ||
"name": "@mdx-js/runtime", | ||
"version": "0.16.1", | ||
"description": "Parse and render MDX in a runtime environment", | ||
"version": "0.16.0", | ||
"license": "MIT", | ||
"author": "John Otander", | ||
"keywords": [ | ||
"mdx", | ||
"markdown", | ||
"react", | ||
"jsx", | ||
"remark", | ||
"mdxast" | ||
], | ||
"homepage": "https://mdxjs.com", | ||
"repository": "mdx-js/mdx", | ||
"bugs": "https://github.com/mdx-js/mdx/issues", | ||
"author": "John Otander <johnotander@gmail.com> (http://johnotander.com)", | ||
"contributors": [ | ||
"John Otander <johnotander@gmail.com> (http://johnotander.com)", | ||
"Tim Neutkens <tim@zeit.co>", | ||
"Matija Marohnić <matija.marohnic@gmail.com>", | ||
"Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)" | ||
], | ||
"main": "dist", | ||
"scripts": { | ||
"test": "jest", | ||
"prepare": "babel src -d dist" | ||
"test": "jest" | ||
}, | ||
"keywords": [ | ||
"mdx", | ||
"react" | ||
"files": [ | ||
"dist/", | ||
"src/" | ||
], | ||
"dependencies": { | ||
"@mdx-js/mdx": "^0.16.1", | ||
"@mdx-js/tag": "^0.16.1", | ||
"buble": "^0.19.3" | ||
}, | ||
"devDependencies": { | ||
@@ -28,11 +49,6 @@ "babel-cli": "^6.26.0", | ||
}, | ||
"dependencies": { | ||
"@mdx-js/mdx": "^0.16.0", | ||
"@mdx-js/tag": "^0.16.0", | ||
"buble": "^0.19.3" | ||
}, | ||
"jest": { | ||
"testEnvironment": "node" | ||
}, | ||
"gitHead": "2c1c8676327f97b060283c5a9047574d8ada11ec" | ||
"gitHead": "b69654652e22043592da6db45bc8306b05c783ad" | ||
} |
@@ -1,15 +0,21 @@ | ||
# Runtime MDX | ||
# `@mdx-js/runtime` | ||
Parse and render MDX in a runtime environment | ||
[![Build Status][build-badge]][build] | ||
[![lerna][lerna-badge]][lerna] | ||
[![Join the community on Spectrum][spectrum-badge]][spectrum] | ||
## :warning: Warning | ||
Parse and render [MDX][] in a runtime environment. | ||
This is not the preferred way to use MDX since it introduces a substantial amount of overhead and dramatically increases bundle sizes. | ||
It should also not be used with user input that isn't sandboxed. | ||
> :warning: **warning**: this is not the preferred way to use MDX since it | ||
> introduces a substantial amount of overhead and dramatically increases | ||
> bundle sizes. | ||
> It should also not be used with user input that isn’t sandboxed. | ||
## Installation | ||
[npm][]: | ||
```sh | ||
npm i -S @mdx-js/runtime | ||
``` | ||
npm install --save @mdx-js/runtime | ||
``` | ||
@@ -33,4 +39,40 @@ ## Usage | ||
## Related | ||
## Contribute | ||
- [MDX Docs](https://github.com/mdx-js/mdx) | ||
See [`contributing.md` in `mdx-js/mdx`][contributing] for ways to get started. | ||
This organisation has a [Code of Conduct][coc]. | ||
By interacting with this repository, organisation, or community you agree to | ||
abide by its terms. | ||
## License | ||
[MIT][] © [Compositor][] and [ZEIT][] | ||
<!-- Definitions --> | ||
[build]: https://travis-ci.org/mdx-js/mdx | ||
[build-badge]: https://travis-ci.org/mdx-js/mdx.svg?branch=master | ||
[lerna]: https://lernajs.io/ | ||
[lerna-badge]: https://img.shields.io/badge/maintained%20with-lerna-cc00ff.svg | ||
[spectrum]: https://spectrum.chat/mdx | ||
[spectrum-badge]: https://withspectrum.github.io/badge/badge.svg | ||
[contributing]: https://github.com/mdx-js/mdx/blob/master/contributing.md | ||
[coc]: https://github.com/mdx-js/mdx/blob/master/code-of-conduct.md | ||
[mit]: license | ||
[compositor]: https://compositor.io | ||
[zeit]: https://zeit.co | ||
[mdx]: https://github.com/mdx-js/mdx | ||
[npm]: https://docs.npmjs.com/cli/install |
import React from 'react' | ||
import { transform } from 'buble' | ||
import {transform} from 'buble' | ||
import mdx from '@mdx-js/mdx' | ||
import { MDXTag } from '@mdx-js/tag' | ||
import {MDXTag} from '@mdx-js/tag' | ||
export default ({ scope = {}, components = {}, mdPlugins = [], hastPlugins = [], children, ...props }) => { | ||
export default ({ | ||
scope = {}, | ||
components = {}, | ||
mdPlugins = [], | ||
hastPlugins = [], | ||
children, | ||
...props | ||
}) => { | ||
const fullScope = { | ||
@@ -14,15 +21,25 @@ MDXTag, | ||
const jsx = mdx.sync(children, { | ||
mdPlugins, | ||
hastPlugins, | ||
skipExport: true, | ||
}).trim() | ||
const jsx = mdx | ||
.sync(children, { | ||
mdPlugins, | ||
hastPlugins, | ||
skipExport: true | ||
}) | ||
.trim() | ||
const { code } = transform(jsx) | ||
const {code} = transform(jsx) | ||
const keys = Object.keys(fullScope) | ||
const values = keys.map(key => fullScope[key]) | ||
const fn = new Function('_fn', 'React', ...keys, `return ${code}`) | ||
// eslint-disable-next-line no-new-func | ||
const fn = new Function( | ||
'_fn', | ||
'React', | ||
...keys, | ||
`${code} | ||
return React.createElement(MDXContent);` | ||
) | ||
return fn({}, React, ...values) | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
7268
1
78
5
81
Updated@mdx-js/mdx@^0.16.1
Updated@mdx-js/tag@^0.16.1