Skip to content

panicked at crates/rolldown/src/utils/chunk/render_chunk_exports.rs:28:54 no entry found for key when bundling aliased entries with shared cjs dep #1722

@hi-ogawa

Description

@hi-ogawa

Reproduction link or steps

I was investigating panic in Vite's playground/alias vitejs/rolldown-vite#28 (comment) and it looks like the same error can be reproduced with this stripped down example:

(Initial repro using `vue` and `@vue/shared`)
import * as rolldown from "rolldown";
import { createRequire } from "node:module";

const require = createRequire(import.meta.url);

async function main() {
  const bundle = await rolldown.rolldown({
    cwd: import.meta.dirname,
    // works if single entry
    input: ["vue", "foo"],
    resolve: {
      alias: {
        "foo": "vue",
        // works if removed
        "@vue/shared": require.resolve("@vue/shared/dist/shared.cjs.prod.js"),
      },
    }
  });
  await bundle.write({
    format: "esm",
  });
  process.exit(0);
}

main();

Also this is the original vite config in the playground:

New repro without vue

https://github.com/hi-ogawa/rolldown/tree/b31fa276a6aa6ee370984652425356b2b1d9e7e8/examples/repro-alias

  • index.js
import * as rolldown from "rolldown";
import { createRequire } from "node:module";

const require = createRequire(import.meta.url);

async function main() {
  const bundle = await rolldown.rolldown({
    cwd: import.meta.dirname,
    // works if single entry (each one works alone)
    input: [
      "test-dep-main",
      "foo",
    ],
    resolve: {
      alias: {
        "foo": "test-dep-main",
      },
    }
  });
  await bundle.write({
    format: "esm",
  });
  process.exit(0);
}

main();
  • test-dep-main/index.js
export const main = "main";
export { sub } from "test-dep-sub";
  • test-dep-sub/index.cjs
module.exports.sub = "sub";
  • command
$ node examples/repro-alias/index.js 
thread 'tokio-runtime-worker' panicked at crates/rolldown/src/utils/chunk/render_chunk_exports.rs:28:54:
no entry found for key
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
node:internal/process/promises:289
            triggerUncaughtException(err, true /* fromPromise */);
            ^

[Error: Panic in async function] { code: 'GenericFailure' }

What is expected?

Not panic and build should succeed.

What is actually happening?

thread 'tokio-runtime-worker' panicked at crates/rolldown/src/utils/chunk/render_chunk_exports.rs:28:54:
no entry found for key
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

System Info

System:
    OS: Linux 6.9 Arch Linux
    CPU: (16) x64 12th Gen Intel(R) Core(TM) i7-12650H
    Memory: 22.02 GB / 31.06 GB
    Container: Yes
    Shell: 5.2.26 - /usr/bin/bash
  Binaries:
    Node: 20.14.0 - ~/.volta/tools/image/node/20.14.0/bin/node
    npm: 10.7.0 - ~/.volta/tools/image/node/20.14.0/bin/npm
    pnpm: 9.6.0 - ~/.volta/tools/image/node/20.14.0/bin/pnpm
  Browsers:
    Chromium: 126.0.6478.126
  npmPackages:
    rolldown: 0.12.2 => 0.12.2

Any additional comments?

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Priority

None yet

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions