fix(skills): run sherpa-onnx-tts bin under ESM#31965
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2243df47c8
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const result = spawnSync(process.execPath, [scriptPath], { | ||
| encoding: "utf8", | ||
| }); |
There was a problem hiding this comment.
Isolate bin regression test from inherited SHERPA env
This test assumes the child process has no SHERPA_ONNX_RUNTIME_DIR/SHERPA_ONNX_MODEL_DIR, but spawnSync inherits the parent environment by default. If either variable is set in a developer shell or CI job, the script takes a different validation path and expect(result.stderr).toContain("Missing runtime/model directory.") fails even though ESM loading is fine, making the regression test non-deterministic across environments.
Useful? React with 👍 / 👎.
Greptile SummaryThis PR converts the sherpa-onnx-tts bin script from CommonJS to ESM, fixing a critical module loading bug in Node.js 22+. The change is minimal and surgical - only three import statements were converted from Confidence Score: 5/5
Last reviewed commit: 2243df4 |
|
Landed via temp rebase onto main.
Thanks @bmendonca3! |
Summary
Describe the problem and fix in 2–5 bullets:
skills/sherpa-onnx-tts/bin/sherpa-onnx-ttsused CommonJSrequire(...)in atype: modulerepo, so directnodeexecution fails before argument parsing.import fs/path/spawnSync ...) and added a regression test that executes the bin script as a real Node entrypoint.Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
User-visible / Behavior Changes
node skills/sherpa-onnx-tts/bin/sherpa-onnx-tts ...now loads correctly in ESM mode and reaches normal usage/runtime validation instead of crashing at module load.Security Impact (required)
No)No)No)No)No)Yes, explain risk + mitigation:Repro + Verification
Environment
Steps
upstream/main, run:node skills/sherpa-onnx-tts/bin/sherpa-onnx-tts --helpReferenceError: require is not defined in ES module scope.Expected
Actual
require(...).Evidence
Attach at least one:
Human Verification (required)
What you personally verified (not just CI), and how:
node skills/sherpa-onnx-tts/bin/sherpa-onnx-tts --help(module-loadrequirecrash).node skills/sherpa-onnx-tts/bin/sherpa-onnx-tts(usage output path).pnpm test src/agents/skills.sherpa-onnx-tts-bin.test.ts.pnpm tsgo,pnpm lint.Compatibility / Migration
Yes)No)No)Failure Recovery (if this breaks)
skills/sherpa-onnx-tts/bin/sherpa-onnx-ttssrc/agents/skills.sherpa-onnx-tts-bin.test.tsRisks and Mitigations
List only real risks for this PR. Add/remove entries as needed. If none, write
None.