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

fix: ensure that webpack is run once per arch for universal builds #3433

Merged
merged 2 commits into from
Nov 30, 2023

Conversation

MarshallOfSound
Copy link
Member

@MarshallOfSound MarshallOfSound commented Nov 30, 2023

On universal webpack builds we capture native_modules from node_modules and store them in .webpack, these means the packager level rebuild hook doesn't rebuild anything. We need to rebuild once-per-arch which means we also need to webpack once-per-arch.

Currently this is fairly naive and missing some things but is safe to land in it's current form and we can improve on it later.

  • We build webpack runs sequentially, this is because they share a node_modules folder, we could probably instead run webpack once and map native_modules to their resolved webpack locations and rebuild N times but only run webpack once
  • We hardcode the universal -> arm64/x64 mapping, this can probably be extended to resolving all packager matrixes

image

@MarshallOfSound MarshallOfSound requested a review from a team as a code owner November 30, 2023 10:03
@@ -102,7 +102,7 @@ export default class PluginInterface implements IForgePluginInterface {
async (_, __, task) => {
if ((hook as any).__hookName) {
// Also give it the task
await (hook as any).call(task, this.config, ...(hookArgs as any[]));
return await (hook as any).call(task, this.config, ...(hookArgs as any[]));
Copy link
Member Author

Choose a reason for hiding this comment

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

This allows internal hooks to return sub-listrs to do some pretty terminal stuff

Choose a reason for hiding this comment

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

Cc

// TODO: Figure out how to get matrix from packager
let arches: string[] = [arch];
if (arch === 'universal') {
arches = ['arm64', 'x64'];
Copy link
Member

Choose a reason for hiding this comment

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

Tbh hardcoding this is fine, making it dynamic is probably not worth the squeeze

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah this is defs the 99% case, the 1% case is folks running package --arch=all but idk if that even works at the moment let alone with webpack 😅

On universal webpack builds we capture native_modules from node_modules
and store them in .webpack, these means the packager level rebuild hook
doesn't rebuild anything.  We need to rebuild once-per-arch which means
we also need to webpack once-per-arch.

Currently this is fairly naive and missing some things but is safe to land
in it's current form and we can improve on it later.
* We build webpack runs sequentially, this is because they share a node_modules
  folder, we could probably instead run webpack once and map native_modules to
  their resolved webpack locations and rebuild N times but only run webpack once
* We hardcode the universal -> arm64/x64 mapping, this can probably be extended to
  resolving all packager matrixes
@MarshallOfSound MarshallOfSound merged commit f3cd9c6 into main Nov 30, 2023
7 checks passed
Brooooooklyn referenced this pull request in toeverything/AFFiNE Dec 11, 2023
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [@electron-forge/maker-base](https://togithub.com/electron/forge) | [`7.1.0` -> `7.2.0`](https://renovatebot.com/diffs/npm/@electron-forge%2fmaker-base/7.1.0/7.2.0) | [![age](https://developer.mend.io/api/mc/badges/age/npm/@electron-forge%2fmaker-base/7.2.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/@electron-forge%2fmaker-base/7.2.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/@electron-forge%2fmaker-base/7.1.0/7.2.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@electron-forge%2fmaker-base/7.1.0/7.2.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) |

---

### Release Notes

<details>
<summary>electron/forge (@&#8203;electron-forge/maker-base)</summary>

### [`v7.2.0`](https://togithub.com/electron/forge/releases/tag/v7.2.0)

[Compare Source](https://togithub.com/electron/forge/compare/v7.1.0...v7.2.0)

#### What's Changed

##### Features

-   feat: add support for sequential groups of webpack builds by [@&#8203;MarshallOfSound](https://togithub.com/MarshallOfSound) in [https://github.com/electron/forge/pull/3435](https://togithub.com/electron/forge/pull/3435)

##### Fixes

-   fix: handle webpack configs exported as default by [@&#8203;MarshallOfSound](https://togithub.com/MarshallOfSound) in [https://github.com/electron/forge/pull/3427](https://togithub.com/electron/forge/pull/3427)
-   fix: set empty publicPath for preload scripts by [@&#8203;MarshallOfSound](https://togithub.com/MarshallOfSound) in [https://github.com/electron/forge/pull/3428](https://togithub.com/electron/forge/pull/3428)
-   fix: ensure that webpack is run once per arch for universal builds by [@&#8203;MarshallOfSound](https://togithub.com/MarshallOfSound) in [https://github.com/electron/forge/pull/3433](https://togithub.com/electron/forge/pull/3433)

##### Documentation

-   docs: remove mention of v5 -> v6 migration by [@&#8203;erickzhao](https://togithub.com/erickzhao) in [https://github.com/electron/forge/pull/3412](https://togithub.com/electron/forge/pull/3412)
-   docs: add notes on publishing a new monorepo package by [@&#8203;erickzhao](https://togithub.com/erickzhao) in [https://github.com/electron/forge/pull/3415](https://togithub.com/electron/forge/pull/3415)

##### Other Changes

-   build(docs): enable API documentation builds for Forge v7 by [@&#8203;erickzhao](https://togithub.com/erickzhao) in [https://github.com/electron/forge/pull/3413](https://togithub.com/electron/forge/pull/3413)
-   ci: allow manual API documentation publish by [@&#8203;dsanders11](https://togithub.com/dsanders11) in [https://github.com/electron/forge/pull/3414](https://togithub.com/electron/forge/pull/3414)
-   refactor: dedupe key resolver for static publishers by [@&#8203;MarshallOfSound](https://togithub.com/MarshallOfSound) in [https://github.com/electron/forge/pull/3421](https://togithub.com/electron/forge/pull/3421)
-   chore: bump electronjs/node to 2.1.0 (main) by [@&#8203;electron-roller](https://togithub.com/electron-roller) in [https://github.com/electron/forge/pull/3422](https://togithub.com/electron/forge/pull/3422)
-   chore: update deps to clear some audit warnings by [@&#8203;dsanders11](https://togithub.com/dsanders11) in [https://github.com/electron/forge/pull/3429](https://togithub.com/electron/forge/pull/3429)

**Full Changelog**: electron/forge@v7.1.0...v7.2.0

![image](https://togithub.com/electron/forge/assets/33054982/9c4d7096-4942-419a-96b1-123c197e5cf6)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/toeverything/AFFiNE).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy44MS4zIiwidXBkYXRlZEluVmVyIjoiMzcuODEuMyIsInRhcmdldEJyYW5jaCI6ImNhbmFyeSJ9-->
Brooooooklyn referenced this pull request in toeverything/AFFiNE Dec 11, 2023
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [@electron-forge/maker-base](https://togithub.com/electron/forge) | [`7.1.0` -> `7.2.0`](https://renovatebot.com/diffs/npm/@electron-forge%2fmaker-base/7.1.0/7.2.0) | [![age](https://developer.mend.io/api/mc/badges/age/npm/@electron-forge%2fmaker-base/7.2.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/@electron-forge%2fmaker-base/7.2.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/@electron-forge%2fmaker-base/7.1.0/7.2.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@electron-forge%2fmaker-base/7.1.0/7.2.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) |

---

### Release Notes

<details>
<summary>electron/forge (@&#8203;electron-forge/maker-base)</summary>

### [`v7.2.0`](https://togithub.com/electron/forge/releases/tag/v7.2.0)

[Compare Source](https://togithub.com/electron/forge/compare/v7.1.0...v7.2.0)

#### What's Changed

##### Features

-   feat: add support for sequential groups of webpack builds by [@&#8203;MarshallOfSound](https://togithub.com/MarshallOfSound) in [https://github.com/electron/forge/pull/3435](https://togithub.com/electron/forge/pull/3435)

##### Fixes

-   fix: handle webpack configs exported as default by [@&#8203;MarshallOfSound](https://togithub.com/MarshallOfSound) in [https://github.com/electron/forge/pull/3427](https://togithub.com/electron/forge/pull/3427)
-   fix: set empty publicPath for preload scripts by [@&#8203;MarshallOfSound](https://togithub.com/MarshallOfSound) in [https://github.com/electron/forge/pull/3428](https://togithub.com/electron/forge/pull/3428)
-   fix: ensure that webpack is run once per arch for universal builds by [@&#8203;MarshallOfSound](https://togithub.com/MarshallOfSound) in [https://github.com/electron/forge/pull/3433](https://togithub.com/electron/forge/pull/3433)

##### Documentation

-   docs: remove mention of v5 -> v6 migration by [@&#8203;erickzhao](https://togithub.com/erickzhao) in [https://github.com/electron/forge/pull/3412](https://togithub.com/electron/forge/pull/3412)
-   docs: add notes on publishing a new monorepo package by [@&#8203;erickzhao](https://togithub.com/erickzhao) in [https://github.com/electron/forge/pull/3415](https://togithub.com/electron/forge/pull/3415)

##### Other Changes

-   build(docs): enable API documentation builds for Forge v7 by [@&#8203;erickzhao](https://togithub.com/erickzhao) in [https://github.com/electron/forge/pull/3413](https://togithub.com/electron/forge/pull/3413)
-   ci: allow manual API documentation publish by [@&#8203;dsanders11](https://togithub.com/dsanders11) in [https://github.com/electron/forge/pull/3414](https://togithub.com/electron/forge/pull/3414)
-   refactor: dedupe key resolver for static publishers by [@&#8203;MarshallOfSound](https://togithub.com/MarshallOfSound) in [https://github.com/electron/forge/pull/3421](https://togithub.com/electron/forge/pull/3421)
-   chore: bump electronjs/node to 2.1.0 (main) by [@&#8203;electron-roller](https://togithub.com/electron-roller) in [https://github.com/electron/forge/pull/3422](https://togithub.com/electron/forge/pull/3422)
-   chore: update deps to clear some audit warnings by [@&#8203;dsanders11](https://togithub.com/dsanders11) in [https://github.com/electron/forge/pull/3429](https://togithub.com/electron/forge/pull/3429)

**Full Changelog**: electron/forge@v7.1.0...v7.2.0

![image](https://togithub.com/electron/forge/assets/33054982/9c4d7096-4942-419a-96b1-123c197e5cf6)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/toeverything/AFFiNE).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy44MS4zIiwidXBkYXRlZEluVmVyIjoiMzcuODEuMyIsInRhcmdldEJyYW5jaCI6ImNhbmFyeSJ9-->
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