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

fix(serve): do not set port for modern client #2624

Merged
merged 3 commits into from
Apr 14, 2021
Merged

Conversation

snitin315
Copy link
Member

What kind of change does this PR introduce?
fix

Did you add tests for your changes?
NA

If relevant, did you update the documentation?
NA
Summary

we removed client.port in webpack/webpack-dev-server#3181

Refer webpack/webpack-dev-server#3181 (comment)

Does this PR introduce a breaking change?
No

Other information
No

@codecov
Copy link

codecov bot commented Apr 14, 2021

Codecov Report

Merging #2624 (8699374) into master (21291d2) will increase coverage by 0.12%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2624      +/-   ##
==========================================
+ Coverage   95.11%   95.23%   +0.12%     
==========================================
  Files          31       31              
  Lines        1514     1512       -2     
  Branches      431      429       -2     
==========================================
  Hits         1440     1440              
+ Misses         74       72       -2     
Impacted Files Coverage Δ
packages/serve/src/startDevServer.ts 90.16% <ø> (+2.86%) ⬆️
packages/generators/src/addon-generator.ts 93.18% <0.00%> (-2.28%) ⬇️
packages/generators/src/loader-generator.ts 91.66% <0.00%> (ø)
packages/generators/src/plugin-generator.ts 100.00% <0.00%> (+14.28%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 21291d2...8699374. Read the comment docs.

const devServerFlags = require('webpack-dev-server/bin/cli-flags').devServer;

const isModernClient = Boolean(devServerFlags.find((flag) => flag.name === 'client-web-socket-url'));

options.port = await findPort(options.port);
options.client = options.client || {};
Copy link
Member

Choose a reason for hiding this comment

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

We move it under isModerClient too

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh yes!

@alexander-akait
Copy link
Member

To be honestly I don't understand why we do it, if client port is not specified or 0 we just get self.location.port (basic workflow), so when you run without proxy, we already get port from browser, if we proxy hostname developer uses the same port so self.location.port will work, only one situation possible when you proxy dev server on other port, but in this case you need manually set client.port, because we don't know original hostname/port

@alexander-akait
Copy link
Member

alexander-akait commented Apr 14, 2021

It was my mistake here, we should not do it here, we should improve it on dev server, i.e. options.client.port || options.port, when we should do release and improve public here webpack/webpack-dev-server#3181 and do release again

Difficult...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants