diff --git a/docs/generated/packages/rspack/executors/rspack.json b/docs/generated/packages/rspack/executors/rspack.json index 3074d5fb35dc0..af209168355cb 100644 --- a/docs/generated/packages/rspack/executors/rspack.json +++ b/docs/generated/packages/rspack/executors/rspack.json @@ -155,7 +155,7 @@ "description": "Generates a `package.json` and pruned lock file with the project's `node_module` dependencies populated for installing in a container. If a `package.json` exists in the project's directory, it will be reused with dependencies populated." } }, - "required": ["main", "outputPath", "tsConfig", "rspackConfig"], + "required": ["outputPath", "tsConfig", "rspackConfig"], "definitions": { "assetPattern": { "oneOf": [ diff --git a/packages/rspack/src/executors/rspack/schema.d.ts b/packages/rspack/src/executors/rspack/schema.d.ts index a8b50defde283..2d3ce45f375be 100644 --- a/packages/rspack/src/executors/rspack/schema.d.ts +++ b/packages/rspack/src/executors/rspack/schema.d.ts @@ -2,7 +2,7 @@ import type { Mode } from '@rspack/core'; export interface RspackExecutorSchema { target?: 'web' | 'node'; - main: string; + main?: string; index?: string; tsConfig: string; typeCheck?: boolean; diff --git a/packages/rspack/src/executors/rspack/schema.json b/packages/rspack/src/executors/rspack/schema.json index a86ceca1772a2..0df44d650ddfa 100644 --- a/packages/rspack/src/executors/rspack/schema.json +++ b/packages/rspack/src/executors/rspack/schema.json @@ -133,7 +133,7 @@ "description": "Generates a `package.json` and pruned lock file with the project's `node_module` dependencies populated for installing in a container. If a `package.json` exists in the project's directory, it will be reused with dependencies populated." } }, - "required": ["main", "outputPath", "tsConfig", "rspackConfig"], + "required": ["outputPath", "tsConfig", "rspackConfig"], "definitions": { "assetPattern": { "oneOf": [ diff --git a/packages/rspack/src/utils/create-compiler.ts b/packages/rspack/src/utils/create-compiler.ts index cbe05992d0315..3bea5335d0e49 100644 --- a/packages/rspack/src/utils/create-compiler.ts +++ b/packages/rspack/src/utils/create-compiler.ts @@ -41,6 +41,8 @@ export async function createCompiler( config.devServer ??= options.devServer; } + validateConfig(config); + return rspack(config); } @@ -49,3 +51,16 @@ export function isMultiCompiler( ): compiler is MultiCompiler { return 'compilers' in compiler; } + +function validateConfig(config: Configuration) { + if (!config.entry) { + throw new Error( + 'Entry is required. Please set the `main` option in the executor or the `entry` property in the rspack config.' + ); + } + if (!config.output) { + throw new Error( + 'Output is required. Please set the `outputPath` option in the executor or the `output` property in the rspack config.' + ); + } +}