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

fix: deprecate configuration via package.json #12176

Merged
merged 1 commit into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 7 additions & 3 deletions docs/guides/configuration.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ Puppeteer will look up the file tree for any of the following formats:
- `puppeteer.config.js`, and
- `puppeteer.config.cjs`

Puppeteer will also read a `puppeteer` key from your application's
`package.json`.

See the [`Configuration`](../api/puppeteer.configuration) interface for possible
options.

Expand All @@ -49,6 +46,13 @@ After adding a configuration file, you may need to remove and reinstall

:::

:::caution

Previous versions of Puppeteer allowed configuration via the `config` key in
`package.json`. This behavior is now deprecated and will be removed in the future.

:::

### Examples

#### Changing the default cache directory
Expand Down
11 changes: 11 additions & 0 deletions packages/puppeteer/src/getConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,17 @@ export const getConfiguration = (): Configuration => {
downloadHost;
}

if (
Object.keys(process.env).some(key => {
return key.startsWith('npm_package_config_puppeteer_');
}) &&
configuration.logLevel === 'warn'
) {
console.warn(
`Configuring Puppeteer via npm/package.json is deprecated. Use https://pptr.dev/guides/configuration instead.`
);
}

configuration.cacheDirectory =
process.env['PUPPETEER_CACHE_DIR'] ??
process.env['npm_config_puppeteer_cache_dir'] ??
Expand Down