Skip to content

docs: document deno eval CJS/ESM auto-detection (2.8)#3091

Open
lunadogbot wants to merge 1 commit intodenoland:mainfrom
lunadogbot:docs/2.8-eval-auto-detect
Open

docs: document deno eval CJS/ESM auto-detection (2.8)#3091
lunadogbot wants to merge 1 commit intodenoland:mainfrom
lunadogbot:docs/2.8-eval-auto-detect

Conversation

@lunadogbot
Copy link
Copy Markdown

Summary

Documents the new CJS/ESM auto-detection heuristic in deno eval shipping in Deno 2.8 (denoland/deno#32472). deno eval parses the snippet, treats it as ESM if it contains import/export declarations, and otherwise runs it as CommonJS — so require() works without --ext=cjs.

  • Replaces the existing "CommonJS support" section in runtime/reference/cli/eval.md with "CommonJS and ESM auto-detection".
  • Side-by-side example for both detected paths.
  • Calls out --ext=mjs / --ext=cjs as the override when the heuristic gets it wrong.

Test plan

  • deno task serve — section renders, examples readable.

Replaces the vague "CommonJS support" section in eval.md with a
description of the new 2.8 heuristic — import/export declarations
select ESM, otherwise CJS. Adds a side-by-side example and notes
\`--ext=mjs\` / \`--ext=cjs\` as the override.

Refs denoland/deno#32472
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