Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: make it possible to run install.js script with puppeteer-core #5325

Merged
merged 4 commits into from Jan 28, 2020
Merged

feat: make it possible to run install.js script with puppeteer-core #5325

merged 4 commits into from Jan 28, 2020

Conversation

gziolo
Copy link
Contributor

@gziolo gziolo commented Jan 20, 2020

Problem

At the moment, when you set puppeteer-core as a dependency of your project, you won't have Chromium installed as part of npm install run. This is great. However, the existing setup prevents 3rd party tools to run install.js script, which might be desired in some scenarios.

We see the growing number of complaints about Chromium download in @wordpress/scripts (A set of reusable scripts tailored for WordPress development) package which for many use cases is not necessary when you don’t want to use e2e tests. Some projects decide to not use this package because of the time and size factors introduced by the installation process of Chromium. We are seeking for a way to make it a non-issue. The idea is to use puppeteer-core and use install.js script only when someone opts-in for the e2e script and actually runs it.

Related Issues

Sharing some issues from the WordPress project, which triggered this proposal:

Solution

Update utils/prepare_puppeteer_core.js to remove install from script section package.json for puppeteer-core. This is nearly identical to the current configuration but opens install.js for usage from puppeteer-core. At the same time, it would become a public API, so the project would have to maintain it.

It will allow starting using puppeteer-core as a dependency in the @wordpress/scripts package intended to offer zero-config reusable scripts for WordPress development. This way, folks who don't use Puppeteer in their workflows won't complain about the install process of Chromium. Instead, it should be possible to install Chromium on demand, when the script which needs it would run for the first time. The update could run whenever the version changes as part of the regular run as well.

The only inconvenience would be that other dependency which set puppeteer as a peer dependency would warn. Still, it's something that can be ignored and listed in the docs in the troubleshooting section.

Open Question

Should the same change get applied to puppeteer-firefox? I see this guard clause:

if (require('./package.json').name === 'puppeteer-core')
return;

However, it's not clear for me how it would work with puppeteer-core.

docs/api.md Outdated Show resolved Hide resolved
Co-Authored-By: Mathias Bynens <mathias@qiwi.be>
@mathiasbynens
Copy link
Member

As you point out, this makes install.js a public API. Please add a comment to the top of install.js pointing this out. Other than that this LGTM. Thanks for the patch!

@gziolo
Copy link
Contributor Author

gziolo commented Jan 28, 2020

As you point out, this makes install.js a public API. Please add a comment to the top of install.js pointing this out.

Added with 601a571 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants