{"id":25709,"library":"gulp-swc","title":"gulp-swc","description":"Gulp plugin for integrating the SWC (rust-based JavaScript/TypeScript compiler) into Gulp pipelines. Current stable version is 2.2.0 (released 2024-07-23), with a bus factor of less than 10 contributors and monthly releases. It provides fast transpilation via SWC, supports both CommonJS and ESM, and requires peer dependencies `@swc/core` (^1.7.20) and `gulp` (3.x, 4.x, or 5.x). Compared to gulp-babel or gulp-typescript, it offers significantly faster compilation and native TypeScript support without separate type checking. Node.js >=18 required.","status":"active","version":"2.2.0","language":"javascript","source_language":"en","source_url":"git://github.com/konclave/gulp-swc","tags":["javascript","gulpplugin","swc","compiler","typescript","transpiler"],"install":[{"cmd":"npm install gulp-swc","lang":"bash","label":"npm"},{"cmd":"yarn add gulp-swc","lang":"bash","label":"yarn"},{"cmd":"pnpm add gulp-swc","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Mandatory peer dependency; provides the SWC compiler engine.","package":"@swc/core","optional":false},{"reason":"Mandatory peer dependency; gulp is required to run the pipeline.","package":"gulp","optional":false}],"imports":[{"note":"CommonJS require is the standard pattern for Gulp plugins; ESM import may be unavailable or experimental.","wrong":"import swc from 'gulp-swc';","symbol":"gulpSwc","correct":"const swc = require('gulp-swc');"},{"note":"If using ESM (with 'type': 'module' in package.json or .mjs extension), default import works correctly.","wrong":"import { default as swc } from 'gulp-swc';","symbol":"default","correct":"import swc from 'gulp-swc';"},{"note":"No common mistakes with this symbol; it's a default export function.","wrong":null,"symbol":"gulpSwc","correct":"export function gulpSwc() { ... }"}],"quickstart":{"code":"const gulp = require('gulp');\nconst swc = require('gulp-swc');\n\ngulp.task('build', function () {\n  return gulp\n    .src('src/**/*.ts')\n    .pipe(swc({\n      jsc: {\n        parser: {\n          syntax: 'typescript'\n        },\n        target: 'es2020',\n        minify: {\n          compress: true,\n          mangle: true\n        }\n      },\n      module: {\n        type: 'commonjs'\n      }\n    }))\n    .pipe(gulp.dest('dist'));\n});","lang":"javascript","description":"Demonstrates a basic Gulp task that compiles TypeScript files using SWC with a custom configuration for parser, target, minification, and module type."},"warnings":[{"fix":"Upgrade Node.js to >=18 or pin gulp-swc to v1.x.","message":"gulp-swc dropped support for Node.js <18 in v2.0.0. Older versions (1.x) are no longer maintained.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Always pass an options object: swc({}).","message":"The swc() function called without options (i.e., no configuration argument) is deprecated since v2.1.0. Future versions will require at least an empty object.","severity":"deprecated","affected_versions":">=2.1.0"},{"fix":"Order: .pipe(sourcemaps.init()).pipe(swc()).pipe(sourcemaps.write()).","message":"When using gulp-sourcemaps, you must call swc() after sourcemaps.init() and before sourcemaps.write(). An incorrect order causes source map corruption.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Update @swc/core and adjust SWC options according to SWC changelog.","message":"Peer dependency @swc/core was updated from ^1.3.46 to ^1.7.20 in v2.0.0. Incompatible options (e.g., 'target' field renamed) may cause runtime errors.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Always provide a static configuration object or call a synchronous function that returns an object.","message":"The plugin expects the SWC configuration object to be a plain object; passing a function or promise causes unexpected behavior.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Upgrade to Gulp v4 or v5.","message":"Support for Gulp v3 (gulp@~3.9.0) is deprecated since v2.0.0 and will be removed in v3.0.0.","severity":"deprecated","affected_versions":">=2.0.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Ensure gulp-swc runs in a Node.js environment (not bundled for browser). In tooling scripts, use CommonJS require with Node >=18.","cause":"Trying to use gulp-swc in a browser/Node vs ESM context where @swc/core is not natively available.","error":"Error: Module \"@swc/core\" has been externalized for browser compatibility and cannot be accessed in client code."},{"fix":"Use const swc = require('gulp-swc'); or import swc from 'gulp-swc';","cause":"Using an incorrect import style (e.g., named import instead of default).","error":"TypeError: swc is not a function"},{"fix":"Always pass an object: swc({...}) or at least swc({}).","cause":"Calling swc() without any arguments or passing a non-object (e.g., a string).","error":"gulp-swc: options must be an object"},{"fix":"Reorder: .pipe(sourcemaps.init()).pipe(swc()).pipe(sourcemaps.write()).","cause":"gulp-sourcemaps .init() is placed after .pipe(swc()) instead of before.","error":"Error: Received null/undefined for source map chain. Ensure sourcemaps are created before swc."}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}