Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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/swift-hotels-exercise.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"app-builder-lib": patch
---

skip circular deps
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ export abstract class NodeModulesCollector {
result[parentKey] = { dependencies: [] }
}
result[parentKey].dependencies!.push(newKey)

if (node.skipCircularDeps) {
continue
}
flatten(value, newKey)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ export class NpmNodeModulesCollector extends NodeModulesCollector {
removeNonProductionDependencie(tree: DependencyTree) {
const dependencies = tree.dependencies || {}
const _dependencies = tree._dependencies || {}
if (dependencies && Object.keys(dependencies).length === 0) {
if (Object.keys(_dependencies).length > 0 && Object.keys(dependencies).length === 0) {
tree.dependencies = this.allDependencies.get(`${tree.name}@${tree.version}`)?.dependencies || {}
tree.skipCircularDeps = true
return
}

for (const [key, value] of Object.entries(dependencies)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export interface DependencyTree {
readonly from?: string
readonly workspaces?: string[]
readonly path: string
skipCircularDeps?: boolean
dependencies?: {
[packageName: string]: DependencyTree
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ export class YarnNodeModulesCollector extends NodeModulesCollector {
removeNonProductionDependencie(tree: DependencyTree) {
const dependencies = tree.dependencies || {}
const _dependencies = tree._dependencies || {}
if (dependencies && Object.keys(dependencies).length === 0) {
if (Object.keys(_dependencies).length > 0 && Object.keys(dependencies).length === 0) {
tree.dependencies = this.allDependencies.get(`${tree.name}@${tree.version}`)?.dependencies || {}
tree.skipCircularDeps = true
return
}

for (const [key, value] of Object.entries(dependencies)) {
Expand Down
118 changes: 118 additions & 0 deletions test/snapshots/HoistedNodeModuleTest.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,65 @@ exports[`pnpm es5-ext without hoisted config 2`] = `
}
`;

exports[`pnpm max stack 1`] = `
{
"linux": [],
}
`;

exports[`pnpm max stack 2`] = `
{
"author": "Toru Nagashima",
"bin": {
"npm-run-all": "bin/npm-run-all/index.js",
"run-p": "bin/run-p/index.js",
"run-s": "bin/run-s/index.js",
},
"dependencies": {
"ansi-styles": "^3.2.1",
"chalk": "^2.4.1",
"cross-spawn": "^6.0.5",
"memorystream": "^0.3.1",
"minimatch": "^3.0.4",
"pidtree": "^0.3.0",
"read-pkg": "^3.0.0",
"shell-quote": "^1.6.1",
"string.prototype.padend": "^3.0.0",
},
"description": "A CLI tool to run multiple npm-scripts in parallel or sequential.",
"devDependencies": {
"@types/node": "^4.9.1",
"babel-plugin-transform-async-to-generator": "^6.24.1",
"babel-preset-power-assert": "^2.0.0",
"babel-register": "^6.26.0",
"codecov": "^3.1.0",
"eslint": "^4.19.1",
"eslint-config-mysticatea": "^12.0.0",
"fs-extra": "^7.0.1",
"mocha": "^5.2.0",
"nyc": "^11.9.0",
"p-queue": "^2.4.2",
"power-assert": "^1.6.1",
"rimraf": "^2.6.2",
"yarn": "^1.12.3",
},
"engines": {
"node": ">= 4",
},
"files": [
"bin",
"lib",
"docs",
],
"homepage": "https://github.com/mysticatea/npm-run-all",
"license": "MIT",
"main": "lib/index.js",
"name": "npm-run-all",
"repository": "mysticatea/npm-run-all",
"version": "4.1.5",
}
`;

exports[`pnpm optional dependencies 1`] = `
{
"linux": [],
Expand Down Expand Up @@ -457,6 +516,65 @@ exports[`yarn electron-clear-data 2`] = `
}
`;

exports[`yarn max stack 1`] = `
{
"linux": [],
}
`;

exports[`yarn max stack 2`] = `
{
"author": "Toru Nagashima",
"bin": {
"npm-run-all": "bin/npm-run-all/index.js",
"run-p": "bin/run-p/index.js",
"run-s": "bin/run-s/index.js",
},
"dependencies": {
"ansi-styles": "^3.2.1",
"chalk": "^2.4.1",
"cross-spawn": "^6.0.5",
"memorystream": "^0.3.1",
"minimatch": "^3.0.4",
"pidtree": "^0.3.0",
"read-pkg": "^3.0.0",
"shell-quote": "^1.6.1",
"string.prototype.padend": "^3.0.0",
},
"description": "A CLI tool to run multiple npm-scripts in parallel or sequential.",
"devDependencies": {
"@types/node": "^4.9.1",
"babel-plugin-transform-async-to-generator": "^6.24.1",
"babel-preset-power-assert": "^2.0.0",
"babel-register": "^6.26.0",
"codecov": "^3.1.0",
"eslint": "^4.19.1",
"eslint-config-mysticatea": "^12.0.0",
"fs-extra": "^7.0.1",
"mocha": "^5.2.0",
"nyc": "^11.9.0",
"p-queue": "^2.4.2",
"power-assert": "^1.6.1",
"rimraf": "^2.6.2",
"yarn": "^1.12.3",
},
"engines": {
"node": ">= 4",
},
"files": [
"bin",
"lib",
"docs",
],
"homepage": "https://github.com/mysticatea/npm-run-all",
"license": "MIT",
"main": "lib/index.js",
"name": "npm-run-all",
"repository": "mysticatea/npm-run-all",
"version": "4.1.5",
}
`;

exports[`yarn ms 1`] = `
{
"linux": [],
Expand Down
51 changes: 51 additions & 0 deletions test/src/HoistedNodeModuleTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,57 @@ test.ifAll("yarn some module add by manual instead of install", () =>
)
)

//https://github.com/electron-userland/electron-builder/issues/8857
test.ifAll("yarn max stack", () =>
assertPack(
"test-app-hoisted",
{
targets: linuxDirTarget,
},
{
isInstallDepsBefore: true,
projectDirCreated: projectDir => {
return Promise.all([
modifyPackageJson(projectDir, data => {
data.dependencies = {
"npm-run-all": "^4.1.5",
}
}),
outputFile(path.join(projectDir, "yarn.lock"), ""),
])
},
packed: async context => {
expect(await readAsarJson(path.join(context.getResources(Platform.LINUX), "app.asar"), "node_modules/npm-run-all/package.json")).toMatchSnapshot()
},
}
)
)

test.ifAll("pnpm max stack", () =>
assertPack(
"test-app-hoisted",
{
targets: linuxDirTarget,
},
{
isInstallDepsBefore: true,
projectDirCreated: projectDir => {
return Promise.all([
modifyPackageJson(projectDir, data => {
data.dependencies = {
"npm-run-all": "^4.1.5",
}
}),
outputFile(path.join(projectDir, "pnpm-lock.yaml"), ""),
])
},
packed: async context => {
expect(await readAsarJson(path.join(context.getResources(Platform.LINUX), "app.asar"), "node_modules/npm-run-all/package.json")).toMatchSnapshot()
},
}
)
)

//github.com/electron-userland/electron-builder/issues/8842
test.ifAll("yarn ms", () =>
assertPack(
Expand Down
Loading