mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-16 22:10:13 +01:00
Convert markdownlint library to an ECMAScript module, replace markdownlint-micromark with micromark, stop publishing (large) markdownlint-browser.js, see https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c for guidance.
This commit is contained in:
parent
191226f070
commit
1e71f6f44e
140 changed files with 1087 additions and 10428 deletions
97
demo/webpack.config.mjs
Normal file
97
demo/webpack.config.mjs
Normal file
|
|
@ -0,0 +1,97 @@
|
|||
// @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) {
|
||||
const { entry, filename, mode, optimization, packageJson } = options;
|
||||
const { name, version, homepage, license } = packageJson;
|
||||
return {
|
||||
"devtool": false,
|
||||
"entry": entry,
|
||||
"externals": {
|
||||
"markdown-it": "markdownit"
|
||||
},
|
||||
"mode": mode,
|
||||
"module": {
|
||||
"rules": [
|
||||
{
|
||||
"test": /\.[cm]?js$/,
|
||||
"exclude": /node_modules/
|
||||
}
|
||||
]
|
||||
},
|
||||
"name": name,
|
||||
"optimization": optimization,
|
||||
"output": {
|
||||
"filename": filename,
|
||||
"library": {
|
||||
"name": name.replace(/(-\w)/g, (m) => m.slice(1).toUpperCase()),
|
||||
"type": "var"
|
||||
},
|
||||
"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,
|
||||
"util": false,
|
||||
"module": require.resolve("./module-stub.cjs")
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
const modeDevelopment = {
|
||||
"mode": "development"
|
||||
};
|
||||
const modeProduction = {
|
||||
"mode": "production",
|
||||
"optimization": {
|
||||
"minimizer": [
|
||||
new TerserPlugin({
|
||||
"extractComments": false,
|
||||
"terserOptions": {
|
||||
"compress": {
|
||||
"passes": 2
|
||||
}
|
||||
}
|
||||
})
|
||||
]
|
||||
}
|
||||
};
|
||||
const entryLibrary = {
|
||||
"entry": "./browser-exports.mjs",
|
||||
"packageJson": libraryPackageJson
|
||||
};
|
||||
export default [
|
||||
config({
|
||||
...entryLibrary,
|
||||
...modeDevelopment,
|
||||
"filename": "markdownlint-browser.js"
|
||||
}),
|
||||
config({
|
||||
...entryLibrary,
|
||||
...modeProduction,
|
||||
"filename": "markdownlint-browser.min.js"
|
||||
})
|
||||
];
|
||||
Loading…
Add table
Add a link
Reference in a new issue