Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/dirty-laws-bake.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"app-builder-lib": patch
---

optimize workspace package resolution in dependency tree
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,15 @@ export abstract class NodeModulesCollector<T extends Dependency<T, OptionalsType

private getTreeFromWorkspaces(tree: T): T {
if (tree.workspaces && tree.dependencies) {
const packageJson: Dependency<string, string> = require(path.join(this.rootDir, "package.json"))
const dependencyName = packageJson.name
for (const [key, value] of Object.entries(tree.dependencies)) {
if (this.rootDir.endsWith(path.normalize(key))) {
if (key === dependencyName) {
return value
}
}
}

return tree
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1


[email protected]:
version "2.2.9"
resolved "https://registry.yarnpkg.com/electron-log/-/electron-log-2.2.9.tgz#e0484cb1a8a84593095e3b69f47361ae15d73bdf"

is-number@^6.0.0:
version "6.0.0"
resolved "https://registry.yarnpkg.com/is-number/-/is-number-6.0.0.tgz#e6d15ad31fc262887cccf217ae5f9316f81b1995"
integrity sha512-Wu1VHeILBK8KAWJUAiSZQX94GmOE45Rg6/538fKwiloUu21KncEkYGPqob2oSZ5mUT73vLGrHQjKw3KMPwfDzg==

[email protected]:
version "3.0.1"
resolved "https://registry.yarnpkg.com/is-odd/-/is-odd-3.0.1.tgz#65101baf3727d728b66fa62f50cda7f2d3989601"
integrity sha512-CQpnWPrDwmP1+SMHXZhtLtJv90yiyVfluGsX5iNCVkrhQtU3TQHsUWPG9wkdk9Lgd5yNpAg9jQEo90CBaXgWMA==
dependencies:
is-number "^6.0.0"

[email protected]:
version "2.0.0"
resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8"
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1


[email protected]:
version "2.2.9"
resolved "https://registry.yarnpkg.com/electron-log/-/electron-log-2.2.9.tgz#e0484cb1a8a84593095e3b69f47361ae15d73bdf"

is-number@^6.0.0:
version "6.0.0"
resolved "https://registry.yarnpkg.com/is-number/-/is-number-6.0.0.tgz#e6d15ad31fc262887cccf217ae5f9316f81b1995"
integrity sha512-Wu1VHeILBK8KAWJUAiSZQX94GmOE45Rg6/538fKwiloUu21KncEkYGPqob2oSZ5mUT73vLGrHQjKw3KMPwfDzg==

is-odd@^3.0.1:
version "3.0.1"
resolved "https://registry.yarnpkg.com/is-odd/-/is-odd-3.0.1.tgz#65101baf3727d728b66fa62f50cda7f2d3989601"
integrity sha512-CQpnWPrDwmP1+SMHXZhtLtJv90yiyVfluGsX5iNCVkrhQtU3TQHsUWPG9wkdk9Lgd5yNpAg9jQEo90CBaXgWMA==
dependencies:
is-number "^6.0.0"

[email protected]:
version "2.0.0"
resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8"
61 changes: 61 additions & 0 deletions test/snapshots/HoistedNodeModuleTest.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -64675,6 +64675,67 @@ exports[`isInstallDepsBefore=true > yarn some module add by manual instead of in
}
`;

exports[`isInstallDepsBefore=true > yarn workspace for scope name 1`] = `
{
"linux": [],
}
`;

exports[`isInstallDepsBefore=true > yarn workspace for scope name 2`] = `
{
"files": {
"index.html": {
"offset": "5150",
"size": 841,
},
"index.js": {
"offset": "5991",
"size": 2501,
},
"node_modules": {
"files": {
"is-number": {
"files": {
"LICENSE": {
"offset": "0",
"size": 1088,
},
"index.js": {
"offset": "1088",
"size": 662,
},
"package.json": {
"offset": "1750",
"size": 871,
},
},
},
"is-odd": {
"files": {
"LICENSE": {
"offset": "2621",
"size": 1091,
},
"index.js": {
"offset": "3712",
"size": 543,
},
"package.json": {
"offset": "4255",
"size": 895,
},
},
},
},
},
"package.json": {
"offset": "8492",
"size": 291,
},
},
}
`;

exports[`yarn several workspaces 1`] = `
{
"linux": [],
Expand Down
25 changes: 25 additions & 0 deletions test/src/HoistedNodeModuleTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ test("yarn workspace", ({ expect }) =>
}
))


test("conflict versions", ({ expect }) =>
assertPack(
expect,
Expand Down Expand Up @@ -71,6 +72,30 @@ test("yarn two package.json w/ native module", ({ expect }) =>
))

describe("isInstallDepsBefore=true", { sequential: true }, () => {

test("yarn workspace for scope name", ({ expect }) =>
assertPack(
expect,
"test-app-yarn-several-workspace",
{
targets: linuxDirTarget,
projectDir: "packages/test-app",
},
{
isInstallDepsBefore: true,
projectDirCreated: projectDir => {
let subAppDir = path.join(projectDir , "packages","test-app")
return modifyPackageJson(subAppDir, data => {
data.name = "@scope/xxx-app"
data.dependencies = {
"is-odd": "3.0.1"
}
})
},
packed: context => verifyAsarFileTree(expect, context.getResources(Platform.LINUX)),
}
))

// https://github.com/electron-userland/electron-builder/issues/8493
test("pnpm es5-ext without hoisted config", ({ expect }) =>
assertPack(
Expand Down