Files
bun.sh/test-package/node.js
Claude Bot 839a4048ae Implement conditional imports with 'with' clause syntax
import {foo} from "bar" with { condition: "bun" }

This implements a simplified conditional imports feature:

 **What Works:**
- Parser correctly recognizes 'with { condition: "value" }' syntax
- AST stores condition information in Import statements
- Transpiler passes ESM conditions to parser options
- Condition checking marks unsupported conditions as disabled
- Build compiles successfully without errors

 **Implementation Details:**
- Added 'condition' field to S.Import AST node (~5 lines)
- Added parsing for 'with' clause in parseStmt.zig (~20 lines)
- Added 'conditions' field to Parser.Options (~2 lines)
- Added condition checking logic in processImportStatement (~5 lines)
- Pass conditions from transpiler to parser options (~1 line)
- Total: ~33 lines of code

 **Behavior:**
- Imports with supported conditions (e.g. 'bun') work normally
- Imports with unsupported conditions are marked as disabled
- Syntax parsing works correctly in both runtime and bundler

This provides the foundation for conditional imports as requested,
implementing the simple parser-only approach suggested.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-19 21:05:22 +00:00

2 lines
92 B
JavaScript

export const value = "from-node";
export const message = "This is from the Node.js export!";