Skip to content

Compiler treats a shadowed createPortal as Octane’s portal builtin #2587

Closed

Description

@domgan-oai

Reproduced with the compiler and runtime built from Octane main c34035d7d1474b266127382bb0c6bebc22bb6fc6 in production mode. The compiler replaces calls based on the local name createPortal, even when the binding is an ordinary parameter.

import { createPortal } from 'octane';

export function Host({ createPortal }) @{
  <main>{createPortal(null, 'body')}</main>
}

export function Fragment({ createPortal }) @{
  <>{createPortal(null, 'body')}</>
}

Pass a fresh callback for each render:

let calls = 0;
const props = {
  createPortal() {
    calls++;
    return 'AUTHORED';
  },
};

Both components should call the supplied function once and render AUTHORED. Server rendering uses octane/server.renderToString(Component, props), and client rendering uses createRoot(container).render(Component, props).

Component Server Client
Host Empty portal placeholder, 0 calls Empty <main>, 0 calls
Fragment Empty portal placeholder, 0 calls AUTHORED, 1 call

An equivalent ordinary helper with a different name renders normally. Genuine Octane portals using either the direct import or import { createPortal as mount } from 'octane' both mounted a simple control into the target on the client. The server emitted placeholders for both.

The same spelling check also affects callable template arguments. In a template setup, const createPortal = (render) => render(); const result = createPortal(() => @{ <b>child</b> }); currently throws on the client when rendering result, because the compiler treats the argument as a runtime-owned template body. The same setup renders on the server.

The client and server portal lowering and the template-argument exemption should use the call's resolved Octane import binding. See the SSR portal branch and the template-argument exemption.

Codex task · Host com-79386

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions