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

move preload bits under Electron only #12491

Merged
merged 1 commit into from
May 5, 2023
Merged

Conversation

paul-marechal
Copy link
Member

@paul-marechal paul-marechal commented May 5, 2023

The preload.js generated script is included in browser builds, this will cause issues for anyone trying to build a browser app.

This commit makes sure the Electron bits aren't used when building a browser app.

Closes #12490

How to test

There should be no mention of preload.js in the generated files for the browser (src-gen/* and gen-webpack.config.js).

Review checklist

Reminder for reviewers

@paul-marechal paul-marechal changed the title move preload logic under Electron only move preload bits under Electron only May 5, 2023
@paul-marechal paul-marechal mentioned this pull request May 5, 2023
1 task
@vince-fugnitto vince-fugnitto added the electron issues related to the electron target label May 5, 2023
Copy link
Member

@vince-fugnitto vince-fugnitto left a comment

Choose a reason for hiding this comment

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

I've noticed some errors when attempting to start the electron application, the app is stuck on the loading screen:

Unable to load preload script: /home/vince/workspaces/theia-work/examples/electron/lib/preload.js
Error: Cannot find module '/home/vince/workspaces/theia-work/examples/electron/lib/preload.js'
    at Module._resolveFilename (VM123 loader:1002:15)
    at o._resolveFilename (VM158 renderer_init:2:3879)
    at Module._load (VM123 loader:848:27)
    at f._load (VM155 asar_bundle:2:13330)
    at o._load (VM158 renderer_init:2:3109)
    at VM158 renderer_init:2:33208
    at VM158 renderer_init:2:33334
    at ___electron_webpack_init__ (VM158 renderer_init:2:33338)
    at VM158 renderer_init:2:33461
    at BuiltinModule.compileForInternalLoader (VM10 loaders:331:7)
(anonymous) @ VM158 renderer_init:2
TypeError: Cannot read properties of undefined (reading 'getSecurityToken')
    at ContainerModule.registry (electron-token-frontend-module.ts:21:74)
    at __webpack_modules__.../../node_modules/inversify/lib/container/container.js.Container.load (container.ts:110:27)
    at index.js:107:1

The `preload.js` generated script is included in browser builds, this
will cause issues for anyone trying to build a browser app.

This commit makes sure the Electron bits aren't used when building a
browser app.
@paul-marechal
Copy link
Member Author

Fixed, wasn't expecting this.pck.ifElectron to not default to an empty string, turns out this.ifElectron does it.

Copy link
Member

@vince-fugnitto vince-fugnitto left a comment

Choose a reason for hiding this comment

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

LGTM 👍

  • the example-browser app works as expected (CI also successfully passes)
  • the example-electron app works as expected
  • a browser-only app referenced by file: no longer fails on build

@paul-marechal paul-marechal merged commit 9dd0921 into master May 5, 2023
@paul-marechal paul-marechal deleted the mp/electron-preload branch May 5, 2023 20:51
@github-actions github-actions bot added this to the 1.38.0 milestone May 5, 2023
@danepowell
Copy link
Contributor

I see the deadline for the 1.38.0 milestone is May 25, more than two weeks from now. Since this fixes a critical regression in 1.37.0, could we please get a 1.37.1 release prior to then?

@vince-fugnitto
Copy link
Member

@danepowell the patch v1.37.1 release was performed which fixes the regression 👍

@danepowell
Copy link
Contributor

Awesome, thank you!

@tsmaeder
Copy link
Contributor

tsmaeder commented May 11, 2023

@vince-fugnitto is this a release off master or is it branched off the 1.37 release with a "community-release" branch we can backport other fixes to? I was under the impression we don't do fix releases off master.

vince-fugnitto pushed a commit that referenced this pull request May 11, 2023
The `preload.js` generated script is included in browser builds, this
will cause issues for anyone trying to build a browser app.

This commit makes sure the Electron bits aren't used when building a
browser app.
@vince-fugnitto
Copy link
Member

@tsmaeder it's just a standard patch release that we've done in the past since the regression was brought up multiple times in discussions and issues. The release was performed branched off of https://github.com/eclipse-theia/theia/tree/release/1.37.0 and https://github.com/eclipse-theia/theia/tree/release/1.37.x was created (which includes the cherry-pick of 9f4ac12 and the release).

@tsmaeder
Copy link
Contributor

@vince-fugnitto so this is the normal process we're using to patch community releases, right? And any further patches for the community release like in #12479 should go to the branch https://github.com/eclipse-theia/theia/tree/release/1.37.x, right?

@vince-fugnitto
Copy link
Member

@tsmaeder it's just the normal process when doing any patch release not necessarily community one.
I think branching off of https://github.com/eclipse-theia/theia/tree/release/1.37.x (1.37.1) for the community release (will ultimately be 1.37.2) is fine yea.

@tsmaeder
Copy link
Contributor

A community release is just a release designated as "community". So no branch off the existing branch 1.37.x require, IMO. Just as long as we branched off the 1.37.0 tag and not master. I put a topic in the community call to get everyone on the same page.

@vince-fugnitto
Copy link
Member

@tsmaeder right it's definitely not, I only mentioned it since it seems to be a convention we followed in the past https://github.com/eclipse-theia/theia/tree/1.34-community-2023-02 (we have branches with -community- in them).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
electron issues related to the electron target
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

regression: unable to build browser-only application
4 participants