Skip to content
Closed
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
23 changes: 18 additions & 5 deletions packages/rspack-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,12 @@
},
"dependencies": {
"@discoveryjs/json-ext": "^0.5.7",
"@rspack/dev-server": "~1.1.5",
"exit-hook": "^4.0.0",
"webpack-bundle-analyzer": "4.10.2"
"exit-hook": "^4.0.0"
},
"devDependencies": {
"@rslib/core": "0.19.1",
"@rspack/core": "workspace:*",
"@rspack/dev-server": "~1.1.5",
"@rspack/test-tools": "workspace:*",
"@types/webpack-bundle-analyzer": "^4.7.0",
"cac": "^6.7.14",
Expand All @@ -50,10 +49,24 @@
"picocolors": "^1.1.1",
"pirates": "^4.0.7",
"ts-node": "^10.9.2",
"typescript": "^5.9.3"
"typescript": "^5.9.3",
"webpack-bundle-analyzer": "4.10.2"
},
"peerDependencies": {
"@rspack/core": "^1.0.0-alpha || ^1.x"
"@rspack/core": "^1.0.0-alpha || ^1.x",
"@rspack/dev-server": "~1.1.5",
"webpack-bundle-analyzer": "4.10.2"
Copy link

Copilot AI Jan 8, 2026

Choose a reason for hiding this comment

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

The version constraint for webpack-bundle-analyzer in peerDependencies uses an exact version (4.10.2) which is overly restrictive. Consider using a more flexible version range like "^4.10.2" to allow users to use newer compatible versions without peer dependency warnings. This follows the pattern used for @rspack/core which uses "^1.0.0-alpha || ^1.x".

Suggested change
"webpack-bundle-analyzer": "4.10.2"
"webpack-bundle-analyzer": "^4.10.2"

Copilot uses AI. Check for mistakes.
Copy link
Author

Choose a reason for hiding this comment

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

The previous contraint was fixed to 4.10.2, IMHO there is nothing to change here.

},
"peerDependenciesMeta": {
"@rspack/core": {
"optional": false
},
Comment on lines +61 to +63
Copy link
Author

Choose a reason for hiding this comment

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

@rspack/core was already a peerDependency but it was not explicitly configured as non-optional.

Comment on lines +61 to +63
Copy link

Copilot AI Jan 8, 2026

Choose a reason for hiding this comment

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

Setting "optional": false for @rspack/core in peerDependenciesMeta is redundant, as peer dependencies are required by default. You can remove this entry and only keep the entries for optional peer dependencies (@rspack/dev-server and webpack-bundle-analyzer).

Suggested change
"@rspack/core": {
"optional": false
},

Copilot uses AI. Check for mistakes.
"@rspack/dev-server": {
"optional": true
},
"webpack-bundle-analyzer": {
"optional": true
}
},
"publishConfig": {
"access": "public",
Expand Down
12 changes: 12 additions & 0 deletions packages/rspack-cli/src/commands/preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,18 @@ export class PreviewCommand implements RspackCommand {
setDefaultNodeEnv(options, 'production');
normalizeCommonOptions(options, 'preview');

const packageName = '@rspack/dev-server';
try {
require.resolve(packageName);
} catch {
const logger = cli.getLogger();
logger.warn(
Copy link

Copilot AI Jan 8, 2026

Choose a reason for hiding this comment

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

The error message uses logger.warn but then exits with code 2, which indicates an error. Consider using logger.error instead of logger.warn for consistency, since this is a fatal error that prevents the command from running.

Suggested change
logger.warn(
logger.error(

Copilot uses AI. Check for mistakes.
`Package "${packageName}" is not installed. Please install it before using "rspack preview" command.`,
);
process.exit(2);
}

// Lazy import @rspack/dev-server to avoid loading it on build mode
const { RspackDevServer } = await import('@rspack/dev-server');

let { config } = await cli.loadConfig(options);
Expand Down
11 changes: 11 additions & 0 deletions packages/rspack-cli/src/commands/serve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,17 @@ export class ServeCommand implements RspackCommand {
normalizeCommonOptions(cliOptions, 'serve');
cliOptions.hot = normalizeHotOption(cliOptions.hot);

const packageName = '@rspack/dev-server';
try {
require.resolve(packageName);
} catch {
const logger = cli.getLogger();
logger.warn(
Copy link

Copilot AI Jan 8, 2026

Choose a reason for hiding this comment

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

The error message uses logger.warn but then exits with code 2, which indicates an error. Consider using logger.error instead of logger.warn for consistency, since this is a fatal error that prevents the command from running.

Suggested change
logger.warn(
logger.error(

Copilot uses AI. Check for mistakes.
`Package "${packageName}" is not installed. Please install it before using "rspack serve" command.`,
);
process.exit(2);
}

// Lazy import @rspack/dev-server to avoid loading it on build mode
const { RspackDevServer } = await import('@rspack/dev-server');

Expand Down
12 changes: 6 additions & 6 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading