Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature]: support more command-line flags #7573

Closed
hardfist opened this issue Aug 14, 2024 · 6 comments · Fixed by #7710
Closed

[Feature]: support more command-line flags #7573

hardfist opened this issue Aug 14, 2024 · 6 comments · Fixed by #7710
Labels
feat New feature or request good first issue Good for newcomers team The issue/pr is created by the member of Rspack.

Comments

@hardfist
Copy link
Contributor

hardfist commented Aug 14, 2024

What problem does this feature solve?

Rspack currently missing some cli flags which cause some migration pain for users, see https://birtles.blog/2024/08/14/lessons-learned-switching-to-rspack/#command-line-flags

Rspack CLI includes a built-in dev server but unfortunately, the command-line flags differ from webpack-dev-server in a few places, notably missing options like --port and --hot/--no-hot.
To handle such cases I ended up using various --env values and checking them in rspack.config.js’s configuration function. This seems like a potentially unnecessary point of friction that could be eased in a future release.

we can align more flags to make migration easier

What does the proposed API of configuration look like?

seems no need to support all flags(some flags are rarely used and hard to understand), but we can support some common flags like

--port
--hot | --no-hot
--host
@hardfist hardfist added feat New feature or request pending triage The issue/PR is currently untouched. labels Aug 14, 2024
@github-actions github-actions bot added the team The issue/pr is created by the member of Rspack. label Aug 14, 2024
@hardfist hardfist added good first issue Good for newcomers and removed pending triage The issue/PR is currently untouched. labels Aug 14, 2024
@shulaoda
Copy link
Collaborator

Can you answer my question? I see these two variables below, but it doesn't seem to have been actually used?

const usedPorts: number[] = [];
const servers: RspackDevServerType[] = [];

@hardfist
Copy link
Contributor Author

hardfist commented Aug 28, 2024

Can you answer my question? I see these two variables below, but it doesn't seem to have been actually used?

const usedPorts: number[] = [];
const servers: RspackDevServerType[] = [];

it's used here, if multi compiler specify same port, it will throw error

@shulaoda
Copy link
Collaborator

it's used here, if multi compiler specify same port, it will throw error

if (usedPorts.find(port => portNumber === port)) {
throw new Error(
"Unique ports must be specified for each devServer option in your rspack configuration. Alternatively, run only 1 devServer config using the --config-name flag to specify your desired config."
);
}
usedPorts.push(portNumber);

But it doesn't seem to be used anywhere else except here. usedPorts seems to be absolutely empty.

@hardfist
Copy link
Contributor Author

hardfist commented Aug 28, 2024

it's used here, if multi compiler specify same port, it will throw error

if (usedPorts.find(port => portNumber === port)) {
throw new Error(
"Unique ports must be specified for each devServer option in your rspack configuration. Alternatively, run only 1 devServer config using the --config-name flag to specify your desired config."
);
}
usedPorts.push(portNumber);

But it doesn't seem to be used anywhere else except here. usedPorts seems to be absolutely empty.

why,the push will update usedports

@shulaoda
Copy link
Collaborator

why the push will update usedports

This is where I am confused, this code seems meaningless.

@hardfist
Copy link
Contributor Author

if you have two compiler and both use same port,during loop the usedports is updated so it can be used to detect conflict in next iteration

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat New feature or request good first issue Good for newcomers team The issue/pr is created by the member of Rspack.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants