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

Generated code should reuse shared packages #15173

Open
sdirix opened this issue Mar 12, 2025 · 1 comment · May be fixed by #15185
Open

Generated code should reuse shared packages #15173

sdirix opened this issue Mar 12, 2025 · 1 comment · May be fixed by #15185

Comments

@sdirix
Copy link
Member

sdirix commented Mar 12, 2025

In Theia we generate code for Browser, Node and Electron. In the generated code we import third party dependencies like inversify. In Theia we encourage users to use @theia/core/shared/inversify in their code, so we should do the same for the generated code.

This prevents issues in which an adopter project has a different package layput than Theia does. For example if inversify is not hoisted to the root of node_modules of an adopter, their webpack build of src-gen will fail as the generated require('inversify') can't be resolved, while their @theia/core/shared/inversify imports will resolve as inversify is successfully nested in @theia/core.

@msujew
Copy link
Member

msujew commented Mar 12, 2025

+1 for this, as I've encountered this issue in #14708 and similar changes multiple times in the past.

sdirix added a commit to eclipsesource/theia that referenced this issue Mar 13, 2025
Src-gen is executed in the environment controlled by adopters. In the
generated code dependencies are imported. If these dependencies are not
located where webpack expects them, the adopter will experience build
errors. This is not a common case, but it does happen in practice.

The generated code is made more robust by reusing the shared core
dependencies where applicable. As it's common to declare '@theia/core'
as a dependency within the adopter package, this more commonly results
in a working build.

Resolves eclipse-theia#15173

Contributed on behalf of STMicroelectronics
@sdirix sdirix linked a pull request Mar 13, 2025 that will close this issue
2 tasks
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 a pull request may close this issue.

2 participants