@@ -18,10 +18,8 @@ import picomatch from 'next/dist/compiled/picomatch'
18
18
import { getModuleBuildInfo } from '../loaders/get-module-build-info'
19
19
import { getPageFilePath } from '../../entries'
20
20
import { resolveExternal } from '../../handle-externals'
21
- import swcLoader , { type SWCLoaderOptions } from '../loaders/next-swc-loader'
22
21
import { isMetadataRouteFile } from '../../../lib/metadata/is-metadata-route'
23
22
import { getCompilationSpan } from '../utils'
24
- import { isClientComponentEntryModule } from '../loaders/utils'
25
23
26
24
const PLUGIN_NAME = 'TraceEntryPointsPlugin'
27
25
export const TRACE_IGNORES = [
@@ -139,10 +137,6 @@ export class TraceEntryPointsPlugin implements webpack.WebpackPluginInstance {
139
137
private traceIgnores : string [ ]
140
138
private esmExternals ?: NextConfigComplete [ 'experimental' ] [ 'esmExternals' ]
141
139
private compilerType : CompilerNameValues
142
- private swcLoaderConfig : {
143
- loader : string
144
- options : Partial < SWCLoaderOptions >
145
- }
146
140
147
141
constructor ( {
148
142
rootDir,
@@ -153,7 +147,6 @@ export class TraceEntryPointsPlugin implements webpack.WebpackPluginInstance {
153
147
traceIgnores,
154
148
esmExternals,
155
149
outputFileTracingRoot,
156
- swcLoaderConfig,
157
150
} : {
158
151
rootDir : string
159
152
compilerType : CompilerNameValues
@@ -163,7 +156,6 @@ export class TraceEntryPointsPlugin implements webpack.WebpackPluginInstance {
163
156
traceIgnores ?: string [ ]
164
157
outputFileTracingRoot ?: string
165
158
esmExternals ?: NextConfigComplete [ 'experimental' ] [ 'esmExternals' ]
166
- swcLoaderConfig : TraceEntryPointsPlugin [ 'swcLoaderConfig' ]
167
159
} ) {
168
160
this . rootDir = rootDir
169
161
this . appDir = appDir
@@ -174,7 +166,6 @@ export class TraceEntryPointsPlugin implements webpack.WebpackPluginInstance {
174
166
this . traceIgnores = traceIgnores || [ ]
175
167
this . tracingRoot = outputFileTracingRoot || rootDir
176
168
this . compilerType = compilerType
177
- this . swcLoaderConfig = swcLoaderConfig
178
169
}
179
170
180
171
// Here we output all traced assets and webpack chunks to a
@@ -409,18 +400,6 @@ export class TraceEntryPointsPlugin implements webpack.WebpackPluginInstance {
409
400
}
410
401
} )
411
402
412
- const readOriginalSource = ( path : string ) => {
413
- return new Promise < string | Buffer > ( ( resolve ) => {
414
- compilation . inputFileSystem . readFile ( path , ( err , result ) => {
415
- if ( err ) {
416
- // we can't throw here as that crashes build un-necessarily
417
- return resolve ( '' )
418
- }
419
- resolve ( result || '' )
420
- } )
421
- } )
422
- }
423
-
424
403
const readFile = async (
425
404
path : string
426
405
) : Promise < Buffer | string | null > => {
@@ -429,60 +408,6 @@ export class TraceEntryPointsPlugin implements webpack.WebpackPluginInstance {
429
408
// map the transpiled source when available to avoid
430
409
// parse errors in node-file-trace
431
410
let source : Buffer | string = mod ?. originalSource ?.( ) ?. buffer ( )
432
-
433
- try {
434
- // fallback to reading raw source file, this may fail
435
- // due to unsupported syntax but best effort attempt
436
- let usingOriginalSource = false
437
- if ( ! source || isClientComponentEntryModule ( mod ) ) {
438
- source = await readOriginalSource ( path )
439
- usingOriginalSource = true
440
- }
441
- const sourceString = source . toString ( )
442
-
443
- // If this is a client component we need to trace the
444
- // original transpiled source not the client proxy which is
445
- // applied before this plugin is run due to the
446
- // client-module-loader
447
- if (
448
- usingOriginalSource &&
449
- // don't attempt transpiling CSS or image imports
450
- path . match ( / \. ( t s x | t s | j s | c j s | m j s | j s x ) $ / )
451
- ) {
452
- let transformResolve : ( result : string ) => void
453
- let transformReject : ( error : unknown ) => void
454
- const transformPromise = new Promise < string > (
455
- ( resolve , reject ) => {
456
- transformResolve = resolve
457
- transformReject = reject
458
- }
459
- )
460
-
461
- // TODO: should we apply all loaders except the
462
- // client-module-loader?
463
- swcLoader . apply (
464
- {
465
- resourcePath : path ,
466
- getOptions : ( ) => {
467
- return this . swcLoaderConfig . options
468
- } ,
469
- async : ( ) => {
470
- return ( err : unknown , result : string ) => {
471
- if ( err ) {
472
- return transformReject ( err )
473
- }
474
- return transformResolve ( result )
475
- }
476
- } ,
477
- } ,
478
- [ sourceString , undefined ]
479
- )
480
- source = await transformPromise
481
- }
482
- } catch {
483
- /* non-fatal */
484
- }
485
-
486
411
return source || ''
487
412
}
488
413
0 commit comments