Skip to content

build: drop @types/webpack-env in favor of webpack/module types#47798

Merged
dsanders11 merged 2 commits intomainfrom
build/drop-types-webpack-env
Aug 9, 2025
Merged

build: drop @types/webpack-env in favor of webpack/module types#47798
dsanders11 merged 2 commits intomainfrom
build/drop-types-webpack-env

Conversation

@dsanders11
Copy link
Copy Markdown
Member

@dsanders11 dsanders11 commented Jul 17, 2025

Description of Change

This change was prompted by #47621 which is trying to bring in the latest @types/webpack-env and causing TS build errors due to conflicting types. Webpack added module.d.ts in v5.62.0, which serves the same purpose as @types/webpack-env, so this PR switches to it and drops @types/webpack-env.

This PR also adds a path mapping in tsconfig.json to map @node/* to ../third_party/electron_node and types the requires of Node.js modules so that we get accurate types for them, which required tweaking our existing types a bit.

Checklist

  • PR description included and stakeholders cc'd

Release Notes

Notes: none

@dsanders11 dsanders11 added target/35-x-y PR should also be added to the "35-x-y" branch. target/36-x-y PR should also be added to the "36-x-y" branch. target/37-x-y PR should also be added to the "37-x-y" branch. target/38-x-y PR should also be added to the "38-x-y" branch. labels Jul 17, 2025
Comment thread lib/renderer/init.ts Outdated
Comment thread lib/renderer/init.ts
}
if (esmPreloads.length) {
const { runEntryPointWithESMLoader } = __non_webpack_require__('internal/modules/run_main');
const { runEntryPointWithESMLoader } = __non_webpack_require__('internal/modules/run_main') as typeof import('@node/lib/internal/modules/run_main');
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can we not map this magically somehow in TS, declaring the type of non_webpack_require better or something?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Not that I'm aware of. If we could, it would also be a bit tricky because it would be mapping internal/modules/run_main to ../third_party/electron_node/lib/internal/modules/run_main implicitly, which would be coupling __non_webpack_require__ to just requiring modules from ../third_party/electron_node which probably isn't something we want.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think defining it as internal/* mapping to ../third_party/electron_node/lib/internal/$1 is fine if that's possible?

@dsanders11 dsanders11 force-pushed the build/drop-types-webpack-env branch from 0554134 to ad0d440 Compare July 17, 2025 16:34
@dsanders11 dsanders11 marked this pull request as ready for review July 17, 2025 17:26
Comment thread lib/node/asar-fs-wrapper.ts
Comment thread build/webpack/webpack.config.base.js
@dsanders11 dsanders11 force-pushed the build/drop-types-webpack-env branch from ad0d440 to 830ffb9 Compare August 8, 2025 19:42
@dsanders11 dsanders11 removed the target/35-x-y PR should also be added to the "35-x-y" branch. label Aug 8, 2025
@dsanders11 dsanders11 merged commit a201d6c into main Aug 9, 2025
103 of 105 checks passed
@dsanders11 dsanders11 deleted the build/drop-types-webpack-env branch August 9, 2025 01:09
@release-clerk
Copy link
Copy Markdown

release-clerk Bot commented Aug 9, 2025

No Release Notes

@trop
Copy link
Copy Markdown
Contributor

trop Bot commented Aug 9, 2025

I was unable to backport this PR to "37-x-y" cleanly;
you will need to perform this backport manually.

@trop
Copy link
Copy Markdown
Contributor

trop Bot commented Aug 9, 2025

I was unable to backport this PR to "36-x-y" cleanly;
you will need to perform this backport manually.

@trop trop Bot added needs-manual-bp/37-x-y needs-manual-bp/36-x-y and removed target/37-x-y PR should also be added to the "37-x-y" branch. target/36-x-y PR should also be added to the "36-x-y" branch. labels Aug 9, 2025
@trop
Copy link
Copy Markdown
Contributor

trop Bot commented Aug 9, 2025

I have automatically backported this PR to "38-x-y", please check out #48015

@trop trop Bot added in-flight/38-x-y and removed target/38-x-y PR should also be added to the "38-x-y" branch. labels Aug 9, 2025
@trop
Copy link
Copy Markdown
Contributor

trop Bot commented Aug 11, 2025

@dsanders11 has manually backported this PR to "37-x-y", please check out #48046

@trop
Copy link
Copy Markdown
Contributor

trop Bot commented Aug 11, 2025

@dsanders11 has manually backported this PR to "36-x-y", please check out #48047

@trop trop Bot added in-flight/36-x-y merged/38-x-y PR was merged to the "38-x-y" branch. merged/37-x-y PR was merged to the "37-x-y" branch. merged/36-x-y PR was merged to the "36-x-y" branch. and removed needs-manual-bp/36-x-y in-flight/38-x-y in-flight/37-x-y in-flight/36-x-y labels Aug 11, 2025
kigh-ota pushed a commit to kigh-ota/electron that referenced this pull request Sep 30, 2025
…tron#47798)

* build: drop @types/webpack-env in favor of webpack/module types

* chore: improve type when assigning to global.require
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merged/36-x-y PR was merged to the "36-x-y" branch. merged/37-x-y PR was merged to the "37-x-y" branch. merged/38-x-y PR was merged to the "38-x-y" branch. semver/none

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants