Skip to content

Conversation

knagaitsev
Copy link
Collaborator

  • This is a bugfix
  • This is a feature
  • This is a code refactor
  • This is a test update
  • This is a docs update
  • This is a metadata update

For Bugs and Features; did you add new tests?

Yes

Motivation / Use-Case

I am working on going through createConfig and moving any CLI-specific behavior to the API. Since there is only one createConfig file, I think it makes sense to parallel it with one API helper to update options and set defaults.

I think it will get out of hand to have a helper for each option that needs to have a default setting, such as what I am doing in:

So the above PRs need to be updated to use this if we agree on this solution.

Breaking Changes

None

Additional Info

I will add tests for transportMode later, since serverMode and clientMode will be removed.

@codecov
Copy link

codecov bot commented Jul 12, 2019

Codecov Report

Merging #2117 into master will increase coverage by 0.02%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2117      +/-   ##
==========================================
+ Coverage   92.53%   92.56%   +0.02%     
==========================================
  Files          32       33       +1     
  Lines        1260     1265       +5     
  Branches      362      361       -1     
==========================================
+ Hits         1166     1171       +5     
  Misses         87       87              
  Partials        7        7
Impacted Files Coverage Δ
lib/Server.js 97.34% <100%> (-0.03%) ⬇️
lib/utils/normalizeOptions.js 100% <100%> (ø)

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 317e3ce...939e715. Read the comment docs.

Copy link
Member

@alexander-akait alexander-akait left a comment

Choose a reason for hiding this comment

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

Good idea, maybe we can move normalize all options inside this util

@knagaitsev
Copy link
Collaborator Author

/cc @hiroppy thoughts?

@hiroppy
Copy link
Member

hiroppy commented Jul 15, 2019

Sorry for the late reply.

maybe we can move normalize all options inside this util

Agree 👌

@knagaitsev
Copy link
Collaborator Author

Good idea, maybe we can move normalize all options inside this util

I agree, but I don't think we should move them in this PR because some of them will cause breaking changes (since the normalizing done in createConfig is currently CLI only.)

@hiroppy
Copy link
Member

hiroppy commented Jul 15, 2019

We might be better to change the base branch to the next for safety.

@alexander-akait
Copy link
Member

alexander-akait commented Jul 15, 2019

@hiroppy i think don't need use next branch for this, it is just refactor

@knagaitsev
Copy link
Collaborator Author

@hiroppy Currently there are no breaking changes, I just moved stuff from the start of the Server.js file into the new helper. Then I plan to move other options from createConfig into here. When it is a breaking change I will add it in on next.

@alexander-akait
Copy link
Member

/cc @hiroppy for me we can merge this for master version

beforeAll(() => {
let webpackConfig;
if (data.multiCompiler) {
// eslint-disable-next-line global-require
Copy link
Member

Choose a reason for hiding this comment

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

You can delete this comment

// eslint-disable-next-line global-require
webpackConfig = require('../../fixtures/multi-compiler-config/webpack.config');
} else {
// eslint-disable-next-line global-require
Copy link
Member

Choose a reason for hiding this comment

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

ditto

@knagaitsev
Copy link
Collaborator Author

/cc @evilebottnawi @hiroppy

hiroppy
hiroppy previously approved these changes Jul 23, 2019
no-undefined
*/

function updateOptions(compiler, options) {
Copy link
Member

Choose a reason for hiding this comment

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

@Loonride maybe normalizeOptions better name here? Anyway code looks good

@alexander-akait
Copy link
Member

/cc @hiroppy

@hiroppy hiroppy merged commit 0c95a9e into webpack:master Jul 23, 2019
knagaitsev added a commit to knagaitsev/webpack-dev-server that referenced this pull request Jul 31, 2019
* refactor(server): add update options api helper

* test(server): removed global require eslint comments

* refactor(server): switch update options to normalize options
@knagaitsev knagaitsev added gsoc Google Summer of Code scope: cli labels Aug 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gsoc Google Summer of Code scope: cli

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants