Skip to content

Add JavaScript as a language target - #38

Merged
rijesha merged 3 commits into
mainfrom
copilot/add-javascript-language-support
Nov 29, 2025
Merged

Add JavaScript as a language target#38
rijesha merged 3 commits into
mainfrom
copilot/add-javascript-language-support

Conversation

Copilot AI commented Nov 29, 2025

Copy link
Copy Markdown
Contributor

Adds JavaScript code generation that produces human-readable CommonJS modules, reusing patterns from the TypeScript generator.

Code Generator

  • src/struct_frame/js_gen.py - Generates .sf.js files with CommonJS require/module.exports syntax
  • Boilerplate files in src/struct_frame/boilerplate/js/ for struct serialization, framing, and parsing

CLI Integration

  • Added --build_js and --js_path flags to generate.py

Test Infrastructure

  • JavaScript test suite in tests/js/ mirroring TypeScript tests
  • Updated test_config.json with JavaScript language configuration
  • Modified tests/runner/base.py and plugins.py to handle JS test execution from generated directory

Usage

PYTHONPATH=src python3 src/main.py myproto.proto --build_js --js_path gen/js

Generated output:

const { Struct } = require('./struct_base');
const { msg_encode } = require('./struct_frame');

const basic_types_BasicTypesMessage = new Struct('basic_types_BasicTypesMessage')
    .Int8('small_int')
    .UInt16LE('medium_uint')
    .String('device_id', 32)
    .compile();
module.exports.basic_types_BasicTypesMessage = basic_types_BasicTypesMessage;

All 74 tests pass including cross-platform compatibility between C, C++, Python, TypeScript, and JavaScript.

Original prompt

This section details on the original issue you should resolve

<issue_title>Add Javascript as a language</issue_title>
<issue_description>This generator and tests should reuse a lot of the code from the typescript tests. One of the languages can act as a wrapper. There is also js being created, if this js is being used it needs to still be human readable. </issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits November 29, 2025 01:02
- Create js_gen.py for JavaScript code generation with CommonJS syntax
- Add JavaScript boilerplate files (struct_base.js, struct_frame.js, etc.)
- Update generate.py with --build_js and --js_path CLI flags
- Update __init__.py to export FileJsGen
- Add JavaScript test configuration to test_config.json
- Create JavaScript test files mirroring TypeScript tests
- Update test runner base.py and plugins.py to handle JavaScript tests
- All 74 tests pass including cross-platform compatibility

Co-authored-by: rijesha <7819200+rijesha@users.noreply.github.com>
Co-authored-by: rijesha <7819200+rijesha@users.noreply.github.com>
Copilot AI changed the title [WIP] Add JavaScript as a language support Add JavaScript as a language target Nov 29, 2025
Copilot AI requested a review from rijesha November 29, 2025 01:07
@rijesha
rijesha marked this pull request as ready for review November 29, 2025 01:09
@rijesha
rijesha merged commit 0340272 into main Nov 29, 2025
@rijesha
rijesha deleted the copilot/add-javascript-language-support branch December 6, 2025 03:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Javascript as a language

2 participants