Skip to content
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

Replace Babel w/ estree #1399

Merged
merged 1 commit into from
Dec 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 0 additions & 57 deletions packages/babel-plugin-apply-mdx-type-props/index.js

This file was deleted.

37 changes: 2 additions & 35 deletions packages/babel-plugin-apply-mdx-type-props/package.json
Original file line number Diff line number Diff line change
@@ -1,37 +1,4 @@
{
"name": "babel-plugin-apply-mdx-type-prop",
"version": "2.0.0-next.8",
"description": "Apply the MDX type prop used in the MDX pragma",
"repository": "mdx-js/mdx",
"homepage": "https://mdxjs.com",
"bugs": "https://github.com/mdx-js/mdx/issues",
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
},
"author": "John Otander <[email protected]> (http://johnotander.com)",
"contributors": [
"JounQin <[email protected]> (https://www.1stg.me)"
],
"license": "MIT",
"files": [
"index.js"
],
"keywords": [
"mdx",
"markdown",
"react",
"jsx",
"remark",
"babel"
],
"dependencies": {
"@babel/helper-plugin-utils": "^7.10.4"
},
"scripts": {
"test-api": "jest test",
"test-coverage": "jest test --coverage",
"test": "yarn test-coverage"
},
"gitHead": "bf7deab69996449cb99c2217dff75e65855eb2c1"
"private": true,
"name": "babel-plugin-apply-mdx-type-prop"
}
117 changes: 4 additions & 113 deletions packages/babel-plugin-apply-mdx-type-props/readme.md
Original file line number Diff line number Diff line change
@@ -1,117 +1,8 @@
# babel-plugin-apply-mdx-type-prop

[![Build][build-badge]][build]
[![Downloads][downloads-badge]][downloads]
[![Sponsors][sponsors-badge]][opencollective]
[![Backers][backers-badge]][opencollective]
[![Chat][chat-badge]][chat]
Deprecated!

Create a Babel plugin to both add `mdxType` props to components and extract all
those found named.
Used by [MDX][].
Created for but no longer used in [MDX](https://mdxjs.com).

## Install

[npm][]:

```sh
npm install babel-plugin-apply-mdx-type-prop
```

[yarn][]:

```sh
yarn add babel-plugin-apply-mdx-type-prop
```

## Use

Say we have the following code in `input.jsx`:

```jsx
export const Foo = () => (
<div>
<Button />
</div>
)

export default () => (
<>
<h1>Hello!</h1>
<TomatoBox />
</>
)
```

And our script, `example.js`:

```js
const fs = require('fs')
const babel = require('@babel/core')
const BabelPluginApplyMdxTypeProp = require('babel-plugin-apply-mdx-type-prop')

// Construct one for every file you’re processing.
const applyMdxTypeProp = new BabelPluginApplyMdxTypeProp()

const result = babel.transformSync(fs.readFileSync('./input.jsx'), {
configFile: false,
plugins: ['@babel/plugin-syntax-jsx', applyMdxTypeProp.plugin]
})

console.log(result.code)
console.log(applyMdxTypeProp.state.names)
```

Now, running `node example` yields:

```jsx
export const Foo = () => (
<div>
<Button mdxType="Button" />
</div>
)

export default () => (
<>
<h1>Hello!</h1>
<TomatoBox mdxType="TomatoBox" />
</>
)
```

```js
['Button', 'TomatoBox']
```

## API

### `BabelPluginApplyMdxTypeProp()`

Constructor for an instance to transform and capture MDX types.

Note that this isn’t a Babel plugin but _creates_ one.

###### Returns

Instance with:

* `plugin` — Plugin for Babel
* `state` — Object with a `names` field listing all (including duplicates)
found types

## License

MIT

[build-badge]: https://github.com/mdx-js/mdx/workflows/CI/badge.svg
[build]: https://github.com/mdx-js/mdx/actions
[downloads-badge]: https://img.shields.io/npm/dm/babel-plugin-apply-mdx-type-prop.svg
[downloads]: https://www.npmjs.com/package/babel-plugin-apply-mdx-type-prop
[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg
[backers-badge]: https://opencollective.com/unified/backers/badge.svg
[opencollective]: https://opencollective.com/unified
[chat-badge]: https://img.shields.io/badge/chat-discussions-success.svg
[chat]: https://github.com/mdx-js/mdx/discussions
[mdx]: https://mdxjs.com
[npm]: https://docs.npmjs.com/cli/install
[yarn]: https://yarnpkg.com/cli/add
This used to add `mdxType`, `parentName` props to JSX elements,
and track which components were used.
56 changes: 0 additions & 56 deletions packages/babel-plugin-apply-mdx-type-props/test/index.test.js

This file was deleted.

71 changes: 0 additions & 71 deletions packages/babel-plugin-extract-export-names/index.js

This file was deleted.

34 changes: 2 additions & 32 deletions packages/babel-plugin-extract-export-names/package.json
Original file line number Diff line number Diff line change
@@ -1,34 +1,4 @@
{
"name": "babel-plugin-extract-export-names",
"version": "2.0.0-next.8",
"description": "Extract export names",
"repository": "mdx-js/mdx",
"homepage": "https://mdxjs.com",
"bugs": "https://github.com/mdx-js/mdx/issues",
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/unified"
},
"author": "John Otander <[email protected]> (http://johnotander.com)",
"license": "MIT",
"files": [
"index.js"
],
"keywords": [
"mdx",
"markdown",
"react",
"jsx",
"remark",
"babel"
],
"dependencies": {
"@babel/helper-plugin-utils": "^7.10.4"
},
"scripts": {
"test-api": "jest test",
"test-coverage": "jest test --coverage",
"test": "yarn test-coverage"
},
"gitHead": "bf7deab69996449cb99c2217dff75e65855eb2c1"
"private": true,
"name": "babel-plugin-extract-export-names"
}
Loading