single-file transpilation
Compiling each file on its own without looking at the rest of the project, which is fast but cannot use type information.
In more detail
Tools such as esbuild, SWC and Babel work this way. They cannot tell whether an imported name is a type, so code must make that explicit with type-only imports. The isolatedModules and verbatimModuleSyntax options warn about code these tools cannot handle.
Related terms
- verbatimModuleSyntax — The compiler option that keeps every import and export exactly as written, except those marked type, which are removed.
- transpiler — A tool that translates source code into another language at a similar level, such as TypeScript into plain JavaScript.
- esbuild — A very fast JavaScript and TypeScript bundler and transpiler written in Go.
- SWC — A fast TypeScript and JavaScript compiler written in Rust, used by tools such as Next.js to transpile code.
Taught in
- ECMAScript Modules, CJS Interop And verbatimModuleSyntax — Production TypeScript