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/package.json b/package.json index 62945d2522..df3c69bb53 100644 --- a/package.json +++ b/package.json @@ -110,6 +110,7 @@ "@types/temp": "^0.9.1", "@types/write-pkg": "^4.0.0", "@types/ws": "^6.0.1", + "@types/yargs": "^16", "@typescript-eslint/eslint-plugin": "^5.12.1", "@typescript-eslint/parser": "^5.12.1", "async-retry": "^1.3.1", @@ -126,26 +127,24 @@ "got": "^11.8.3", "handlebars": "^4.7.3", "is-git-clean": "^1.1.0", - "jest": "^27.5.1", - "jest-jasmine2": "^27.5.1", + "jest": "^28.0.3", + "jest-environment-jsdom": "^28.0.2", + "jest-jasmine2": "^28.0.3", "jsdom": "^19.0.0", "jsdom-worker": "^0.2.1", "mkdirp": "^0.5.1", "node-fetch": "^2.6.1", "offline-iconfont": "^1.1.0", - "parse-github-url": "^1.0.2", "prettier": "^2.5.1", "read-pkg": "^5.2.0", - "regenerator-runtime": "^0.13.3", "rimraf": "^3.0.2", "runscript": "^1.4.0", "semver": "^6.3.0", "simple-git": "^3.3.0", - "strip-html-comments": "^1.0.0", "temp": "^0.9.4", - "ts-jest": "^27.0.3", - "uuid": "^8.3.2", + "ts-jest": "^28.0.0", "write-pkg": "^4.0.0", + "yargs": "^16.1.0", "yauzl": "^2.10.0" } } 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/packages/extension-manager/package.json b/packages/extension-manager/package.json index 134fe7420c..23d11db5a0 100644 --- a/packages/extension-manager/package.json +++ b/packages/extension-manager/package.json @@ -18,7 +18,6 @@ "fs-extra": "^8.1.0", "node-fetch": "^2.6.1", "requestretry": "^7.0.0", - "uuid": "^8.3.2", "yauzl": "^2.10.0" }, "devDependencies": { diff --git a/packages/file-service/package.json b/packages/file-service/package.json index 370a06ae13..742484e854 100644 --- a/packages/file-service/package.json +++ b/packages/file-service/package.json @@ -26,14 +26,12 @@ "mv": "^2.1.1", "nsfw": "^2.1.2", "trash": "^5.2.0", - "uuid": "^3.3.2", "vscode-languageserver-types": "^3.16.0", "write-file-atomic": "^3.0.0" }, "devDependencies": { "@opensumi/ide-core-browser": "2.17.2", "@opensumi/ide-dev-tool": "^1.3.1", - "@types/mv": "^2.1.0", - "@types/uuid": "^3.4.4" + "@types/mv": "^2.1.0" } } diff --git a/scripts/publish.ts b/scripts/publish.ts index bd417ec0ac..f0fa165e56 100644 --- a/scripts/publish.ts +++ b/scripts/publish.ts @@ -8,7 +8,7 @@ import { argv } from 'yargs'; import git from 'git-rev-sync'; import chalk from 'chalk'; -import pkg from '../package.json'; +import pkg from '../lerna.json'; import Package, { readAllMainPackages } from './pkg'; import { generateManifest } from './manifest'; diff --git a/scripts/start.ts b/scripts/start.ts index f537eff760..7b72ef60e5 100644 --- a/scripts/start.ts +++ b/scripts/start.ts @@ -1,7 +1,7 @@ import { startFromFolder } from './fn/module'; import { argv } from 'yargs'; -const folderName = argv.folder as string || 'packages/startup'; -const scriptName = argv.script as string || 'start'; +const folderName = (argv.folder as string) || 'packages/startup'; +const scriptName = (argv.script as string) || 'start'; if (!folderName) { throw Error('folderName is required.'); 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';