Skip to content

Preserve V8 Explicit Compile Hints magic comments #4247

@Inqnuam

Description

@Inqnuam

Feature Request: Preserve //# allFunctionsCalledOnLoad Comment for V8 Explicit Compile Hints

V8 recently introduced a feature called Explicit Compile Hints, which is already available in Chrome 136 and newer.

Currently, esbuild only preserves hashbangs and legal comments by default. It would be helpful if esbuild could also preserve the new //# allFunctionsCalledOnLoad comment—either by default, via a new option, or based on the target configuration.

I'm not sure when exactly this should be enabled or disabled (e.g., during build vs transform), so I'm open to discussion on the best approach.


Input:

//# allFunctionsCalledOnLoad

function testfunc2() {
  // this is a comment
  console.log('testfunc2 called!');
}

testfunc2();

current output:

function testfunc2() {
  console.log("testfunc2 called!");
}
testfunc2();

desired output:

//# allFunctionsCalledOnLoad
function testfunc2() {
  console.log("testfunc2 called!");
}
testfunc2();

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions