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

Remove any usage of barrel files from core #6507

Open
2 of 4 tasks
pnicolli opened this issue Nov 30, 2024 · 4 comments · Fixed by #6509
Open
2 of 4 tasks

Remove any usage of barrel files from core #6507

pnicolli opened this issue Nov 30, 2024 · 4 comments · Fixed by #6509

Comments

@pnicolli
Copy link
Contributor

pnicolli commented Nov 30, 2024

PLIP (Plone Improvement Proposal)

This is a first step for #5419 and for deprecating the usage of barrel files entirely. Eventually, those files should be removed in Plone 7.

Responsible Persons

Proposer: @pnicolli

Seconder: @sneridagh

Abstract

Barrel files create issues in code splitting and bundling, especially because we currently use an older bundler, but even modern bundlers have a hard time with those. Several articles and examples can be found online

Motivation

Solving this issue is mandatory to improve performance and eventually it is already decided that those files should not exist in Plone 7.

Assumptions

Volto 18 should have the files for backwards compatibility, the usage of those should just be avoided.

Proposal & Implementation

Update every import in core volto. Add a eslint rule that raises a warning for each import from barrel files. Update the docs to reflect this choice and guide the migration.

Deliverables

for Plone 6.1 / Volto 18:

for Plone 7:

  • Fixer to help remove barrel imports from add-ons?

Initial work on a codemod for automating the migration:
https://github.com/plone/volto/blob/7b047fb4b2d71395ddba05b7e2570fcec70fc8d4/packages/volto/src/replace-barrel-imports.cjs

  • Remove the unused barrel files.

Risks

No risks involved. This has to be fully backwards compatible.

Participants

@pnicolli
@sneridagh
@stevepiercy

@github-project-automation github-project-automation bot moved this to Needs discussion in Volto Team Meeting Nov 30, 2024
@pnicolli pnicolli moved this from To do to In progress in Performance optimization Nov 30, 2024
@pnicolli pnicolli changed the title [PLIP] Remove any usage of barrel files from core Remove any usage of barrel files from core Nov 30, 2024
@pnicolli pnicolli self-assigned this Nov 30, 2024
@github-project-automation github-project-automation bot moved this from Needs discussion to Done in Volto Team Meeting Dec 8, 2024
@github-project-automation github-project-automation bot moved this from In progress to Done in Performance optimization Dec 8, 2024
@davisagli
Copy link
Member

davisagli commented Dec 9, 2024

We shouldn't close this PLIP until the barrel files are actually removed in Plone 7, right?

@davisagli davisagli reopened this Dec 9, 2024
@github-project-automation github-project-automation bot moved this from Done to In progress in Performance optimization Dec 9, 2024
@pnicolli
Copy link
Contributor Author

pnicolli commented Dec 9, 2024

@davisagli this was opened after a brief discussion at the conf and @sneridagh and I just thought about a first step to remove the usage of those files without actually removing the files. When I wrote the PLIP I just had this in mind but maybe did not clarify that properly here, so it's fine for me to close this. On the other hand, though, the actual removal of the files and/or any upgrade needed with it should also have a PLIP and I'm not sure there is one at this time.

@davisagli
Copy link
Member

@pnicolli I updated the Deliverables section to make it clear what was already done for Plone 6.1 and what needs to be done for Plone 7.

@sneridagh
Copy link
Member

@ichim-david I added in the description the pointer to the initial codemod script that I've been using in the Vite PR:

https://github.com/plone/volto/blob/7b047fb4b2d71395ddba05b7e2570fcec70fc8d4/packages/volto/src/replace-barrel-imports.cjs

@sneridagh sneridagh added this to the Plone 7.0 milestone Dec 17, 2024
@sneridagh sneridagh moved this to Backlog in Volto Roadmap Dec 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: In progress
Status: No status
Status: Backlog
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants