Skip to content

Document module header and import conventions - #1502

Merged
sergey-shandar merged 4 commits into
mainfrom
agent/module-import-conventions
Aug 12, 2026
Merged

Document module header and import conventions#1502
sergey-shandar merged 4 commits into
mainfrom
agent/module-import-conventions

Conversation

@sergey-shandar

Copy link
Copy Markdown
Contributor

Summary

  • define the TypeScript module header/import order: module JSDoc, import type, migrated .mjs runtime imports, then remaining .ts runtime imports
  • define the JavaScript form: keep module-level @import tags in the same leading JSDoc block as @module, followed by one blank line and runtime .mjs imports
  • make the blank line after the module JSDoc block an explicit rule so the header remains detached from source-level imports/declarations and survives declaration emit
  • update existing standalone @import examples in AGENTS.md and the migration TODO to match the convention

Impact

Documentation/convention change only. No runtime code or public package API changes.

Validation

  • inspected both commit patches
  • compared the branch against main; only AGENTS.md and todo/migrate-typescript-to-mjs.md are changed
  • no CHANGELOG entry is required for documentation-only changes

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
functionalscript bea596e Commit Preview URL

Branch Preview URL
Aug 12 2026, 03:08 PM

@sergey-shandar

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9d80e0c163

ℹ️ 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".

Comment thread AGENTS.md Outdated

@o2alexanderfedin o2alexanderfedin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reviewed at 9d80e0c1630a20e6852e8dc154a856b7d02a41b9. Approving. Docs-only, and it writes
down the conventions I've been checking by hand on every migration PR for the past day, which
is the right place for them.

The blank-line rule's justification is correct — I tested it rather than agreeing with it.
The text claims the blank line after the module JSDoc block "keeps the header detached from the
first import/declaration and preserves it through declaration emit." On
fjs/media/json/rtti/module.f.mjs:

with the blank line     @module in emitted .d.mts = 1
without the blank line  @module in emitted .d.mts = 0

Deleting that one line silently drops the module documentation from the published declaration.
That's exactly the failure that cost this migration series 18 files' worth of docs earlier, and
it's the kind of thing that no test catches and review only catches if someone happens to look
— so making it an explicit rule rather than folklore is worth doing.

The @import-placement rule matches where the tree is already heading. #1500 moved 21
files to the consolidated form and merged, so this documents settled practice rather than
proposing something new.

One number worth having in view: 90 of 147 .f.mjs files still use the standalone
@import comment form
the rule now forbids — including fjs/media/json/rtti/proof.f.mjs
from #1498, merged only hours ago. That's not an objection; an incremental convention landing
ahead of the cleanup is normal, and todo/migrate-typescript-to-mjs.md gains a tracked
checklist item for it in this same PR, which is the right way to handle it. I mention it only
so the size of the tail is known — roughly 61% of migrated modules, and new files are still
being written in the old style, which argues for doing the sweep sooner rather than later.

The [§4](#4-documentation) cross-reference resolves, and broken relative markdown links are
144 — identical to main, none added.

@sergey-shandar
sergey-shandar marked this pull request as ready for review August 12, 2026 15:10
@sergey-shandar
sergey-shandar added this pull request to the merge queue Aug 12, 2026
Merged via the queue into main with commit bb0d6aa Aug 12, 2026
19 checks passed
sergey-shandar pushed a commit that referenced this pull request Aug 12, 2026
#1502 documents it in AGENTS.md §4: module-level `@import` tags belong in the
same JSDoc block as `@module`, not in separate comments, and a blank line
separates that block from the first import. These modules predate the rule.

Moves 6 `@import` tags into their headers across 5 files — two of them were
interleaved between runtime imports — and adds the required blank line to the
two headers that carry no tags.

Generated output is unaffected.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FyMg2KPgfJeQ5FXGXjyFmd
@sergey-shandar
sergey-shandar deleted the agent/module-import-conventions branch August 12, 2026 18:12
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