Skip to content

Fix: Webpack fallback release config #3232

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

Merged
merged 8 commits into from
Jul 17, 2024
Merged

Conversation

codebykat
Copy link
Contributor

Fix

Alternative to #3231, trying to see if this fixes the build artifacts.

Ref: https://medium.com/@6465660/webpack-compilation-error-critical-dependency-the-request-of-a-dependency-is-an-expression-13350139f2a5

And I'm mad about it 😠

@codebykat codebykat changed the base branch from trunk to release/2.22.0 July 11, 2024 18:41
@codebykat codebykat requested a review from roundhill July 11, 2024 18:41
@twstokes
Copy link

twstokes commented Jul 11, 2024

✅ I was able to successfully run and log in (via WordPress.com) using the Mac artifact from this job.

@codebykat codebykat marked this pull request as ready for review July 11, 2024 18:55
@codebykat
Copy link
Contributor Author

I also downloaded the Mac artifact and was able to log in. Can we find someone to test these on the Linux and Windows VMs?

Assuming they work, @roundhill how do you feel about proceeding with this fix?

@twstokes
Copy link

twstokes commented Jul 11, 2024

Can we find someone to test these on the Linux and Windows VMs?

I can be that someone, with real machines. 👍

@twstokes
Copy link

@codebykat is starting the app and logging in enough to test for this change?

@codebykat
Copy link
Contributor Author

Yes! If you're able to log in that definitely shows it has the correct config.

@twstokes
Copy link

twstokes commented Jul 11, 2024

Windows 64-bit installer: ✅
Debian 64-bit: ⚠️ Application loaded and the WordPress.com auth flow worked up until Simplenote was brought back to the foreground and it showed an auth error. Force-quitting and reloading seemed to resolve it.

@roundhill
Copy link
Contributor

Here's an approach for loading the config for webback from the file system:

function getConfigFromFileSystem() {
  const configPath = fs.existsSync('./config-local.json')
    ? './config-local.json'
    : './config.json';

  return fs.readFileSync(configPath, 'utf8');
}

module.exports = () => {
  const isDevMode = process.env.NODE_ENV === 'development';
  const config = JSON.parse(getConfigFromFileSystem());
  ...

This fixed the issue where getConfig() was being called before we set the fallback.

@codebykat
Copy link
Contributor Author

Ugh. I've updated this PR to have webpack require fs and look to see which of the config files exist so that it can fall back without throwing a warning. I spent a VERY long time trying to allow get-config.js to require fs, but absolutely could not get webpack to provide it in the bundle no matter what I tried. As a result, the function getConfig is no more, and all uses of it now need to rely on the global config which is being magically provided by webpack. I made some config adjustments so TS is aware of the situation and won't complain.

I included a package upgrade as I got a notification about a high risk vulnerability in electron-updater, allowing a code signing bypass for Windows, which seemed important to address.

Once the artifacts build and we have tested them on all platforms, I think we've got our next (and hopefully final??) release candidate.

Copy link
Contributor

@roundhill roundhill left a comment

Choose a reason for hiding this comment

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

Overall working well, I saw a weird thing with the webpack target for a while...

Copy link
Contributor

@roundhill roundhill left a comment

Choose a reason for hiding this comment

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

Our config woes seem resolved 😅

  • Build works with and without config-local.json present
  • Sign-in works on both web and electron builds

Comment on lines -51 to 50
const config = getConfig();
if (config.is_app_engine) {
Copy link
Contributor

Choose a reason for hiding this comment

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

What happens here?

With my limited Electron + Webpack + TS understanding, I think at this point config would be undefined, making the if below unreachable. Unless... config is somehow injected?

Copy link
Contributor

Choose a reason for hiding this comment

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

It's because config is actually set as a Webpack plugin, defined here:

config: JSON.stringify(config),

With my limited knowledge that is why it exists everywhere :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep exactly, as long as you don't define it inside the file, webpack will inject it. (If it IS defined in the file then webpack will assume you want a locally-defined version instead.)

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for the info @roundhill @codebykat

@mokagio mokagio changed the base branch from release/2.22.0 to release/2.22.1 July 16, 2024 04:21
@mokagio
Copy link
Contributor

mokagio commented Jul 16, 2024

@codebykat @roundhill I update the target branch for this PR to release/2.22.1, #3233, as discussed internally. TL;DR given 2.22.0 has already been tagged, any fix on top of it needs to come in a new version, in this case, a patch version or hotfix.

@codebykat codebykat merged commit 02efedb into release/2.22.1 Jul 17, 2024
7 checks passed
@codebykat codebykat deleted the fix/release-config branch July 17, 2024 03:02
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.

4 participants