Skip to content

PERF010 · Namespace import

Severity: info · Category: performance

Flags a value import * as X from '<package>' from a bare (node_modules) package. Type-only imports (import type * as T) and non-bare specifiers (relative, $lib, $app, $env, #…) are not flagged. Static (CLI) analysis of src/**/*.svelte scripts.

A namespace import (import * as X) is only tree-shakeable while every access to X stays static (X.foo()); passing X around or indexing it dynamically (X[key]) forces the bundler to assume every export is reachable and keep the whole module. Named imports are reliably shakeable and make the dependency surface explicit — even packages like three or d3 ship less when imported by name.

<script>
// Instead of: import * as _ from 'lodash';
import debounce from 'lodash/debounce';
// Instead of: import * as THREE from 'three';
import { Scene, WebGLRenderer } from 'three';
</script>