@mdx-js/mdx
Advanced tools
Comparing version 2.0.0-next.1 to 2.0.0-next.3
@@ -9,2 +9,3 @@ const {transformSync} = require('@babel/core') | ||
const BabelPluginExtractImportNames = require('babel-plugin-extract-import-names') | ||
const BabelPluginExtractExportNames = require('babel-plugin-extract-export-names') | ||
@@ -83,9 +84,2 @@ function toJSX(node, parentNode = {}, options = {}) { | ||
const exportNames = groups.export | ||
.map(node => | ||
node.value.match(/^export\s*(var|const|let|class|function)?\s*(\w+)/) | ||
) | ||
.map(match => (Array.isArray(match) ? match[2] : null)) | ||
.filter(Boolean) | ||
const importStatements = groups.import | ||
@@ -99,10 +93,2 @@ .map(childNode => toJSX(childNode, node)) | ||
let layoutProps = 'const layoutProps = {' | ||
if (exportNames.length !== 0) { | ||
layoutProps += '\n ' + exportNames.join(',\n ') + '\n' | ||
} | ||
layoutProps += '};' | ||
const mdxLayout = `const MDXLayout = ${layout ? layout : '"wrapper"'}` | ||
@@ -126,3 +112,5 @@ | ||
const babelPluginExtractImportNamesInstance = new BabelPluginExtractImportNames() | ||
transformSync(importStatements, { | ||
const babelPluginExtractExportNamesInstance = new BabelPluginExtractExportNames() | ||
const importsAndExports = [importStatements, exportStatements].join('\n') | ||
transformSync(importsAndExports, { | ||
configFile: false, | ||
@@ -133,6 +121,8 @@ babelrc: false, | ||
require('@babel/plugin-syntax-object-rest-spread'), | ||
babelPluginExtractImportNamesInstance.plugin | ||
babelPluginExtractImportNamesInstance.plugin, | ||
babelPluginExtractExportNamesInstance.plugin | ||
] | ||
}) | ||
const importNames = babelPluginExtractImportNamesInstance.state.names | ||
const exportNames = babelPluginExtractExportNamesInstance.state.names | ||
@@ -162,2 +152,10 @@ const babelPluginApplyMdxPropInstance = new BabelPluginApplyMdxProp() | ||
let layoutProps = 'const layoutProps = {' | ||
if (exportNames.length !== 0) { | ||
layoutProps += '\n ' + exportNames.join(',\n ') + '\n' | ||
} | ||
layoutProps += '};' | ||
const allJsxNames = [ | ||
@@ -164,0 +162,0 @@ ...babelPluginApplyMdxPropInstance.state.names, |
{ | ||
"name": "@mdx-js/mdx", | ||
"version": "2.0.0-next.1", | ||
"version": "2.0.0-next.3", | ||
"description": "Parse MDX and transpile to JSX", | ||
@@ -42,24 +42,25 @@ "repository": "mdx-js/mdx", | ||
"dependencies": { | ||
"@babel/core": "7.9.6", | ||
"@babel/plugin-syntax-jsx": "7.8.3", | ||
"@babel/core": "7.10.5", | ||
"@babel/plugin-syntax-jsx": "7.10.4", | ||
"@babel/plugin-syntax-object-rest-spread": "7.8.3", | ||
"@mdx-js/util": "^2.0.0-next.1", | ||
"babel-plugin-apply-mdx-type-prop": "^2.0.0-next.1", | ||
"babel-plugin-extract-import-names": "^2.0.0-next.1", | ||
"@mdx-js/util": "^2.0.0-next.3", | ||
"babel-plugin-apply-mdx-type-prop": "^2.0.0-next.3", | ||
"babel-plugin-extract-export-names": "^2.0.0-next.3", | ||
"babel-plugin-extract-import-names": "^2.0.0-next.3", | ||
"camelcase-css": "2.0.1", | ||
"detab": "2.0.3", | ||
"hast-to-hyperscript": "8.1.0", | ||
"hast-util-raw": "5.0.2", | ||
"hast-to-hyperscript": "9.0.0", | ||
"hast-util-raw": "6.0.0", | ||
"lodash.uniq": "4.5.0", | ||
"mdast-util-to-hast": "9.1.0", | ||
"remark-footnotes": "1.0.0", | ||
"remark-mdx": "^2.0.0-next.1", | ||
"remark-mdxjs": "^2.0.0-next.1", | ||
"remark-parse": "8.0.1", | ||
"remark-mdx": "^2.0.0-next.3", | ||
"remark-mdxjs": "^2.0.0-next.3", | ||
"remark-parse": "8.0.2", | ||
"remark-squeeze-paragraphs": "4.0.0", | ||
"unified": "9.0.0", | ||
"unist-builder": "2.0.3", | ||
"unist-util-visit": "2.0.2" | ||
"unist-util-visit": "2.0.3" | ||
}, | ||
"gitHead": "166fd9d72a05bb6f09bcb1b1dadb150f4c72fbaa" | ||
"gitHead": "d0059c8cf5147281c096e28be81d3914ad2e14e8" | ||
} |
@@ -55,4 +55,2 @@ # `@mdx-js/mdx` | ||
<!-- Definitions --> | ||
[build]: https://travis-ci.com/mdx-js/mdx | ||
@@ -59,0 +57,0 @@ [build-badge]: https://travis-ci.com/mdx-js/mdx.svg?branch=master |
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
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
19882
21
482
70
+ Added@types/parse5@5.0.3(transitive)
+ Addedbabel-plugin-extract-export-names@2.0.0-next.8(transitive)
+ Addedhast-to-hyperscript@9.0.0(transitive)
+ Addedhast-util-from-parse5@6.0.1(transitive)
+ Addedhast-util-raw@6.0.0(transitive)
+ Addedhast-util-to-parse5@6.0.0(transitive)
+ Addedhastscript@6.0.0(transitive)
+ Addedparse5@6.0.1(transitive)
+ Addedremark-parse@8.0.2(transitive)
+ Addedunist-util-visit@2.0.3(transitive)
- Removed@babel/core@7.9.6(transitive)
- Removed@babel/plugin-syntax-jsx@7.8.3(transitive)
- Removedhast-to-hyperscript@7.0.48.1.0(transitive)
- Removedhast-util-from-parse5@5.0.3(transitive)
- Removedhast-util-raw@5.0.2(transitive)
- Removedhast-util-to-parse5@5.1.2(transitive)
- Removedhastscript@5.1.2(transitive)
- Removedparse5@5.1.1(transitive)
- Removedremark-parse@8.0.1(transitive)
- Removedstyle-to-object@0.2.3(transitive)
- Removedunist-util-is@3.0.0(transitive)
- Removedunist-util-visit@2.0.2(transitive)
Updated@babel/core@7.10.5
Updated@mdx-js/util@^2.0.0-next.3
Updatedhast-to-hyperscript@9.0.0
Updatedhast-util-raw@6.0.0
Updatedremark-mdx@^2.0.0-next.3
Updatedremark-mdxjs@^2.0.0-next.3
Updatedremark-parse@8.0.2
Updatedunist-util-visit@2.0.3