Skip to content

refactor(client): migrate client to built-in logger #2631

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

Merged
merged 12 commits into from
Jun 20, 2020

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?

Motivation / Use-Case

Migrating to built-in logger in client

Followed slightly different approach for the actual log util than #2563

Breaking Changes

Yes, new client log levels

@hiroppy Do we need to worry about this for webpack@5 b6af4e9#diff-bd664d218d585ff7bd6ceced46bd877aR3

Additional Info

@codecov
Copy link

codecov bot commented May 28, 2020

Codecov Report

Merging #2631 into v4 will increase coverage by 0.10%.
The diff coverage is 96.55%.

Impacted file tree graph

@@            Coverage Diff             @@
##               v4    #2631      +/-   ##
==========================================
+ Coverage   92.35%   92.46%   +0.10%     
==========================================
  Files          34       34              
  Lines        1321     1300      -21     
  Branches      373      365       -8     
==========================================
- Hits         1220     1202      -18     
+ Misses         96       93       -3     
  Partials        5        5              
Impacted Files Coverage Δ
client-src/default/index.js 92.47% <92.30%> (+0.25%) ⬆️
client-src/clients/SockJSClient.js 63.63% <100.00%> (ø)
client-src/clients/WebsocketClient.js 55.81% <100.00%> (ø)
client-src/default/utils/log.js 100.00% <100.00%> (+8.82%) ⬆️
client-src/default/utils/reloadApp.js 86.95% <100.00%> (ø)
lib/Server.js 95.90% <100.00%> (ø)
lib/utils/createConfig.js 95.50% <100.00%> (+0.10%) ⬆️

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 cb80c00...0afc8c6. Read the comment docs.

@@ -1,5 +1,11 @@
'use strict';

// webpack@5 doesn't inject node polyfill automatically
window.global = window.global || window;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this was needed to make the other polyfills work. Is this way to handle this okay, or is it a problem that this is ignoring webpack's node option https://webpack.js.org/configuration/node/ ?

Any suggestions?

Copy link
Member

Choose a reason for hiding this comment

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

Hm, why we need process and util?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hm, why we need process and util?

@evilebottnawi webpack5 tests were not passing, this made them work. Not sure if there is a better solution. @hiroppy Originally put that in here:
b6af4e9#diff-bd664d218d585ff7bd6ceced46bd877aR3

Copy link
Member

Choose a reason for hiding this comment

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

We can use alias here when we will switch on webpack@5, we really need full process/browser and util/util packages? Maybe we can copy post some function to avoid using full packages?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

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.

Some improvements and questions

lib/options.json Outdated
"none",
"warning"
]
"enum": ["none", "error", "warn", "info", "log", "verbose"]
Copy link
Member

Choose a reason for hiding this comment

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

Let's move it to clientOptions, i.e.:

clientOptions: { 
  logging: {
    level: 'info',
    // Let's avoid implement debug in this PR, just for future, schema should not contain debug too
    debug: [
      'MyPlugin',
      /MyPlugin/,
      (name) => name.contains('MyPlugin')
    ]
  }
}

Like here https://webpack.js.org/configuration/other-options/#infrastructurelogging

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@evilebottnawi Should we rename the client-log-level option then? Maybe client-logging? I think just logging might be confusing.

Copy link
Member

Choose a reason for hiding this comment

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

@Loonride webpack has infrastructureLogging, so better to keep this same - https://webpack.js.org/configuration/other-options/

Copy link
Member

Choose a reason for hiding this comment

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

I think we should move all client options to clientOptions, maybe we should rename clientOptions to client, less characters in the name, what do you think?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, I moved logging into clientOptions. I agree that it should be renamed to client, but that is an easy fix, I will do it later

@@ -55,17 +61,20 @@ const onSocketMessage = {
status.currentHash = hash;
},
'still-ok': function stillOk() {
log.info('[WDS] Nothing changed.');
log.info('Nothing changed.');
if (options.useWarningOverlay || options.useErrorOverlay) {
overlay.clear();
}
sendMessage('StillOk');
},
'log-level': function logLevel(level) {
Copy link
Member

Choose a reason for hiding this comment

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

Let't rename it to logging

@@ -1,5 +1,11 @@
'use strict';

// webpack@5 doesn't inject node polyfill automatically
window.global = window.global || window;
Copy link
Member

Choose a reason for hiding this comment

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

Hm, why we need process and util?

@alexander-akait
Copy link
Member

/cc @Loonride

@knagaitsev knagaitsev force-pushed the refactor/client-builtin-logger branch from 7ca1907 to eaa9d15 Compare June 14, 2020 19:46
// webpack@5 doesn't inject node polyfill automatically
window.global = window.global || window;
window.process = window.process || {};
window.process.env = window.process.env || {};
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@evilebottnawi I substituted process/browser out for this, I think it is all that is needed. I think we still need the util/util package as a dependency, since something in tapable needs it.

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 job, I think we need to babel for our client, because we need support IE11 😄

@knagaitsev knagaitsev force-pushed the refactor/client-builtin-logger branch from 863fef8 to 0afc8c6 Compare June 19, 2020 06:19
@knagaitsev
Copy link
Collaborator Author

Proper handling of babel for the client should be merged before this: #2652

@alexander-akait alexander-akait merged commit e4761bf into webpack:v4 Jun 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants