Skip to content

Commit

Permalink
refactor(swc/trace): simplify config
Browse files Browse the repository at this point in the history
  • Loading branch information
kwonoj committed Apr 21, 2022
1 parent 1eb5446 commit 48ba33c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
13 changes: 6 additions & 7 deletions packages/next/build/webpack-config.ts
Expand Up @@ -457,20 +457,19 @@ export default async function getBaseWebpackConfig(
const getBabelOrSwcLoader = (isMiddleware: boolean, buildDir: string) => {
if (
useSWCLoader &&
config?.experimental?.swcTraceProfiling?.enabled &&
config?.experimental?.swcTraceProfiling &&
!swcTraceFlushGuard
) {
// This will init subscribers once only in a single process lifecycle,
// even though it can be called multiple times.
// Subscriber need to be initialized _before_ any actual swc's call (transform, etcs)
// to collect correct trace spans when they are called.
swcTraceFlushGuard = require('./swc')?.initCustomTraceSubscriber?.(
config?.experimental?.swcTraceProfiling?.traceFileName ??
path.join(
buildDir,
config.distDir,
`swc-trace-profile-${Date.now()}.json`
)
path.join(
buildDir,
config.distDir,
`swc-trace-profile-${Date.now()}.json`
)
)
}

Expand Down
5 changes: 1 addition & 4 deletions packages/next/server/config-shared.ts
Expand Up @@ -128,10 +128,7 @@ export interface ExperimentalConfig {
skipDefaultConversion?: boolean
}
>
swcTraceProfiling?: {
enabled: boolean
traceFileName?: string
}
swcTraceProfiling?: boolean
}

/**
Expand Down

0 comments on commit 48ba33c

Please sign in to comment.