Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .github/workflows/tests_primary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,33 +73,33 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
node-version: [20]
node-version: [22]
shardIndex: [1, 2]
shardTotal: [2]
shardWeights: ['58:42']
include:
- os: windows-latest
node-version: 20
node-version: 22
shardIndex: 1
shardTotal: 3
shardWeights: '44:33:23'
- os: windows-latest
node-version: 20
node-version: 22
shardIndex: 2
shardTotal: 3
shardWeights: '44:33:23'
- os: windows-latest
node-version: 20
node-version: 22
shardIndex: 3
shardTotal: 3
shardWeights: '44:33:23'
- os: ubuntu-latest
node-version: 22
node-version: 20
shardIndex: 1
shardTotal: 2
shardWeights: '58:42'
- os: ubuntu-latest
node-version: 22
node-version: 20
shardIndex: 2
shardTotal: 2
shardWeights: '58:42'
Expand Down
16 changes: 10 additions & 6 deletions packages/playwright/src/transform/esmLoaderSync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,19 @@ import { currentFileDepsCollector } from './compilationCache';
import { resolveHook, shouldTransform, transformHook } from './transform';
import { fileIsModule } from '../util';

export function resolve(specifier: string, context: { parentURL?: string }, nextResolve: Function) {
export function resolve(specifier: string, context: { parentURL?: string, conditions?: string[] }, nextResolve: Function) {
if (context.parentURL && context.parentURL.startsWith('file://')) {
const filename = url.fileURLToPath(context.parentURL);
const resolved = resolveHook(filename, specifier);
// Pass the resolved absolute path (not a file:// URL) to nextResolve: unlike the
// ESM-only asynchronous loader, these hooks also serve require(), whose default
// resolver rejects file:// specifiers but accepts absolute paths for both kinds.
if (resolved !== undefined)
specifier = resolved;
if (resolved !== undefined) {
// These hooks serve both require() and import. The two default resolvers disagree on
// what an already-resolved specifier should look like:
// - require()'s resolver wants an absolute path and rejects file:// specifiers;
// - the ESM resolver wants a file:// URL and, on Windows, mistakes an absolute path's
// drive letter for a URL scheme ("Received protocol 'c:'").
// The `import` condition is present only for ESM resolution, so use it to pick the form.
specifier = context.conditions?.includes('import') ? url.pathToFileURL(resolved).toString() : resolved;
}
}
const result = nextResolve(specifier, context);
if (result?.url && result.url.startsWith('file://'))
Expand Down
Loading