puppeteer/lib
Andrey Lushnikov f230722ff0
refactor: avoid dynamic requires in lib/ folder (#3208)
This patch removes all dynamic requires in Puppeteer. This should
make it much simpler to bundle puppeteer/puppeteer-core packages.

We used dynamic requires in a few places in lib/:
- BrowserFetcher was choosing between `http` and `https` based on some
  runtime value. This was easy to fix with explicit `require`.
- BrowserFetcher and Launcher needed to know project root to store
  chromium revisions and to read package name and chromium revision from
  package.json. (projectRoot value would be different in node6).
  Instead of doing a backwards logic to infer these
  variables, we now pass them directly from `//index.js`.

With this patch, I was able to bundle Puppeteer using browserify and
the following config in `package.json`:

```json
  "browser": {
    "./lib/BrowserFetcher.js": false,
    "ws": "./lib/BrowserWebSocket",
    "fs": false,
    "child_process": false,
    "rimraf": false,
    "readline": false
  }
```

(where `lib/BrowserWebSocket.js` is a courtesy of @Janpot from
https://github.com/GoogleChrome/puppeteer/pull/2374/)

And command:

```sh
$ browserify -r puppeteer:./index.js > ppweb.js
```

References #2119
2018-09-06 20:33:41 +01:00
..
.eslintrc.js Introduce Eslint to validate style 2017-06-11 01:32:59 -07:00
Browser.js feat(browsercontext): implement BrowserContext.overridePermissions (#3159) 2018-08-30 23:36:09 +01:00
BrowserFetcher.js refactor: avoid dynamic requires in lib/ folder (#3208) 2018-09-06 20:33:41 +01:00
Connection.js fix: fix null-type bugs (#3137) 2018-08-24 15:17:36 -07:00
Coverage.js fix(coverage): report anonymous scripts with debugger:// urls (#2875) 2018-07-11 21:05:16 -07:00
Dialog.js chore: upgrade to TypeScript 3.0.1 (#3024) 2018-08-06 11:31:33 -07:00
EmulationManager.js chore: upgrade to TypeScript 3.0.1 (#3024) 2018-08-06 11:31:33 -07:00
Errors.js feat: introduce puppeteer/Errors (#3056) 2018-08-09 16:51:12 -07:00
ExecutionContext.js fix: fix null-type bugs (#3137) 2018-08-24 15:17:36 -07:00
externs.d.ts refactor: drop object factory from execution context (#3099) 2018-08-16 16:16:27 -07:00
FrameManager.js fix: fix null-type bugs (#3137) 2018-08-24 15:17:36 -07:00
helper.js refactor: avoid dynamic requires in lib/ folder (#3208) 2018-09-06 20:33:41 +01:00
Input.js fix: fix null-type bugs (#3137) 2018-08-24 15:17:36 -07:00
Launcher.js refactor: avoid dynamic requires in lib/ folder (#3208) 2018-09-06 20:33:41 +01:00
Multimap.js chore: upgrade to TypeScript 3.0.1 (#3024) 2018-08-06 11:31:33 -07:00
NavigatorWatcher.js fix(page): Page.goto should properly handle historyAPI in beforeunload (#3198) 2018-09-05 22:59:29 +01:00
NetworkManager.js feat(network): introduce Response.statusText() (#3193) 2018-09-05 21:03:24 +01:00
Page.js fix(page): Page.goto should properly handle historyAPI in beforeunload (#3198) 2018-09-05 22:59:29 +01:00
Pipe.js feat(chromium): roll Chromium to r574897 (#2887) 2018-07-13 11:07:24 -07:00
Puppeteer.js refactor: avoid dynamic requires in lib/ folder (#3208) 2018-09-06 20:33:41 +01:00
Target.js fix: fix null-type bugs (#3137) 2018-08-24 15:17:36 -07:00
TaskQueue.js chore: upgrade to TypeScript 3.0.1 (#3024) 2018-08-06 11:31:33 -07:00
Tracing.js Revert "chore(tests): redirect debugError to the output category of tests (#2969)" (#2987) 2018-07-30 16:41:39 -07:00
USKeyboardLayout.js feat(keyboard): Accept codes (#1116) 2017-10-23 12:43:45 -07:00
Worker.js refactor: drop object factory from execution context (#3099) 2018-08-16 16:16:27 -07:00