Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary: Fix open dependency ESM/CommonJS compatibility
Problem
The open package (used for opening HTML reports/plots in the browser) switched to pure ESM in v9. When @captor/openseries-ts was used in a CommonJS app (e.g. CaptorAB/nodejs), it caused:
[ERR_REQUIRE_ESM]: require() of ES Module .../node_modules/open/index.js not supported
Solution
Dynamic import — Replaced static import open from "open" with (await import("open")).default so open is loaded only when needed and via dynamic import, which works from both ESM and CommonJS.
Pinned version — Set "open": "^8.4.0" to stay on the last CJS-compatible line (v8.x) and keep compatibility with consumers who pin open at 8.4.0.
Changes
package.json — open updated from ^8.0.0 to ^8.4.0.
src/plot.ts — Dynamic import for the plotSeries auto-open behavior.
src/sharpeplot.ts — Dynamic import for the sharpeplot auto-open behavior.
scripts/report.ts — Dynamic import for the report CLI auto-open behavior.
Tests, lint, typecheck, and build all pass. The package should work in both ESM and CommonJS setups without the previous ESM error.