Skip to content

Commit dc34579

Browse files
committed
🐛 fix invalid path for relative import
which is used to import the metadata storage of class-transformer fix #100
1 parent ebcdfb6 commit dc34579

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

jest.config.ts

+9-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import { pathsToModuleNameMapper } from 'ts-jest';
33
// eslint-disable-next-line @typescript-eslint/no-var-requires
44
const { compilerOptions } = require('./tsconfig.json');
55

6+
const EXCLUDE_PATHS = new Set(['class-transformer/cjs/storage']);
7+
68
module.exports = {
79
clearMocks: true,
810
testMatch: [
@@ -18,7 +20,13 @@ module.exports = {
1820
],
1921
},
2022
modulePaths: [compilerOptions.baseUrl],
21-
moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths),
23+
moduleNameMapper: pathsToModuleNameMapper(
24+
Object.fromEntries(
25+
Object.entries(compilerOptions.paths).filter(
26+
(e): e is [string, string[]] => !EXCLUDE_PATHS.has(e[0]),
27+
),
28+
),
29+
),
2230
setupFiles: ['./test/setup.ts'],
2331
setupFilesAfterEnv: ['jest-extended/all'],
2432
};

lib/features/validate-headers/utils.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as transformer from 'class-transformer';
2-
import { defaultMetadataStorage } from 'class-transformer/types/storage';
2+
import { defaultMetadataStorage } from 'class-transformer/cjs/storage';
33
import * as validator from 'class-validator';
44

55
import { applyDecorators, IsRecord, MutuallyExclusive } from '../../utils';

tsconfig.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"paths": {
2727
"webpack-userscript": ["lib"],
2828
"webpack-userscript/*": ["lib/*"],
29-
"class-transformer/types/storage": ["node_modules/class-transformer/cjs/storage"]
29+
"class-transformer/cjs/storage": ["node_modules/class-transformer/types/storage"]
3030
}
3131
},
3232
"include": ["**/*.ts"]

0 commit comments

Comments
 (0)