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: 5 additions & 0 deletions .changeset/khaki-olives-add.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@callstack/repack": patch
---

Don't error on missing `--entry-file` when entry is defined in `rspack.config.js` or `webpack.config.js`.
10 changes: 6 additions & 4 deletions packages/repack/src/commands/common/getEnvOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ export function getEnvOptions(cliOptions: CliOptions): EnvOptions {
cliOptions.arguments.bundle.minify ?? env.mode === 'production';

const { entryFile } = cliOptions.arguments.bundle;
env.entry =
path.isAbsolute(entryFile) || entryFile.startsWith('./')
? entryFile
: `./${entryFile}`;
if (entryFile) {
env.entry =
path.isAbsolute(entryFile) || entryFile.startsWith('./')
? entryFile
: `./${entryFile}`;
}

env.bundleFilename = cliOptions.arguments.bundle.bundleOutput;
env.sourceMapFilename = cliOptions.arguments.bundle.sourcemapOutput;
Expand Down
8 changes: 4 additions & 4 deletions packages/repack/src/commands/rspack/bundle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,17 @@ export async function bundle(
arguments: { bundle: args },
};

if (!args.entryFile) {
throw new Error("Option '--entry-file <path>' argument is missing");
}

if (args.verbose) {
process.env[VERBOSE_ENV_KEY] = '1';
}

const envOptions = getEnvOptions(cliOptions);
const config = await loadConfig<Configuration>(rspackConfigPath, envOptions);

if (!args.entryFile && !config.entry) {
throw new Error("Option '--entry-file <path>' argument is missing");
}

const errorHandler = async (error: Error | null, stats?: Stats) => {
if (error) {
console.error(error);
Expand Down
8 changes: 4 additions & 4 deletions packages/repack/src/commands/webpack/bundle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,6 @@ export async function bundle(
arguments: { bundle: args },
};

if (!args.entryFile) {
throw new Error("Option '--entry-file <path>' argument is missing");
}

if (args.verbose) {
process.env[VERBOSE_ENV_KEY] = '1';
}
Expand All @@ -57,6 +53,10 @@ export async function bundle(
envOptions
);

if (!args.entryFile && !webpackConfig.entry) {
throw new Error("Option '--entry-file <path>' argument is missing");
}

const errorHandler = async (error: Error | null, stats?: webpack.Stats) => {
if (error) {
console.error(error);
Expand Down