Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AsyncFunction cannot run dynamic import #18137

Open
Akkuma opened this issue Mar 12, 2025 · 0 comments
Open

AsyncFunction cannot run dynamic import #18137

Akkuma opened this issue Mar 12, 2025 · 0 comments
Labels
bug Something isn't working node.js Compatibility with Node.js APIs web-api Something that relates to a standard Web API

Comments

@Akkuma
Copy link

Akkuma commented Mar 12, 2025

What version of Bun is running?

1.2.5

What platform is your computer?

Darwin 23.4.0 arm64 arm

What steps can reproduce the bug?

const AsyncFunction = Object.getPrototypeOf(run).constructor;

export async function run(code: string) {
	return new AsyncFunction(code)();
}

await run(`const t = await import('./doesnt_matter.tsx')`);

If you attempt to run this, which is based on code used inside of mdx, it will error with SyntaxError: Unexpected keyword 'import'. Expected ';' after variable declaration.

What is the expected behavior?

The above code should work as it can run in node.

What do you see instead?

SyntaxError: Unexpected keyword 'import'. Expected ';' after variable declaration.

Additional information

No response

@Akkuma Akkuma added bug Something isn't working needs triage labels Mar 12, 2025
@RiskyMH RiskyMH added node.js Compatibility with Node.js APIs web-api Something that relates to a standard Web API and removed needs triage labels Mar 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working node.js Compatibility with Node.js APIs web-api Something that relates to a standard Web API
Projects
None yet
Development

No branches or pull requests

2 participants