Skip to content

Commit

Permalink
Update dependencies
Browse files Browse the repository at this point in the history
This updates all unified packages to their latest versions.
This largely does not affect users as all unified collective packages
are now ESM and typed, and this project already was.

Two potential changes:

* VFile’s now use `value` instead of `contents`:
  See: https://github.com/vfile/vfile/releases/tag/5.0.0
* When using footnotes, those now come with more semantic markup
  See: syntax-tree/mdast-util-to-hast@0260f76

Closes GH-76.
  • Loading branch information
wooorm committed Aug 12, 2021
1 parent 6585f00 commit a33caec
Show file tree
Hide file tree
Showing 14 changed files with 93 additions and 106 deletions.
2 changes: 1 addition & 1 deletion lib/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* @typedef {BaseProcessorOptions & PluginOptions} ProcessorOptions
*/

import unified from 'unified'
import {unified} from 'unified'
import remarkParse from 'remark-parse'
import remarkRehype from 'remark-rehype'
import {recmaJsxBuild} from './plugin/recma-jsx-build.js'
Expand Down
16 changes: 8 additions & 8 deletions lib/integration/esbuild.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @typedef {import('esbuild').OnLoadResult} OnLoadResult
* @typedef {import('esbuild').OnResolveArgs} OnResolveArgs
* @typedef {import('esbuild').Message} Message
* @typedef {import('vfile').VFileContents} VFileContents
* @typedef {import('vfile').VFileValue} VFileValue
* @typedef {import('vfile-message').VFileMessage} VFileMessage
* @typedef {import('unist').Point} Point
* @typedef {import('../core.js').ProcessorOptions} ProcessorOptions
Expand All @@ -15,7 +15,7 @@

import {promises as fs} from 'fs'
import got from 'got'
import vfile from 'vfile'
import {VFile} from 'vfile'
import {createFormatAwareProcessors} from '../util/create-format-aware-processors.js'
import {extnamesToRegex} from '../util/extnames-to-regex.js'

Expand Down Expand Up @@ -119,15 +119,15 @@ export function esbuild(options = {}) {
: await fs.readFile(data.path)
)

