From 36320f81c54efbcefe63a35dee5e175320f02583 Mon Sep 17 00:00:00 2001 From: Kaizen Conroy <36202692+kaizencc@users.noreply.github.com> Date: Mon, 23 Jan 2023 23:39:24 -0500 Subject: [PATCH] chore(node-bundle): ignore invalid package.json files (#23799) package.json files are required to have a `name` property. However, for some reason some deps can have embedded package.json files that do not adhere to this. For example, `minimatch/dist/cjs/package.json` looks like this: ```json { "type": "commonjs" } ``` This kills `yarn pkglint` because pkglint is expecting a real package (with a real name), which is running `node-bundle`. I've decided that simply ignoring these invalid package.jsons is the right thing to do. Can confirm that this does fix `yarn pkglint`. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* (cherry picked from commit 3334acc53aa5e5f5f1eb73666cd85cc9fe286d13) --- tools/@aws-cdk/node-bundle/src/api/bundle.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/@aws-cdk/node-bundle/src/api/bundle.ts b/tools/@aws-cdk/node-bundle/src/api/bundle.ts index 302422075f0ef..c65f0e53fb117 100644 --- a/tools/@aws-cdk/node-bundle/src/api/bundle.ts +++ b/tools/@aws-cdk/node-bundle/src/api/bundle.ts @@ -307,7 +307,7 @@ export class Bundle { } const inputs = Object.keys(this.bundle.metafile!.inputs); const packages = new Set(Array.from(inputs).map(i => this.closestPackagePath(path.join(this.packageDir, i)))); - this._dependencies = Array.from(packages).map(p => this.createPackage(p)).filter(d => d.name !== this.manifest.name); + this._dependencies = Array.from(packages).map(p => this.createPackage(p)).filter(d => d.name !== undefined && d.name !== this.manifest.name); return this._dependencies; }