@@ -43,7 +43,11 @@ import { WellKnownErrorsPlugin } from './webpack/plugins/wellknown-errors-plugin
4343import { regexLikeCss } from './webpack/config/blocks/css'
4444import { CopyFilePlugin } from './webpack/plugins/copy-file-plugin'
4545import { FlightManifestPlugin } from './webpack/plugins/flight-manifest-plugin'
46- import { TelemetryPlugin } from './webpack/plugins/telemetry-plugin'
46+ import {
47+ Feature ,
48+ SWC_TARGET_TRIPLE ,
49+ TelemetryPlugin ,
50+ } from './webpack/plugins/telemetry-plugin'
4751import type { Span } from '../trace'
4852import { getRawPageExtensions } from './utils'
4953import browserslist from 'next/dist/compiled/browserslist'
@@ -406,6 +410,15 @@ export default async function getBaseWebpackConfig(
406410 const distDir = path . join ( dir , config . distDir )
407411
408412 let useSWCLoader = ! babelConfigFile
413+ let SWCBinaryTarget : [ Feature , boolean ] | undefined = undefined
414+ if ( useSWCLoader ) {
415+ // TODO: we do not collect wasm target yet
416+ const binaryTarget = require ( './swc' ) ?. getBinaryMetadata ?.( )
417+ ?. target as SWC_TARGET_TRIPLE
418+ SWCBinaryTarget = binaryTarget
419+ ? [ `swc/target/${ binaryTarget } ` as const , true ]
420+ : undefined
421+ }
409422
410423 if ( ! loggedSwcDisabled && ! useSWCLoader && babelConfigFile ) {
411424 Log . info (
@@ -1492,23 +1505,26 @@ export default async function getBaseWebpackConfig(
14921505 ! dev &&
14931506 ! isServer &&
14941507 new TelemetryPlugin (
1495- new Map ( [
1496- [ 'swcLoader' , useSWCLoader ] ,
1497- [ 'swcMinify' , config . swcMinify ] ,
1498- [ 'swcRelay' , ! ! config . compiler ?. relay ] ,
1499- [ 'swcStyledComponents' , ! ! config . compiler ?. styledComponents ] ,
1500- [
1501- 'swcReactRemoveProperties' ,
1502- ! ! config . compiler ?. reactRemoveProperties ,
1503- ] ,
1508+ new Map (
15041509 [
1505- 'swcExperimentalDecorators' ,
1506- ! ! jsConfig ?. compilerOptions ?. experimentalDecorators ,
1507- ] ,
1508- [ 'swcRemoveConsole' , ! ! config . compiler ?. removeConsole ] ,
1509- [ 'swcImportSource' , ! ! jsConfig ?. compilerOptions ?. jsxImportSource ] ,
1510- [ 'swcEmotion' , ! ! config . experimental . emotion ] ,
1511- ] )
1510+ [ 'swcLoader' , useSWCLoader ] ,
1511+ [ 'swcMinify' , config . swcMinify ] ,
1512+ [ 'swcRelay' , ! ! config . compiler ?. relay ] ,
1513+ [ 'swcStyledComponents' , ! ! config . compiler ?. styledComponents ] ,
1514+ [
1515+ 'swcReactRemoveProperties' ,
1516+ ! ! config . compiler ?. reactRemoveProperties ,
1517+ ] ,
1518+ [
1519+ 'swcExperimentalDecorators' ,
1520+ ! ! jsConfig ?. compilerOptions ?. experimentalDecorators ,
1521+ ] ,
1522+ [ 'swcRemoveConsole' , ! ! config . compiler ?. removeConsole ] ,
1523+ [ 'swcImportSource' , ! ! jsConfig ?. compilerOptions ?. jsxImportSource ] ,
1524+ [ 'swcEmotion' , ! ! config . experimental . emotion ] ,
1525+ SWCBinaryTarget ,
1526+ ] . filter < [ Feature , boolean ] > ( Boolean as any )
1527+ )
15121528 ) ,
15131529 ] . filter ( Boolean as any as ExcludesFalse ) ,
15141530 }
0 commit comments