or run

tessl search
Log in

Version

Files

tile.json

task.mdevals/scenario-1/

MDX Re-Export Compiler

Create a utility that compiles MDX content containing export-all statements using the @mdx-js/mdx compiler.

Requirements

Your task is to build a compiler function that:

  1. Accepts MDX source code as a string
  2. Compiles the MDX using @mdx-js/mdx in both output formats (program and function-body)
  3. Returns an object containing both compiled outputs

The function should properly handle MDX files that use the export * from syntax to re-export all exports from other modules.

Input Format

The function should accept:

  • A string containing MDX source code
  • The source code may include export * from './module' statements

Output Format

The function should return an object with two properties:

  • program: The compiled code in program format (default ES module format)
  • functionBody: The compiled code in function-body format

Example Scenario

Given MDX source that re-exports from multiple modules:

# Component Library

export * from './buttons'
export * from './inputs'
export const version = '1.0.0'

The compiler should produce valid JavaScript in both output formats that properly handles the export-all statements.

Test Cases

  • Compiling MDX with a single export-all statement in program format produces valid ES module code @test
  • Compiling MDX with a single export-all statement in function-body format produces valid function body code @test
  • Compiling MDX with multiple export-all statements and named exports works correctly @test

Implementation

@generates

API

/**
 * Compiles MDX source code in both output formats
 *
 * @param {string} mdxSource - MDX source code containing export statements
 * @returns {Promise<{program: string, functionBody: string}>} Compiled code in both formats
 */
export async function compileMdxWithExports(mdxSource) {
  // Implementation here
}

Dependencies { .dependencies }

@mdx-js/mdx { .dependency }

Provides MDX compilation support for transforming MDX files into JavaScript modules.