From a60084919922dbd4badbee1f68222fcc537c2113 Mon Sep 17 00:00:00 2001 From: James Chen Date: Fri, 23 Feb 2024 11:40:05 +0800 Subject: [PATCH 1/2] Add optionalDependencies support for deploy --- scripts/deploy.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/scripts/deploy.js b/scripts/deploy.js index e3fd1e5..a3d5b3e 100644 --- a/scripts/deploy.js +++ b/scripts/deploy.js @@ -20,6 +20,8 @@ const pkgName2Main = {}; const pkgName2Types = {}; const filesToCopy = []; const allDeps = {}; +const allOptionalDeps = {}; + pkgFileList.forEach(pkgFile => { const pkg = JSON.parse(fs.readFileSync(pkgFile, 'utf8')); const pkgName = pkg.name; @@ -56,6 +58,15 @@ pkgFileList.forEach(pkgFile => { allDeps[dep] = depVersion; } + for (const dep in pkg.optionalDependencies) { + const depVersion = pkg.optionalDependencies[dep]; + if (dep in allOptionalDeps && allOptionalDeps[dep] !== depVersion) { + console.warn(`optional package '${pkgName}' has different dep version of package '${dep}', which is '${depVersion}'`); + continue; + } + allOptionalDeps[dep] = depVersion; + } + }); // copy files @@ -132,6 +143,7 @@ console.log('generate package.json'); const rootPkgFile = ps.join(rootDir, 'package.json'); const rootPkg = JSON.parse(fs.readFileSync(rootPkgFile, 'utf8')); rootPkg.dependencies = allDeps; +rootPkg.optionalDependencies = allOptionalDeps; delete rootPkg.devDependencies; delete rootPkg.scripts; for (const dep in rootPkg.dependencies) { From 5333ef57cc5e73931569c80d655855b915d3e25b Mon Sep 17 00:00:00 2001 From: James Chen Date: Fri, 23 Feb 2024 11:40:12 +0800 Subject: [PATCH 2/2] 2.2.7 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 5df8765..3bef4da 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@cocos/ccbuild", - "version": "2.2.6", + "version": "2.2.7", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@cocos/ccbuild", - "version": "2.2.6", + "version": "2.2.7", "hasInstallScript": true, "license": "MIT", "workspaces": [ diff --git a/package.json b/package.json index 6267868..4387485 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@cocos/ccbuild", - "version": "2.2.6", + "version": "2.2.7", "description": "The next generation of build tool for Cocos engine.", "main": "./lib/index.js", "types": "./lib/index.d.ts",