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
(5.0): Refactoring navigateToUrl to reduce byte size #395
Conversation
DeepCode Report (#215515)DeepCode analyzed this pull request. |
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.
two questions
singleSpaNavigate("#/route?yoshi=criminal"); | ||
spyOn(window.history, "pushState"); | ||
singleSpaNavigate("#/route?yoshi=freeanimal"); | ||
expect(location.hash).toBe("#/route?yoshi=freeanimal"); |
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.
👀
return uri; | ||
const anchor = document.createElement("a"); | ||
anchor.href = str; | ||
return anchor; |
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.
wow this is quite the update
is an anchor tag the same return object shape as what was previously returned from this function?
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.
Not quite - path
becomes pathname
, etc. This accounts for the changes I made later on in the navigateToUrl function
@@ -45,6 +45,7 @@ | |||
"@babel/core": "^7.5.5", | |||
"@babel/plugin-syntax-dynamic-import": "^7.2.0", | |||
"@babel/preset-env": "^7.5.5", | |||
"@rollup/plugin-replace": "^2.2.1", |
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 come in addition to a change to the rollup config?
or was this just an accidental inclusion from another PR?
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.
Yeah good catch - this is for process.env.BABEL_ENV
. I made the change to the rollup config but lost it in my frantic switching between branches. Will reinstate.
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.
🐽
is this also something we could do to have dev-specific errors as well? e.g. if(dev)
and have replace be dev: false
?
This technique could be used for dev/prod error messages. But I think better would be to use the technique described in https://github.com/facebook/react/tree/master/scripts/error-codes |
* Adding prettier, speeding up pre-commit, and making clean script cross platform (#391) * Speeding up pre-commit, and making clean script cross platform * Adding prettier * Upgrading nodejs version in Travis (#394) * (5.0): Remove deprecated lifecycles (#390) * (5.0) Improving perf with babel/rollup changes (#392) * Improving perf with babel/rollup changes * Upgrading travis' node version * Removing babel-loader * (5.0): Reducing bundle size by removing class syntax (#393) * Avoiding classes to save bytes * Upgrading node version in travis * (5.0): Various refactors that improve performance (#396) * Various refactors that improve performance * Self review * Self review * (5.0): Refactoring navigateToUrl to reduce byte size (#395) * Refactoring navigateToUrl to reduce byte size * Anthony's feedback * should be functionally the same as it was before. (#403) but now with less duplication! * Switching to error codes for production single-spa (#400) * Switching to error codes for production single-spa * Self review * Self review * Self review * Self review * Self review * Self review * Anthony's feedback * Anthony's feedback * (5.0): Breaking - remove err.name and err.appName from thrown errors. (#404) * Switching to error codes for production single-spa * Self review * Self review * Self review * Self review * Self review * Self review * Anthony's feedback * Switching from name property to appOrParcelName * Self review * Adding support for warningMillis timeout config. Resolves #346. (#389) * Adding support for warningMillis timeout config. Resolves #346. * Self review * Adding more tests, and self review * Excluding failing tests temporarily * Linter errors * Self review * Tests * Self review * Self review * Fixing tests * Uncommenting fit * Updating link to error codes (#406) * Switching from object rest spread to manual assign. (#401) * Switching from object rest spread to manual assign. * More assigns * Self review * Prototype pollution * Self review * Self review * Small updates to parcel-related errors (#407) * Small updates to parcel-related errors * Self review * v5.0.0-beta.0 * Adding banner comment to output bundles (#409) * Adding banner comment to output bundles * Self review * Improving description and keywords (#410) * v5.0.0-beta.1 * Small improvements to error messages (#423) * Migrating references of CanopyTax org to single-spa Co-authored-by: Anthony Frehner <frehner@users.noreply.github.com>
Before:
After:
Two perf things here:
opts
, and used @rollup/plugin-replace to remove the code that only exists for testsparseUri
andnavigateToUrl
to use browser anchor tags instead of the 3p lib that was pasted in earlier.