Unverified Commit 8d84b087 authored by Tim Neutkens's avatar Tim Neutkens Committed by GitHub

Add event for webpack 5 usage (#24222)

parent 239e033b
...@@ -90,6 +90,7 @@ import getBaseWebpackConfig from './webpack-config' ...@@ -90,6 +90,7 @@ import getBaseWebpackConfig from './webpack-config'
import { PagesManifest } from './webpack/plugins/pages-manifest-plugin' import { PagesManifest } from './webpack/plugins/pages-manifest-plugin'
import { writeBuildId } from './write-build-id' import { writeBuildId } from './write-build-id'
import { normalizeLocalePath } from '../next-server/lib/i18n/normalize-locale-path' import { normalizeLocalePath } from '../next-server/lib/i18n/normalize-locale-path'
import { isWebpack5 } from 'next/dist/compiled/webpack/webpack'
const staticCheckWorker = require.resolve('./utils') const staticCheckWorker = require.resolve('./utils')
...@@ -169,6 +170,7 @@ export default async function build( ...@@ -169,6 +170,7 @@ export default async function build(
telemetry.record( telemetry.record(
eventCliSession(PHASE_PRODUCTION_BUILD, dir, { eventCliSession(PHASE_PRODUCTION_BUILD, dir, {
webpackVersion: isWebpack5 ? 5 : 4,
cliCommand: 'build', cliCommand: 'build',
isSrcDir: path.relative(dir, pagesDir!).startsWith('src'), isSrcDir: path.relative(dir, pagesDir!).startsWith('src'),
hasNowJson: !!(await findUp('now.json', { cwd: dir })), hasNowJson: !!(await findUp('now.json', { cwd: dir })),
......
...@@ -161,6 +161,7 @@ export default async function exportApp( ...@@ -161,6 +161,7 @@ export default async function exportApp(
if (telemetry) { if (telemetry) {
telemetry.record( telemetry.record(
eventCliSession(PHASE_EXPORT, distDir, { eventCliSession(PHASE_EXPORT, distDir, {
webpackVersion: null,
cliCommand: 'export', cliCommand: 'export',
isSrcDir: null, isSrcDir: null,
hasNowJson: !!(await findUp('now.json', { cwd: dir })), hasNowJson: !!(await findUp('now.json', { cwd: dir })),
......
...@@ -144,6 +144,7 @@ export default class HotReloader { ...@@ -144,6 +144,7 @@ export default class HotReloader {
private previewProps: __ApiPreviewProps private previewProps: __ApiPreviewProps
private watcher: any private watcher: any
private rewrites: CustomRoutes['rewrites'] private rewrites: CustomRoutes['rewrites']
public isWebpack5: any
constructor( constructor(
dir: string, dir: string,
...@@ -173,6 +174,7 @@ export default class HotReloader { ...@@ -173,6 +174,7 @@ export default class HotReloader {
this.config = config this.config = config
this.previewProps = previewProps this.previewProps = previewProps
this.rewrites = rewrites this.rewrites = rewrites
this.isWebpack5 = isWebpack5
} }
public async run( public async run(
......
...@@ -308,6 +308,7 @@ export default class DevServer extends Server { ...@@ -308,6 +308,7 @@ export default class DevServer extends Server {
const telemetry = new Telemetry({ distDir: this.distDir }) const telemetry = new Telemetry({ distDir: this.distDir })
telemetry.record( telemetry.record(
eventCliSession(PHASE_DEVELOPMENT_SERVER, this.distDir, { eventCliSession(PHASE_DEVELOPMENT_SERVER, this.distDir, {
webpackVersion: this.hotReloader.isWebpack5 ? 5 : 4,
cliCommand: 'dev', cliCommand: 'dev',
isSrcDir: relative(this.dir, this.pagesDir!).startsWith('src'), isSrcDir: relative(this.dir, this.pagesDir!).startsWith('src'),
hasNowJson: !!(await findUp('now.json', { cwd: this.dir })), hasNowJson: !!(await findUp('now.json', { cwd: this.dir })),
......
...@@ -32,6 +32,7 @@ type EventCliSessionStarted = { ...@@ -32,6 +32,7 @@ type EventCliSessionStarted = {
imageLoader: string | null imageLoader: string | null
trailingSlashEnabled: boolean trailingSlashEnabled: boolean
reactStrictMode: boolean reactStrictMode: boolean
webpackVersion: number | null
} }
function hasBabelConfig(dir: string): boolean { function hasBabelConfig(dir: string): boolean {
...@@ -138,6 +139,7 @@ export function eventCliSession( ...@@ -138,6 +139,7 @@ export function eventCliSession(
imageLoader: images?.loader, imageLoader: images?.loader,
trailingSlashEnabled: !!userConfiguration?.trailingSlash, trailingSlashEnabled: !!userConfiguration?.trailingSlash,
reactStrictMode: !!userConfiguration?.reactStrictMode, reactStrictMode: !!userConfiguration?.reactStrictMode,
webpackVersion: event.webpackVersion || null,
} }
return [{ eventName: EVENT_VERSION, payload }] return [{ eventName: EVENT_VERSION, payload }]
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment