Skip to content

Change urlRerouteOnly default value to true. #828

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 6 commits into from
Jul 6, 2021

Conversation

jolyndenning
Copy link
Member

@jolyndenning jolyndenning commented Jul 6, 2021

When urlRerouteOnly is true, single-spa does not reroute, fire extraneous popstate events, etc when the URL does not change during a navigation.

The option was introduced in a minor version of single-spa@5, but turned off. However, I think it's a good default to have it on, as it's a good performance boost for those following best practices of using the URL as the thing that determines whether a reroute is needed.

This is a breaking change that I'm thinking will be part of 6.0

@github-actions
Copy link

github-actions bot commented Jul 6, 2021

File size impact

dist (+712 bytes)
Overall impact on dist files size
Diff 6.0 after merge
+712 329,921 330,633
Detailed impact on dist files size
File Diff 6.0 after merge Event
lib/es2015/single-spa.dev.js +144 55,945 56,089 changed
lib/es2015/single-spa.min.js +36 18,518 18,554 changed
lib/esm/single-spa.dev.js +144 59,689 59,833 changed
lib/esm/single-spa.min.js +36 20,662 20,698 changed
lib/system/single-spa.dev.js +138 69,528 69,666 changed
lib/system/single-spa.min.js +36 20,686 20,722 changed
lib/umd/single-spa.dev.js +142 63,971 64,113 changed
lib/umd/single-spa.min.js +36 20,922 20,958 changed
Impact on dist files cache

8 files in you users cache are now outdated because their content have changed.

Bytes outdated
329,921
Generated by file size impact during file-size-impact#1005427376

@jolyndenning jolyndenning changed the base branch from master to 6.0 July 6, 2021 01:44
history.replaceState({ some: "state" }, document.title);
// calling triggerAppChange forcibly increments the counters which is weird for this test
// but it also ensures we wait for the reroute to finish (if it's taking place)
it(`Fires artificial popstate events with correct target`, async () => {
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 you can do aysnc (done) here if that makes thing easier.

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Oh, good to know

src/start.js Outdated
@@ -7,7 +7,7 @@ let started = false;

export function start(opts) {
started = true;
if (opts && opts.urlRerouteOnly) {
if (opts) {
Copy link
Member

Choose a reason for hiding this comment

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

Is it possible that !!opts === true && opts.urlRerouteOnly === undefined ? Does that need to be checked?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, but it's okay if urlRerouteOnly is undefined, since it's just used for a truthiness check and will count as false. For a while, I was doing opts.hasOwnProperty("urlRerouteOnly"), but figured it wasn't worth doing that since there's no reason to provide options except to set urlRerouteOnly.

I guess it might be confusing though for start() to behave differently from start({}). I'll change it.

@jolyndenning
Copy link
Member Author

Going to merge this now, as feedback was addressed.

@jolyndenning jolyndenning merged commit c9475eb into 6.0 Jul 6, 2021
@jolyndenning jolyndenning deleted the url-reroute-only-default branch July 6, 2021 18:39
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.

2 participants