Skip to content

feat: add JavaScript/JSX asset handler#370

Merged
lrasmus merged 6 commits intoStatTag:masterfrom
aabhinavvvvvvv:feat/javascript-handler
Apr 1, 2026
Merged

feat: add JavaScript/JSX asset handler#370
lrasmus merged 6 commits intoStatTag:masterfrom
aabhinavvvvvvv:feat/javascript-handler

Conversation

@aabhinavvvvvvv
Copy link
Copy Markdown
Contributor

Summary

Adds a JavaScriptHandler to detect libraries, inputs, and outputs in JavaScript files, closing #362.

Files changed:

  • app/services/assets/handlers/javascript.js — new handler supporting .js, .jsx, .mjs, .cjs files
  • app/constants/assets-config.js — registers JavaScript extensions
  • app/preload.js — instantiates JavaScriptHandler
  • app/utils/workflow.js — registers handler in getAssetType, getAllDependencies, getLibraryDependencies
  • app/images/js.svg — JavaScript icon for the dependency graph
  • app/components/Workflow/DependencyGraph/CustomNodes/Code/CodeNode.js — icon entry for JS nodes
  • app/components/Workflow/DependencyGraph/DependencyGraphEChart.js — icon entry for JS nodes
  • docs/Assets.md — documents what the handler detects
  • test/services/assets/handlers/javascript.spec.js — 20 unit tests for the handler
  • test/services/assets/asset.spec.js — extension detection tests
  • test/utils/workflow.spec.js — dependency and asset type tests

Detection coverage:

Category Patterns
Libraries ES module imports (import x from 'y', named, namespace, side-effect) and CommonJS require('y')
Inputs fs.readFileSync, fs.readFile, fs.createReadStream
Outputs fs.writeFileSync, fs.writeFile, fs.appendFile, fs.appendFileSync, fs.createWriteStream

Copy link
Copy Markdown
Contributor

@lrasmus lrasmus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code looks good - I have a few requests for additional unit tests. The code appears to handle these scenarios, I just want to ensure we have test cases to show they work.

Copy link
Copy Markdown
Contributor

@lrasmus lrasmus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wonderful job with all the new added tests - it uncovered something I hadn't detected in code review. Please see the note about one of the tests currently failing, and let me know if you're seeing something different on your end.

@aabhinavvvvvvv
Copy link
Copy Markdown
Contributor Author

the require regex was missing the ^[^/]*? guard that the import regexes had. Fixed that, and also corrected the Windows path test to use single backslashes. All 31 tests passing now.

Copy link
Copy Markdown
Contributor

@lrasmus lrasmus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect, thank you SO much for this implementation, and for the quick changes on the unit tests!

@lrasmus lrasmus merged commit 3f584e5 into StatTag:master Apr 1, 2026
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.

2 participants