Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions packages/rstack/rslib.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { defineConfig } from '@rslib/core';
import pkgJson from './package.json' with { type: 'json' };

const fullyMinifiedChunks = /lintStaged\.js$/;
const fullyMinifiedChunks = /staged\.js$/;

export default defineConfig({
lib: [{ syntax: 'es2023', dts: true }],
Expand Down Expand Up @@ -32,7 +32,8 @@ export default defineConfig({
css: false,
jsOptions: [
{
// Fully minify the bundled lint-staged code to reduce package size.
// Fully minify the staged chunk, including bundled lint-staged code,
// to reduce package size.
include: fullyMinifiedChunks,
},
{
Expand Down
10 changes: 8 additions & 2 deletions packages/rstack/src/cli/commands.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { join } from 'node:path';
import { color } from 'rslog';
import { getConfigState } from '../config.ts';
import { runSetupCLI } from '../setup/index.ts';
import { runStagedCLI } from '../staged.ts';
import { insertConfigArg, parseCliArgs } from './args.ts';

declare global {
Expand Down Expand Up @@ -154,11 +152,19 @@ export async function setupCommands(): Promise<void> {
}

if (command === 'staged') {
const { runStagedCLI } = await import(
/* rspackChunkName: 'staged' */
'../staged.ts'
);
await runStagedCLI(args.slice(1));
return;
}

if (command === 'setup') {
const { runSetupCLI } = await import(
/* rspackChunkName: 'setup' */
'../setup/index.ts'
);
runSetupCLI(args.slice(1));
return;
}
Expand Down
5 changes: 1 addition & 4 deletions packages/rstack/src/staged.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { parseArgs } from 'node:util';
import lintStaged from 'lint-staged';
import { color } from 'rslog';
import { loadRstackConfig } from './config.ts';

Expand Down Expand Up @@ -70,10 +71,6 @@ export async function runStagedCLI(args: string[]): Promise<void> {
);
}

const { default: lintStaged } = await import(
/* rspackChunkName: 'lintStaged' */
'lint-staged'
);
const success = await lintStaged({
allowEmpty: values['allow-empty'] ?? values.allowEmpty,
concurrent: values.concurrent === undefined ? undefined : JSON.parse(values.concurrent),
Expand Down