question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Remove legacy `getModulesData` JS function and `_googlesitekitLegacyData.modules` global

See original GitHub issue

Related to #3647: All usages of the legacy function getModulesData which relies on the _googlesitekitLegacyData.modules global should be refactored, and then those two pieces should be entirely removed.


Do not alter or remove anything below. The following sections will be managed by moderators only.

Acceptance criteria

  • All JS components currently relying on getModulesData should be refactored to use the getModules or getModule datastore selector instead, using React hooks.
  • The getModulesData function should be entirely removed.
  • The _googlesitekitLegacyData.modules global should be entirely removed, including where it is set in PHP.

Implementation Brief

Update getModules code when changing from getModulesData

  • In any place where we change from getModulesData to getModules, note that the data returned from getModules is slightly different. Most of the keys/values/info is the same, but here’s a map of the old to new keys:
    • sort (old) => order (new)
    • screenID (old) => N/A (not needed)
    • autoActivate (old) => forceActive (new)
    • required (old) => dependencies (new)
    • settings (old) => N/A (if any data from settings is needed by components using getModulesData it will need refactoring)
    • All other keys are the same or are only available in the new API

SettingsModules component

Some component require changing to functional components to use hooks, but this is straightforward:

Other changes that don’t require converting to functional components but require refactoring:

Misc changes

PHP Changes

Test Coverage

  • Aside from the tests removed, mentioned above, no test changes should occur. Existing tests should pass.

Visual Regression Changes

  • No changes should occur.

QA Brief

  • Notifications and Settings pages, mainly, should continue to function as before. This change removes global code set by PHP, so check the developer/browser console during browsing and ensure no errors/warnings related to the _googlesitekitLegacyData.modules variable are displayed.

Changelog entry

  • N/A

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
eugene-manuilovcommented, Aug 3, 2021

@tofumatt the getDataErrorComponent function also relies on getModulesData function but it looks like we don’t use it anymore and can delete it. Could you please update IB to delete the file with the getDataErrorComponent function entirely? Plus, could you, please, clarify what exactly needs to be deleted from the Assets.php file?

1reaction
tofumattcommented, Jul 28, 2021

A bit of the functional conversions/refactoring here might be a bit tricky for anyone less familiar with these files, so marking this as an 11… but it’s a high estimate and covers potentially the broad QA requirements of this issue as well.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to remove all Global Modules in Node.js ? - GeeksforGeeks
For Window users: The Windows user can remove all the Node.js modules globally by just deleting the content of the following directory:
Read more >
[#MDL-57490] Remove old legacy global js functions
We've got a number of functions in javascript-static (e.g. checkall) which have been in the global namespace for nearly 14 years and are...
Read more >
How to migrate legacy JS app to modules - Stack Overflow
As you move a function from legacy.js to myNiceModule.js , check to see if it still has clients that are aware of it...
Read more >
DevTools architecture refresh: migrating to JavaScript modules
How we migrate Chrome DevTools to JavaScript modules. ... goal would be to remove all "legacy export objects", cleaning up the global scope....
Read more >
Deprecated and obsolete features - JavaScript - MDN Web Docs
These features are likely stable because removing them will cause backward compatibility issues and break legacy websites. (JavaScript has ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found