fix(require): allow requiring internals (#3153)
This commit is contained in:
parent
3162c06f49
commit
6a4195fd1d
|
|
@ -124,8 +124,15 @@ if (!package) {
|
||||||
homepage: pwInternalJSON.homepage,
|
homepage: pwInternalJSON.homepage,
|
||||||
main: 'index.js',
|
main: 'index.js',
|
||||||
exports: {
|
exports: {
|
||||||
import: './index.mjs',
|
// Root import: we have a wrapper ES Module to support the following syntax.
|
||||||
require: './index.js',
|
// const { chromium } = require('playwright');
|
||||||
|
// import { chromium } from 'playwright';
|
||||||
|
'.': {
|
||||||
|
import: './index.mjs',
|
||||||
|
require: './index.js',
|
||||||
|
},
|
||||||
|
// Anything else can be required/imported by providing a relative path.
|
||||||
|
'./': './',
|
||||||
},
|
},
|
||||||
scripts: {
|
scripts: {
|
||||||
install: 'node install.js',
|
install: 'node install.js',
|
||||||
|
|
|
||||||
|
|
@ -16,10 +16,16 @@
|
||||||
|
|
||||||
import { chromium, selectors, devices, errors } from 'playwright-chromium';
|
import { chromium, selectors, devices, errors } from 'playwright-chromium';
|
||||||
import playwright from 'playwright-chromium';
|
import playwright from 'playwright-chromium';
|
||||||
|
import errorsFile from 'playwright-chromium/lib/errors.js';
|
||||||
|
|
||||||
if (playwright.chromium !== chromium)
|
if (playwright.chromium !== chromium)
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
|
|
||||||
|
if (playwright.errors !== errors)
|
||||||
|
process.exit(1);
|
||||||
|
if (errors.TimeoutError !== errorsFile.TimeoutError)
|
||||||
|
process.exit(1);
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
for (const browserType of [chromium]) {
|
for (const browserType of [chromium]) {
|
||||||
const browser = await browserType.launch();
|
const browser = await browserType.launch();
|
||||||
|
|
|
||||||
|
|
@ -16,10 +16,16 @@
|
||||||
|
|
||||||
import { firefox, selectors, devices, errors } from 'playwright-firefox';
|
import { firefox, selectors, devices, errors } from 'playwright-firefox';
|
||||||
import playwright from 'playwright-firefox';
|
import playwright from 'playwright-firefox';
|
||||||
|
import errorsFile from 'playwright-firefox/lib/errors.js';
|
||||||
|
|
||||||
if (playwright.firefox !== firefox)
|
if (playwright.firefox !== firefox)
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
|
|
||||||
|
if (playwright.errors !== errors)
|
||||||
|
process.exit(1);
|
||||||
|
if (errors.TimeoutError !== errorsFile.TimeoutError)
|
||||||
|
process.exit(1);
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
for (const browserType of [firefox]) {
|
for (const browserType of [firefox]) {
|
||||||
const browser = await browserType.launch();
|
const browser = await browserType.launch();
|
||||||
|
|
|
||||||
|
|
@ -16,10 +16,16 @@
|
||||||
|
|
||||||
import { webkit, selectors, devices, errors } from 'playwright-webkit';
|
import { webkit, selectors, devices, errors } from 'playwright-webkit';
|
||||||
import playwright from 'playwright-webkit';
|
import playwright from 'playwright-webkit';
|
||||||
|
import errorsFile from 'playwright-webkit/lib/errors.js';
|
||||||
|
|
||||||
if (playwright.webkit !== webkit)
|
if (playwright.webkit !== webkit)
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
|
|
||||||
|
if (playwright.errors !== errors)
|
||||||
|
process.exit(1);
|
||||||
|
if (errors.TimeoutError !== errorsFile.TimeoutError)
|
||||||
|
process.exit(1);
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
for (const browserType of [webkit]) {
|
for (const browserType of [webkit]) {
|
||||||
const browser = await browserType.launch();
|
const browser = await browserType.launch();
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
import { chromium, firefox, webkit, selectors, devices, errors } from 'playwright';
|
import { chromium, firefox, webkit, selectors, devices, errors } from 'playwright';
|
||||||
import playwright from 'playwright';
|
import playwright from 'playwright';
|
||||||
|
import errorsFile from 'playwright/lib/errors.js';
|
||||||
|
|
||||||
if (playwright.chromium !== chromium)
|
if (playwright.chromium !== chromium)
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
|
|
@ -24,6 +25,11 @@ if (playwright.firefox !== firefox)
|
||||||
if (playwright.webkit !== webkit)
|
if (playwright.webkit !== webkit)
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
|
|
||||||
|
if (playwright.errors !== errors)
|
||||||
|
process.exit(1);
|
||||||
|
if (errors.TimeoutError !== errorsFile.TimeoutError)
|
||||||
|
process.exit(1);
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
for (const browserType of [chromium, firefox, webkit]) {
|
for (const browserType of [chromium, firefox, webkit]) {
|
||||||
const browser = await browserType.launch();
|
const browser = await browserType.launch();
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,10 @@ const browsers = process.argv.slice(3);
|
||||||
|
|
||||||
const playwright = require(requireName);
|
const playwright = require(requireName);
|
||||||
|
|
||||||
|
// Requiring internals should work.
|
||||||
|
const errors = require(requireName + '/lib/errors');
|
||||||
|
const installer = require(requireName + '/lib/install/installer');
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
for (const browserType of browsers) {
|
for (const browserType of browsers) {
|
||||||
const browser = await playwright[browserType].launch();
|
const browser = await playwright[browserType].launch();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue