Skip to content

Commit

Permalink
elbwalker package directories
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderkirtzel committed Feb 17, 2025
1 parent 9ef5fed commit 36a4f61
Showing 1 changed file with 34 additions and 10 deletions.
44 changes: 34 additions & 10 deletions packages/config/jest/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,35 @@
import path from 'path';
import { fileURLToPath } from 'url';

function getModuleMapper() {
// Check if we're in watch mode (dev) or regular test mode
const isWatchMode = process.argv.includes('--watchAll');

// Use either src or dist folder based on watch mode
const targetDir = isWatchMode ? '/src' : '/dist';

const packagesDir = path.join(
path.dirname(fileURLToPath(import.meta.url)),
'..',
'..',
'/',
);

function getDirectory(dir, target = targetDir) {
return path.join(packagesDir, dir, target);
}

return {
'^@elbwalker/jest$1': getDirectory('config/jest$1', ''),
'^@elbwalker/types': getDirectory('types', 'src'),
'^@elbwalker/utils': getDirectory('utils'),
'^@elbwalker/walker.js': getDirectory('sources/walkerjs'),
'^@elbwalker/destination-web-(.*)$': getDirectory('destinations/web/$1'),
'^@elbwalker/destination-node-(.*)$': getDirectory('destinations/node/$1'),
'^@elbwalker/source-(.*)$': getDirectory('sources/$1'),
};
}

const config = {
transform: {
'^.+\\.(t|j)sx?$': [
Expand All @@ -21,16 +53,8 @@ const config = {
moduleFileExtensions: ['js', 'ts', 'mjs'],
rootDir: 'src',
moduleDirectories: ['node_modules', 'src'],
// extensionsToTreatAsEsm: ['.ts', '.tsx'],
// moduleNameMapper: {
// '^@elbwalker/(.*)$': '<rootDir>/../../../$1/src',
// },
// moduleNameMapper: {
// '^@elbwalker/(.*)$': '<rootDir>/../../../$1/',
// },
// transformIgnorePatterns: [
// '/node_modules/(?!(@elbwalker)/)',
// ],
extensionsToTreatAsEsm: ['.ts', '.tsx'],
moduleNameMapper: getModuleMapper(),
};

export default config;

0 comments on commit 36a4f61

Please sign in to comment.