mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-09-22 05:40:48 +02:00
Add support for "browser" condition (e.g., as used by Webpack) by stubbing-away Node imports (fixes #1441).
This commit is contained in:
parent
65eeb4c8d9
commit
a009407088
6 changed files with 45 additions and 32 deletions
22
lib/node-imports-browser.mjs
Normal file
22
lib/node-imports-browser.mjs
Normal file
|
@ -0,0 +1,22 @@
|
|||
// @ts-check
|
||||
|
||||
const getError = () => new Error("Node APIs are not available in browser context.");
|
||||
const throwForSync = () => {
|
||||
throw getError();
|
||||
};
|
||||
|
||||
export const fs = {
|
||||
"access": (path, callback) => callback(getError()),
|
||||
"accessSync": throwForSync,
|
||||
"readFile": (path, options, callback) => callback(getError()),
|
||||
"readFileSync": throwForSync
|
||||
};
|
||||
|
||||
export { default as module } from "./node-imports-browser-module.cjs";
|
||||
|
||||
export const os = {};
|
||||
|
||||
export const path = {
|
||||
"dirname": throwForSync,
|
||||
"resolve": throwForSync
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue