fix(expect): revert node: protocol imports to restore webpack/browser compatibility (#16167)

This commit is contained in:
Jonathan Zawada
2026-05-12 10:19:33 +02:00
committed by GitHub
parent a67f66f3a1
commit 2adfa48981
10 changed files with 23 additions and 11 deletions
+1
View File
@@ -2,6 +2,7 @@
### Fixes
- `[expect, jest-message-util, jest-pattern, jest-regex-util, jest-util]` Revert `node:` protocol imports to restore webpack/browser-bundle compatibility ([#16167](https://github.com/jestjs/jest/pull/16167))
- `[jest-runtime]` Fall back to native ESM when a `.js` file contains ESM syntax but has no `"type":"module"` marker ([#16152](https://github.com/jestjs/jest/pull/16152))
### Chore & Maintenance
+11
View File
@@ -612,6 +612,17 @@ const config = defineConfig(
],
},
},
{
files: [
'packages/jest-message-util/src/**/*',
'packages/jest-pattern/src/**/*',
'packages/jest-regex-util/src/**/*',
'packages/jest-util/src/**/*',
],
rules: {
'unicorn/prefer-node-protocol': 'off',
},
},
{
files: ['packages/**/*.ts'],
rules: {
+2 -2
View File
@@ -5,8 +5,8 @@
* LICENSE file in the root directory of this source tree.
*/
import * as path from 'node:path';
import {fileURLToPath} from 'node:url';
import * as path from 'path';
import {fileURLToPath} from 'url';
import {codeFrameColumns} from '@babel/code-frame';
import chalk from 'chalk';
import * as fs from 'graceful-fs';
@@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/
import * as path from 'node:path';
import * as path from 'path';
import {replacePathSepForRegex} from 'jest-regex-util';
export class TestPathPatterns {
+1 -1
View File
@@ -6,7 +6,7 @@
*
*/
import {sep} from 'node:path';
import {sep} from 'path';
export const escapePathForRegex = (dir: string): string => {
if (sep === '\\') {
+1 -1
View File
@@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/
import type {WriteStream} from 'node:tty';
import type {WriteStream} from 'tty';
export default function clearLine(stream: WriteStream): void {
if (stream.isTTY) {
@@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/
import type * as Process from 'node:process';
import type * as Process from 'process';
import deepCyclicCopy from './deepCyclicCopy';
const BLACKLIST = new Set(['env', 'mainModule', '_events']);
@@ -81,7 +81,7 @@ function createProcessEnv(): NodeJS.ProcessEnv {
}
export default function createProcessObject(): typeof Process {
const process = require('node:process');
const process = require('process');
const newProcess = deepCyclicCopy(process, {
blacklist: BLACKLIST,
keepPrototype: true,
+1 -1
View File
@@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/
import {isNativeError} from 'node:util/types';
import {isNativeError} from 'util/types';
export const isError =
typeof Error.isError === 'function' ? Error.isError : isNativeError;
+1 -1
View File
@@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/
import type {WriteStream} from 'node:tty';
import type {WriteStream} from 'tty';
import chalk from 'chalk';
import clearLine from './clearLine';
import isInteractive from './isInteractive';
@@ -5,8 +5,8 @@
* LICENSE file in the root directory of this source tree.
*/
import {isAbsolute} from 'node:path';
import {pathToFileURL} from 'node:url';
import {isAbsolute} from 'path';
import {pathToFileURL} from 'url';
import interopRequireDefault from './interopRequireDefault';
async function importModule(