Skip to content

Fix examples for ESM - #309

Merged
keichi merged 1 commit into
masterfrom
fix-examples-for-esm
Oct 15, 2026
Merged

keichi merged 1 commit into
masterfrom
fix-examples-for-esm

Conversation

@keichi

@keichi keichi commented Oct 15, 2026

Copy link
Copy Markdown
Owner

Since #308, node example/<name>.ts fails with ERR_MODULE_NOT_FOUND because the extensionless import of ../lib/binary_parser can no longer be resolved, and __dirname is undefined in ES modules.

  • Import the library as ../lib/binary_parser.ts
  • Use import.meta.dirname instead of __dirname

All examples now run with node example/<name>.ts (Node.js 22.18+ for type stripping).

Import the library with its .ts extension and use import.meta.dirname
instead of __dirname so that the examples can be run directly with
node example/<name>.ts.
@keichi
keichi merged commit ae8cc83 into master Oct 15, 2026
8 checks passed
@keichi
keichi deleted the fix-examples-for-esm branch October 15, 2026 14:33
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.

1 participant