MCPcopy
hub / github.com/vercel/next.js / createParserFromPath

Function createParserFromPath

packages/next-codemod/lib/parser.ts:13–24  ·  view source on GitHub ↗
(filePath: string)

Source from the content-addressed store, hash-verified

11}
12
13function createParserFromPath(filePath: string): j.JSCodeshift {
14 const isDeclarationFile = /\.d\.(m|c)?ts$/.test(filePath)
15 if (isDeclarationFile) {
16 return j.withParser(babylonParse(dtsOptions))
17 }
18
19 // jsx is allowed in .js files, feed them into the tsx parser.
20 // tsx parser :.js, .jsx, .tsx
21 // ts parser: .ts, .mts, .cts
22 const isTsFile = /\.(m|c)?.ts$/.test(filePath)
23 return isTsFile ? j.withParser('ts') : j.withParser('tsx')
24}
25
26export { createParserFromPath }

Callers 15

transformerFunction · 0.90
transformerFunction · 0.90
transformerFunction · 0.90
transformerFunction · 0.90
transformerFunction · 0.90
transformerFunction · 0.90
transformerFunction · 0.90
transformerFunction · 0.90
transformerFunction · 0.90
transformerFunction · 0.90

Calls 1

testMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…