diff --git a/docs/advanced-features/compiler.md b/docs/advanced-features/compiler.md index 1b8bab1d62d4a6..d22570a5360b69 100644 --- a/docs/advanced-features/compiler.md +++ b/docs/advanced-features/compiler.md @@ -154,7 +154,7 @@ First, update to the latest version of Next.js: `npm install next@latest`. Then, ```js { "compilerOptions": { - "jsxImportSource": true + "jsxImportSource": 'preact' } } ``` diff --git a/packages/next/build/webpack-config.ts b/packages/next/build/webpack-config.ts index 1e59408578e68e..88c89f4c2189ae 100644 --- a/packages/next/build/webpack-config.ts +++ b/packages/next/build/webpack-config.ts @@ -1519,10 +1519,16 @@ export default async function getBaseWebpackConfig( ['swcMinify', config.swcMinify], ['swcRelay', !!config.compiler?.relay], ['swcStyledComponents', !!config.compiler?.styledComponents], - ['swcReactRemoveProperties', !!config.reactRemoveProperties], - ['swcExperimentalDecorators', !!config.experimentalDecorators], - ['swcRemoveConsole', !!config.removeConsole], - ['swcImportSource', !!config.importSource], + [ + 'swcReactRemoveProperties', + !!config.compiler?.reactRemoveProperties, + ], + [ + 'swcExperimentalDecorators', + !!jsConfig?.compilerOptions?.experimentalDecorators, + ], + ['swcRemoveConsole', !!config.compiler?.removeConsole], + ['swcImportSource', !!jsConfig.compilerOptions?.jsxImportSource], ]) ), ].filter(Boolean as any as ExcludesFalse), diff --git a/packages/next/build/webpack/plugins/telemetry-plugin.ts b/packages/next/build/webpack/plugins/telemetry-plugin.ts index 86269e8de8ab59..1243fc56358438 100644 --- a/packages/next/build/webpack/plugins/telemetry-plugin.ts +++ b/packages/next/build/webpack/plugins/telemetry-plugin.ts @@ -44,6 +44,7 @@ const FEATURE_MODULE_MAP: ReadonlyMap = new Map([ const BUILD_FEATURES: Array = [ 'swcLoader', 'swcMinify', + 'swcRelay', 'swcStyledComponents', 'swcReactRemoveProperties', 'swcExperimentalDecorators', @@ -62,6 +63,7 @@ export class TelemetryPlugin implements webpack.WebpackPluginInstance { // Build feature usage is on/off and is known before the build starts constructor(buildFeaturesMap: Map) { for (const featureName of BUILD_FEATURES) { + console.error('FEATURES MAP', buildFeaturesMap) this.usageTracker.set(featureName, { featureName, invocationCount: buildFeaturesMap.get(featureName) ? 1 : 0, diff --git a/test/integration/telemetry/test/index.test.js b/test/integration/telemetry/test/index.test.js index a3b1884765cfb9..478ed10bd10447 100644 --- a/test/integration/telemetry/test/index.test.js +++ b/test/integration/telemetry/test/index.test.js @@ -621,6 +621,12 @@ describe('Telemetry CLI', () => { expect(optimizeFonts).toContain(`"invocationCount": 1`) regex.exec(stderr).pop() // swcLoader regex.exec(stderr).pop() // swcMinify + regex.exec(stderr).pop() // swcRelay + regex.exec(stderr).pop() // swcStyledComponents + regex.exec(stderr).pop() // swcExperimentalDecorators + regex.exec(stderr).pop() // swcReactRemoveProperties + regex.exec(stderr).pop() // swcRemoveConsole + regex.exec(stderr).pop() // swcImportSource const image = regex.exec(stderr).pop() expect(image).toContain(`"featureName": "next/image"`) expect(image).toContain(`"invocationCount": 1`) @@ -647,6 +653,8 @@ describe('Telemetry CLI', () => { path.join(appDir, 'jsconfig.json') ) + console.log('STDERR', stderr) + const regex = /NEXT_BUILD_FEATURE_USAGE[\s\S]+?{([\s\S]+?)}/g regex.exec(stderr).pop() // optimizeCss regex.exec(stderr).pop() // build-lint @@ -656,7 +664,7 @@ describe('Telemetry CLI', () => { expect(swcLoader).toContain(`"invocationCount": 1`) const swcMinify = regex.exec(stderr).pop() expect(swcMinify).toContain(`"featureName": "swcMinify"`) - //expect(swcMinify).toContain(`"invocationCount": 1`) + expect(swcMinify).toContain(`"invocationCount": 1`) const swcRelay = regex.exec(stderr).pop() expect(swcRelay).toContain(`"featureName": "swcRelay"`) expect(swcRelay).toContain(`"invocationCount": 1`) @@ -680,7 +688,7 @@ describe('Telemetry CLI', () => { expect(swcRemoveConsole).toContain(`"invocationCount": 1`) const swcImportSource = regex.exec(stderr).pop() expect(swcImportSource).toContain(`"featureName": "swcImportSource"`) - expect(swcImportSource).toContain(`"invocationCount": 1`) + expect(swcImportSource).toContain(`"invocationCount": 0`) }) it('emits telemetry for usage of `optimizeCss`', async () => {