Skip to content

Conversation

@twlite
Copy link
Member

@twlite twlite commented May 29, 2025

Replaces tsup (esbuild) with tsdown (rolldown)

@netlify
Copy link

netlify bot commented May 29, 2025

Deploy Preview for commandkit ready!

Name Link
🔨 Latest commit 1a6884c
🔍 Latest deploy log https://app.netlify.com/projects/commandkit/deploys/683879317ac4f2000884e769
😎 Deploy Preview https://deploy-preview-205--commandkit.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@twlite twlite marked this pull request as draft May 29, 2025 14:05
@twlite twlite requested a review from Copilot May 29, 2025 14:06
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR replaces the existing tsup‐based (esbuild) bundler with tsdown (rolldown) and updates related plugin APIs and configuration.

  • Swap out tsup.config.ts for a tsdown.config.ts with equivalent settings.
  • Refactor the CompilerPluginRuntime and plugin interfaces to a unified transform(code, id) API.
  • Rename and wire through esbuildPluginsrolldownPlugins in configs, CLI commands, and package.json.

Reviewed Changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
packages/commandkit/tsup.config.ts Removed obsolete tsup configuration.
packages/commandkit/tsdown.config.ts Added new tsdown configuration with macro transform plugin.
packages/commandkit/src/plugins/plugin-runtime/builtin/MacroPlugin.ts Updated to use code/id and skip JSON inputs.
packages/commandkit/src/plugins/plugin-runtime/builtin/CommonDirectiveTransformer.ts Same code/id refactor and JSON skip.
packages/commandkit/src/plugins/plugin-runtime/CompilerPluginRuntime.ts Rewritten lifecycle: init/destroy, unified transform, removed esbuild hooks.
packages/commandkit/src/plugins/CompilerPlugin.ts Simplified interface to transform(code, id) and removed unused hooks.
packages/commandkit/src/config/types.ts Renamed esbuildPlugins to rolldownPlugins.
packages/commandkit/src/config/default.ts Swapped in @rollup/plugin-json under rolldownPlugins.
packages/commandkit/src/config/config.ts Merged rolldownPlugins instead of esbuildPlugins.
packages/commandkit/src/cli/production.ts Changed from esbuildPlugins to rolldownPlugins.
packages/commandkit/src/cli/development.ts Same swap of plugin array key.
packages/commandkit/src/cli/build.ts Uses tsdown.build, wires rolldownPlugins, adds init/destroy, removes require polyfill.
packages/commandkit/src/CommandKit.ts Moved plugin/handler initialization, stored options in a field.
packages/commandkit/package.json Swapped tsuptsdown in scripts and dependencies; added JSON plugin.
Comments suppressed due to low confidence (1)

packages/commandkit/src/cli/build.ts:134

  • [nitpick] The require() polyfill was removed from the injected entry file; if user code still relies on require, it could break. Verify that all dependencies use ESM imports or reintroduce a lightweight polyfill.
-${isDev ? `... requireScript ...` : wrapInAsyncIIFE([envScript(isDev)])}

OnResolveArgs,
OnResolveResult,
} from './plugin-runtime/types';
import { OnResolveArgs } from './plugin-runtime/types';
Copy link

Copilot AI May 29, 2025

Choose a reason for hiding this comment

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

The import OnResolveArgs is no longer used in this file; consider removing it to clean up unused code.

Suggested change
import { OnResolveArgs } from './plugin-runtime/types';

Copilot uses AI. Check for mistakes.
},
],
};
console.log(err);
Copy link

Copilot AI May 29, 2025

Choose a reason for hiding this comment

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

[nitpick] Use console.error instead of console.log when logging errors, so they are correctly classified in stderr.

Suggested change
console.log(err);
console.error(err);

Copilot uses AI. Check for mistakes.

export class CommandKit extends EventEmitter {
#started = false;
private options: CommandKitOptions;
Copy link

Copilot AI May 29, 2025

Choose a reason for hiding this comment

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

The options field is assigned in the constructor but never referenced elsewhere; consider removing it or using it to drive configuration.

Suggested change
private options: CommandKitOptions;
// Removed unused options field

Copilot uses AI. Check for mistakes.
params: PluginTransformParameters,
): Promise<MaybeFalsey<TransformedResult>> {
if (!this.options.enabled) return null;
if (/\.json$/.test(params.id)) return null;
Copy link

Copilot AI May 29, 2025

Choose a reason for hiding this comment

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

[nitpick] This JSON skip regex is duplicated in CommonDirectiveTransformer; consider extracting it into a shared constant to reduce duplication.

Copilot uses AI. Check for mistakes.
@twlite twlite marked this pull request as ready for review May 29, 2025 17:19
@twlite twlite merged commit a3c0e63 into main May 29, 2025
5 checks passed
@twlite twlite deleted the rolldown branch June 2, 2025 08:34
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