-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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(store-devtools): replace direct with indirect eval
#4216
fix(store-devtools): replace direct with indirect eval
#4216
Conversation
`unwrapAction` internally runs `eval` if the argument is of type `string`. It is unclear why that `unwrapAction` was necessary in the first place, and it looks like an artifact from a older codebase. The line was added in 2018. Since `eval` is not best practice and according to ngrx#4213, esbuild has issues with it, it is removed.
✅ Deploy Preview for ngrx-io ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site configuration. |
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 eval
is probably there because you can dispatch an action via the DevTools. I assume this is just a string, and eval
parses it to an action object.
IIRC manually dispatching actions didn't completely work with the NgRx global store.
I'll test/verify this later this week, if that's the case we can also resort to the alternatives mentioned in https://esbuild.github.io/content-types/#direct-eval
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.
My assumption was correct, via de DevTools you can dispatch an action.
This will be a string.
Because of this, I think we need to keep parsing the string using eval
, but with the workaround mentioned in https://esbuild.github.io/content-types/#direct-eval
Got it, will do and also add a unit tests so that in the future it is clear why we require that kind of feature. |
This reverts commit 08f7b10.
use an indirect eval to avoid issues with esbuild: https://esbuild.github.io/content-types/#direct-eval
Okay, @timdeschryver, the updated version with tests has been pushed. |
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.
Thanks @rainerhahnekamp !
@rainerhahnekamp is the PR title still relevant? I guess we should update it since |
eval
and unwrapAction
eval
@markostanimirovic, you're right. I've renamed the title. |
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.
Thanks Rainer!
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
From my perspective, this removes the unnecessary
eval
method to get an action's payload.If somebody knows why the
eval
was there in the first place (no test is failing), we could provide a safer, alternative version ofunwrapAction
.What is the current behavior?
Closes #4213
What is the new behavior?
The
payload
is directly used.Does this PR introduce a breaking change?
Other information