There are 3 ways to import `@playwright/test` library in the modern Node.js ecosystem: - Using `require`: works great, this patch doesn't change it - Using `import` statement from `.mjs` file - we have wrong `default` for @playwright/test that should be a `test`. This is what test checks for - Using `import test from '@playwright/test'` from `.ts` file - was broken because TypeScript thought it's a CJS module, whereas it's a ESM module in reality. Also, typescript types import from `.d.ts` file was broken because we had no default export (`export *` syntax does not export default). |
||
|---|---|---|
| .. | ||
| common | ||
| installation-tests | ||
| playwright-chromium | ||
| playwright-core | ||
| playwright-firefox | ||
| playwright-test | ||
| playwright-webkit | ||
| .gitignore | ||
| build_package.js | ||
| README.md | ||
Managing and Publishing Playwright Packages
Overview
- Playwright ships multiple packages to NPM. All packages that are published to NPM are listed as folders under
//packages/. - Playwright's root package.json is never published to NPM. It is only used for devmode, e.g. when running
npm installwith no arguments or installing from github. - Playwright dependencies for all packages are the same and are managed with the
root package.json. - Playwright browser versions for all packages are the same and are managed with the
browsers.json.
NOTE As of May 20, 2020, the only exception is the
playwright-electronpackage that doesn't follow the pack and is published manually. This is due to it's pre-1.0 status.
Building NPM package
To build a package that will be shipped to NPM, use //packages/build_package.js script.
The script populates package folder with contents, and then uses npm pack to archive the folder.
As of May 20, 2020, //packages/build_package.js does the following:
- copies certain files and folders from
playwright-internalto the subpackage (e.g.//lib,//types,//LICENSEetc) - generates
package.jsonand puts it in the subpackage - generates
browsers.jsonand puts it in the subpackage - uses
npm packto pack the subpackage folder - removes all the files that were added during the process
To build playwright package and save result as ./playwright.tgz file:
./packages/build_package.js playwright ./playwright.tgz
To debug what files are put into the folder, use --no-cleanup flag and inspect the package folder:
./packages/build_package.js playwright ./playwright.tgz --no-cleanup
ls ./packages/playwright # inspect the folder
Testing packages
To test packages, use //packages/installation-tests/installation-tests.sh.
Publishing packages
All package publishing happens exclusively over CI/CD using the //utils/publish_all_packages.sh script.