Skip to content

Commit

Permalink
node-loader: add support showing messages
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Jul 4, 2024
1 parent 010d095 commit cd2907d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
13 changes: 2 additions & 11 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions packages/node-loader/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import fs from 'node:fs/promises'
import {createFormatAwareProcessors} from '@mdx-js/mdx/internal-create-format-aware-processors'
import {extnamesToRegex} from '@mdx-js/mdx/internal-extnames-to-regex'
import {SourceMapGenerator} from 'source-map'
import {reporter} from 'vfile-reporter'
import {VFile} from 'vfile'
import {development as defaultDevelopment} from '#condition'

Expand Down Expand Up @@ -62,6 +63,11 @@ export function createLoader(options) {
const value = await fs.readFile(url)
const file = await process(new VFile({value, path: url}))

/* c8 ignore next 3 -- hard to test. */
if (file.messages.length > 0) {
console.error(reporter(file))
}

return {
format: 'module',
shortCircuit: true,
Expand Down
1 change: 1 addition & 0 deletions packages/node-loader/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"dependencies": {
"@mdx-js/mdx": "^3.0.0",
"source-map": "^0.7.0",
"vfile-reporter": "^8.0.0",
"vfile": "^6.0.0"
},
"devDependencies": {},
Expand Down

0 comments on commit cd2907d

Please sign in to comment.