diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5f5f875..0e878e3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -76,7 +76,7 @@ jobs: - name: Install markdownlint-cli2 dependencies locally run: sudo npm install --no-package-lock --production - name: Lint with formatters - run: node ./markdownlint-cli2 CONTRIBUTING.md README.md + run: node ./markdownlint-cli2.mjs CONTRIBUTING.md README.md lint-dockerfile: runs-on: ubuntu-latest diff --git a/.gitignore b/.gitignore index f09431b..85f9fcd 100644 --- a/.gitignore +++ b/.gitignore @@ -4,5 +4,5 @@ npm-debug.log !test/customRules/node_modules !test/markdownItPlugins/module/node_modules !test/outputFormatters-module/node_modules -webworker/markdownlint-cli2-webworker.js -webworker/setImmediate.js +webworker/markdownlint-cli2-webworker.cjs +webworker/setImmediate.cjs diff --git a/eslint.config.mjs b/eslint.config.mjs index 1bc8300..56b2be9 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -21,8 +21,8 @@ export default [ { "ignores": [ "test/*/**", - "webworker/markdownlint-cli2-webworker.js", - "webworker/setImmediate.js" + "webworker/markdownlint-cli2-webworker.cjs", + "webworker/setImmediate.cjs" ] }, { @@ -66,11 +66,7 @@ export default [ { "files": [ "**/*-formatter-*.js", - "webworker/*.cjs", - "webworker/*.js" - ], - "ignores": [ - "webworker/fs-virtual.js" + "webworker/*.cjs" ], "languageOptions": { "sourceType": "commonjs", diff --git a/markdownlint-cli2.mjs b/markdownlint-cli2.mjs index 0804adf..6ef2c20 100755 --- a/markdownlint-cli2.mjs +++ b/markdownlint-cli2.mjs @@ -886,8 +886,8 @@ const outputSummary = async ( const dirs = [ dir, ...modulePaths ]; const formattersAndParams = outputFormatters ? await importOrRequireIdsAndParams(dirs, outputFormatters, noRequire) - // eslint-disable-next-line unicorn/no-await-expression-member - : [ [ (await import("markdownlint-cli2-formatter-default")).default ] ]; + // eslint-disable-next-line no-inline-comments, unicorn/no-await-expression-member + : [ [ (await import(/* webpackMode: "eager" */ "markdownlint-cli2-formatter-default")).default ] ]; await Promise.all(formattersAndParams.map((formatterAndParams) => { const [ formatter, ...formatterParams ] = formatterAndParams; return formatter(formatterOptions, ...formatterParams); diff --git a/package.json b/package.json index 7bd73a9..46e500f 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "test-watch": "git ls-files | entr npm run test", "update-snapshots": "ava --timeout=1m --update-snapshots test/markdownlint-cli2-test-exec.mjs test/markdownlint-cli2-test-fs.mjs test/markdownlint-cli2-test-main.mjs", "webworker": "cd webworker && webpack --mode none", - "webworker-install": "npm install --no-package-lock --no-save path-browserify setimmediate stream-browserify util webpack-cli && cpy ./node_modules/setimmediate/setImmediate.cjs ./webworker --flat" + "webworker-install": "npm install --no-package-lock --no-save path-browserify setimmediate stream-browserify util webpack-cli && cpy ./node_modules/setimmediate/setImmediate.js ./webworker/setImmediate.cjs --flat" }, "engines": { "node": ">=18" diff --git a/webworker/index.cjs b/webworker/index.cjs deleted file mode 100644 index 13cc62c..0000000 --- a/webworker/index.cjs +++ /dev/null @@ -1,5 +0,0 @@ -// @ts-check - -"use strict"; - -module.exports = require("../markdownlint-cli2.mjs"); diff --git a/webworker/index.html b/webworker/index.html index e6f2ec3..93697b1 100644 --- a/webworker/index.html +++ b/webworker/index.html @@ -10,9 +10,9 @@
- - - - + + + + diff --git a/webworker/index.mjs b/webworker/index.mjs new file mode 100644 index 0000000..5abe053 --- /dev/null +++ b/webworker/index.mjs @@ -0,0 +1,3 @@ +// @ts-check + +export { main } from "../markdownlint-cli2.mjs"; diff --git a/webworker/webpack.config.cjs b/webworker/webpack.config.cjs index c1ea1e1..336498f 100644 --- a/webworker/webpack.config.cjs +++ b/webworker/webpack.config.cjs @@ -7,9 +7,10 @@ const webpack = require("webpack"); const nodeModulePrefixRe = /^node:/u; +/** @type {import("webpack").Configuration} */ module.exports = { "target": "webworker", - "entry": "./index.js", + "entry": "./index.mjs", "output": { "path": __dirname, "filename": "markdownlint-cli2-webworker.cjs", @@ -31,14 +32,14 @@ module.exports = { new webpack.NormalModuleReplacementPlugin( /^stream\/(?:consumers|promises)$/u, (resource) => { - resource.request = require.resolve("./module-empty.js"); + resource.request = require.resolve("./module-empty.cjs"); } ), // Intercept existing "unicorn-magic" package to provide missing import new webpack.NormalModuleReplacementPlugin( /^unicorn-magic$/u, (resource) => { - resource.request = require.resolve("./unicorn-magic-stub.js"); + resource.request = require.resolve("./unicorn-magic-stub.cjs"); } ), // Intercept use of "process" to provide implementation @@ -50,12 +51,13 @@ module.exports = { "fallback": { "buffer": false, "fs": false, - "os": require.resolve("./os-stub.js"), + "module": false, + "os": require.resolve("./os-stub.cjs"), "path": require.resolve("path-browserify"), - "process": require.resolve("./process-stub.js"), - "process-wrapper": require.resolve("./process-stub.js"), + "process": require.resolve("./process-stub.cjs"), + "process-wrapper": require.resolve("./process-stub.cjs"), "stream": require.resolve("stream-browserify"), - "url": require.resolve("./module-empty.js") + "url": require.resolve("./module-empty.cjs") } } };