Skip to content

packagerConfig.ignore in forge.config.js seems got something wrong #1787

@chris0203

Description

@chris0203

Pre-flight checklist

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

Electron Forge version

7.6.0

Electron version

30.0.1

Operating system

Win 10 22H2

Last known working Electron Forge version

No response

Expected behavior

ignore logic

ignore(path) {
    if (path === '/app') return false;
    if (path === '/dist') return false;
    if (path === '/dist-client') return false;
    if (path === "/package.json") return false;
    return true
}

should output

.
└── Project ROOT/
    ├── app/
    ├── dist/
    ├── dist-client/
    └── package.json

Actual behavior

Got some error or not functioning.

Steps to reproduce

I have the project file like this

.
└── Project ROOT/
    ├── src/
    ├── .angular/
    ├── app/
    ├── node_modules/
    ├── projects/
    │   └── client/
    ├── dist/
    ├── dist-client/
    ├── angular.json
    ├── package.json
    └── ....

What I want to package is only 3 folders, dist, dist-client, app and package.json, the final output like this:

.
└── Project ROOT/
    ├── app/
    ├── dist/
    ├── dist-client/
    └── package.json

so I try to ignore files

ignore(path) {
    if(!path) return false;
    if (path === '/app') return false;
    if (path === '/dist') return false;
    if (path === '/dist-client') return false;
    if (path === '/package.json') return false;
    return true
}

When running this got error.

An unhandled rejection has occurred inside Forge:
Error: The main entry point to your app was not found. Make sure "C:\Projects\app\main.js" exists and does not get ignored by your ignore option
at validateElectronApp (C:\Projects\node_modules\@electron\packager\dist\common.js:104:15)
    at async WindowsApp.buildApp (C:\Projects\node_modules\@electron\packager\dist\platform.js:126:9)
    at async WindowsApp.initialize (C:\Projects\node_modules\@electron\packager\dist\platform.js:120:13)
    at async WindowsApp.create (C:\Projects\node_modules\@electron\packager\dist\win32.js:83:9)
    at async Promise.all (index 0)
    at async packager (C:\Projects\node_modules\@electron\packager\dist\packager.js:237:22)

Then I remove if(!path) return false;

ignore(path) {
    // if(!path) return false;
    if (path === '/app') return false;
    if (path === '/dist') return false;
    if (path === '/dist-client') return false;
    if (path === '/package.json') return false;
    return true
}

It no errors, but seems package.json has been ignored, so the Preparing native dependencies is not running.

✔ Checking your system
✔ Preparing to package application
✔ Running packaging hooks
  ✔ Running generateAssets hook
  ✔ Running prePackage hook
❯ Packaging application
  › Determining targets...
  ❯ Packaging for x64 on win32
    ✔ Copying files
    ⠹ Preparing native dependencies
    ⠹ Finalizing package
◼ Running postPackage hook

but I try the other way, like this:

ignore(path) {
    if (path === "/src") return true;
    if (path === "/angular.json") return true;
    if (path === "/node_modules") return true;
    if (path === "/.angular") return true;
    if (path === "/projects") return true;
    ..... and some other folder and files
    return false
}

That the output is what I expected

.
└── Project ROOT/
    ├── app/
    ├── dist/
    ├── dist-client/
    └── package.json

Additional information

This issue is similar to electron/forge#3293

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions