diff --git a/.eslintignore b/.eslintignore index 2cd9862cd76..7d90ff9e87c 100644 --- a/.eslintignore +++ b/.eslintignore @@ -39,4 +39,4 @@ yarn-error.log* # ESLint ignores. assets/ -vendor/ +third_party/ diff --git a/.eslintrc.js b/.eslintrc.js index 42bb469db85..6759911c3ac 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -103,7 +103,7 @@ module.exports = { { name: 'mitt', message: - 'Import Mitt from the vendored location: vendor/mitt/index.js', + 'Import `mitt` from the vendored location: third_party/mitt/index.js', }, ], }, diff --git a/docs/contributing.md b/docs/contributing.md index c97d4021b4b..42103f2410e 100644 --- a/docs/contributing.md +++ b/docs/contributing.md @@ -101,7 +101,7 @@ The following is a description of the primary folders in Puppeteer: - `utils/mochaRunner` - contains the source code for our test runner. - `compat` - contains code separated by module import type. See [`compat/README.md`](https://github.com/puppeteer/puppeteer/blob/main/compat/README.md) for details. - `test-d` contains type tests using [`tsd`](https://github.com/SamVerschueren/tsd). -- `vendor` contains all dependencies that we vendor into the final build. See the [`vendor/README.md`](https://github.com/puppeteer/puppeteer/blob/main/vendor/README.md) for details. +- `third_party` contains all dependencies that we vendor into the final build. See the [`third_party/README.md`](https://github.com/puppeteer/puppeteer/blob/main/third_party/README.md) for details. ### Shipping CJS and ESM bundles @@ -113,10 +113,10 @@ We compile into the `lib` directory which is what we publish on the npm reposito lib - cjs - puppeteer <== the output of compiling `src/tsconfig.cjs.json` - - vendor <== the output of compiling `vendor/tsconfig.cjs.json` + - third_party <== the output of compiling `third_party/tsconfig.cjs.json` - esm - puppeteer <== the output of compiling `src/tsconfig.esm.json` - - vendor <== the output of compiling `vendor/tsconfig.esm.json` + - third_party <== the output of compiling `third_party/tsconfig.json` ``` ### `tsconfig.json` for the tests @@ -184,7 +184,7 @@ A barrier for introducing new installation dependencies is especially high: - **Do not add** installation dependency unless it's critical to project success. -There are additional considerations for dependencies that are environment agonistic. See the [`vendor/README.md`](https://github.com/puppeteer/puppeteer/blob/main/vendor/README.md) for details. +There are additional considerations for dependencies that are environment agonistic. See the [`third_party/README.md`](https://github.com/puppeteer/puppeteer/blob/main/third_party/README.md) for details. ## Running & Writing Tests diff --git a/package.json b/package.json index 205bf373f40..ec238d31f34 100644 --- a/package.json +++ b/package.json @@ -57,11 +57,11 @@ "check:protocol-revision": "tsx scripts/ensure-correct-devtools-protocol-package", "check:pinned-deps": "tsx scripts/ensure-pinned-deps", "build": "npm run build:prod", - "build:dev": "run-s generate:sources build:tsc:dev && run-p bundle:vendor generate:artifacts", - "build:prod": "run-s generate:sources build:tsc:prod && run-p bundle:vendor generate:artifacts", + "build:dev": "run-s generate:sources build:tsc:dev && run-p bundle:third_party generate:artifacts", + "build:prod": "run-s generate:sources build:tsc:prod && run-p bundle:third_party generate:artifacts", "build:tsc:dev": "tsc -b test", "build:tsc:prod": "tsc -b tsconfig.lib.json", - "bundle:vendor": "rollup --config rollup.vendor.config.js" + "bundle:third_party": "rollup --config rollup.third_party.config.js" }, "files": [ "lib", diff --git a/rollup.vendor.config.js b/rollup.third_party.config.js similarity index 78% rename from rollup.vendor.config.js rename to rollup.third_party.config.js index a87ea405d2b..0ca4ba3e43c 100644 --- a/rollup.vendor.config.js +++ b/rollup.third_party.config.js @@ -13,22 +13,23 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import path from 'path'; +import glob from 'glob'; import dts from 'rollup-plugin-dts'; import resolve from 'rollup-plugin-node-resolve'; -import glob from 'glob'; export default ['cjs', 'esm'].flatMap(outputType => { const configs = []; - const vendorPath = path.resolve(__dirname, `lib/${outputType}/vendor`); - for (const jsFile of glob.sync(path.join(vendorPath, '**/*.js'))) { + // Note we don't use path.join here. We cannot since `glob` does not support + // the backslash path separator. + const thirdPartyPath = `lib/${outputType}/third_party`; + for (const jsFile of glob.sync(`${thirdPartyPath}/**/*.js`)) { configs.push({ input: jsFile, output: {file: jsFile, exports: 'auto', format: outputType}, plugins: [resolve()], }); } - for (const typesFile of glob.sync(path.join(vendorPath, '**/*.d.ts'))) { + for (const typesFile of glob.sync(`${thirdPartyPath}/**/*.d.ts`)) { configs.push({ input: typesFile, output: {file: typesFile, format: outputType}, diff --git a/src/common/EventEmitter.ts b/src/common/EventEmitter.ts index d4b1b8f9635..7fa77ab47fa 100644 --- a/src/common/EventEmitter.ts +++ b/src/common/EventEmitter.ts @@ -14,7 +14,11 @@ * limitations under the License. */ -import mitt, {Emitter, EventType, Handler} from '../../vendor/mitt/index.js'; +import mitt, { + Emitter, + EventType, + Handler, +} from '../../third_party/mitt/index.js'; /** * @public diff --git a/src/tsconfig.cjs.json b/src/tsconfig.cjs.json index d5530e7bf98..ba409245e30 100644 --- a/src/tsconfig.cjs.json +++ b/src/tsconfig.cjs.json @@ -7,6 +7,6 @@ }, "references": [ {"path": "../compat/cjs/tsconfig.json"}, - {"path": "../vendor/tsconfig.json"} + {"path": "../third_party/tsconfig.json"} ] } diff --git a/src/tsconfig.esm.json b/src/tsconfig.esm.json index 392770c9bf3..4478592376b 100644 --- a/src/tsconfig.esm.json +++ b/src/tsconfig.esm.json @@ -7,6 +7,6 @@ }, "references": [ {"path": "../compat/esm/tsconfig.json"}, - {"path": "../vendor/tsconfig.cjs.json"} + {"path": "../third_party/tsconfig.cjs.json"} ] } diff --git a/vendor/README.md b/third_party/README.md similarity index 98% rename from vendor/README.md rename to third_party/README.md index 29e84e6a5cd..38c1844346f 100644 --- a/vendor/README.md +++ b/third_party/README.md @@ -1,4 +1,4 @@ -# `vendor` +# `third_party` This folder contains code that interacts with third party node modules that will be vendored with puppeteer during publishing. diff --git a/vendor/mitt/index.ts b/third_party/mitt/index.ts similarity index 100% rename from vendor/mitt/index.ts rename to third_party/mitt/index.ts diff --git a/vendor/tsconfig.cjs.json b/third_party/tsconfig.cjs.json similarity index 78% rename from vendor/tsconfig.cjs.json rename to third_party/tsconfig.cjs.json index 9cd8c8abb18..9da8dfb79e9 100644 --- a/vendor/tsconfig.cjs.json +++ b/third_party/tsconfig.cjs.json @@ -3,7 +3,7 @@ "compilerOptions": { "composite": true, "declarationMap": false, - "outDir": "../lib/cjs/vendor", + "outDir": "../lib/cjs/third_party", "sourceMap": false } } diff --git a/vendor/tsconfig.json b/third_party/tsconfig.json similarity index 78% rename from vendor/tsconfig.json rename to third_party/tsconfig.json index f1b2c780f12..fac27476032 100644 --- a/vendor/tsconfig.json +++ b/third_party/tsconfig.json @@ -3,7 +3,7 @@ "compilerOptions": { "composite": true, "declarationMap": false, - "outDir": "../lib/esm/vendor", + "outDir": "../lib/esm/third_party", "sourceMap": false } }