Skip to main content

devtools-imports

Conventions for importing code in Devtools to avoid build errors. Covers cross-module imports, internal imports, and the "import * as" requirement.

Source facts

Repository
ChromeDevTools/devtools-frontend
Last source activity
March 16, 2026 at 19:26
Detected SKILL.md language
English
Stars
4,088
Forks
736

Install options

The review-first prompt is selected by default. You can switch to a direct command or download a local copy.

Review the source files

Read SKILL.md and any companion files shown by SkillsMP before deciding whether to install.

Showing SKILL.md

SKILL.md
Source instructions · Read-only preview
name
devtools-imports
description
Conventions for importing code in Devtools to avoid build errors. Covers cross-module imports, internal imports, and the "import * as" requirement.
# Imports This codebase follows a special convention for importing code that must be followed to avoid build errors. In DevTools each folder of code is considered a *module*: - `front_end/models/trace` is the *trace module*. - `front_end/panels/timeline` is the *timeline module*. Within each module there are multiple TypeScript files. *The file that is named the same as the folder name is called the entrypoint*. - `front_end/models/trace/trace.ts` is the *trace module's entrypoint* - `front_end/models/trace/ModelImpl.ts` is part of the implementation of the trace module. ## Importing from another module When you want to reuse code from other modules, *you must import that module via its entrypoint*. Imagine we are in `front_end/panels/timeline/TimelinePanel.ts`. This import is GOOD: ```ts import * as Trace from '../models/trace/trace.js'; // import the entrypoint ``` This import is BAD because we import a file that is NOT the entrypoint: ```ts import * as ModelImpl from '../models/trace/ModelImpl.js' // NEVER ALLOWED ``` Additionally, you **must import using the `import * as` syntax**. ```ts import {ModelImpl, X, Y} from '../models/trace/trace.js'; // BAD ``` ```ts import * as Trace from '../models/trace/trace.js'; // GOOD ``` ## Importing from within the same module If you are within the same module, it is OK to import from files directly rather than go via the entrypoint. You can also import specifically what you need. For example, if you are editing `front_end/models/trace/ModelImpl.ts` this would be acceptable: ```ts import {Foo} from './Foo.js'; // allowed because Foo.ts is in the same directory. ```
View on GitHub