Socket
Socket
Sign inDemoInstall

remark-mdx

Package Overview
Dependencies
Maintainers
1
Versions
126
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

remark-mdx - npm Package Compare versions

Comparing version 0.18.2 to 0.20.3

35

extract-imports-and-exports.js

@@ -52,6 +52,39 @@ const {transformSync} = require('@babel/core')

return sortedNodes.map(({start: _, ...node}, i) => {
const allNodes = sortedNodes.map(({start: _, ...node}, i) => {
const value = values[i]
return {...node, value}
})
// Group adjacent nodes of the same type so that they can be combined
// into a single node later, this also ensures that order is preserved
let currType = allNodes[0].type
const groupedNodes = allNodes.reduce(
(acc, curr) => {
// Default export nodes shouldn't be grouped with other exports
// because they're handled specially by MDX
if (curr.default) {
currType = 'default'
return [...acc, [curr]]
}
if (curr.type === currType) {
const lastNodes = acc.pop()
return [...acc, [...lastNodes, curr]]
}
currType = curr.type
return [...acc, [curr]]
},
[[]]
)
// Combine adjacent nodes into a single node
return groupedNodes
.filter(a => a.length)
.reduce((acc, curr) => {
const node = curr.reduce((acc, curr) => ({
...acc,
value: acc.value + curr.value
}))
return [...acc, node]
}, [])
}

2

index.js

@@ -98,3 +98,3 @@ const isAlphabetical = require('is-alphabetical')

function stringifyEsSyntax(node) {
return node.value
return node.value.trim()
}

@@ -101,0 +101,0 @@

{
"name": "remark-mdx",
"version": "0.18.2",
"version": "0.20.3",
"description": "Support import, export, and JSX in markdown",

@@ -49,3 +49,3 @@ "license": "MIT",

},
"gitHead": "5938d62f831141a98eff52ddafca7d302ce9b78a"
"gitHead": "f7a232c19a6f35f347a4bfbceecde6ef362d36ba"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc