Skip to content

Commit c5b0baa

Browse files
authored
chore: remove main index.js from playwright-core (#2178)
1 parent d487a31 commit c5b0baa

File tree

13 files changed

+24
-36
lines changed

13 files changed

+24
-36
lines changed

browsers.json

Lines changed: 0 additions & 16 deletions
This file was deleted.

index.js renamed to index-for-dev.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,7 @@
1515
*/
1616

1717
const { Playwright } = require('./lib/server/playwright');
18+
const path = require('path');
1819

19-
module.exports = new Playwright(__dirname, require('./browsers.json')['browsers']);
20+
const playwrightRoot = path.join(__dirname, 'packages', 'playwright');
21+
module.exports = new Playwright(playwrightRoot, require(path.join(playwrightRoot, 'browsers.json'))['browsers']);

install-from-github.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,10 @@ async function downloadAllBrowsersAndGenerateProtocolTypes() {
6464
const { installBrowsersWithProgressBar } = require('./lib/install/installer');
6565
const protocolGenerator = require('./utils/protocol-types-generator');
6666
const browserPaths = require('./lib/install/browserPaths');
67-
const browsersPath = browserPaths.browsersPath(__dirname);
68-
const browsers = require('./browsers.json')['browsers'];
69-
await installBrowsersWithProgressBar(__dirname);
67+
const playwrightRoot = path.join(__dirname, 'packages', 'playwright');
68+
const browsersPath = browserPaths.browsersPath(playwrightRoot);
69+
const browsers = require(path.join(playwrightRoot, 'browsers.json'))['browsers'];
70+
await installBrowsersWithProgressBar(playwrightRoot);
7071
for (const browser of browsers) {
7172
const browserPath = browserPaths.browserDirectory(browsersPath, browser);
7273
await protocolGenerator.generateProtocol(browser.name, browserPaths.executablePath(browserPath, browser)).catch(console.warn);

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
"engines": {
88
"node": ">=10.15.0"
99
},
10-
"main": "index.js",
1110
"scripts": {
1211
"ctest": "cross-env BROWSER=chromium node --unhandled-rejections=strict test/test.js",
1312
"ftest": "cross-env BROWSER=firefox node --unhandled-rejections=strict test/test.js",

test/fixtures.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ async function testSignal(state, action, exitOnClose) {
2626
handleSIGHUP: true,
2727
executablePath: state.browserType.executablePath(),
2828
});
29-
const res = spawn('node', [path.join(__dirname, 'fixtures', 'closeme.js'), state.playwrightPath, state.browserType.name(), JSON.stringify(options), exitOnClose ? 'true' : '']);
29+
const res = spawn('node', [path.join(__dirname, 'fixtures', 'closeme.js'), path.join(state.playwrightPath, 'index-for-dev'), state.browserType.name(), JSON.stringify(options), exitOnClose ? 'true' : '']);
3030
let wsEndPointCallback;
3131
const wsEndPointPromise = new Promise(x => wsEndPointCallback = x);
3232
let output = '';

test/fixtures/closeme.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
(async() => {
2-
const [, , playwrightRoot, browserType, options, exitOnClose] = process.argv;
3-
const browserServer = await require(playwrightRoot)[browserType].launchServer(JSON.parse(options));
2+
const [, , playwrightIndex, browserType, options, exitOnClose] = process.argv;
3+
const browserServer = await require(playwrightIndex)[browserType].launchServer(JSON.parse(options));
44
browserServer.on('close', (exitCode, signal) => {
55
console.log(`browserClose:${exitCode}:${signal}:browserClose`);
66
if (exitOnClose)

test/test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
*/
1717

1818
const fs = require('fs');
19+
const path = require('path');
1920
const TestRunner = require('../utils/testrunner/');
2021
const {Environment} = require('../utils/testrunner/Test');
2122

@@ -72,7 +73,7 @@ function collect(browserNames) {
7273

7374
// TODO: this should be a preinstalled playwright by default.
7475
const playwrightPath = config.playwrightPath;
75-
const playwright = require(playwrightPath);
76+
const playwright = require(path.join(playwrightPath, 'index-for-dev'));
7677
const { setUnderTest } = require(require('path').join(playwrightPath, 'lib/helper.js'));
7778
setUnderTest();
7879

test/types.d.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ interface TestSetup<STATE> {
4848
MAC: boolean;
4949
LINUX: boolean;
5050
WIN: boolean;
51-
playwright: typeof import('../index');
52-
browserType: import('../index').BrowserType<import('../index').Browser>;
51+
playwright: typeof import('../index-for-dev');
52+
browserType: import('../index-for-dev').BrowserType<import('../index-for-dev').Browser>;
5353
selectors: import('../src/selectors').Selectors;
5454
expect<T>(value: T): Expect<T>;
5555
defaultBrowserOptions: import('../src/server/browserType').LaunchOptions;
@@ -65,16 +65,16 @@ type TestState = {
6565
};
6666

6767
type BrowserState = TestState & {
68-
browser: import('../index').Browser;
69-
browserServer: import('../index').BrowserServer;
68+
browser: import('../index-for-dev').Browser;
69+
browserServer: import('../index-for-dev').BrowserServer;
7070
};
7171

7272
type PageState = BrowserState & {
73-
context: import('../index').BrowserContext;
74-
page: import('../index').Page;
73+
context: import('../index-for-dev').BrowserContext;
74+
page: import('../index-for-dev').Page;
7575
};
7676
type ChromiumPageState = PageState & {
77-
browser: import('../index').ChromiumBrowser;
77+
browser: import('../index-for-dev').ChromiumBrowser;
7878
};
7979
type TestSuite = (setup: TestSetup<TestState>) => void;
8080
type BrowserTestSuite = (setup: TestSetup<BrowserState>) => void;

utils/doclint/check_public_api/test/test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616

1717
const path = require('path');
18-
const playwright = require('../../../..');
18+
const playwright = require('../../../../index-for-dev');
1919
const checkPublicAPI = require('..');
2020
const Source = require('../../Source');
2121
const mdBuilder = require('../MDBuilder');

utils/doclint/cli.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* limitations under the License.
1616
*/
1717

18-
const playwright = require('../../index.js');
18+
const playwright = require('../../index-for-dev');
1919
const path = require('path');
2020
const Source = require('./Source');
2121
const Message = require('./Message');

0 commit comments

Comments
 (0)