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", 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) {