Skip to content

A Web module's JavaScript wrapper (-sMODULARIZE, the factory name) is stated only in ldflags #983

Not planned

Description

@Sunrisepeak

Status: a note for discussion; not scheduled. Recorded in the design record .agents/docs/2026-11-20-program-start-model.md §7, item 2.

Today. A modularised Web program states main = false on the Web row, and mcpp links it with --no-entry (#981). Its JavaScript wrapper is written as ordinary [target.'cfg(os = "emscripten")'.build] ldflags entries, which mcpp passes through without interpreting:

  • -sMODULARIZE
  • -sEXPORT_NAME
  • -sEXPORT_ES6
  • -sENVIRONMENT

Why it is not part of main. The wrapper decides how a page loads and names the module: a global Module, a factory function, or an ES module. It does not decide where the program begins, and it applies to a module with or without main.

To discuss:

  • Does the Web row's artifact need declarative keys for the wrapper's form and the factory name? They would describe how the module is loaded, as the row's naming keys and exe-suffix-fixed describe the launcher.
  • What would mcpp run, mcpp pack and a test runner read from them?
  • How would they combine with a project's own ldflags, so that each fact is stated once?

Activity

  1. added
    discussion
    on Nov 20, 2026
  2. speak-agent commented on Nov 26, 2026

    @speak-agent
    Member

    Closing as not planned for now; the note stays in the design record (.agents/docs/2026-11-20-program-start-model.md §7, item 2).

    The wrapper's form (-sMODULARIZE, -sEXPORT_NAME, -sEXPORT_ES6, -sENVIRONMENT) is a fact of one toolchain, and nothing in the engine reads it today: mcpp run, mcpp pack and the test runner start a Web program through the row's runner and the launcher the link wrote. Passing the words through [target.'cfg(os = "emscripten")'.build] ldflags states each fact once, in the place that already means "words for this row's link".

    Declarative keys would be justified when a command of mcpp has to know the form (a runner that loads a factory, a pack format that writes the page). They would then carry the platform's prefix, as a key whose effect exists on one platform does (SPEC-004 §5.3), and come with the platform's package rather than as keys of the engine. Reopen with that consumer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    discussion

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions