Skip to content

Incorrect dynamic import references when using enableNativePlugin: true #241

Closed
@niksy

Description

@niksy

Describe the bug

When trying to build application with enableNativePlugin: true, dynamic import references are incorrectly renamed/referenced. Everything looks OK when using enableNativePlugin: 'resolver'.

With enableNativePlugin: true

async function main() {
	const { default: default$1 } = await __vitePreload(async () => {
		const { default: default$2 } = await import("./foo.js");
		return { default: default$2 };
	}, []);
	foo(); // ❌
}
main();

With enableNativePlugin: 'resolver'

async function main() {
	const { default: foo } = await __vitePreload(async () => {
		const { default: foo$1 } = await import("./foo.js");
		return { default: foo$1 };
	}, []);
	foo(); // ✅
}
main();

Reproduction

https://stackblitz.com/edit/vitejs-rolldown-vite-43t3ie67?file=vite.config.js

Steps to reproduce

  1. Run npm run build
  2. Observe dist/main.js output

System Info

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
    npm: 10.8.2 - /usr/local/bin/npm
    pnpm: 8.15.6 - /usr/local/bin/pnpm
  npmPackages:
    rolldown-vite:  6.3.18

Used Package Manager

npm

Logs

No response

Validations

Metadata

Metadata

Assignees

Labels

feat: native pluginsrelated to exprimental.enableNativePlugins

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions