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

fix(perf): lazy load babel/code-frame #55024

Merged
merged 6 commits into from
Sep 6, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/next/src/lib/typescript/diagnosticFormatter.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { codeFrameColumns } from 'next/dist/compiled/babel/code-frame'
import chalk from 'next/dist/compiled/chalk'
import path from 'path'

Expand Down Expand Up @@ -369,6 +368,7 @@ export function getFormattedDiagnostic(
message += reason + '\n'

if (!isLayoutOrPageError && diagnostic.file) {
const { codeFrameColumns } = require('next/dist/compiled/babel/code-frame')
const pos = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start!)
const line = pos.line + 1
const character = pos.character + 1
Expand Down
4 changes: 3 additions & 1 deletion packages/next/src/server/lib/router-utils/setup-dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
} from '../../../build/swc'
import type { Socket } from 'net'
import ws from 'next/dist/compiled/ws'
import { codeFrameColumns } from 'next/dist/compiled/babel/code-frame'

import fs from 'fs'
import url from 'url'
Expand Down Expand Up @@ -237,6 +236,9 @@ async function startWatcher(opts: SetupOpts) {
start.column
} ${formattedTitle}`
if (source.source.content) {
const {
codeFrameColumns,
} = require('next/dist/compiled/babel/code-frame')
message +=
'\n\n' +
codeFrameColumns(
Expand Down