MCPcopy Create free account
hub / github.com/TanStack/router / getModuleErrors

Function getModuleErrors

packages/start-plugin-core/tests/validate-module.ts:14–33  ·  view source on GitHub ↗
(
  code: string,
  filename = 'module.tsx',
)

Source from the content-addressed store, hash-verified

12 * @returns the error messages; an empty array means the module is valid.
13 */
14export async function getModuleErrors(
15 code: string,
16 filename = 'module.tsx',
17): Promise<Array<string>> {
18 let javascript: string
19 try {
20 const result = await transformWithOxc(code, filename, {
21 jsx: 'preserve',
22 typescript: { onlyRemoveTypeImports: true },
23 })
24 javascript = result.code
25 } catch (error) {
26 return [stripVTControlCharacters((error as Error).message)]
27 }
28 const { errors } = parseSync('module.jsx', javascript, {
29 sourceType: 'module',
30 showSemanticErrors: true,
31 })
32 return errors.map((error) => error.message)
33}
34
35/** Matches a declaration of `name` in generated code, however it is printed. */
36export function declarationOf(name: string): RegExp {

Calls

no outgoing calls

Tested by 1

compileChunkFunction · 0.72