module.exports = {
preset: 'ts-jest',
+ globals: {
+ __DEV__: true,
+ },
+ coverageDirectory: 'coverage',
+ coverageReporters: ['html', 'lcov', 'text'],
collectCoverageFrom: ['src/**/*.ts'],
coveragePathIgnorePatterns: [
'/node_modules/',
'src/entries',
'src/consola.ts',
],
- testMatch: [
- '**/__tests__/**/*.spec.ts?(x)',
- // '**/__tests__/**/*.spec.[jt]s?(x)',
- // '**/?(*.)+(spec|test).[jt]s?(x)',
- ],
+ testMatch: ['<rootDir>/__tests__/**/*.spec.ts?(x)'],
testEnvironment: 'node',
}
) {
// force production mode when minifying
if (minify) env = 'production'
+ const isProductionBuild =
+ process.env.__DEV__ === 'false' || env === 'production'
+ const isBundlerESMBuild = format === 'es'
const config = {
input,
plugins: [
replace({
- __VERSION__: pkg.version,
- 'process.env.NODE_ENV': `'${env}'`,
+ __VERSION__: JSON.stringify(pkg.version),
+ __DEV__: isBundlerESMBuild
+ ? // preserve to be handled by bundlers
+ `process.env.NODE_ENV !== 'production'`
+ : // hard coded dev/prod builds
+ !isProductionBuild,
}),
alias({
resolve: ['ts'],
--- /dev/null
+// Global compile-time constants
+declare var __DEV__: boolean
{
- "include": ["src/**/*.ts", "__tests__/**/*.ts"],
+ "include": ["src/global.d.ts", "src/**/*.ts", "__tests__/**/*.ts"],
"compilerOptions": {
"target": "esnext",
"module": "commonjs",