or run

tessl search
Log in

Version

Files

tile.json

task.mdevals/scenario-3/

MDX Processor Toolkit

Overview

Build a reusable toolkit that processes multiple MDX and Markdown files with consistent configuration. The toolkit should efficiently handle both file formats and apply consistent transformations across all files.

Requirements

Your toolkit should:

  1. Create a reusable processor that can compile MDX files
  2. Process multiple files efficiently using the same processor instance
  3. Return compilation results for each file with proper error handling

Implementation Details

Create a file processor-toolkit.js that exports a class or set of functions with the following functionality:

Core Functionality

  1. Processor Factory: Create a function that initializes a reusable processor
  2. Batch Processing: Process an array of files (with content and path information) using the processor
  3. Error Handling: Gracefully handle compilation errors and return results with success/error status

Input/Output Format

Input: Array of file objects with path and content properties

[
  { path: 'example.mdx', content: '# Hello World' },
  { path: 'readme.md', content: '## Documentation' }
]

Output: Array of result objects with compilation status

[
  { path: 'example.mdx', success: true, code: '...compiled code...' },
  { path: 'readme.md', success: false, error: 'error message' }
]

Test Cases { .test-cases }

Test 1: Basic Processor Creation and Usage @test

File: processor-toolkit.test.js

Test description: Create a processor and compile a simple MDX file

Input:

const files = [
  { path: 'test.mdx', content: '# Hello\n\nThis is **bold** text.' }
];

Expected behavior:

  • Processor should successfully compile the file
  • Output should include compiled JavaScript code
  • Result should indicate success: true

Test 2: Multiple File Processing @test

File: processor-toolkit.test.js

Test description: Process multiple files with the same processor instance

Input:

const files = [
  { path: 'doc1.mdx', content: '# Document 1' },
  { path: 'doc2.md', content: '## Document 2' },
  { path: 'doc3.mdx', content: 'Some content with <Component />' }
];

Expected behavior:

  • All files should be processed successfully
  • Each result should have the correct path
  • Processor should handle both .mdx and .md formats
  • All results should indicate success: true

Test 3: Error Handling @test

File: processor-toolkit.test.js

Test description: Handle invalid MDX syntax gracefully

Input:

const files = [
  { path: 'valid.mdx', content: '# Valid Content' },
  { path: 'invalid.mdx', content: '# Test\n\n<UnClosedTag' }
];

Expected behavior:

  • First file should compile successfully (success: true)
  • Second file should fail gracefully (success: false)
  • Error should be captured and included in the result
  • Processing should continue for all files despite errors

Dependencies { .dependencies }

@mdx-js/mdx { .dependency }

Provides MDX compilation capabilities. Use this package to create and configure the processor for transforming MDX and Markdown content.

Constraints

  • Use the package's processor creation capabilities for efficiency
  • Reuse the same processor instance across multiple files
  • Do not create a new processor for each file
  • Handle both synchronous and asynchronous compilation appropriately

Evaluation Criteria

Your solution will be evaluated based on:

  • Correct usage of processor creation functionality
  • Efficient reuse of processor instances
  • Proper error handling and result formatting
  • Support for both MDX and Markdown formats