mirror of
https://github.com/microsoft/playwright.git
synced 2024-12-15 06:02:57 +03:00
chore: read browsers.json with require (#6186)
This fixes the compatibility on Vercel with Next.js when it's used in a serverless function. Next.js uses https://github.com/vercel/nft to trace down the dependencies which a serverless function is using which is currently not capable of detecting the browsers.json in our current setup. Previously we used require to load the browers.json which was replaced by readFileSync in #5318. Since then it was broken. Fixes #5862
This commit is contained in:
parent
6296d276f2
commit
7ec57c0c18
@ -16,7 +16,6 @@
|
||||
*/
|
||||
|
||||
import { execSync } from 'child_process';
|
||||
import fs from 'fs';
|
||||
import * as os from 'os';
|
||||
import path from 'path';
|
||||
import * as util from 'util';
|
||||
@ -235,7 +234,9 @@ export class Registry {
|
||||
}
|
||||
|
||||
constructor(packagePath: string) {
|
||||
const browsersJSON = JSON.parse(fs.readFileSync(path.join(packagePath, 'browsers.json'), 'utf8'));
|
||||
// require() needs to be used there otherwise it breaks on Vercel serverless
|
||||
// functions. See https://github.com/microsoft/playwright/pull/6186
|
||||
const browsersJSON = require(path.join(packagePath, 'browsers.json'));
|
||||
this._descriptors = browsersJSON['browsers'].map((obj: any) => {
|
||||
const name = obj.name;
|
||||
const revisionOverride = (obj.revisionOverrides || {})[hostPlatform];
|
||||
|
Loading…
Reference in New Issue
Block a user