let file = vfile({contents: doc, path: data.path})
let file = new VFile({value: doc, path: data.path})
/** @type {VFileMessage[]} */
let messages = []
/** @type {Message[]} */
const errors = []
/** @type {Message[]} */
const warnings = []
/** @type {VFileContents} */
let contents
/** @type {VFileValue} */
let value
/** @type {VFileMessage} */
let message
/** @type {Point} */
Expand All @@ -149,7 +149,7 @@ export function esbuild(options = {}) {

try {
file = await process(file)
contents = file.contents
value = file.value
messages = file.messages
} catch (error) {
error.fatal = true
Expand All @@ -160,7 +160,7 @@ export function esbuild(options = {}) {
/** @type {{start?: Point, end?: Point}} */
// Non-message errors stored on `vfile.messages`.
/* c8 ignore next */
const location = message.location || {}
const location = message.position || {}
start = location.start
end = location.end
length = 0
Expand Down Expand Up @@ -205,7 +205,7 @@ export function esbuild(options = {}) {

// V8 on Erbium.
/* c8 ignore next 2 */
return {contents, errors, warnings, resolveDir: p.cwd()}
return {contents: value, errors, warnings, resolveDir: p.cwd()}
}
}
}
11 changes: 5 additions & 6 deletions lib/integration/node.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
/**
* @typedef {import('vfile').VFile} VFile
* @typedef {import('../compile.js').CompileOptions} CompileOptions
*/

import path from 'path'
import vfile from 'vfile'
import {VFile} from 'vfile'
import {createFormatAwareProcessors} from '../util/create-format-aware-processors.js'

/**
Expand All @@ -29,16 +28,16 @@ export function createLoader(options) {
}

/**
* @param {string} contents
* @param {string} value
* @param {{url: string, [x: string]: unknown}} context
* @param {Function} defaultTransformSource
*/
async function transformSource(contents, context, defaultTransformSource) {
async function transformSource(value, context, defaultTransformSource) {
if (!extnames.includes(path.extname(context.url))) {
return defaultTransformSource(contents, context, defaultTransformSource)
return defaultTransformSource(value, context, defaultTransformSource)
}

const file = await process(vfile({contents, path: context.url}))
const file = await process(new VFile({value, path: context.url}))
// V8 on Erbium.
/* c8 ignore next 2 */
return {source: String(file).replace(/\/jsx-runtime(?=["'])/g, '$&.js')}
Expand Down
2 changes: 1 addition & 1 deletion lib/integration/require.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function load(filePath, callback) {
// However, setting a timeout, results in `deasync` waiting for it, even
// in cases where the import is already settled!
// That’s why this number is pretty low.
setTimeout(timeout, 64)
setTimeout(timeout, 192)

function timeout() {
done(
Expand Down
10 changes: 5 additions & 5 deletions lib/integration/rollup.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* @typedef {CompileOptions & RollupPluginOptions} ProcessorAndRollupOptions
*/

import vfile from 'vfile'
import {VFile} from 'vfile'
import {createFilter} from '@rollup/pluginutils'
import {createFormatAwareProcessors} from '../util/create-format-aware-processors.js'

Expand All @@ -27,13 +27,13 @@ export function rollup(options = {}) {

return {
name: 'xdm',
// @ts-ignore `map` is added if a `SourceMapGenerator` is passed in.
async transform(contents, path) {
const file = vfile({contents, path})
async transform(value, path) {
const file = new VFile({value, path})

if (filter(file.path) && extnames.includes(file.extname)) {
const compiled = await process(file)
return {code: String(compiled.contents), map: compiled.map}
// @ts-ignore `map` is added if a `SourceMapGenerator` is passed in.
return {code: String(compiled.value), map: compiled.map}
// V8 on Erbium.
/* c8 ignore next 2 */
}
Expand Down
4 changes: 2 additions & 2 deletions lib/integration/webpack.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ export function loader(value, callback) {
compile(
// TS through JSDoc can’t handle `this`
// type-coverage:ignore-next-line
{contents: value, path: this.resourcePath},
{value, path: this.resourcePath},
// TS through JSDoc can’t handle `this`
// type-coverage:ignore-next-line
{...getOptions(this)}
).then((file) => {
// @ts-ignore conflict between UInt8Array and Buffer is expected, and a tradeoff made in vfile typings to avoid `@types/node` being required
callback(null, file.contents, file.map)
callback(null, file.value, file.map)
return file
}, callback)
}
1 change: 1 addition & 0 deletions lib/plugin/recma-stringify.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ export function recmaStringify(options) {
})

if (sourceMap) {
// @ts-ignore custom source map.
file.map = sourceMap.toJSON()
}

Expand Down
23 changes: 7 additions & 16 deletions lib/plugin/remark-mdx.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,24 @@
/**
* @typedef {import('unified').Processor} Processor
*
* @typedef {import('acorn').Parser} AcornParser
* @typedef {import('acorn').Options} AcornOptions
*
* @typedef {Object} MdxOptions
* @property {AcornParser} [acorn]
* @property {AcornOptions} [acornOptions]
* @property {boolean} [addResult=true]
* @typedef {import('micromark-extension-mdxjs').Options} Options
*/

import syntaxMdxjs from 'micromark-extension-mdxjs'
import mdx from 'mdast-util-mdx'

const {fromMarkdown, toMarkdown} = mdx
import {mdxjs} from 'micromark-extension-mdxjs'
import {mdxFromMarkdown, mdxToMarkdown} from 'mdast-util-mdx'

/**
* Add the micromark and mdast extensions for MDX.js (JS aware MDX).
*
* @this {Processor}
* @param {MdxOptions} [options]
* @param {Options} [options]
* @return {void}
*/
export function remarkMdx(options) {
const data = this.data()

add('micromarkExtensions', syntaxMdxjs(options))
add('fromMarkdownExtensions', fromMarkdown)
add('toMarkdownExtensions', toMarkdown)
add('micromarkExtensions', mdxjs(options))
add('fromMarkdownExtensions', mdxFromMarkdown)
add('toMarkdownExtensions', mdxToMarkdown)

/**
* @param {string} field
Expand Down
5 changes: 2 additions & 3 deletions lib/util/resolve-file-and-options.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
/**
* @typedef {import('vfile').VFileCompatible} VFileCompatible
* @typedef {import('vfile').VFile} VFile
* @typedef {import('../core.js').ProcessorOptions} ProcessorOptions
* @typedef {import('../compile.js').CompileOptions} CompileOptions
*/

import vfile from 'vfile'
import {VFile} from 'vfile'
import {md} from './extnames.js'

/**
Expand All @@ -17,7 +16,7 @@ import {md} from './extnames.js'
* @returns {{file: VFile, options: ProcessorOptions}}
*/
export function resolveFileAndOptions(vfileCompatible, options) {
const file = vfile(vfileCompatible)
const file = new VFile(vfileCompatible)
const {format, ...rest} = options || {}
return {
file,
Expand Down
30 changes: 15 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,16 @@
"hast-util-to-estree": "^2.0.0",
"loader-utils": "^2.0.0",
"markdown-extensions": "^1.0.0",
"mdast-util-mdx": "^0.1.0",
"micromark-extension-mdxjs": "^0.3.0",
"mdast-util-mdx": "^1.0.0",
"micromark-extension-mdxjs": "^1.0.0",
"periscopic": "^3.0.0",
"remark-parse": "^9.0.0",
"remark-rehype": "^8.1.0",
"unified": "^9.0.0",
"remark-parse": "^10.0.0",
"remark-rehype": "^9.0.0",
"unified": "^10.0.0",
"unist-util-position-from-estree": "^1.0.0",
"unist-util-stringify-position": "^3.0.0",
"unist-util-visit": "^3.0.0",
"vfile": "^4.0.0"
"unist-util-visit": "^4.0.0",
"vfile": "^5.0.0"
},
"optionalDependencies": {
"deasync": "^0.1.0"
Expand Down Expand Up @@ -86,14 +86,14 @@
"prettier": "^2.0.0",
"react": "^17.0.0",
"react-dom": "^17.0.0",
"rehype-katex": "^5.0.0",
"rehype-raw": "^5.1.0",
"remark-cli": "^9.0.0",
"remark-footnotes": "^3.0.0",
"remark-frontmatter": "^3.0.0",
"remark-gfm": "^1.0.0",
"remark-math": "^4.0.0",
"remark-preset-wooorm": "^8.0.0",
"rehype-katex": "^6.0.0",
"rehype-raw": "^6.0.0",
"remark-cli": "^10.0.0",
"remark-footnotes": "^4.0.0",
"remark-frontmatter": "^4.0.0",
"remark-gfm": "^2.0.0",
"remark-math": "^5.0.0",
"remark-preset-wooorm": "^9.0.0",
"rimraf": "^3.0.0",
"rollup": "^2.0.0",
"source-map": "^0.7.0",
Expand Down
Loading

0 comments on commit a33caec

Please sign in to comment.