Skip to content

Conversation

@beyondkmp
Copy link
Contributor

@beyondkmp beyondkmp commented Feb 6, 2025

Root Cause
In the data returned by npm list, if there are duplicate packages with the same version in the dependencies, only one will be present.

image

image

How to fix

First, traverse all the packages and store them in a map. Then, when removing non-production dependencies, if you find that the dependencies are empty, retrieve them again from the complete list of packages.

UT

//github.com/electron-userland/electron-builder/issues/8842
test.ifAll("yarn ms", () =>
  assertPack(
    "test-app-hoisted",
    {
      targets: linuxDirTarget,
    },
    {
      isInstallDepsBefore: true,
      projectDirCreated: projectDir => {
        return Promise.all([
          modifyPackageJson(projectDir, data => {
            data.dependencies = {
              "@sentry/electron": "5.11.0",
              "electron-clear-data": "^1.0.5",
            }
            data.devDependencies = {
              electron: "34.0.2",
            }
          }),
          outputFile(path.join(projectDir, "yarn.lock"), ""),
        ])
      },
      packed: async context => {
        expect(await readAsarJson(path.join(context.getResources(Platform.LINUX), "app.asar"), "node_modules/ms/package.json")).toMatchSnapshot()
      },
    }
  )
)

@changeset-bot
Copy link

changeset-bot bot commented Feb 6, 2025

🦋 Changeset detected

Latest commit: e9e6755

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

This PR includes changesets to release 8 packages
Name Type
app-builder-lib 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

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

@beyondkmp beyondkmp changed the title Fix: Node modules collector ms fix: Node modules collector ms Feb 6, 2025
@beyondkmp beyondkmp changed the title fix: Node modules collector ms fix: Fix the issue of the missing ms package Feb 6, 2025
@mmaietta mmaietta merged commit 0f2c963 into electron-userland:master Feb 6, 2025
15 checks passed
@github-actions github-actions bot mentioned this pull request Feb 6, 2025
@beyondkmp beyondkmp deleted the nodeModulesCollectorMS branch February 6, 2025 06:39
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