Skip to content

Commit

Permalink
chore: rename vendor to third_party (#9021)
Browse files Browse the repository at this point in the history
This PR renames `vendor` to `third_party` to better adhere to internal
codebase nomenclature.
  • Loading branch information
jrandolf committed Sep 28, 2022
1 parent f8de7b1 commit 2a21896
Show file tree
Hide file tree
Showing 12 changed files with 25 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .eslintignore
Expand Up @@ -39,4 +39,4 @@ yarn-error.log*

# ESLint ignores.
assets/
vendor/
third_party/
2 changes: 1 addition & 1 deletion .eslintrc.js
Expand Up @@ -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',
},
],
},
Expand Down
8 changes: 4 additions & 4 deletions docs/contributing.md
Expand Up @@ -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

Expand All @@ -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
Expand Down Expand Up @@ -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

Expand Down
6 changes: 3 additions & 3 deletions package.json
Expand Up @@ -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",
Expand Down
11 changes: 6 additions & 5 deletions rollup.vendor.config.js → rollup.third_party.config.js
Expand Up @@ -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},
Expand Down
6 changes: 5 additions & 1 deletion src/common/EventEmitter.ts
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/tsconfig.cjs.json
Expand Up @@ -7,6 +7,6 @@
},
"references": [
{"path": "../compat/cjs/tsconfig.json"},
{"path": "../vendor/tsconfig.json"}
{"path": "../third_party/tsconfig.json"}
]
}
2 changes: 1 addition & 1 deletion src/tsconfig.esm.json
Expand Up @@ -7,6 +7,6 @@
},
"references": [
{"path": "../compat/esm/tsconfig.json"},
{"path": "../vendor/tsconfig.cjs.json"}
{"path": "../third_party/tsconfig.cjs.json"}
]
}
2 changes: 1 addition & 1 deletion vendor/README.md → 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.
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion vendor/tsconfig.cjs.json → third_party/tsconfig.cjs.json
Expand Up @@ -3,7 +3,7 @@
"compilerOptions": {
"composite": true,
"declarationMap": false,
"outDir": "../lib/cjs/vendor",
"outDir": "../lib/cjs/third_party",
"sourceMap": false
}
}
2 changes: 1 addition & 1 deletion vendor/tsconfig.json → third_party/tsconfig.json
Expand Up @@ -3,7 +3,7 @@
"compilerOptions": {
"composite": true,
"declarationMap": false,
"outDir": "../lib/esm/vendor",
"outDir": "../lib/esm/third_party",
"sourceMap": false
}
}

0 comments on commit 2a21896

Please sign in to comment.