Skip to content

feat!: update ts version and build cjs and esm separatelly#28

Merged
Qbit982 merged 1 commit intomainfrom
update_ts_and_build
May 6, 2025
Merged

feat!: update ts version and build cjs and esm separatelly#28
Qbit982 merged 1 commit intomainfrom
update_ts_and_build

Conversation

@Qbit982
Copy link
Contributor

@Qbit982 Qbit982 commented May 5, 2025

Update TypeScript Version and Build CJS/MJS Separately

Summary by Sourcery

Update project build configuration to support both CommonJS and ES modules with improved TypeScript setup

New Features:

  • Add support for ES modules and CommonJS module exports
  • Implement separate build outputs for ESM and CJS

Enhancements:

  • Upgrade TypeScript to version 5.8.3
  • Improve TypeScript compiler options for modern module resolution

Build:

  • Replace TypeScript compilation with Gulp-based build process
  • Add Gulp tasks for building ESM and CJS modules
  • Update build scripts to use new Gulp workflow

Chores:

  • Update development dependencies
  • Modify package.json export configuration

@sourcery-ai
Copy link

sourcery-ai bot commented May 5, 2025

Reviewer's Guide

This pull request updates the TypeScript version to ^5.8.3 and refactors the build process using Gulp to generate separate CommonJS (CJS) and ECMAScript Module (ESM) builds. It modifies tsconfig.json to support the new build targets and updates package.json with new dependencies (gulp, rimraf, @gravity-ui/gulp-utils), adjusted scripts to use Gulp, and an exports field to direct consumers to the appropriate CJS/ESM entry points.

File-Level Changes

Change Details Files
Updated TypeScript version and related dependencies.
  • Upgraded TypeScript from ^4.9.5 to ^5.8.3.
  • Updated other development dependencies like @commitlint/*, rimraf, etc.
package.json
package-lock.json
Introduced Gulp for building separate CJS and ESM modules.
  • Added new dev dependencies: gulp, gulp-cli, gulp-sourcemaps, rimraf, @gravity-ui/gulp-utils.
  • Created gulpfile.js with tasks (clean, compile-to-esm, compile-to-cjs, build) to handle the dual build process.
  • Modified build and added clean scripts in package.json to use Gulp tasks.
  • Removed direct tsc usage from build script.
package.json
gulpfile.js
package-lock.json
Configured TypeScript for dual CJS/ESM output and updated target.
  • Changed compilerOptions.target to es2022.
  • Updated compilerOptions.module to esnext and moduleResolution to bundler.
  • Set compilerOptions.outDir to build/esm (Gulp overrides for CJS).
  • Enabled importHelpers and verbatimModuleSyntax.
  • Removed specific module setting (handled by Gulp per target).
tsconfig.json
Updated package manifest (package.json) for dual module support.
  • Added exports field defining separate entry points (import and require) for ESM and CJS builds, including types.
  • Removed top-level main and types (now handled by exports, though kept for compatibility).
  • Moved nano-staged configuration higher in the file.
package.json
Adjusted type import syntax.
  • Changed import {GatewayError} to import type {GatewayError} for type-only import.
lib/utils/common.ts

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @Qbit982 - I've reviewed your changes - here's some feedback:

  • Consider removing or clarifying the purpose of the top-level main and types fields, as the exports field now defines the primary entry points.
  • The new Gulp build adds complexity; evaluate if invoking tsc directly with configuration overrides could achieve the same CJS/ESM outputs more simply.
Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟡 Complexity: 1 issue found
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@Qbit982 Qbit982 changed the title Update ts and build feat(main): update ts version and build cjs and esm separatelly May 5, 2025
@Qbit982 Qbit982 force-pushed the update_ts_and_build branch from 563428a to 7daa252 Compare May 5, 2025 15:01
@SeqviriouM SeqviriouM changed the title feat(main): update ts version and build cjs and esm separatelly feat!: update ts version and build cjs and esm separatelly May 6, 2025
@Qbit982 Qbit982 force-pushed the update_ts_and_build branch from 7e6dade to d7c0c43 Compare May 6, 2025 10:16
@Qbit982 Qbit982 merged commit fa520fb into main May 6, 2025
3 checks passed
@Qbit982 Qbit982 deleted the update_ts_and_build branch May 6, 2025 10:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants