Skip to content

Commit

Permalink
fix: deprecate configuration via package.json (#12176)
Browse files Browse the repository at this point in the history
  • Loading branch information
OrKoN committed Apr 2, 2024
1 parent 308bc8d commit c96c762
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
10 changes: 7 additions & 3 deletions docs/guides/configuration.mdx
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
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

0 comments on commit c96c762

Please sign in to comment.