Skip to content

Commit

Permalink
Add logging when a custom babelrc is loaded (#26570)
Browse files Browse the repository at this point in the history
Partially solves #26539 by adding back the log output when a config file is used



## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.

## Documentation / Examples

- [ ] Make sure the linting passes
  • Loading branch information
timneutkens committed Jun 24, 2021
1 parent 650ebed commit 77895fd
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions packages/next/build/babel/loader/get-config.ts
Expand Up @@ -6,6 +6,7 @@ import loadConfig from 'next/dist/compiled/babel/core-lib-config'

import { NextBabelLoaderOptions, NextJsLoaderContext } from './types'
import { consumeIterator } from './util'
import * as Log from '../../output/log'

const nextDistPath = /(next[\\/]dist[\\/]next-server[\\/]lib)|(next[\\/]dist[\\/]client)|(next[\\/]dist[\\/]pages)/

Expand Down Expand Up @@ -181,11 +182,6 @@ function getFreshConfig(
configFile,
} = loaderOptions

// Ensures webpack invalidates the cache for this loader when the config file changes
if (configFile) {
this.addDependency(configFile)
}

let customConfig: any = configFile
? getCustomBabelConfig(configFile)
: undefined
Expand Down Expand Up @@ -329,6 +325,11 @@ export default function getConfig(
filename
)

if (loaderOptions.configFile) {
// Ensures webpack invalidates the cache for this loader when the config file changes
this.addDependency(loaderOptions.configFile)
}

const cacheKey = getCacheKey(cacheCharacteristics)
if (configCache.has(cacheKey)) {
const cachedConfig = configCache.get(cacheKey)
Expand All @@ -345,6 +346,12 @@ export default function getConfig(
}
}

if (loaderOptions.configFile) {
Log.info(
`Using external babel configuration from ${loaderOptions.configFile}`
)
}

const freshConfig = getFreshConfig.call(
this,
cacheCharacteristics,
Expand Down

0 comments on commit 77895fd

Please sign in to comment.