import fs from 'fs' ; import type { StylableConfig } from '@stylable/core' ; import { stylableModuleFactory } from '@stylable/module-utils' ; import { resolveNamespace } from '@stylable/node' ; const stylableRuntimePath = require . resolve ( '@stylable/runtime' ) ; const stylableCorePath = require . resolve ( '@stylable/core' ) ; const { version : runtimeVersion } = require ( '@stylable/runtime/package.json' ) as { version : string ; } ; const { version : coreVersion } = require ( '@stylable/core/package.json' ) as { version : string ; } ; function getCacheKey ( fileData , filename , configString , options ? ) { return ( fileData + configString + ( options && options . instrument ? 'instrument' : '' ) + filename + stylableRuntimePath + runtimeVersion + stylableCorePath + coreVersion ) ; } export interface StylableJestConfig { stylable ? : Partial < StylableConfig > ; } export const createTransformer = ( options ? ) => { const process = stylableModuleFactory ( { fileSystem : fs , requireModule : require , projectRoot : '' , resolveNamespace , ... options ?. stylable , } , { runtimePath : stylableRuntimePath } ) ; return { process , getCacheKey , canInstrument : false , } ; } ;