diff --git a/packages/puppeteer-core/package.json b/packages/puppeteer-core/package.json index beaf0f06ea7..7465a6a1c39 100644 --- a/packages/puppeteer-core/package.json +++ b/packages/puppeteer-core/package.json @@ -34,16 +34,15 @@ "node": ">=14.1.0" }, "scripts": { + "build:docs": "wireit", "build:tsc": "wireit", "build:types": "wireit", - "build:docs": "wireit", "build": "wireit", "check": "tsx tools/ensure-correct-devtools-protocol-package", - "format:types": "wireit", + "clean": "tsc -b --clean && rimraf lib src/generated", "generate:package-json": "wireit", "generate:sources": "wireit", - "prepack": "wireit", - "clean": "tsc -b --clean && rimraf lib src/generated" + "prepack": "wireit" }, "wireit": { "prepack": { @@ -58,8 +57,7 @@ "build": { "dependencies": [ "build:tsc", - "format:types", - "generate:package-json" + "build:types" ] }, "generate:sources": { @@ -76,9 +74,6 @@ }, "generate:package-json": { "command": "tsx ../../tools/generate_module_package_json.ts lib/esm/package.json", - "dependencies": [ - "build:tsc" - ], "files": [ "../../tools/generate_module_package_json.ts" ], @@ -86,58 +81,46 @@ "lib/esm/package.json" ] }, - "build:types": { - "command": "api-extractor run --local", - "files": [ - "tsconfig.json", - "api-extractor.json", - "lib/esm/puppeteer/types.d.ts" - ], - "output": [ - "lib/types.d.ts" - ], - "dependencies": [ - "build:tsc" - ] - }, "build:docs": { "command": "api-extractor run --local --config \"./api-extractor.docs.json\"", "files": [ - "tsconfig.json", "api-extractor.docs.json", - "lib/esm/puppeteer/puppeteer-core.d.ts" + "lib/esm/puppeteer/puppeteer-core.d.ts", + "tsconfig.json" ], "dependencies": [ "build:tsc" ] }, - "format:types": { - "command": "eslint --cache-location .eslintcache --cache --ext=ts --no-ignore --no-eslintrc -c=../../.eslintrc.types.cjs --fix lib/types.d.ts", - "dependencies": [ - "build:types" - ], - "clean": false, - "files": [ - "lib/types.d.ts", - "../../.eslintrc.types.cjs" - ], - "output": [ - "lib/types.d.ts" - ] - }, "build:tsc": { "command": "tsc -b && rollup --config rollup.third_party.config.mjs", "clean": "if-file-deleted", "dependencies": [ + "generate:package-json", "generate:sources" ], "files": [ - "rollup.third_party.config.mjs", - "**/tsconfig{.*,}.json", - "{compat,src,third_party}/**/*.ts" + "{compat,src,third_party}/**", + "rollup.third_party.config.mjs" ], "output": [ - "lib/{cjs,esm}/**/*.{ts,js}{.map,}" + "lib/{cjs,esm}/**", + "!lib/esm/package.json" + ] + }, + "build:types": { + "command": "api-extractor run --local && eslint --cache-location .eslintcache --cache --ext=ts --no-ignore --no-eslintrc -c=../../.eslintrc.types.cjs --fix lib/types.d.ts", + "files": [ + "../../.eslintrc.types.cjs", + "api-extractor.json", + "lib/esm/puppeteer/types.d.ts", + "tsconfig.json" + ], + "output": [ + "lib/types.d.ts" + ], + "dependencies": [ + "build:tsc" ] } }, diff --git a/packages/puppeteer/package.json b/packages/puppeteer/package.json index 766c46cb0e0..0cb2678c7ac 100644 --- a/packages/puppeteer/package.json +++ b/packages/puppeteer/package.json @@ -34,12 +34,11 @@ "node": ">=14.1.0" }, "scripts": { + "build:docs": "wireit", "build:tsc": "wireit", "build:types": "wireit", - "build:docs": "wireit", "build": "wireit", "clean": "tsc -b --clean && rimraf lib", - "format:types": "wireit", "generate:package-json": "wireit", "postinstall": "node install.js", "prepack": "wireit" @@ -57,15 +56,11 @@ "build": { "dependencies": [ "build:tsc", - "format:types", - "generate:package-json" + "build:types" ] }, "generate:package-json": { "command": "tsx ../../tools/generate_module_package_json.ts lib/esm/package.json", - "dependencies": [ - "build:tsc" - ], "files": [ "../../tools/generate_module_package_json.ts" ], @@ -73,40 +68,17 @@ "lib/esm/package.json" ] }, - "build:types": { - "command": "api-extractor run --local", - "dependencies": [ - "build:tsc" - ], - "files": [ - "tsconfig.json", - "api-extractor.json", - "lib/esm/puppeteer/types.d.ts" - ], - "output": [ - "lib/types.d.ts" - ] - }, "build:docs": { "command": "api-extractor run --local --config \"./api-extractor.docs.json\"", + "files": [ + "api-extractor.docs.json", + "lib/esm/puppeteer/puppeteer-core.d.ts", + "tsconfig.json" + ], "dependencies": [ "build:tsc" ] }, - "format:types": { - "command": "eslint --cache-location .eslintcache --cache --ext=ts --no-ignore --no-eslintrc -c=../../.eslintrc.types.cjs --fix lib/types.d.ts", - "dependencies": [ - "build:types" - ], - "clean": false, - "files": [ - "lib/types.d.ts", - "../../.eslintrc.types.cjs" - ], - "output": [ - "lib/types.d.ts" - ] - }, "build:tsc": { "command": "tsc -b", "clean": "if-file-deleted", @@ -114,11 +86,26 @@ "../puppeteer-core:build" ], "files": [ - "**/tsconfig{.*,}.json", "src/**" ], "output": [ - "lib/{cjs,esm}/**/*.{ts,js}{.map,}" + "lib/{cjs,esm}/**", + "!lib/esm/package.json" + ] + }, + "build:types": { + "command": "api-extractor run --local && eslint --cache-location .eslintcache --cache --ext=ts --no-ignore --no-eslintrc -c=../../.eslintrc.types.cjs --fix lib/types.d.ts", + "files": [ + "../../.eslintrc.types.cjs", + "api-extractor.json", + "lib/esm/puppeteer/types.d.ts", + "tsconfig.json" + ], + "output": [ + "lib/types.d.ts" + ], + "dependencies": [ + "build:tsc" ] } }, diff --git a/packages/testserver/package.json b/packages/testserver/package.json index 9e205f1c13f..7f72f9080ef 100644 --- a/packages/testserver/package.json +++ b/packages/testserver/package.json @@ -4,9 +4,22 @@ "description": "testing server", "main": "lib/index.js", "scripts": { - "build": "tsc -b", + "build": "wireit", "clean": "tsc -b --clean && rimraf lib" }, + "wireit": { + "build": { + "command": "tsc -b", + "clean": "if-file-deleted", + "files": [ + "src/**" + ], + "output": [ + "lib/**", + "tsconfig.tsbuildinfo" + ] + } + }, "repository": { "type": "git", "url": "https://github.com/puppeteer/puppeteer/tree/main/packages/testserver" diff --git a/tools/generate_module_package_json.ts b/tools/generate_module_package_json.ts index 7a0beef4f01..75737463d51 100644 --- a/tools/generate_module_package_json.ts +++ b/tools/generate_module_package_json.ts @@ -14,11 +14,13 @@ * limitations under the License. */ -import fs from 'fs'; +import {mkdirSync, writeFileSync} from 'fs'; +import {dirname} from 'path'; /** * Outputs the dummy package.json file to the path specified * by the first argument. */ -fs.writeFileSync(process.argv[2], `{"type": "module"}`); +mkdirSync(dirname(process.argv[2]), {recursive: true}); +writeFileSync(process.argv[2], `{"type": "module"}`);