Skip to content

Commit 0653d03

Browse files
devjiwonchoiztanner
andcommitted
Refactor logging in TypeScript utils and metadata to remove redundant '[next]' prefix
Co-authored-by: Zack Tanner <[email protected]>
1 parent 6cdc85c commit 0653d03

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

packages/next/src/server/typescript/rules/metadata.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,13 @@ function updateVirtualFileWithType(
8787
TYPE_IMPORT
8888

8989
if (virtualTsEnv.sys.fileExists(fileName)) {
90-
log('[next] Updating file: ' + fileName)
90+
log('Updating file: ' + fileName)
9191
// FIXME: updateFile() breaks as the file doesn't exists, which is weird.
9292
// virtualTsEnv.updateFile(fileName, newSource)
9393
virtualTsEnv.deleteFile(fileName)
9494
virtualTsEnv.createFile(fileName, newSource)
9595
} else {
96-
log('[next] Creating file: ' + fileName)
96+
log('Creating file: ' + fileName)
9797
virtualTsEnv.createFile(fileName, newSource)
9898
}
9999

packages/next/src/server/typescript/utils.ts

+8-5
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ let appDirRegExp: RegExp
1616
export let virtualTsEnv: VirtualTypeScriptEnvironment
1717

1818
export function log(message: string) {
19-
info.project.projectService.logger.info(message)
19+
info.project.projectService.logger.info('[next] ' + message)
2020
}
2121

2222
// This function has to be called initially.
@@ -31,7 +31,7 @@ export function init(opts: {
3131
'^' + (projectDir + '(/src)?/app').replace(/[\\/]/g, '[\\/]')
3232
)
3333

34-
log('[next] Initializing Next.js TypeScript plugin: ' + projectDir)
34+
log('Initializing Next.js TypeScript plugin: ' + projectDir)
3535

3636
const compilerOptions = info.project.getCompilerOptions()
3737
const fsMap = createDefaultMapFromNodeModules(
@@ -48,11 +48,14 @@ export function init(opts: {
4848
compilerOptions
4949
)
5050

51-
if (!virtualTsEnv) {
52-
throw new Error('[next] Failed to create virtual TypeScript environment.')
51+
if (virtualTsEnv) {
52+
log(
53+
'Failed to create virtual TypeScript environment. This is a bug in Next.js TypeScript plugin. Please report it by opening an issue at https://github.com/vercel/next.js/issues.'
54+
)
55+
return
5356
}
5457

55-
log('[next] Successfully initialized Next.js TypeScript plugin!')
58+
log('Successfully initialized Next.js TypeScript plugin!')
5659
}
5760

5861
export function getTs() {

0 commit comments

Comments
 (0)