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

Fixed circular import error in dev with HMR in App component when imported in the main default config #6524

Merged
merged 2 commits into from
Dec 9, 2024

Conversation

sneridagh
Copy link
Member

For 18.2.0, after move the core code to use direct imports in #6509 in projects still using some barrel imports, in dev mode, HMR errored due to a circular import error.

ReferenceError: Cannot access '__WEBPACK_DEFAULT_EXPORT__' before initialization

Investigating, I managed to pinpoint the problem in the default config of the component registry, since we have in there App registered. It seems that it's in there to provide maximum flexibility for providing a complete different App, if needed. It's used by the old generator, but not anymore by the project-less setup. So it has to go, and use shadowing for that purpose.

I'll add a note for React 19 to remove it.

I workaround it by not relying on import/export as side effect for the apply the setting for components, but as a function called exactly where we want it to be applied (hopefully, after all initialization and the import phase).

@sneridagh sneridagh requested a review from pnicolli December 8, 2024 22:52
Copy link

netlify bot commented Dec 8, 2024

Deploy Preview for plone-components canceled.

Name Link
🔨 Latest commit f429caa
🔍 Latest deploy log https://app.netlify.com/sites/plone-components/deploys/6756238b07039900082b263d

@sneridagh sneridagh changed the title Fixed circular import error in dev with HMR in App component when i… Fixed circular import error in dev with HMR in App component when imported in the main default config Dec 8, 2024
@sneridagh sneridagh merged commit 6421335 into main Dec 9, 2024
68 checks passed
@sneridagh sneridagh deleted the fix18.2.0HMRFlawCircularImportApp branch December 9, 2024 08:27
sneridagh added a commit that referenced this pull request Dec 12, 2024
* main:
  Fixed types declaration extractor from Volto core, re-enable it on release (#6534)
  Release 18.3.0
  Release @plone/slate 18.0.4
  Release @plone/helpers 1.0.0
  Make helpers release-able
  Release @plone/registry 2.2.0
  Release @plone/components 3.0.0
  Release @plone/types 1.1.0
  [slots] @plone/slots first developments (#6409)
  improve link integrity popup (#6516)
  Add missing styleWrapper style builder information in container/Grid (#6527)
  update: skip scroll to top on inital SSR completion. (#6523)
  Release 18.2.3
  Fixed circular import error in dev with HMR in core Views and Widgets shadow customizations (#6526)
  Release 18.2.2
  Fixed circular import error in dev with HMR in core Blocks shadow customizations (#6525)
  Release 18.2.1
  Release @plone/slate 18.0.3
  Fixed circular import error in dev with HMR in `App` component when imported in the main default config (#6524)
  Update @plone/* packages info (#6521)
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.

2 participants