Skip to content

fix(diagnostics): name the imported package and hint at a static import for uncompiled import() - #3527

Open
espetro wants to merge 2 commits into
vercel-labs:mainfrom
espetro:fix/dynamic-import-package-name
Open

espetro wants to merge 2 commits into
vercel-labs:mainfrom
espetro:fix/dynamic-import-package-name

Conversation

@espetro

@espetro espetro commented Nov 11, 2026

Copy link
Copy Markdown
Contributor

Version: scriptc 0.4.11, main at 918d80b.

Repro:

// dyn.ts
const m = await import("ms");
console.log(m.default(1000));

scriptc build dyn.ts where no static import names ms.

Actual: the SC2013 refusal names @types/ms (the resolved declaration package) instead of ms, and gives no way forward.

Expected: the diagnostic names the package the user wrote, and hints at the fix: add a static import so the package joins the module graph, or allow a Node island.

Changes: a shared runtimePackageName strips the @types/ scoping, unsupportedPackageImportDiag takes an optional hint, and the lazy import lowering passes it. Test added in tests/harness/lazy-package-import.test.ts; the lazy-import, diagnostics and lower-stdlib suites pass locally (37 tests). pnpm lint could not run in my environment (ESLint JSON parse failure); oxlint and format:check are clean.

Whether literal import("pkg") should follow into the module graph is a separate question, filed as an issue.

@vercel

vercel Bot commented Nov 11, 2026

Copy link
Copy Markdown
Contributor

@espetro is attempting to deploy a commit to the Vercel Labs Team on Vercel.

A member of the Team first needs to authorize it.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant