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

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

Remove any usage of barrel files from core #6507

pnicolli opened this issue Nov 30, 2024 · 12 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
@Shyam-Raghuwanshi
Copy link
Contributor

hi @davisagli can I work on issue - Remove the unused barrel files
or should I wait for it

@stevepiercy
Copy link
Collaborator

@Shyam-Raghuwanshi PLIPs are not suitable for first-time contributors. Also @pnicolli is already assigned to this issue, and several other core contributors are working on it.

@sneridagh
Copy link
Member

@davisagli @pnicolli @stevepiercy this one has been demoted from Plone 7.
We could make it happen in 19, but all the breakage that it will provide will be too much for the outcome (since all projects and add-ons would have to adapt).
I think that given the current scenario, I would say that the current state in Volto is good enough. We could enforce for 19 the ESlint rule that will raise a warning not just for core but for projects and add-ons as well.
TBH, I'd close it, and create another if we want to do the above.

@davisagli
Copy link
Member

this one has been demoted from Plone 7.

@sneridagh That means that Plone 7 will NOT remove barrel files, which is not what you meant to say, right?

@sneridagh
Copy link
Member

@davisagli It won't be necessary to remove something that it won't have.

@sneridagh
Copy link
Member

Let's use other wording then! Sorry about it :P

@pnicolli
Copy link
Contributor Author

We could make it happen in 19, but all the breakage that it will provide will be too much for the outcome (since all projects and add-ons would have to adapt). I think that given the current scenario, I would say that the current state in Volto is good enough. We could enforce for 19 the ESlint rule that will raise a warning not just for core but for projects and add-ons as well. TBH, I'd close it, and create another if we want to do the above.

I agree that we should close it if we don't plan to actually remove the barrel file from Volto 19. The current state of having the files for backwards compatibility but not using it ourselves in core is good enough in my opinion.

@davisagli
Copy link
Member

@pnicolli No one is saying we should remove the barrel files in Volto 19. The first line of this PLIP says "Eventually, those files should be removed in Plone 7." So closing the PLIP now would suggest that we no longer plan to do that, or have already done it. I guess the latter is true, since we are not using them in Seven. Okay.

@github-project-automation github-project-automation bot moved this from Backlog to Done in Volto Roadmap Feb 25, 2025
@github-project-automation github-project-automation bot moved this from In progress to Done in Performance optimization Feb 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment