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: smart unpack for local module with dll #8645

Merged
merged 20 commits into from
Nov 27, 2024

Conversation

beyondkmp
Copy link
Collaborator

@beyondkmp beyondkmp commented Oct 31, 2024

Fix the following case: the foo module contains dll files that need to be packaged into asapUnpack

test.ifDevOrWinCi("smart unpack local module with dll file", () => {
  return app(
    {
      targets: Platform.WINDOWS.createTarget(DIR_TARGET),
    },
    {
      isInstallDepsBefore:true,
      projectDirCreated: async (projectDir, tmpDir) => {
        const tempDir = await tmpDir.getTempDir()
        let localPath = path.join(tempDir, "foo")
        await outputFile(path.join(localPath, "package.json"), `{"name":"foo","version":"9.0.0","main":"index.js","license":"MIT","dependencies":{"ms":"2.0.0"}}`)
        await outputFile(path.join(localPath, "test.dll"), `test`)
        await modifyPackageJson(projectDir, data => {
          data.dependencies = {
            debug: "3.1.0",
            "edge-cs": "1.2.1",
            foo: `file:${localPath}`,
          }
        })
      },
      packed: async context => {
        await verifySmartUnpack(context.getResources(Platform.WINDOWS))
      },
    }
  )()
})

Copy link

changeset-bot bot commented Oct 31, 2024

🦋 Changeset detected

Latest commit: 25669c7

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 10 packages
Name Type
app-builder-lib Patch
builder-util Patch
dmg-builder Patch
electron-builder-squirrel-windows Patch
electron-builder Patch
electron-forge-maker-appimage Patch
electron-forge-maker-nsis-web Patch
electron-forge-maker-nsis Patch
electron-forge-maker-snap Patch
electron-publish Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

netlify bot commented Oct 31, 2024

Deploy Preview for car-park-attendant-cleat-11576 failed.

Name Link
🔨 Latest commit d37e117
🔍 Latest deploy log https://app.netlify.com/sites/car-park-attendant-cleat-11576/deploys/6725608451942f000855d4e1

@mmaietta
Copy link
Collaborator

I see this is a new test case being added, is it already broken on master? Trying to determine how we verify the results of the unpack refactor

@beyondkmp
Copy link
Collaborator Author

It was already broken on master for local modules and workspace modules.

When running the above test case on the master branch, the output is as follows, where the foo module is inside the asar file rather than in asarUnpack.

{
  "files": {
    "app": {
      "files": {
        "package.json": {
          "files": {
            "readme.md": {
              "size": "<size>",
            },
          },
        },
        "readme.md": {
          "size": "<size>",
        },
      },
    },
    "index.html": {
      "size": "<size>",
    },
    "index.js": {
      "size": "<size>",
    },
    "node_modules": {
      "files": {
        "debug": {
          "files": {
            "LICENSE": {
              "size": "<size>",
            },
            "Makefile": {
              "size": "<size>",
            },
            "node.js": {
              "size": "<size>",
            },
            "package.json": {
              "size": "<size>",
            },
            "src": {
              "files": {
                "browser.js": {
                  "size": "<size>",
                },
                "debug.js": {
                  "size": "<size>",
                },
                "index.js": {
                  "size": "<size>",
                },
                "node.js": {
                  "size": "<size>",
                },
              },
            },
          },
        },
        "edge-cs": {
          "files": {
            "LICENSE.txt": {
              "size": "<size>",
              "unpacked": true,
            },
            "lib": {
              "files": {
                "bootstrap": {
                  "files": {
                    "Dummy.cs": {
                      "size": "<size>",
                      "unpacked": true,
                    },
                    "project.json": {
                      "size": "<size>",
                      "unpacked": true,
                    },
                  },
                  "unpacked": true,
                },
                "edge-cs.dll": {
                  "size": "<size>",
                  "unpacked": true,
                },
                "edge-cs.js": {
                  "size": "<size>",
                  "unpacked": true,
                },
              },
              "unpacked": true,
            },
            "package.json": {
              "size": "<size>",
              "unpacked": true,
            },
            "src": {
              "files": {
                "Edge.js.CSharp": {
                  "files": {
                    "EdgeCompiler.cs": {
                      "size": "<size>",
                      "unpacked": true,
                    },
                    "gulpfile.js": {
                      "size": "<size>",
                      "unpacked": true,
                    },
                    "package.json": {
                      "size": "<size>",
                      "unpacked": true,
                    },
                    "project.json": {
                      "size": "<size>",
                      "unpacked": true,
                    },
                  },
                  "unpacked": true,
                },
                "edge-cs": {
                  "files": {
                    "EdgeCompiler.cs": {
                      "size": "<size>",
                      "unpacked": true,
                    },
                    "Properties": {
                      "files": {
                        "AssemblyInfo.cs": {
                          "size": "<size>",
                          "unpacked": true,
                        },
                      },
                      "unpacked": true,
                    },
                  },
                  "unpacked": true,
                },
              },
              "unpacked": true,
            },
            "tools": {
              "files": {
                "install.js": {
                  "size": "<size>",
                  "unpacked": true,
                },
              },
              "unpacked": true,
            },
          },
          "unpacked": true,
        },
        "foo": {
          "files": {
            "package.json": {
              "size": "<size>",
            },
            "test.dll": {
              "size": "<size>",
            },
          },
          "unpacked": true,
        },
        "ms": {
          "files": {
            "index.js": {
              "size": "<size>",
            },
            "license.md": {
              "size": "<size>",
            },
            "package.json": {
              "size": "<size>",
            },
          },
        },
      },
    },
    "package.json": {
      "size": "<size>",
    },
  },
}

@mmaietta
Copy link
Collaborator

It was already broken on master for local modules and workspace modules.

Is this new test case also broken on v25.1.8? (Test doesn't run on my mac) Trying to discern if this is due to electron/asar migration and is a high priority fix or if it was a long-standing issue and can be fixed after official v26 release as a patch.

@beyondkmp
Copy link
Collaborator Author

This has been present since v25.1.8, and wasn't introduced as an electron/asar feature. However, there hasn't been any feedback about it until now, when I discovered it while adding unit tests.

@beyondkmp beyondkmp merged commit f4d40f9 into electron-userland:master Nov 27, 2024
9 checks passed
@beyondkmp beyondkmp deleted the smartUnpack branch November 27, 2024 23:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants