Skip to content
This repository has been archived by the owner on May 3, 2024. It is now read-only.

feat(external-fallbacks): enable modules to have external fallbacks #984

Merged
merged 23 commits into from
Sep 12, 2023

Conversation

JAdshead
Copy link
Contributor

@JAdshead JAdshead commented Apr 25, 2023

This PR requires release and update of Holocron with the changes outlined in americanexpress/holocron#143

Description

Enable modules which require externals to use a fallback when the root module does not provide one.
Record each modules required externals when the module is required by one-app.
When rendering html to the client include all the fallback script tags required for the modules used in the initial render.
pass the registry of required externals down to the client then hydrate when client initializes

Motivation and Context

This will allow more flexibility to holocron modules when a required external is missing. It also provides an additional upgrade path for major versions of external dependencies.

How Has This Been Tested?

Types of Changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation (adding or updating documentation)
  • Dependency update
  • Security update

Checklist:

  • My change requires a change to the documentation and I have updated the documentation accordingly.
  • These changes should be applied to a maintenance branch.
  • This change requires cross browser checks.
  • Performance tests should be ran against the server prior to merging.
  • This change impacts caching for client browsers.
  • This change impacts HTTP headers.
  • This change adds additional environment variable requirements for One App users.
  • I have added the Apache 2.0 license header to any new files created.

What is the Impact to Developers Using One App?

@github-actions
Copy link
Contributor

github-actions bot commented Apr 25, 2023

Size Change: +21.7 kB (+3%)

Total Size: 710 kB

Filename Size Change
./build/app/app.js 164 kB +31 B (0%)
./build/app/app~vendors.js 411 kB +21.7 kB (+6%) 🔍
ℹ️ View Unchanged
Filename Size
./build/app/runtime.js 7.07 kB
./build/app/service-worker-client.js 7.25 kB
./build/app/vendors.js 121 kB

compressed-size-action

.gitignore Outdated Show resolved Hide resolved
src/client/initClient.jsx Outdated Show resolved Hide resolved
src/server/plugins/reactHtml/index.jsx Show resolved Hide resolved
src/server/plugins/reactHtml/index.jsx Outdated Show resolved Hide resolved
src/server/utils/onModuleLoad.js Outdated Show resolved Hide resolved
src/server/utils/onModuleLoad.js Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
@JAdshead JAdshead force-pushed the feat/module-external-fallback branch 3 times, most recently from 595c686 to 46f41c3 Compare August 3, 2023 17:35
package.json Outdated Show resolved Hide resolved
@JAdshead JAdshead marked this pull request as ready for review August 18, 2023 17:36
@JAdshead JAdshead requested review from a team as code owners August 18, 2023 17:36
@JAdshead JAdshead requested a review from a team August 29, 2023 19:30
@@ -29,6 +29,8 @@ export default async function initClient() {
try {
// eslint-disable-next-line no-underscore-dangle
setModuleMap(global.__CLIENT_HOLOCRON_MODULE_MAP__);
// eslint-disable-next-line no-underscore-dangle
setRequiredExternalsRegistry(global.__HOLOCRON_EXTERNALS__);
Copy link
Member

Choose a reason for hiding this comment

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

NIT: for consistency with __CLIENT_HOLOCRON_MODULE_MAP__, why not __CLIENT_HOLOCRON_EXTERNALS__?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

__CLIENT_HOLOCRON_MODULE_MAP__ is the only key with the CLIENT prefix, this is probably as the module map being set is specifically for the client and differs from the module map loaded on the server.


export const setModulesUsingExternals = (moduleNames) => {
modulesUsingExternals = new ImmutableSet(moduleNames);
};
Copy link
Member

Choose a reason for hiding this comment

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

Removing parts of the old system? is this still backwards compatible and this functionality is now achieved in a different way?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

for the most part this has been reimplemented in holocron - https://github.com/americanexpress/holocron/pull/143/files#diff-c59d732ae8137c4f28a025d9cabd09b4fd3166326f1822eb6b9a94089d89d777R68-R77

it does appear that the call to clearModulesUsingExternals has been removed when it should not have.

code-forger
code-forger previously approved these changes Sep 1, 2023
Copy link
Member

@code-forger code-forger left a comment

Choose a reason for hiding this comment

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

Approved with 1 NIT and 1 question

Matthew-Mallimo
Matthew-Mallimo previously approved these changes Sep 5, 2023
@JAdshead JAdshead merged commit 7d51efe into main Sep 12, 2023
9 checks passed
@JAdshead JAdshead deleted the feat/module-external-fallback branch September 12, 2023 17:10
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants