From dacdc72430e4dca0c134303b445a70b7fe9cbe17 Mon Sep 17 00:00:00 2001 From: magic-akari Date: Mon, 18 Jul 2022 10:28:23 +0800 Subject: [PATCH] fix: add version to cache key (#114) --- index.ts | 5 +++-- tsconfig.json | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/index.ts b/index.ts index 9166116..38bb22c 100644 --- a/index.ts +++ b/index.ts @@ -4,7 +4,8 @@ import * as path from 'path' import * as process from 'process' import getCacheKeyFunction from '@jest/create-cache-key-function' import type { Transformer, TransformOptions } from '@jest/transform' -import { transformSync, transform, Options } from '@swc/core' +import { transformSync, transform, Options, version as swcVersion } from '@swc/core' +import { version } from './package.json' function createTransformer(swcTransformOpts?: Options & { experimental?: { @@ -20,7 +21,7 @@ function createTransformer(swcTransformOpts?: Options & { }): Transformer { const computedSwcOptions = buildSwcTransformOpts(swcTransformOpts) - const cacheKeyFunction = getCacheKeyFunction([], [JSON.stringify(computedSwcOptions)]) + const cacheKeyFunction = getCacheKeyFunction([], [swcVersion, version, JSON.stringify(computedSwcOptions)]) const { enabled: canInstrument, ...instrumentOptions } = swcTransformOpts?.experimental?.customCoverageInstrumentation ?? {} return { canInstrument: !!canInstrument, // Tell jest we'll instrument by our own diff --git a/tsconfig.json b/tsconfig.json index 9651257..b61cb6b 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -23,6 +23,7 @@ // "importHelpers": true, /* Import emit helpers from 'tslib'. */ // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */ // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */ + "resolveJsonModule": true, /* Strict Type-Checking Options */ "strict": true /* Enable all strict type-checking options. */,