Skip to content

[Feature Request]: same namespace import statements are not merged in output #4324

@sapphi-red

Description

@sapphi-red

Reproduction link or steps

  1. Open https://stackblitz.com/edit/github-nci4o6nk-b1edypmd?file=src%2Ffile.js,src%2Ffile2.js,rolldown.config.mjs
  2. pnpm i runs automatically
  3. pnpm run build runs automatically
  4. output includes import * as http$1 from "node:http"; and import * as http from "node:http";, while only one import { URL } from "node:net"; exists
  5. run npm run build:up to use rollup
  6. output includes only one import * as http from "node:http";

What is expected?

Same namespace import statements are merged in output.
In other words,

import * as http from "node:http";
import { URL } from "node:net";

//#region src/file.js
console.log("file", http, URL);

//#endregion
//#region src/file2.js
console.log("file2", http, URL);

//#endregion

is output.

What is actually happening?

Same namespace import statements are not merged in output.
In other words,

import * as http$1 from "node:http";
import * as http from "node:http";
import { URL } from "node:net";

//#region src/file.js
console.log("file", http$1, URL);

//#endregion
//#region src/file2.js
console.log("file2", http, URL);

//#endregion

is output.

Also it seems a panick is happening as well

thread '' panicked at /home/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/tokio-1.44.2/src/runtime/task/state.rs:188:9:
assertion failed: prev.is_running()
worker (tid = 43) sent an error! unreachable
[Error [RuntimeError]: unreachable]

System Info

Stackblitz

  System:
    OS: Linux 5.0 undefined
    CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: 1.0 - /bin/jsh
  Binaries:
    Node: 20.19.1 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 10.8.2 - /usr/local/bin/npm
    pnpm: 8.15.6 - /usr/local/bin/pnpm
  npmPackages:
    @rolldown/browser:  1.0.0-beta.8-commit.6aca0ce

Any additional comments?

This isn't much important in terms of code size because you normally run a minifier (no minifier supports deduping it though). But it's important for dts generation as the renamed type name is included in the error message (related vitejs/vite#14582).

Metadata

Metadata

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions