Skip to content
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

Add event for webpack 5 usage #24222

Merged
merged 5 commits into from
Apr 20, 2021
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
2 changes: 2 additions & 0 deletions packages/next/build/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ import getBaseWebpackConfig from './webpack-config'
import { PagesManifest } from './webpack/plugins/pages-manifest-plugin'
import { writeBuildId } from './write-build-id'
import { normalizeLocalePath } from '../next-server/lib/i18n/normalize-locale-path'
import { isWebpack5 } from 'next/dist/compiled/webpack/webpack'

const staticCheckWorker = require.resolve('./utils')

Expand Down Expand Up @@ -169,6 +170,7 @@ export default async function build(

telemetry.record(
eventCliSession(PHASE_PRODUCTION_BUILD, dir, {
webpackVersion: isWebpack5 ? 5 : 4,
cliCommand: 'build',
isSrcDir: path.relative(dir, pagesDir!).startsWith('src'),
hasNowJson: !!(await findUp('now.json', { cwd: dir })),
Expand Down
1 change: 1 addition & 0 deletions packages/next/export/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ export default async function exportApp(
if (telemetry) {
telemetry.record(
eventCliSession(PHASE_EXPORT, distDir, {
webpackVersion: null,
cliCommand: 'export',
isSrcDir: null,
hasNowJson: !!(await findUp('now.json', { cwd: dir })),
Expand Down
2 changes: 2 additions & 0 deletions packages/next/server/hot-reloader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ export default class HotReloader {
private previewProps: __ApiPreviewProps
private watcher: any
private rewrites: CustomRoutes['rewrites']
public isWebpack5: any

constructor(
dir: string,
Expand Down Expand Up @@ -173,6 +174,7 @@ export default class HotReloader {
this.config = config
this.previewProps = previewProps
this.rewrites = rewrites
this.isWebpack5 = isWebpack5
}

public async run(
Expand Down
1 change: 1 addition & 0 deletions packages/next/server/next-dev-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ export default class DevServer extends Server {
const telemetry = new Telemetry({ distDir: this.distDir })
telemetry.record(
eventCliSession(PHASE_DEVELOPMENT_SERVER, this.distDir, {
webpackVersion: this.hotReloader.isWebpack5 ? 5 : 4,
cliCommand: 'dev',
isSrcDir: relative(this.dir, this.pagesDir!).startsWith('src'),
hasNowJson: !!(await findUp('now.json', { cwd: this.dir })),
Expand Down
2 changes: 2 additions & 0 deletions packages/next/telemetry/events/version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ type EventCliSessionStarted = {
imageLoader: string | null
trailingSlashEnabled: boolean
reactStrictMode: boolean
webpackVersion: number | null
}

function hasBabelConfig(dir: string): boolean {
Expand Down Expand Up @@ -138,6 +139,7 @@ export function eventCliSession(
imageLoader: images?.loader,
trailingSlashEnabled: !!userConfiguration?.trailingSlash,
reactStrictMode: !!userConfiguration?.reactStrictMode,
webpackVersion: event.webpackVersion || null,
}
return [{ eventName: EVENT_VERSION, payload }]
}