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

feat: support multiple Webpack runtimes #701

Merged
merged 4 commits into from
Apr 5, 2021
Merged

feat: support multiple Webpack runtimes #701

merged 4 commits into from
Apr 5, 2021

Conversation

wvanrensselaer
Copy link
Contributor

@wvanrensselaer wvanrensselaer commented Feb 5, 2021

Addresses: #635

Summary

We have a case where we're running multiple Webpack runtimes on the same page which both use Loadable. This change adds an optional chunkLoadingGlobal option to LoadablePlugin and loadableReady which namespaces jsonpFunction or chunkLoadingGlobal.

Test plan

I didn't see unit tests for LoadablePlugin but I tested in a local application which rendered two Webpack apps in the same page. I can push this to a repo if you'd like. It correctly adds the namespace:

namespace: 'header'

(window["__header__LOADABLE_LOADED_CHUNKS__"] = window["__header__LOADABLE_LOADED_CHUNKS__"] || []).push([["foo"],{

namespace: 'content'

(window["__content__LOADABLE_LOADED_CHUNKS__"] = window["__content__LOADABLE_LOADED_CHUNKS__"] || []).push([["foo"],{

Comment on lines 52 to 53
window.__LOADABLE_LOADED_CHUNKS__ = window.__LOADABLE_LOADED_CHUNKS__ || []
const loadedChunks = window.__LOADABLE_LOADED_CHUNKS__
const prefix = namespace ? `__${namespace}` : ''
const loadedChunksKey = `${prefix}__LOADABLE_LOADED_CHUNKS__`
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Probably a breaking change since namespace is separately used for getRequiredChunkKey above. Maybe I should add a separate more explicit option. Maybe just a chunkLoadingGlobal option for both loadableReady and LoadablePlugin which overrides the whole thing?

@theKashey theKashey self-requested a review February 5, 2021 06:47
@theKashey
Copy link
Collaborator

everything looks good 👍

@wvanrensselaer
Copy link
Contributor Author

Thanks @theKashey, anything more needed from my side? I'm not able to merge due to some CI checks.

Any concern with my comment about the namespace in loadableReady? Currently that namespace is just for the ChunkExtractor key (__LOADABLE_REQUIRED_CHUNKS__). Overloading it for the chunkLoadingGlobal (__LOADABLE_LOADED_CHUNKS__) requires also setting it in the LoadablePlugin which would make this semver major.

Base automatically changed from master to main February 7, 2021 21:56
@wvanrensselaer
Copy link
Contributor Author

Updated to differentiate from the existing namespace option in loadableReady and avoid breaking update.

@gileck
Copy link

gileck commented Mar 1, 2021

@wvanrensselaer Thanks for this PR, We encountered the same issue and this would fix it for us, I like the solution with the new option in loadableReady - make sense!
When are you planning to merge it?
Thanks!

@wvanrensselaer
Copy link
Contributor Author

Just waiting on @theKashey, is this good to merge?

@theKashey
Copy link
Collaborator

🤯 I didn't merge it. :coneofshame:

@gileck
Copy link

gileck commented Mar 7, 2021

🤯 I didn't merge it. :coneofshame:

Hi @theKashey, When do you plan to merge it? we are waiting for this bug fix to resolve an issue we have with multiple components on the same site. Thanks

@theKashey
Copy link
Collaborator

Hey, trying to find some extra time to go through all open important tasks and do proper testing before the merge - there are a few moments that worries me a little - but yet with no luck.

@theKashey theKashey merged commit d351367 into gregberge:main Apr 5, 2021
@xvld xvld mentioned this pull request Apr 20, 2021
@theKashey
Copy link
Collaborator

Released 5.15.0

fivethreeo pushed a commit to fivethreeo/loadable-components that referenced this pull request Nov 16, 2022
* feat: support multiple Webpack runtimes

* namespace chunk loading global in loadableReady

* Change namespace to chunkLoadingGlobal

* Update size snapshot
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.

None yet

3 participants