Skip to content

Commit

Permalink
Move the gather exports babel plugin to its own package (gatsbyjs#121)
Browse files Browse the repository at this point in the history
* new package

* added tests

* use new package
  • Loading branch information
avigoldman authored and johno committed Jul 17, 2019
1 parent ce2a97f commit 96b5e27
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 39 deletions.
2 changes: 1 addition & 1 deletion packages/gatsby-plugin-mdx/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
},
"dependencies": {
"@babel/plugin-proposal-object-rest-spread": "^7.0.0-beta.54",
"babel-plugin-gather-exports": "0.0.1",
"babel-plugin-pluck-exports": "0.0.1",
"babel-plugin-pluck-imports": "0.0.1",
"debug": "^3.1.0",
"escape-string-regexp": "^1.0.5",
"fs-extra": "^7.0.0",
"gray-matter": "^4.0.1",
"htmltojsx": "^0.3.0",
"json5": "^1.0.1",
"lodash": "^4.17.10",
"mdast-util-to-string": "^1.0.4",
"mdast-util-toc": "^2.0.1",
Expand Down
34 changes: 0 additions & 34 deletions packages/gatsby-plugin-mdx/utils/babel-plugin-gather-exports.js

This file was deleted.

8 changes: 4 additions & 4 deletions packages/gatsby-plugin-mdx/utils/extract-exports.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
const babel = require("@babel/core");
const babelReact = require("@babel/preset-react");
const objRestSpread = require("@babel/plugin-proposal-object-rest-spread");
const gatherExportsGenerator = require("./babel-plugin-gather-exports");
const BabelPluginGatherExports = require("babel-plugin-gather-exports");

// grab all the export values
module.exports = code => {
const gatherExports = gatherExportsGenerator();
const instance = new BabelPluginGatherExports();
babel.transform(code, {
presets: [babelReact],
plugins: [gatherExports, objRestSpread]
plugins: [instance.plugin, objRestSpread]
});

const exportedVariables = gatherExports.results();
const exportedVariables = instance.state.exports;

// grab the frontmatter
const {
Expand Down

0 comments on commit 96b5e27

Please sign in to comment.