Skip to content
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

docs: ADR to make redux dependency optional #275

Closed
wants to merge 4 commits into from

Conversation

binodpant
Copy link
Contributor

Description:

An ADR to explore a way to make redux and react-redux optional dependencies for consumers of frontend-platform that don't actually use the 'store' feature of the AppProvider

Merge checklist:

  • Consider running your code modifications in the included example app within frontend-platform. This can be done by running npm start and opening http://localhost:8080.
  • Consider testing your code modifications in another local micro-frontend using local aliases configured via the module.config.js file in frontend-build.
  • Verify your commit title/body conforms to the conventional commits format (e.g., fix, feat) and is appropriate for your code change. Consider whether your code is a breaking change, and modify your commit accordingly.

Post merge:

  • After the build finishes for the merged commit, verify the new release has been pushed to NPM.

@codecov
Copy link

codecov bot commented Jan 14, 2022

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (6646854) 80.79% compared to head (d091cc0) 80.79%.
Report is 264 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #275   +/-   ##
=======================================
  Coverage   80.79%   80.79%           
=======================================
  Files          38       38           
  Lines         885      885           
  Branches      163      163           
=======================================
  Hits          715      715           
  Misses        159      159           
  Partials       11       11           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@adamstankiewicz adamstankiewicz left a comment

Choose a reason for hiding this comment

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

Awesome, looking great! Added a few nits/suggestions for consideration

docs/decisions/0006-make-redux-deps-optional.rst Outdated Show resolved Hide resolved
docs/decisions/0006-make-redux-deps-optional.rst Outdated Show resolved Hide resolved
Copy link
Contributor

@davidjoy davidjoy left a comment

Choose a reason for hiding this comment

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

Does this work? Webpack is doing the transpilation of import statements, and I'm fairly certain it'll explode if the package doesn't exist. This is what the "fallback" option in webpack configs helps with... it lets webpack proceed with a fallback value instead of blowing up. I think.

@binodpant
Copy link
Contributor Author

Does this work? Webpack is doing the transpilation of import statements, and I'm fairly certain it'll explode if the package doesn't exist. This is what the "fallback" option in webpack configs helps with... it lets webpack proceed with a fallback value instead of blowing up. I think.

hmm good point, I was hoping (I have not tried this yet) to use the method described (try..catch basically) in t he npm doc to avoid failures in case of missing import. but if that does not like you said then fallback may be what I have to use. But not sure what we would fallback to, in this case, just a null perhaps?

@binodpant
Copy link
Contributor Author

hmm good point, I was hoping (I have not tried this yet) to use the method described (try..catch basically) in t he npm doc to avoid failures in case of missing import. but if that does not like you said then fallback may be what I have to use. But not sure what we would fallback to, in this case, just a null perhaps?

also was thinking of dynamic import like this , would this enable us to completely contain this change inside the frontend-platform? see below for an untested idea in OptionalReduxProvider.... I have to leave for the day but interested in exploring both the fallback and dynamic import options

The fallback I was not clear if needs to be in consumer webpack or frontend-build webpack files? It would not be ideal if consumers have to edit their webpack files for this?

let Provider;
(async () => {
  try {
    const reactRedux = await import('react-redux');
    Provider = reactRedux.Provider;
  } catch (importError) { Provider = null; }
})();

@binodpant
Copy link
Contributor Author

@adamstankiewicz suggested perhaps we can explore not even attempting an import, in the case store is not provided, within the method call instead of at top level thus comletely obviating the need to import react-redux unless store is provided

will explore this option too, thanks Adam

@binodpant
Copy link
Contributor Author

I haven't had a chance to get back to this yet but the next steps it to try the above proposed dynamic import

@Mashal-m
Copy link
Contributor

Hey @binodpant, What is the current status of this PR, is it ready to review and merge?

@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Nov 17, 2023
@openedx-webhooks
Copy link

Thanks for the pull request, @binodpant! Please note that it may take us up to several weeks or months to complete a review and merge your PR.

Feel free to add as much of the following information to the ticket as you can:

  • supporting documentation
  • Open edX discussion forum threads
  • timeline information ("this must be merged by XX date", and why that is)
  • partner information ("this is a course on edx.org")
  • any other information that can help Product understand the context for the PR

All technical communication about the code itself will be done via the GitHub pull request interface. As a reminder, our process documentation is here.

Please let us know once your PR is ready for our review and all tests are green.

⚠️ We can't start reviewing your pull request until you've submitted a signed contributor agreement or indicated your institutional affiliation. Please see the CONTRIBUTING file for more information. If you've signed an agreement in the past, you may need to re-sign. See The New Home of the Open edX Codebase for details.

Once you've signed the CLA, please allow 1 business day for it to be processed. After this time, you can re-run the CLA check by adding a comment here that you have signed it. If the problem persists, you can tag the @openedx/cla-problems team in a comment on your PR for further assistance.

@mphilbrick211 mphilbrick211 added the inactive PR author has been unresponsive for several months label Nov 17, 2023
@mphilbrick211
Copy link

Closing this for now as it has been inactive for quite some time.

@openedx-webhooks
Copy link

@binodpant Even though your pull request wasn’t merged, please take a moment to answer a two question survey so we can improve your experience in the future.

@mphilbrick211 mphilbrick211 added closed inactivity PR was closed because the author abandoned it and removed inactive PR author has been unresponsive for several months labels Dec 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed inactivity PR was closed because the author abandoned it open-source-contribution PR author is not from Axim or 2U
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

6 participants