Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions packages/compiler/src/frontend/program.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2158,6 +2158,21 @@ function preflight7(load: LoadResult): {
refuse(refusal.message, "%Error", ambientNote);
continue;
}
// A BARE side-effect import (`import "x";` — no default, named, or
// namespace binding: stmt.importClause is undefined) of a module
// that exists ONLY as an ambient 'declare module' type surface has
// no runtime module AND nothing bound from it for other code to
// reference — the two facts together make dropping the statement
// behaviorally exact, not an approximation. This is the standard
// shape of a bundler-only stylesheet import (`import
// "pkg/dist/style.css";`, ambient-declared via a `declare module
// "*.css"` surface): real CSS side effects don't exist in a
// compiled binary with no browser to apply them to, so there is
// nothing this program could have observed from the import
// succeeding that it can no longer observe. A bound import
// (`import styles from "x.css"`, `import { x } from "x"`) still
// fences below — something WOULD be missing.
if (stmt.importClause === undefined && ambientDeclared(spec)) continue;
// Runtime-resolvable (or a shape the probe stays conservative
// about) with no compilable types answer: scriptc's fence.
diags.push(
Expand Down