mirror of
https://github.com/oxc-project/oxc.git
synced 2026-09-14 19:36:11 +08:00
08dad63678
## Summary - Add `ModuleKind::CommonJS` variant to support CommonJS module type in the parser - Enable top-level `return` statements (CommonJS files are wrapped in a function) - Enable top-level `new.target` (allowed in CommonJS function wrapper) - Add proper errors for `import`/`export` statements in CommonJS - Add proper errors for `import.meta` in CommonJS The CommonJS source type can be set via: - `SourceType::with_commonjs(true)` method - Babel's `sourceType: "commonjs"` option Closes #16200 ## Test plan - [x] Added test cases in `tasks/coverage/misc/pass/` for valid CommonJS features - [x] Added test cases in `tasks/coverage/misc/fail/` for invalid CommonJS usage - [x] Enabled Babel conformance tests for `sourceType: "commonjs"` - [x] All existing tests pass 🤖 Generated with [Claude Code](https://claude.com/claude-code)
3 lines
96 B
JavaScript
3 lines
96 B
JavaScript
// CommonJS does NOT allow export statements (use module.exports instead)
|
|
export const foo = 1;
|