Skip to content

Commit cd2907d

Browse files
committedJul 4, 2024
node-loader: add support showing messages
1 parent 010d095 commit cd2907d

File tree

3 files changed

+9
-11
lines changed

3 files changed

+9
-11
lines changed
 

‎package-lock.json

+2-11
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎packages/node-loader/lib/index.js

+6
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import fs from 'node:fs/promises'
2020
import {createFormatAwareProcessors} from '@mdx-js/mdx/internal-create-format-aware-processors'
2121
import {extnamesToRegex} from '@mdx-js/mdx/internal-extnames-to-regex'
2222
import {SourceMapGenerator} from 'source-map'
23+
import {reporter} from 'vfile-reporter'
2324
import {VFile} from 'vfile'
2425
import {development as defaultDevelopment} from '#condition'
2526

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

66+
/* c8 ignore next 3 -- hard to test. */
67+
if (file.messages.length > 0) {
68+
console.error(reporter(file))
69+
}
70+
6571
return {
6672
format: 'module',
6773
shortCircuit: true,

‎packages/node-loader/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
"dependencies": {
4646
"@mdx-js/mdx": "^3.0.0",
4747
"source-map": "^0.7.0",
48+
"vfile-reporter": "^8.0.0",
4849
"vfile": "^6.0.0"
4950
},
5051
"devDependencies": {},

0 commit comments

Comments
 (0)
Please sign in to comment.