diff --git a/jest.config.js b/jest.config.js index 44e054e850..054d2a36ab 100644 --- a/jest.config.js +++ b/jest.config.js @@ -6,6 +6,7 @@ const tsModuleNameMapper = pathsToModuleNameMapper(tsconfig.compilerOptions.path const baseConfig = { preset: 'ts-jest', testRunner: 'jest-jasmine2', + resolver: '/tools/dev-tool/src/jest-resolver.js', coverageProvider: process.env.JEST_COVERAGE_PROVIDER || 'babel', // https://dev.to/vantanev/make-your-jest-tests-up-to-20-faster-by-changing-a-single-setting-i36 maxWorkers: '50%', diff --git a/packages/core-browser/package.json b/packages/core-browser/package.json index 8b1d01043a..c439815a47 100644 --- a/packages/core-browser/package.json +++ b/packages/core-browser/package.json @@ -25,7 +25,6 @@ "ajv": "^6.10.0", "classnames": "2.2.6", "clsx": "^1.0.4", - "file-icons-js": "^1.0.3", "font-awesome": "^4.7.0", "fuzzy": "^0.1.3", "jsonc-parser": "^2.1.0", diff --git a/tools/dev-tool/src/jest-resolver.js b/tools/dev-tool/src/jest-resolver.js new file mode 100644 index 0000000000..d551ca7284 --- /dev/null +++ b/tools/dev-tool/src/jest-resolver.js @@ -0,0 +1,16 @@ +// 关于 resolver 的文档请看: https://jestjs.io/docs/configuration#resolver-string + +module.exports = (path, options) => + // Call the defaultResolver, so we leverage its cache, error handling, etc. + options.defaultResolver(path, { + ...options, + // Use packageFilter to process parsed `package.json` before the resolution (see https://www.npmjs.com/package/resolve#resolveid-opts-cb) + packageFilter: (pkg) => { + if (pkg.name === 'nanoid') { + // 一个对于 jest@28 的 workaround,具体原因请见:https://github.com/microsoft/accessibility-insights-web/pull/5421/commits/9ad4e618019298d82732d49d00aafb846fb6bac7 + delete pkg['exports']; + delete pkg['module']; + } + return pkg; + }, + }); diff --git a/typings/css.escape/index.d.ts b/typings/css.escape/index.d.ts deleted file mode 100644 index 74031e1c2e..0000000000 --- a/typings/css.escape/index.d.ts +++ /dev/null @@ -1,4 +0,0 @@ -declare module 'css.escape' { - function escape(value: string): string; - export = escape; -} diff --git a/typings/file-icons-js/index.d.ts b/typings/file-icons-js/index.d.ts deleted file mode 100644 index c1794cca94..0000000000 --- a/typings/file-icons-js/index.d.ts +++ /dev/null @@ -1,4 +0,0 @@ -declare module 'file-icons-js' { - function getClass(filePath: string): string; - function getClassWithColor(filePath: string): string; -} diff --git a/typings/path-match/index.d.ts b/typings/path-match/index.d.ts deleted file mode 100644 index 16e73e2436..0000000000 --- a/typings/path-match/index.d.ts +++ /dev/null @@ -1 +0,0 @@ -declare module 'path-match'; diff --git a/typings/rc/index.d.ts b/typings/rc/index.d.ts deleted file mode 100644 index cc4f5a45eb..0000000000 --- a/typings/rc/index.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -declare module 'rc-util/*'; - -declare module 'rc-dropdown'; - -declare module 'rc-notification'; - -declare module 'rc-dialog'; - -declare module 'react-lifecycles-compat';