Skip to content

[Bug]: Get undefined when using re-export alias with import(). #1497

@colinaaa

Description

@colinaaa

Version

System:
    OS: macOS 26.3
    CPU: (12) arm64 Apple M2 Max
    Memory: 467.14 MB / 96.00 GB
    Shell: 4.5.0 - /opt/homebrew/bin/fish
  Browsers:
    Chrome: 145.0.7632.117
    Firefox: 137.0.1
    Safari: 26.3
  npmPackages:
    @rslib/core: ^0.19.6 => 0.19.6

Details

// index.js
import { foo } from './foo.js'

export async function main() {
  const { fooVersion } = await import('./version.js')

  foo(fooVersion)
}
// foo.js
export function foo(bar) {
    return bar
}

export const version = 'fooooooooo' /** Avoid const inline */
// version.js
export { version as fooVersion } from './foo.js'

Reproduce link

https://github.com/colinaaa-reproductions/rslib-repro-undefined-export

Reproduce Steps

  1. pnpm install
  2. pnpm build

You will see the incorrect output like this:

function foo(bar) {
    return bar;
}
const version = 'fooooooooo';
async function main() {
    const { fooVersion } = await import("./900.js").then((mod)=>({
            fooVersion: mod.version
        }));
    foo(fooVersion);
}
export { main, version };

where 900.js does not have any export

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions