-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
feat: allow filter overlay message with function #4813
feat: allow filter overlay message with function #4813
Conversation
Haven't look into test, but based on manual testing on the example it's working. In case anyone want to take over feel free to proceed to fork my implementation and update on top, my time for OSS is quite limited recently. 😢 |
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## master #4813 +/- ##
==========================================
- Coverage 91.99% 91.96% -0.04%
==========================================
Files 16 16
Lines 1673 1704 +31
Branches 625 647 +22
==========================================
+ Hits 1539 1567 +28
- Misses 123 126 +3
Partials 11 11
☔ View full report in Codecov by Sentry. |
lib/Server.js
Outdated
*/ | ||
const encodeOverlaySettings = (setting) => | ||
typeof setting === "function" | ||
? encodeURIComponent(setting.toString()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Usage of encodeURIComponent here is intentional, because without it URLSearchParams
will encode white space into +
character, which could not be decoded correctly in parseURL
in client.
Alternative is to use URLSearchParams
in client side, but I think the drawback of that is cannot support old browser.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, I have a couple questions
@alexander-akait I realize there is #2843 , maybe will do side quest then |
@malcolm-kee Yeah, it will be great, I think it is not a problem problem, because most of our code is encupsulated also API is almost the same, so feel free to try it I will help |
4f481cd
to
f7b1747
Compare
2dcb797
to
4658fde
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, I see we don't have tests on it right? is it hard to test?
Will try using |
Yeah, thank you, feel free to ping me if you will need help |
Thank you good job, I think we can merge and release it |
@alexander-akait I'm adding more tests and realize that the following code will overwrite the overlay settings: https://github.com/webpack/webpack-dev-server/blob/master/client-src/index.js#L170-L176 What's the use case of supporting that socket message from server? |
@malcolm-kee some tools can't inject your code in webpack bundle process, but they need to enable/disable some features, so we provide ability to do, i.e you can use own websocket server and do it, but I am thinking no one currently use it |
Got it. For completeness let me handle that. |
Thank you |
I found bug. |
@alexander-akait by the way I also plan to let |
type: "BUILD_ERROR", | ||
level: "warning", | ||
messages: warnings, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be BUILD_WARNING
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the event type purpose is to determine how to transition the state:
webpack-dev-server/client-src/overlay/state-machine.js
Lines 32 to 38 in f7386f6
BUILD_ERROR: { | |
target: "displayBuildError", | |
actions: ["setMessages", "showOverlay"], | |
}, | |
RUNTIME_ERROR: { | |
target: "displayRuntimeError", | |
actions: ["setMessages", "showOverlay"], |
I don't mind refactor to add event type BUILD_WARNING
and remove level
property, although it does introduce some duplication in the state machine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's fine 👍🏻
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thank you for working on this 🚀
We will also need to document this on https://webpack.js.org/configuration/dev-server/#overlay
const overlayFilterFunction = new Function( | ||
"message", | ||
`var callback = ${overlayFilterFunctionString} | ||
return callback(message)` | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this new Function()
breaks devserver for chrome extensions with the following error
Uncaught EvalError: Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: "script-src 'self'".
it could be fixed by adding 'unsafe-eval'
in the manifest but that isn't really an option for us so we're going to roll back for now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wentokay We can optionally inject this, can you open an issue?
For Bugs and Features; did you add new tests?
Motivation / Use-Case
Resolves
Breaking Changes
Additional Info