From dba1738128e94fc2fd15b882bee94d961dace0d6 Mon Sep 17 00:00:00 2001 From: Elizabeth Craig Date: Fri, 9 Jan 2026 17:28:14 -0800 Subject: [PATCH 1/3] Allow ESM imports in jest --- .vscode/launch.json | 22 +------------ ...-37a6b8a7-6fa0-4f2a-8ef5-34bca5edf36a.json | 11 +++++++ packages/beachball/package.json | 13 ++++---- .../beachball/src/__fixtures__/registry.ts | 10 ++++-- yarn.lock | 31 ++++++++++++++++--- 5 files changed, 53 insertions(+), 34 deletions(-) create mode 100644 change/change-37a6b8a7-6fa0-4f2a-8ef5-34bca5edf36a.json diff --git a/.vscode/launch.json b/.vscode/launch.json index 02f701137..9580603b8 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -11,6 +11,7 @@ "runtimeExecutable": null, "program": "${workspaceRoot}/scripts/debugTests.js", "cwd": "${fileDirname}", + "runtimeArgs": ["--nolazy", "--inspect", "--experimental-vm-modules"], "args": ["--", "--runInBand", "--watch", "--testTimeout=1000000", "${file}"], "sourceMaps": true, "outputCapture": "std", @@ -33,27 +34,6 @@ "processId": "${command:PickProcess}", "sourceMaps": true, "skipFiles": ["/**"] - }, - { - // Debug configuration for Jest extension - "name": "vscode-jest-tests.v2", - "type": "node", - "request": "launch", - "runtimeExecutable": "npm", - "cwd": "${workspaceFolder}", - "runtimeArgs": ["run-script", "test"], - "args": [ - "--", - "--runInBand", - "--watch", - "--testTimeout=1000000", - "--no-coverage", - "--testNamePattern", - "${jest.testNamePattern}", - "--runTestsByPath", - "${jest.testFile}" - ], - "console": "integratedTerminal" } ] } diff --git a/change/change-37a6b8a7-6fa0-4f2a-8ef5-34bca5edf36a.json b/change/change-37a6b8a7-6fa0-4f2a-8ef5-34bca5edf36a.json new file mode 100644 index 000000000..88557bd02 --- /dev/null +++ b/change/change-37a6b8a7-6fa0-4f2a-8ef5-34bca5edf36a.json @@ -0,0 +1,11 @@ +{ + "changes": [ + { + "type": "none", + "comment": "Allow ESM imports in jest", + "packageName": "beachball", + "email": "elcraig@microsoft.com", + "dependentChangeType": "none" + } + ] +} \ No newline at end of file diff --git a/packages/beachball/package.json b/packages/beachball/package.json index d74c21170..30f37924c 100644 --- a/packages/beachball/package.json +++ b/packages/beachball/package.json @@ -26,12 +26,12 @@ "depcheck": "yarn run -T depcheck .", "lint": "yarn run -T eslint --color --max-warnings=0 src", "start": "yarn run -T tsc -w --preserveWatchOutput", - "test": "yarn run -T jest", + "test": "cross-env NODE_OPTIONS='--experimental-vm-modules' yarn run -T jest", "test:all": "yarn test:unit && yarn test:func && yarn test:e2e", - "test:e2e": "yarn run -T jest --selectProjects e2e", - "test:func": "yarn run -T jest --selectProjects functional", - "test:unit": "yarn run -T jest --selectProjects unit", - "test:watch": "yarn run -T jest --watch", + "test:e2e": "yarn test --selectProjects e2e", + "test:func": "yarn test --selectProjects functional", + "test:unit": "yarn test --selectProjects unit", + "test:watch": "yarn test --watch", "update-snapshots": "yarn test:unit -u && yarn test:func -u && yarn test:e2e -u" }, "dependencies": { @@ -55,7 +55,8 @@ "@types/tmp": "^0.2.3", "@types/yargs-parser": "^21.0.0", "@verdaccio/types": "^13.0.0", - "get-port": "^5.0.0", + "cross-env": "^10.1.0", + "get-port": "^7.0.0", "normalized-tmpdir": "1.0.1", "strip-ansi": "^6.0.1", "tmp": "^0.2.1", diff --git a/packages/beachball/src/__fixtures__/registry.ts b/packages/beachball/src/__fixtures__/registry.ts index b2c357eaa..d00017bd9 100644 --- a/packages/beachball/src/__fixtures__/registry.ts +++ b/packages/beachball/src/__fixtures__/registry.ts @@ -2,7 +2,6 @@ import { ConfigBuilder } from '@verdaccio/config'; import { fork, type ChildProcess } from 'child_process'; import execa from 'execa'; import fs from 'fs'; -import getPort from 'get-port'; import os from 'os'; import path from 'path'; import { removeTempDir, tmpdir } from './tmpdir'; @@ -58,7 +57,14 @@ export class Registry { // If this is consistently having problems, probably it's best to increase portRange. const maxPort = this.startPort + portRange; console.log(`Looking for free ports in range ${this.startPort} to ${maxPort}`); - const tryPort = await getPort({ port: getPort.makeRange(this.startPort, maxPort) }); + + const port: number[] = []; + for (let i = this.startPort; i <= maxPort; i++) { + port.push(i); + } + + const getPort = await import('get-port'); + const tryPort = await getPort.default({ port }); // Try to start the server. If it fails, it's likely a config error or something where a retry // won't be helpful, so just let it throw. diff --git a/yarn.lock b/yarn.lock index 5c9818f85..de24be7ae 100644 --- a/yarn.lock +++ b/yarn.lock @@ -435,6 +435,13 @@ __metadata: languageName: node linkType: hard +"@epic-web/invariant@npm:^1.0.0": + version: 1.0.0 + resolution: "@epic-web/invariant@npm:1.0.0" + checksum: 10c0/72dbeb026e4e4eb3bc9c65739b91408ca77ab7d603a2494fa2eff3790ec22892c4caba751cffdf30f5ccf0e7ba79c1e9c96cf0a357404b9432bf1365baac23ca + languageName: node + linkType: hard + "@eslint-community/eslint-utils@npm:^4.8.0, @eslint-community/eslint-utils@npm:^4.9.1": version: 4.9.1 resolution: "@eslint-community/eslint-utils@npm:4.9.1" @@ -2354,8 +2361,9 @@ __metadata: "@vercel/detect-agent": "npm:^1.2.1" "@verdaccio/types": "npm:^13.0.0" cosmiconfig: "npm:^9.0.1" + cross-env: "npm:^10.1.0" execa: "npm:^5.1.1" - get-port: "npm:^5.0.0" + get-port: "npm:^7.0.0" minimatch: "npm:^3.1.5" normalized-tmpdir: "npm:1.0.1" p-graph: "npm:^1.3.0" @@ -2855,6 +2863,19 @@ __metadata: languageName: node linkType: hard +"cross-env@npm:^10.1.0": + version: 10.1.0 + resolution: "cross-env@npm:10.1.0" + dependencies: + "@epic-web/invariant": "npm:^1.0.0" + cross-spawn: "npm:^7.0.6" + bin: + cross-env: dist/bin/cross-env.js + cross-env-shell: dist/bin/cross-env-shell.js + checksum: 10c0/834a862db456ba1fedf6c6da43436b123ae38f514fa286d6f0937c14fa83f13469f77f70f2812db041ae2d84f82bac627040b8686030aca27fbdf113dfa38b63 + languageName: node + linkType: hard + "cross-spawn@npm:^7.0.3, cross-spawn@npm:^7.0.6": version: 7.0.6 resolution: "cross-spawn@npm:7.0.6" @@ -3854,10 +3875,10 @@ __metadata: languageName: node linkType: hard -"get-port@npm:^5.0.0": - version: 5.1.1 - resolution: "get-port@npm:5.1.1" - checksum: 10c0/2873877a469b24e6d5e0be490724a17edb39fafc795d1d662e7bea951ca649713b4a50117a473f9d162312cb0e946597bd0e049ed2f866e79e576e8e213d3d1c +"get-port@npm:^7.0.0": + version: 7.1.0 + resolution: "get-port@npm:7.1.0" + checksum: 10c0/896051fea0fd3df58c050566754ab91f46406e898ce0c708414739d908a5ac03ffef3eca7a494ea9cc1914439e8caccd2218010d1eeabdde914b9ff920fa28fc languageName: node linkType: hard From 4239987d448b235a573e1cffa2d5404e824c99c5 Mon Sep 17 00:00:00 2001 From: Elizabeth Craig Date: Fri, 1 May 2026 19:26:23 -0700 Subject: [PATCH 2/3] deps --- package.json | 3 +++ yarn.lock | 13 ++----------- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/package.json b/package.json index 6c11594f0..3ebe31b8b 100644 --- a/package.json +++ b/package.json @@ -68,6 +68,9 @@ "lodash": "^4.18.1", "express/qs@6.11.0": "^6.14.2", "@cypress/request/qs@6.10.4": "^6.14.2", + "@verdaccio/core/minimatch@7.4.6": "^7.4.9", + "verdaccio/minimatch@7.4.6": "^7.4.9", + "verdaccio-memory/minimatch@7.4.6": "^7.4.9", "@verdaccio/core/ajv@8.17.1": "^8.18.0", "@verdaccio/core/ajv@8.18.0": "^8.18.0" }, diff --git a/yarn.lock b/yarn.lock index de24be7ae..39be273e7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2412,7 +2412,7 @@ __metadata: languageName: node linkType: hard -"brace-expansion@npm:^2.0.1, brace-expansion@npm:^2.0.2": +"brace-expansion@npm:^2.0.2": version: 2.0.3 resolution: "brace-expansion@npm:2.0.3" dependencies: @@ -5576,16 +5576,7 @@ __metadata: languageName: node linkType: hard -"minimatch@npm:7.4.6": - version: 7.4.6 - resolution: "minimatch@npm:7.4.6" - dependencies: - brace-expansion: "npm:^2.0.1" - checksum: 10c0/e587bf3d90542555a3d58aca94c549b72d58b0a66545dd00eef808d0d66e5d9a163d3084da7f874e83ca8cc47e91c670e6c6f6593a3e7bb27fcc0e6512e87c67 - languageName: node - linkType: hard - -"minimatch@npm:7.4.9, minimatch@npm:^7.4.6": +"minimatch@npm:7.4.9, minimatch@npm:^7.4.6, minimatch@npm:^7.4.9": version: 7.4.9 resolution: "minimatch@npm:7.4.9" dependencies: From cb43d62b4d37cf87d466f198ab783540d9821692 Mon Sep 17 00:00:00 2001 From: Elizabeth Craig Date: Fri, 1 May 2026 19:27:04 -0700 Subject: [PATCH 3/3] depcheck --- packages/beachball/.depcheckrc.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/beachball/.depcheckrc.yml b/packages/beachball/.depcheckrc.yml index 66075a2df..ee594e560 100644 --- a/packages/beachball/.depcheckrc.yml +++ b/packages/beachball/.depcheckrc.yml @@ -1,6 +1,8 @@ ignore-path: ../../.gitignore ignores: + # used in scripts + - cross-env # used in __fixtures__/registry.ts by partial name - verdaccio-auth-memory - verdaccio-memory