Skip to content

Commit

Permalink
Disable babel if not required
Browse files Browse the repository at this point in the history
  • Loading branch information
kdy1 committed Feb 5, 2025
1 parent 5391ca6 commit 5d94226
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
7 changes: 7 additions & 0 deletions packages/next/src/build/babel/loader/get-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,10 @@ function getFreshConfig(
}

if (loaderOptions.transformMode === 'standalone') {
if (!reactCompilerPluginsIfEnabled.length) {
return null
}

options.plugins = [jsx, ...reactCompilerPluginsIfEnabled]
options.presets = [
[
Expand Down Expand Up @@ -462,6 +466,9 @@ export default function getConfig(
const cacheKey = getCacheKey(cacheCharacteristics)
if (configCache.has(cacheKey)) {
const cachedConfig = configCache.get(cacheKey)
if (!cachedConfig) {
return null
}

return {
...cachedConfig,
Expand Down
3 changes: 3 additions & 0 deletions packages/next/src/build/babel/loader/transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ export default function transform(
target,
filename,
})
if (!babelConfig) {
return { code: source, map: inputSourceMap }
}
getConfigSpan.stop()

const normalizeSpan = parentSpan.traceChild('babel-turbo-normalize-file')
Expand Down

0 comments on commit 5d94226

Please sign in to comment.