From 6790e2fd322c2de7005a516919a8258ff8f7656d Mon Sep 17 00:00:00 2001 From: marlin dalpozzo Date: Thu, 15 Aug 2024 15:12:26 -0700 Subject: [PATCH] chore: update uuid from v8 to v9 this will help to address an issue with jest >28 by default expects cjs exports in browser env https://jest-archive-august-2023.netlify.app/docs/28.x/upgrading-to-jest28/#packagejson-exports https://github.com/uuidjs/uuid/blob/main/CHANGELOG.md#900-2022-09-05 see: "add Jest/jsdom compatibility" in changelog - this commit also removes test/jest resolver.js file which only existed to resolve the jest cjs browser issue --- jest.config.ts | 1 - package.json | 2 +- src/tests/common/resolver.js | 33 --------------------------------- yarn.lock | 13 ++----------- 4 files changed, 3 insertions(+), 46 deletions(-) delete mode 100644 src/tests/common/resolver.js diff --git a/jest.config.ts b/jest.config.ts index d83f09588..d26c5bd67 100644 --- a/jest.config.ts +++ b/jest.config.ts @@ -7,7 +7,6 @@ const config: Config.InitialOptions = { setupFilesAfterEnv: ['src/tooling/helpers.ts'], testEnvironment: 'jsdom', coveragePathIgnorePatterns: ['tooling'], - resolver: `/src/tests/common/resolver.js`, }; export default config; diff --git a/package.json b/package.json index 9a1abe05a..b7455fde9 100644 --- a/package.json +++ b/package.json @@ -81,7 +81,7 @@ "tributejs": "^5.1.3", "use-deep-compare-effect": "^1.8.1", "use-local-storage-state": "^4.0.0", - "uuid": "^8.3.1" + "uuid": "^9.0.1" }, "devDependencies": { "@appfolio/eslint-config-appfolio-react": "^2.0.2", diff --git a/src/tests/common/resolver.js b/src/tests/common/resolver.js deleted file mode 100644 index 000a61c56..000000000 --- a/src/tests/common/resolver.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -// see the following docs for more info: -// https://jest-archive-august-2023.netlify.app/docs/28.x/upgrading-to-jest28/#packagejson-exports -// https://github.com/microsoft/accessibility-insights-web/pull/5421#issuecomment-1109168149 - -// Call the defaultResolver, so we leverage its cache, error handling, etc. -module.exports = (path, options) => - 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) => { - // This is a workaround for https://github.com/uuidjs/uuid/pull/616 - // - // jest-environment-jsdom 28+ tries to use browser exports instead of default exports, - // but uuid only offers an ESM browser export and not a CommonJS one. Jest does not yet - // support ESM modules natively, so this causes a Jest error related to trying to parse - // "export" syntax. - // - // This workaround prevents Jest from considering uuid's module-based exports at all; - // it falls back to uuid's CommonJS+node "main" property. - // - // Once we're able to migrate our Jest config to ESM and a browser crypto - // implementation is available for the browser+ESM version of uuid to use (eg, via - // https://github.com/jsdom/jsdom/pull/3352 or a similar polyfill), this can go away. - if (pkg.name === 'uuid') { - delete pkg.exports; - delete pkg.module; - } - return pkg; - }, - }); diff --git a/yarn.lock b/yarn.lock index a9c4b42a9..e72e4a1b0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -171,7 +171,7 @@ __metadata: uncontrollable: ^4.1.0 use-deep-compare-effect: ^1.8.1 use-local-storage-state: ^4.0.0 - uuid: ^8.3.1 + uuid: ^9.0.1 peerDependencies: react: ">= 16.8" react-dom: ">= 16.8" @@ -16343,16 +16343,7 @@ __metadata: languageName: node linkType: hard -"uuid@npm:^8.3.1": - version: 8.3.2 - resolution: "uuid@npm:8.3.2" - bin: - uuid: dist/bin/uuid - checksum: 5575a8a75c13120e2f10e6ddc801b2c7ed7d8f3c8ac22c7ed0c7b2ba6383ec0abda88c905085d630e251719e0777045ae3236f04c812184b7c765f63a70e58df - languageName: node - linkType: hard - -"uuid@npm:^9.0.0": +"uuid@npm:^9.0.0, uuid@npm:^9.0.1": version: 9.0.1 resolution: "uuid@npm:9.0.1" bin: