Skip to content

[Bug]: __NO_SIDE_EFFECTS__ wrapper removes async import #9074

@dangreen

Description

@dangreen

Reproduction link or steps

// src/entry.js
// @__NO_SIDE_EFFECTS__
export function wrapper(load) {
  return {
    load
  }
}

export const pages = [wrapper(() => import('./page.js'))]
// src/page.js
export const message = 'Hello from page.js'
// build.js
import path from 'node:path'
import { rolldown } from 'rolldown'

const root = import.meta.dirname
const build = await rolldown({
  input: path.join(root, 'src/entry.js'),
  platform: 'node'
})

await build.write({
  dir: path.join(root, 'dist'),
  format: 'esm',
  entryFileNames: 'entry.js'
})

What is expected?

// @__NO_SIDE_EFFECTS__
function wrapper(load) {
  return {
    load
  }
}

const pages = [wrapper(() => import('./page-DuIEzloN.js'))];

export { pages, wrapper };

What is actually happening?

//#region src/entry.js
/* @__NO_SIDE_EFFECTS__ */
function wrapper(load) {
	return { load };
}
const pages = [/* @__PURE__ */ wrapper(() => void 0)];
//#endregion
export { pages, wrapper };

System Info

System:
    OS: Linux 6.12 Ubuntu 25.04 25.04 (Plucky Puffin)
    CPU: (8) x64 AMD Ryzen 5 PRO 3400G with Radeon Vega Graphics
    Memory: 1.72 GB / 13.58 GB
    Container: Yes
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 24.14.1 - /cache/asdf/installs/nodejs/24.14.1/bin/node
    npm: 11.11.0 - /cache/asdf/plugins/nodejs/shims/npm
    pnpm: 10.33.0 - /cache/asdf/shims/pnpm
  npmPackages:
    rolldown: ^1.0.0-rc.15 => 1.0.0-rc.15

Any additional comments?

Same setup with rollup works correctly.

OR if remove NO_SIDE_EFFECTS, rolldown works correctly

export function wrapper(load) {
  return {
    load
  }
}

export const pages = [wrapper(() => import('./page.js'))]

OR if wrapper is not exported, rolldown also works correctly

// @__NO_SIDE_EFFECTS__
function wrapper(load) {
  return {
    load
  }
}

export const pages = [wrapper(() => import('./page.js'))]

Metadata

Metadata

Labels

No labels
No labels

Type

Priority

None yet

Effort

None yet

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions