Skip to content

Support merging client reference chunks #605

Description

@hi-ogawa

See contexts in hi-ogawa/vite-plugins#895 hi-ogawa/vite-plugins#904. We probably need to set preserveEntrySignatures: "allow-extension" somewhere https://rollupjs.org/configuration-options/#preserveentrysignatures

Activity

  1. hi-ogawa commented on Aug 23, 2025

    @hi-ogawa
    ContributorAuthor

    Instead of relying on emitFile + manualChunks, it might be easier to expose own API to let users control this virtual construction

    for (const meta of Object.values(manager.clientReferenceMetaMap)) {
    // vite/rollup can apply tree-shaking to dynamic import of this form
    const key = JSON.stringify(meta.referenceKey)
    const id = JSON.stringify(meta.importId)
    const exports = meta.renderedExports
    .map((name) => (name === 'default' ? 'default: _default' : name))
    .sort()
    code += `
    ${key}: async () => {
    const {${exports}} = await import(${id});
    return {${exports}};
    },
    `
    }
    code = `export default {${code}};\n`

    To be able to group import(id), we'll probably need another wrapper virtual for each group though, which will then maybe start to look like hi-ogawa/vite-plugins#891

  2. added theissue type on Aug 23, 2025
  3. locked and limited conversation to collaborators on Sep 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions