packager icon indicating copy to clipboard operation
packager copied to clipboard

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

Open chris0203 opened this issue 11 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.

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

chris0203 avatar Dec 13 '24 01:12 chris0203

👋 Thanks for opening your first issue here! If you have a question about using Electron Packager, read the support docs. If you're reporting a 🐞 bug, please make sure you include steps to reproduce it. Development and issue triage is community-driven, so please be patient and we will get back to you as soon as we can.

To help make it easier for us to investigate your issue, please follow the contributing guidelines.

welcome[bot] avatar Jan 31 '25 01:01 welcome[bot]

On a related matter, why can path be undefined? What's that supposed to mean?

Agritite avatar Sep 02 '25 07:09 Agritite