vite-plugin-istanbul
Advanced tools
Comparing version 2.4.0 to 2.5.0
@@ -1,2 +0,2 @@ | ||
# [2.4.0](https://github.com/ifaxity/vite-plugin-istanbul/compare/v2.3.0...v2.4.0) (2022-01-17) | ||
# [2.5.0](https://github.com/ifaxity/vite-plugin-istanbul/compare/v2.4.0...v2.5.0) (2022-02-09) | ||
@@ -6,2 +6,2 @@ | ||
* Support for env files from config ([4accd4a](https://github.com/ifaxity/vite-plugin-istanbul/commit/4accd4ac43bf9593b0d9be3472dd35c799817d67)) | ||
* Support instrument in build mode ([90b7e8b](https://github.com/ifaxity/vite-plugin-istanbul/commit/90b7e8bab49dfaadef65c22e3949ce54f9d2668c)) |
@@ -13,2 +13,3 @@ import { Plugin } from 'vite'; | ||
cwd?: string; | ||
forceBuildInstrument?: boolean; | ||
} | ||
@@ -15,0 +16,0 @@ declare const _default: (opts?: IstanbulPluginOptions) => Plugin; |
@@ -20,3 +20,3 @@ "use strict"; | ||
module.exports = function istanbulPlugin(opts = {}) { | ||
var _a, _b, _c, _d; | ||
var _a, _b, _c, _d, _e; | ||
// Only instrument when we want to, as we only want instrumentation in test | ||
@@ -26,8 +26,9 @@ // By default the plugin is always on | ||
const checkProd = (_b = opts === null || opts === void 0 ? void 0 : opts.checkProd) !== null && _b !== void 0 ? _b : true; | ||
const forceBuildInstrument = (_c = opts === null || opts === void 0 ? void 0 : opts.forceBuildInstrument) !== null && _c !== void 0 ? _c : false; | ||
const logger = (0, vite_1.createLogger)('warn', { prefix: 'vite-plugin-istanbul' }); | ||
const exclude = new test_exclude_1.default({ | ||
cwd: (_c = opts.cwd) !== null && _c !== void 0 ? _c : process.cwd(), | ||
cwd: (_d = opts.cwd) !== null && _d !== void 0 ? _d : process.cwd(), | ||
include: opts.include, | ||
exclude: opts.exclude, | ||
extension: (_d = opts.extension) !== null && _d !== void 0 ? _d : DEFAULT_EXTENSION, | ||
extension: (_e = opts.extension) !== null && _e !== void 0 ? _e : DEFAULT_EXTENSION, | ||
excludeNodeModules: true, | ||
@@ -46,3 +47,3 @@ }); | ||
name: PLUGIN_NAME, | ||
apply: 'serve', | ||
apply: forceBuildInstrument ? 'build' : 'serve', | ||
// istanbul only knows how to instrument JavaScript, | ||
@@ -68,3 +69,3 @@ // this allows us to wait until the whole code is JavaScript to | ||
const env = (_a = (opts.cypress ? CYPRESS_COVERAGE : VITE_COVERAGE)) === null || _a === void 0 ? void 0 : _a.toLowerCase(); | ||
if ((checkProd && isProduction) || | ||
if ((checkProd && isProduction && !forceBuildInstrument) || | ||
(!requireEnv && env === 'false') || | ||
@@ -71,0 +72,0 @@ (requireEnv && env !== 'true')) { |
{ | ||
"name": "vite-plugin-istanbul", | ||
"version": "2.4.0", | ||
"version": "2.5.0", | ||
"author": "iFaxity (christian@faxity.se)", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -45,2 +45,3 @@ vite-plugin-istanbul | ||
* `opts.checkProd {boolean}` - Optional boolean to enforce the plugin to skip instrumentation for production environments, checks *NODE_ENV* for "production" (case insensitive). Defaults to true. | ||
* `opts.forceBuildInstrument {boolean}` - Optional boolean to enforce the plugin to add instrumentation in build mode. Defaults to false. | ||
@@ -47,0 +48,0 @@ Examples |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
15288
126
74