tsproject
raw JSON → 4.1.0-dev.1 verified Fri May 01 auth: no javascript maintenance
TsProject is a TypeScript minifier and modular bundle optimizer that integrates with Gulp via Vinyl streams. It compiles TypeScript project configuration files (tsconfig.json) and supports ES6 module bundling, minification with identifier shortening, and cache-optimized incremental builds. Current stable version is 2.0.2 (latest release), with a v4.0.0 beta (4.1.0-dev.1) targeting TypeScript 4.0. Release cadence is infrequent, with major version bumps aligned to TypeScript releases. Key differentiators include native bundle support within tsconfig.json and compile-time bundling, unlike tools like r.js or Webpack. Requires Node >=14, ships TypeScript types, and is primarily used as a Gulp plugin.
Common errors
error Error: Cannot find module 'tsproject' ↓
cause tsproject is not installed or not in node_modules.
fix
Run 'npm install tsproject --save-dev' and ensure it's in the same directory as your gulpfile.
error TypeError: tsproject is not a function ↓
cause Using import or calling the export as a function instead of using tsproject.src.
fix
Use 'var tsproject = require('tsproject');' and call 'tsproject.src(...)'.
error Error: Cannot read property 'src' of undefined ↓
cause Incorrect require path or missing default export.
fix
Ensure require('tsproject') returns an object with 'src' method; check node_modules/tsproject/index.js.
error Error: No tsconfig.json found ↓
cause The path provided to tsproject.src does not contain a tsconfig.json file.
fix
Verify the path points to a directory or file that includes a valid tsconfig.json.
Warnings
breaking TsProject v4.0.0 requires TypeScript 4.0+ and Node >=14; older Node versions break. ↓
fix Upgrade Node to 14+ and TypeScript to 4.0+.
deprecated TsProject v2.0.2 is the last stable release; v4.0.0-dev.1 is beta and may have breaking changes. ↓
fix Use v2.0.2 for stability or test with v4.0.0-dev.1 for TypeScript 4.0 support.
gotcha TsProject only supports CommonJS via require(). ESM imports may fail due to lack of ESM module field. ↓
fix Use require() syntax in Node.js; avoid import statements.
gotcha Bundles defined in tsconfig.json require 'files' property to be present; missing files causes empty output. ↓
fix Ensure tsconfig.json includes both 'files' and 'bundles' sections.
Install
npm install tsproject yarn add tsproject pnpm add tsproject Imports
- tsproject wrong
import tsproject from 'tsproject';correctvar tsproject = require('tsproject'); - src wrong
tsproject('./path/to/project');correcttsproject.src('./path/to/project'); - tsproject.src
tsproject.src(configPath, options);
Quickstart
var tsproject = require('tsproject');
var gulp = require('gulp');
gulp.task('build', function() {
return tsproject.src('./src', {
logLevel: 1,
compileOptions: {
target: 'ES5',
module: 'commonjs'
}
})
.pipe(gulp.dest('./dist'));
});