You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Fixes a bug in dynamic imports that was not covered by e2e tests.
Why?
Modules from newly visited pages can have dynamic dependencies. As these pages can have different import maps, the modules are processed by the Interactivity Router to resolve their dependencies. The library on which our implementation is based uses a global function called importShim. That function is in our code, but it's not globally accessible by mistake.
This can cause client-side navigation to fail occasionally when the full-page client-side navigation experimental feature is enabled, showing this error in the console:
Uncaught (in promise) ReferenceError: importShim is not defined
at @wordpress/interactivity-router (interactivity-router":1:1)
at __webpack_require__ (bootstrap:19:1)
at async wrapped (utils.ts:168:14)
Additionally, modules listed in the initial import map fail whenever a new module attempts to import them dynamically.
How?
Adding the missing function to self and initializing the modules that are present in the initial import map.
Testing Instructions
In the admin panel of your test site, go to Gutenberg > Experiments and enable the full-page client-side navigation feature.
Visit a page or a post on your site.
Click on the link that directs to the homepage (or any other page with a Query block containing pagination blocks).
Hover on the Next Page block.
Without the bug fix, the console error mentioned above appears. Ensure it doesn't appear, and the navigation was successful.
There are new e2e tests to cover the missing cases.
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.
If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
Flaky tests detected in 35bfedf.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.
* Modify test files to check dynamic imports
* Add a failing test
* Add importShim to self
* Refactor e2e tests for script modules
* Fix the bug in dynamic imports for initial modules
* Move the initial import map evaluation to loader.ts
* Update changelog
* Rename importShim global to wpInteractivityRouterImport
* Re-arrange assertions in script modules tests
-----------
Co-authored-by: DAreRodz <darerodz@git.wordpress.org>
Co-authored-by: luisherranz <luisherranz@git.wordpress.org>
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What?
Fixes a bug in dynamic imports that was not covered by e2e tests.
Why?
Modules from newly visited pages can have dynamic dependencies. As these pages can have different import maps, the modules are processed by the Interactivity Router to resolve their dependencies. The library on which our implementation is based uses a global function called
importShim
. That function is in our code, but it's not globally accessible by mistake.This can cause client-side navigation to fail occasionally when the full-page client-side navigation experimental feature is enabled, showing this error in the console:
Additionally, modules listed in the initial import map fail whenever a new module attempts to import them dynamically.
How?
Adding the missing function to
self
and initializing the modules that are present in the initial import map.Testing Instructions
There are new e2e tests to cover the missing cases.