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
|
@ -1,8 +0,0 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
|
||||
module.exports = {
|
||||
// @ts-ignore
|
||||
"createRequire": () => require
|
||||
};
|
|
@ -1,12 +1,9 @@
|
|||
// @ts-check
|
||||
|
||||
import { createRequire } from "node:module";
|
||||
const require = createRequire(import.meta.url);
|
||||
import webpack from "webpack";
|
||||
import TerserPlugin from "terser-webpack-plugin";
|
||||
import { __dirname, importWithTypeJson } from "../test/esm-helpers.mjs";
|
||||
const libraryPackageJson = await importWithTypeJson(import.meta, "../package.json");
|
||||
const nodeModulePrefixRe = /^node:/u;
|
||||
|
||||
// eslint-disable-next-line jsdoc/require-jsdoc
|
||||
function config(options) {
|
||||
|
@ -19,14 +16,6 @@ function config(options) {
|
|||
"markdown-it": "markdownit"
|
||||
},
|
||||
"mode": mode,
|
||||
"module": {
|
||||
"rules": [
|
||||
{
|
||||
"test": /\.[cm]?js$/,
|
||||
"exclude": /node_modules/
|
||||
}
|
||||
]
|
||||
},
|
||||
"name": name,
|
||||
"optimization": optimization,
|
||||
"output": {
|
||||
|
@ -38,25 +27,10 @@ function config(options) {
|
|||
"path": __dirname(import.meta)
|
||||
},
|
||||
"plugins": [
|
||||
new webpack.NormalModuleReplacementPlugin(
|
||||
nodeModulePrefixRe,
|
||||
(resource) => {
|
||||
const module = resource.request.replace(nodeModulePrefixRe, "");
|
||||
resource.request = module;
|
||||
}
|
||||
),
|
||||
new webpack.BannerPlugin({
|
||||
"banner": `${name} ${version} ${homepage} @license ${license}`
|
||||
})
|
||||
],
|
||||
"resolve": {
|
||||
"fallback": {
|
||||
"fs": false,
|
||||
"os": false,
|
||||
"path": false,
|
||||
"module": require.resolve("./module-stub.cjs")
|
||||
}
|
||||
},
|
||||
"ignoreWarnings": [
|
||||
{
|
||||
"message": /(asset|entrypoint) size limit/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue