Setup Gulp separates two distinct concerns of the TypeScript toolchain: type checking is handled by the TypeScript compiler (Documentation Index
Fetch the complete documentation index at: https://mintlify.com/jpachecox/setup-gulp/llms.txt
Use this file to discover all available pages before exploring further.
tsc) in isolation, while the actual transpilation to JavaScript is delegated to Babel. This split gives you the full safety of TypeScript’s strict type system during development and CI while keeping the Gulp build pipeline fast and flexible through Babel’s transform-based architecture.
tsconfig.json
The TypeScript configuration is intentionally lean — it focuses on type-checking accuracy and test environment compatibility rather than on emit configuration, since Babel handles compilation:| Option | Effect |
|---|---|
target: "es2016" | Output syntax compatible with modern browsers; supports async/await, for...of, and other ES2016+ constructs natively without heavy polyfills |
module: "commonjs" | Generates require()/module.exports module syntax, compatible with Node.js and the Gulp runtime |
esModuleInterop: true | Allows clean default imports from CommonJS packages (e.g. import fs from 'fs') without the * as workaround |
forceConsistentCasingInFileNames: true | Prevents import path casing mismatches that compile successfully on case-insensitive filesystems (macOS) but fail on Linux CI |
strict: true | Enables the full suite of strict type-checking flags: noImplicitAny, strictNullChecks, strictFunctionTypes, and more |
skipLibCheck: true | Skips type checking of .d.ts declaration files in node_modules, significantly speeding up tsc in projects with many dependencies |
types: ["vitest/globals"] | Injects Vitest’s global type declarations (test, expect, describe, etc.) into every file, matching the globals: true runtime setting in vitest.config.ts and eliminating the need for explicit imports in test files |
Babel compilation pipeline
Whiletsc validates types, Babel is responsible for the actual source-to-JavaScript transformation in the Gulp build. This approach is common in projects that need custom transform pipelines or Gulp integration, because Babel operates on a file-by-file basis without needing a full type graph, making incremental builds faster.
The Babel configuration uses four presets and plugins:
@babel/preset-env
Transpiles modern JavaScript syntax to the target browser environment defined in the
browserslist field (last 2 versions).@babel/preset-typescript
Strips TypeScript type annotations and syntax, converting
.ts files to plain JavaScript without performing type checking.@babel/plugin-transform-runtime
Replaces inline Babel helpers with imports from
@babel/runtime, reducing output bundle size when the same helper is used across multiple files.@babel/plugin-proposal-class-properties
Enables class field syntax (
class Foo { bar = 1 }), which is used in component and section source files.yarn build:compile processes every .ts file under src/ and writes the transpiled output — together with source maps — to the build/ directory. yarn build:types runs tsc purely for type validation and declaration file generation, with no JavaScript emit overlapping the Babel output.
TypeScript in Gulp tasks
Thegulp js, gulp jsComponents, and gulp jsSections tasks form the main JavaScript build pipeline. Each task sources .ts files, pipes them through gulp-babel, and feeds the result to gulp-uglify for minification:
Source TypeScript files
gulp.src() collects .ts files from the relevant directory (src/js/, src/js/components/, or src/js/sections/).Transpile with gulp-babel
gulp-babel invokes Babel on each file using the project’s Babel config. @babel/preset-typescript strips all type annotations and converts TypeScript-specific syntax, while @babel/preset-env handles the remaining ES-to-ES5 downlevelling.Minify with gulp-uglify
The plain JavaScript output is passed to
gulp-uglify, which removes whitespace, renames local variables, and produces production-ready minified bundles.Type definitions
The following@types/* packages are installed to provide TypeScript declarations for the project’s runtime and build dependencies: