Skip to content

Revert "Fix tracing of server actions imported by client components (#78968) #82161

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

Merged
merged 2 commits into from
Jul 29, 2025
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion packages/next/src/build/webpack-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2036,7 +2036,6 @@ export default async function getBaseWebpackConfig(
appDirEnabled: hasAppDir,
traceIgnores: [],
compilerType,
swcLoaderConfig: swcDefaultLoader,
}
),
// Moment.js is an extremely popular library that bundles large locale files
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,8 @@ import picomatch from 'next/dist/compiled/picomatch'
import { getModuleBuildInfo } from '../loaders/get-module-build-info'
import { getPageFilePath } from '../../entries'
import { resolveExternal } from '../../handle-externals'
import swcLoader, { type SWCLoaderOptions } from '../loaders/next-swc-loader'
import { isMetadataRouteFile } from '../../../lib/metadata/is-metadata-route'
import { getCompilationSpan } from '../utils'
import { isClientComponentEntryModule } from '../loaders/utils'

const PLUGIN_NAME = 'TraceEntryPointsPlugin'
export const TRACE_IGNORES = [
Expand Down Expand Up @@ -139,10 +137,6 @@ export class TraceEntryPointsPlugin implements webpack.WebpackPluginInstance {
private traceIgnores: string[]
private esmExternals?: NextConfigComplete['experimental']['esmExternals']
private compilerType: CompilerNameValues
private swcLoaderConfig: {
loader: string
options: Partial<SWCLoaderOptions>
}

constructor({
rootDir,
Expand All @@ -153,7 +147,6 @@ export class TraceEntryPointsPlugin implements webpack.WebpackPluginInstance {
traceIgnores,
esmExternals,
outputFileTracingRoot,
swcLoaderConfig,
}: {
rootDir: string
compilerType: CompilerNameValues
Expand All @@ -163,7 +156,6 @@ export class TraceEntryPointsPlugin implements webpack.WebpackPluginInstance {
traceIgnores?: string[]
outputFileTracingRoot?: string
esmExternals?: NextConfigComplete['experimental']['esmExternals']
swcLoaderConfig: TraceEntryPointsPlugin['swcLoaderConfig']
}) {
this.rootDir = rootDir
this.appDir = appDir
Expand All @@ -174,7 +166,6 @@ export class TraceEntryPointsPlugin implements webpack.WebpackPluginInstance {
this.traceIgnores = traceIgnores || []
this.tracingRoot = outputFileTracingRoot || rootDir
this.compilerType = compilerType
this.swcLoaderConfig = swcLoaderConfig
}

// Here we output all traced assets and webpack chunks to a
Expand Down Expand Up @@ -409,18 +400,6 @@ export class TraceEntryPointsPlugin implements webpack.WebpackPluginInstance {
}
})

const readOriginalSource = (path: string) => {
return new Promise<string | Buffer>((resolve) => {
compilation.inputFileSystem.readFile(path, (err, result) => {
if (err) {
// we can't throw here as that crashes build un-necessarily
return resolve('')
}
resolve(result || '')
})
})
}

const readFile = async (
path: string
): Promise<Buffer | string | null> => {
Expand All @@ -429,60 +408,6 @@ export class TraceEntryPointsPlugin implements webpack.WebpackPluginInstance {
// map the transpiled source when available to avoid
// parse errors in node-file-trace
let source: Buffer | string = mod?.originalSource?.()?.buffer()

try {
// fallback to reading raw source file, this may fail
// due to unsupported syntax but best effort attempt
let usingOriginalSource = false
if (!source || isClientComponentEntryModule(mod)) {
source = await readOriginalSource(path)
usingOriginalSource = true
}
const sourceString = source.toString()

// If this is a client component we need to trace the
// original transpiled source not the client proxy which is
// applied before this plugin is run due to the
// client-module-loader
if (
usingOriginalSource &&
// don't attempt transpiling CSS or image imports
path.match(/\.(tsx|ts|js|cjs|mjs|jsx)$/)
) {
let transformResolve: (result: string) => void
let transformReject: (error: unknown) => void
const transformPromise = new Promise<string>(
(resolve, reject) => {
transformResolve = resolve
transformReject = reject
}
)

// TODO: should we apply all loaders except the
// client-module-loader?
swcLoader.apply(
{
resourcePath: path,
getOptions: () => {
return this.swcLoaderConfig.options
},
async: () => {
return (err: unknown, result: string) => {
if (err) {
return transformReject(err)
}
return transformResolve(result)
}
},
},
[sourceString, undefined]
)
source = await transformPromise
}
} catch {
/* non-fatal */
}

return source || ''
}

Expand Down
19 changes: 0 additions & 19 deletions test/production/app-dir/action-tracing/action-tracing.test.ts

This file was deleted.

14 changes: 0 additions & 14 deletions test/production/app-dir/action-tracing/app/action.ts

This file was deleted.

8 changes: 0 additions & 8 deletions test/production/app-dir/action-tracing/app/layout.tsx

This file was deleted.

15 changes: 0 additions & 15 deletions test/production/app-dir/action-tracing/app/page.tsx

This file was deleted.

1 change: 0 additions & 1 deletion test/production/app-dir/action-tracing/data.txt

This file was deleted.

6 changes: 0 additions & 6 deletions test/production/app-dir/action-tracing/next.config.js

This file was deleted.

Loading