Skip to content

Bad smell: Privileges modules #1

Open

Description

@hyfdev

Motivation: rolldown/rolldown#10580

To make rolldown itself and some features work, rolldown has to add some "extra" rolldown content. These "extra" content currently are treated as if they're users' input though they're not.

To add some js helpers in the output, rolldown has a \0rolldown/runtime.js module to store these content.

To make FBM lazy compiltation works, rolldown has to intercept the lazy entry modules and redirect their content to a new proxy module [original module id]?rolldown-lazy.

These modules are treated as "modules", so users can actually observe them somehow and this causes some issues. To solve these issues, we have to add some privileges to these modules. rolldown/rolldown#10580 is a very good exmaple.

Bad smell behaviors:

  • Users' code doesn't actually import \0rolldown/runtime.js but Rolldown now has to pretend they did and make every bundler state correct
  • [original module id]?rolldown-lazy modules are hard-coded to be hidden from users' plugin observation

Activity

  1. h-a-n-a commented on Aug 3, 2026

    @h-a-n-a
    Member

    @sapphi-red: rolldown/rolldown#10580 (comment)

    isInternal sounds good to me.

  2. hyfdev commented on Aug 3, 2026

    @hyfdev
    MemberAuthor

    @sapphi-red: rolldown/rolldown#10580 (comment)

    isInternal sounds good to me.

    Try to reasoning from the idea, I assume we will have an isInternal props in Module and by default we skip these internal modules from all module level hooks.

    And if users want to observe them, we could expose something like

    {
      resolveId: {
        skipInternalModules: false,
        handler: ..,
      }
    }

    I feel we should first figure out what's the fundamental nature of these content.

  3. h-a-n-a commented on Aug 3, 2026

    @h-a-n-a
    Member

    I'm not sure about the skipInternalModules part. I doubt we want users to observe internal things like that.

  4. hyfdev commented on Aug 3, 2026

    @hyfdev
    MemberAuthor

    Try to reasoning from the idea, I assume we will have an isInternal props in Module and by default we skip these internal modules from all module level hooks.

    I feel they're some difficulties here. rolldown-plugin-lazy-compilation currently is a "normal user plugin", how can we make it to somehow do that "this module I returned is an internal module"? This means we need to provide some "privileges" API to rust plugin API .

    For those who use rust rolldown, isn't this somehow still a "privilege" that can be observed by outside? I know that rust rolldown users aren't a general usage, but I think is a good angle to judge if we're exposing correct interfaces.

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

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions