mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-09-22 05:40:48 +02:00
Replace browserify/uglify-js with webpack, shrink markdownlint-browser.js (fixes #362).
This commit is contained in:
parent
202b50060b
commit
369b0b5934
10 changed files with 844 additions and 3271 deletions
|
@ -2,5 +2,6 @@ demo/markdown-it.min.js
|
|||
demo/markdownlint-browser.js
|
||||
demo/markdownlint-browser.min.js
|
||||
demo/markdownlint-rule-helpers-browser.js
|
||||
demo/markdownlint-rule-helpers-browser.min.js
|
||||
example/typescript/type-check.js
|
||||
lib-es3/
|
||||
|
|
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -1,7 +1,8 @@
|
|||
coverage
|
||||
demo/markdown-it.min.js
|
||||
demo/markdownlint-browser.min.js
|
||||
demo/markdownlint-rule-helpers-browser.js
|
||||
demo/markdownlint-browser.min.js.LICENSE.txt
|
||||
demo/markdownlint-rule-helpers-browser.*
|
||||
lib-es3
|
||||
node_modules
|
||||
!test/node_modules
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
</div>
|
||||
<script src="markdown-it.min.js"></script>
|
||||
<script src="markdownlint-browser.min.js"></script>
|
||||
<script src="markdownlint-rule-helpers-browser.min.js"></script>
|
||||
<script src="default.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -125,7 +125,8 @@
|
|||
case "#fix":
|
||||
var error = JSON.parse(decodeURIComponent(e.target.target));
|
||||
var errors = [ error ];
|
||||
var fixed = window.helpers.applyFixes(markdown.value, errors);
|
||||
var fixed =
|
||||
window.markdownlintRuleHelpers.applyFixes(markdown.value, errors);
|
||||
markdown.value = fixed;
|
||||
onMarkdownInput();
|
||||
e.preventDefault();
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
/* markdownlint - https://github.com/DavidAnson/markdownlint - @license MIT */
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
"use strict";
|
||||
|
||||
// Alias "markdown-it" (expected) to "markdownit" (exported)
|
||||
module.exports = window.markdownit;
|
||||
if (!module.exports) {
|
||||
console.error("markdown-it must be loaded before markdownlint.");
|
||||
}
|
||||
|
||||
// Stub missing implementation of util.promisify (unused here)
|
||||
// eslint-disable-next-line unicorn/import-style
|
||||
var util = require("util");
|
||||
if (!util.promisify) {
|
||||
util.promisify = function promisify(fn) {
|
||||
return fn;
|
||||
};
|
||||
}
|
File diff suppressed because it is too large
Load diff
67
demo/webpack.config.js
Normal file
67
demo/webpack.config.js
Normal file
|
@ -0,0 +1,67 @@
|
|||
// @ts-check
|
||||
|
||||
"use strict";
|
||||
|
||||
const webpack = require("webpack");
|
||||
|
||||
function config(options) {
|
||||
const { entry, filename, mode, packageJson } = options;
|
||||
const { name, version, homepage, license } = packageJson;
|
||||
return {
|
||||
"devtool": false,
|
||||
"entry": entry,
|
||||
"externals": {
|
||||
"markdown-it": "markdownit"
|
||||
},
|
||||
"mode": mode,
|
||||
"name": name,
|
||||
"output": {
|
||||
"filename": filename,
|
||||
"library": name.replace(/(-\w)/g, (m) => m.slice(1).toUpperCase()),
|
||||
"path": __dirname
|
||||
},
|
||||
"plugins": [
|
||||
new webpack.BannerPlugin({
|
||||
"banner": `${name} ${version} ${homepage} @license ${license}`
|
||||
}),
|
||||
new webpack.DefinePlugin({
|
||||
"process.env.NODE_DEBUG": false
|
||||
})
|
||||
],
|
||||
"resolve": {
|
||||
"fallback": {
|
||||
"fs": false,
|
||||
"os": false,
|
||||
"path": false,
|
||||
"util": false
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = [
|
||||
config({
|
||||
"entry": "../lib-es3/lib/markdownlint.js",
|
||||
"filename": "markdownlint-browser.js",
|
||||
"mode": "development",
|
||||
"packageJson": require("../package.json")
|
||||
}),
|
||||
config({
|
||||
"entry": "../lib-es3/lib/markdownlint.js",
|
||||
"filename": "markdownlint-browser.min.js",
|
||||
"mode": "production",
|
||||
"packageJson": require("../package.json")
|
||||
}),
|
||||
config({
|
||||
"entry": "../lib-es3/helpers/helpers.js",
|
||||
"filename": "markdownlint-rule-helpers-browser.js",
|
||||
"mode": "development",
|
||||
"packageJson": require("../helpers/package.json")
|
||||
}),
|
||||
config({
|
||||
"entry": "../lib-es3/helpers/helpers.js",
|
||||
"filename": "markdownlint-rule-helpers-browser.min.js",
|
||||
"mode": "production",
|
||||
"packageJson": require("../helpers/package.json")
|
||||
})
|
||||
];
|
|
@ -853,7 +853,7 @@ function markdownlint(options, callback) {
|
|||
return lintInput(options, false, callback);
|
||||
}
|
||||
|
||||
const markdownlintPromisify = promisify(markdownlint);
|
||||
const markdownlintPromisify = promisify && promisify(markdownlint);
|
||||
|
||||
/**
|
||||
* Lint specified Markdown files.
|
||||
|
@ -985,7 +985,7 @@ function readConfig(file, parsers, callback) {
|
|||
});
|
||||
}
|
||||
|
||||
const readConfigPromisify = promisify(readConfig);
|
||||
const readConfigPromisify = promisify && promisify(readConfig);
|
||||
|
||||
/**
|
||||
* Read specified configuration file.
|
||||
|
|
11
package.json
11
package.json
|
@ -21,7 +21,7 @@
|
|||
"ci": "npm run test-cover && npm run lint && npm run build-declaration && npm run test-declaration && npm run build-config-schema && git diff --exit-code",
|
||||
"build-config-schema": "node schema/build-config-schema.js",
|
||||
"build-declaration": "tsc --allowJs --declaration --emitDeclarationOnly --resolveJsonModule lib/markdownlint.js && rimraf 'lib/{c,md,r}*.d.ts' 'helpers/*.d.ts'",
|
||||
"build-demo": "cpy node_modules/markdown-it/dist/markdown-it.min.js demo && cd demo && rimraf markdownlint-browser.* && cpy file-header.js . --rename=markdownlint-browser.js && tsc --allowJs --resolveJsonModule --outDir ../lib-es3 ../lib/markdownlint.js && cpy ../helpers/package.json ../lib-es3/helpers && browserify ../lib-es3/lib/markdownlint.js --standalone markdownlint >> markdownlint-browser.js && browserify ../lib-es3/helpers/helpers.js --standalone helpers >> markdownlint-rule-helpers-browser.js && uglifyjs markdownlint-browser.js markdownlint-rule-helpers-browser.js --compress --mangle --comments --output markdownlint-browser.min.js",
|
||||
"build-demo": "cpy node_modules/markdown-it/dist/markdown-it.min.js demo && cd demo && rimraf markdownlint-browser.* && tsc --allowJs --resolveJsonModule --outDir ../lib-es3 ../lib/markdownlint.js && cpy ../helpers/package.json ../lib-es3/helpers && webpack",
|
||||
"build-example": "npm install --no-save --ignore-scripts grunt grunt-cli gulp through2",
|
||||
"example": "cd example && node standalone.js && grunt markdownlint --force && gulp markdownlint",
|
||||
"clone-test-repos": "mkdir test-repos && cd test-repos && git clone https://github.com/eslint/eslint eslint-eslint --depth 1 --no-tags --quiet && git clone https://github.com/mkdocs/mkdocs mkdocs-mkdocs --depth 1 --no-tags --quiet && git clone https://github.com/pi-hole/docs pi-hole-docs --depth 1 --no-tags --quiet",
|
||||
|
@ -37,7 +37,6 @@
|
|||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "~14.14.9",
|
||||
"browserify": "~17.0.0",
|
||||
"c8": "~7.3.5",
|
||||
"cpy-cli": "~3.1.1",
|
||||
"eslint": "~7.14.0",
|
||||
|
@ -58,7 +57,8 @@
|
|||
"toml": "~3.0.0",
|
||||
"tv4": "~1.3.0",
|
||||
"typescript": "~4.1.2",
|
||||
"uglify-js": "~3.12.0"
|
||||
"webpack": "~5.11.1",
|
||||
"webpack-cli": "~4.3.1"
|
||||
},
|
||||
"keywords": [
|
||||
"markdown",
|
||||
|
@ -66,8 +66,5 @@
|
|||
"md",
|
||||
"CommonMark",
|
||||
"markdownlint"
|
||||
],
|
||||
"browser": {
|
||||
"markdown-it": "../demo/markdown-it-stub.js"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue