Skip to content

Commit

Permalink
🐛 fix invalid path for relative import
Browse files Browse the repository at this point in the history
which is used to import the metadata storage of class-transformer

fix #100
  • Loading branch information
momocow committed Apr 15, 2023
1 parent ebcdfb6 commit 8e185a9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
10 changes: 9 additions & 1 deletion jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { pathsToModuleNameMapper } from 'ts-jest';
// eslint-disable-next-line @typescript-eslint/no-var-requires
const { compilerOptions } = require('./tsconfig.json');

const EXCLUDE_PATHS = new Set(['class-transformer/cjs/storage']);

module.exports = {
clearMocks: true,
testMatch: [
Expand All @@ -18,7 +20,13 @@ module.exports = {
],
},
modulePaths: [compilerOptions.baseUrl],
moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths),
moduleNameMapper: pathsToModuleNameMapper(
Object.fromEntries(
Object.entries(compilerOptions.paths).filter(
(e): e is [string, string[]] => !EXCLUDE_PATHS.has(e[0]),
),
),
),
setupFiles: ['./test/setup.ts'],
setupFilesAfterEnv: ['jest-extended/all'],
};
2 changes: 1 addition & 1 deletion lib/features/validate-headers/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as transformer from 'class-transformer';
import { defaultMetadataStorage } from 'class-transformer/types/storage';
import { defaultMetadataStorage } from 'class-transformer/cjs/storage';
import * as validator from 'class-validator';

import { applyDecorators, IsRecord, MutuallyExclusive } from '../../utils';
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"paths": {
"webpack-userscript": ["lib"],
"webpack-userscript/*": ["lib/*"],
"class-transformer/types/storage": ["node_modules/class-transformer/cjs/storage"]
"class-transformer/cjs/storage": ["node_modules/class-transformer/types/storage"]
}
},
"include": ["**/*.ts"]
Expand Down

0 comments on commit 8e185a9

Please sign in to comment.