forge icon indicating copy to clipboard operation
forge copied to clipboard

Regression in v7.8.1: `index.html` no longer listed in Webpack assets

Open nikwen opened this issue 6 months ago • 1 comments

Pre-flight checklist

  • [x] I have read the contribution documentation for this project.
  • [x] I agree to follow the code of conduct that this project uses.
  • [x] I have searched the issue tracker for a bug that matches the one I want to file, without success.

Forge version

7.8.1

Electron version

36.4.0

Operating system

Windows 10 (19045.5854)

Last known working Forge version

7.8.0

Expected behavior

Webpack plugins see my renderer's index.html as an asset when calling compilation.getAssets().

Actual behavior

Starting with Forge v7.8.1, Webpack plugins do not see my renderer's index.html as an asset when calling compilation.getAssets() on Windows. (It works fine on macOS.)

This broke the build script of my app.

Steps to reproduce

  1. Clone https://github.com/nikwen/forge-jiti-bug
    • This repo consists of two commits:
      1. 507f56c: The unchanged output of npx create-electron-app@latest forge-jiti-bug --template=webpack-typescript (with Forge v7.8.1)
      2. 83fb84f: Adding a minimal Webpack plugin that logs the result of compilation.getAssets()
  2. npm install
  3. npm start
  4. The output is:
    main_window/preload.js
    main_window/index.js
    
    (This is the list of assets that Webpack plugins see on Forge v7.8.1.)
  5. git checkout forge-v7.8.0
    • This branch has one additional commit d5ef061: Downgrading Forge to v7.8.0
  6. npm install
  7. npm start
  8. The output is:
    main_window/preload.js
    main_window/index.js
    main_window/index.html
    
    (This is the expected behavior — the list of assets that Webpack plugins see on Forge v7.8.0.)

Additional information

  1. This works fine on macOS.
  2. This was introduced by https://github.com/electron/forge/pull/3907 (the jiti PR).
  3. It broke the build script of my app.
  4. Workaround: renaming forge.config.ts to forge.config.tsx (because jiti isn't used for .tsx files)

nikwen avatar Jun 09 '25 01:06 nikwen

I think this is the root cause:

On v7.8.0, Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_TRANSFER is 3000. On v7.8.1, Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_TRANSFER is undefined.

If I set stage: undefined on v7.8.0, I get the same behavior there.

v7.8.1 imports Compilation as a function whereas v7.8.0 imports Compilation as an object.

nikwen avatar Jun 10 '25 00:06 nikwen