diff --git a/coverage.cjs b/coverage.cjs new file mode 100644 index 000000000..4a3068a87 --- /dev/null +++ b/coverage.cjs @@ -0,0 +1,43 @@ +"use strict"; + +const esbuild = require("esbuild"); +const { esbuildPluginIstanbul } = require("esbuild-plugin-istanbul"); + +(async function () { + const { default: getStdin } = await import("get-stdin"); + const plugins = [ + esbuildPluginIstanbul({ + filter: /\.js$/, + loader: "js", + name: "istanbul-loader-js", + }), + ]; + const stdin = { + contents: await getStdin(), + resolveDir: process.cwd(), + sourcefile: "tests.js", + loader: "js", + }; + + const context = await esbuild.context({ + absWorkingDir: process.cwd(), + entryPoints: [], + write: false, + bundle: true, + sourcemap: "inline", + sourcesContent: true, + define: { global: "window", "process.env.NODE_DEBUG": '""' }, + external: ["fs"], + target: "es2022", + plugins, + color: true, + stdin, + }); + + const { outputFiles } = await context.rebuild(); + const js = outputFiles[0].text; + + context.dispose(); + + process.stdout.write(js); +})(); diff --git a/package-lock.json b/package-lock.json index 729573468..3c3d8bcdc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -32,6 +32,8 @@ "debug": "^4.3.4", "dependency-check": "^4.1.0", "esbuild": "^0.23.1", + "esbuild-plugin-istanbul": "^0.3.0", + "get-stdin": "^9.0.0", "lint-staged": "^15.2.2", "mocha": "^10.4.0", "nyc": "^15.1.0", @@ -4575,6 +4577,16 @@ "@esbuild/win32-x64": "0.23.1" } }, + "node_modules/esbuild-plugin-istanbul": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/esbuild-plugin-istanbul/-/esbuild-plugin-istanbul-0.3.0.tgz", + "integrity": "sha512-nRGeDR7sXIG4U7tLed4wXcrwXEu64fd9apm9VaPxe85jeSjvFqYyKaaTX8669Lx/2S+NSA/7Fs9q1jJbLXsWLg==", + "dev": true, + "license": "MIT", + "dependencies": { + "nyc": "^15.1.0" + } + }, "node_modules/escalade": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.2.tgz", @@ -5840,6 +5852,19 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/get-stdin": { + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-9.0.0.tgz", + "integrity": "sha512-dVKBjfWisLAicarI2Sf+JuBE/DghV4UzNAVe9yhEJuzeREd3JhOTE9cUaJTeSa77fsbQUK3pcOpJfM59+VKZaA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/get-stream": { "version": "8.0.1", "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-8.0.1.tgz", diff --git a/package.json b/package.json index 82c30637a..9b4652503 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "test-node": "mocha --recursive -R dot \"test/**/*-test.js\"", "test-dev": "npm run test-node -- -n watch -n watch-path=test --node-option watch-path=lib -R min", "test-headless": "mochify --driver puppeteer", - "test-coverage": "nyc npm run test-headless -- --transform [ babelify --ignore [ test ] --plugins [ babel-plugin-istanbul ] ]", + "test-coverage": "nyc nyc --exclude-after-remap false mochify --driver puppeteer --bundle 'node coverage.cjs'", "test-cloud": "npm run test-headless -- --wd", "test-webworker": "mochify --driver puppeteer --serve . test/webworker/webworker-support-assessment.js", "test-esm-support": "mocha test/es2015/module-support-assessment-test.mjs", @@ -94,9 +94,9 @@ "@mochify/driver-puppeteer": "^0.4.0", "@mochify/driver-webdriver": "^0.2.1", "@sinonjs/eslint-config": "^5.0.3", - "@sinonjs/referee-sinon": "12.0.0", "@sinonjs/eslint-plugin-no-prototype-methods": "^0.1.1", "@sinonjs/referee": "^11.0.1", + "@sinonjs/referee-sinon": "12.0.0", "@studio/changes": "^3.0.0", "babel-plugin-istanbul": "^6.1.1", "babelify": "^10.0.0", @@ -104,6 +104,8 @@ "debug": "^4.3.4", "dependency-check": "^4.1.0", "esbuild": "^0.23.1", + "esbuild-plugin-istanbul": "^0.3.0", + "get-stdin": "^9.0.0", "lint-staged": "^15.2.2", "mocha": "^10.4.0", "nyc": "^15.1.0",