Skip to content

NextjsParser

reference
1 min readUpdated

Kind: Class

Source: atloria-monorepo/libs/parser-core/src/parsers/frontend/nextjs.parser.ts

Next.js Parser

Pure TypeScript class that extends ReactParser to add Next.js-specific features. No NestJS dependencies required.

Extends: ReactParser

Methods

MethodSignatureReturns
parseFileparseFile(filePath: string, content: string)Promise<ParseResult>

Properties

PropertyType
namestring
versionstring
supportedPatternsstring[]

Where it refuses work

  • NextjsParser stops the work with an early return when this.isRouteHandler(filePath).
  • NextjsParser stops the work with an early return when !content.trim().
  • NextjsParser stops the work with an early return when route === '/'.
  • NextjsParser stops the work with an early return when /\/app\/page\.(tsx|jsx|ts|js)$/.test(filePath).
  • NextjsParser stops the work with an early return when route === 'index'.
  • NextjsParser stops the work with an early return when match.

When something fails

  • NextjsParser handles failure in 2 places: it turns it into a return value in 1, and discards it silently in 1. A failure discarded silently leaves no trace for whoever debugs this later.

Was this page helpful?

Download as PDF