Skip to content

Commit

Permalink
fix(puppeteer): export internals (#7991)
Browse files Browse the repository at this point in the history
Signed-off-by: Randolf Jung <jrandolf@chromium.org>

Co-authored-by: Randolf Jung <jrandolf@chromium.org>
  • Loading branch information
jrandolf-zz and jrandolf committed Feb 10, 2022
1 parent 1b120b2 commit 448118c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
10 changes: 8 additions & 2 deletions package.json
Expand Up @@ -5,8 +5,14 @@
"type": "commonjs",
"main": "./cjs-entry.js",
"exports": {
"import": "./lib/esm/puppeteer/node.js",
"require": "./cjs-entry.js"
".": {
"import": "./lib/esm/puppeteer/node.js",
"require": "./cjs-entry.js"
},
"./*": {
"import": "./*",
"require": "./*"
}
},
"types": "lib/types.d.ts",
"repository": "github:puppeteer/puppeteer",
Expand Down
9 changes: 7 additions & 2 deletions scripts/test-install.sh
Expand Up @@ -14,6 +14,9 @@ cd $TMPDIR
# 3. Requiring Puppeteer from Node works.
npm install --loglevel silent "${tarball}"
node --eval="require('puppeteer')"
node --eval="
require('puppeteer/lib/cjs/puppeteer/revisions.js');
"
ls $TMPDIR/node_modules/puppeteer/.local-chromium/

# Testing ES module features
Expand All @@ -22,8 +25,9 @@ cd $TMPDIR
echo '{"type":"module"}' >>$TMPDIR/package.json
npm install --loglevel silent "${tarball}"
node --input-type="module" --eval="import puppeteer from 'puppeteer'"
ls $TMPDIR/node_modules/puppeteer/.local-chromium/

node --input-type="module" --eval="
import 'puppeteer/lib/esm/puppeteer/revisions.js';
"
node --input-type="module" --eval="
import puppeteer from 'puppeteer';
Expand All @@ -35,6 +39,7 @@ import puppeteer from 'puppeteer';
await browser.close();
})();
"
ls $TMPDIR/node_modules/puppeteer/.local-chromium/

# Again for Firefox
TMPDIR="$(mktemp -d)"
Expand Down
3 changes: 2 additions & 1 deletion utils/prepare_puppeteer_core.js
Expand Up @@ -25,5 +25,6 @@ delete json.scripts.install;

json.name = 'puppeteer-core';
json.main = './cjs-entry-core.js';
json.exports.import = './lib/esm/puppeteer/node-puppeteer-core.js';
json.exports['.'].imports = './lib/esm/puppeteer/node-puppeteer-core.js';
json.exports['.'].require = './cjs-entry-core.js';
fs.writeFileSync(packagePath, JSON.stringify(json, null, ' '));

0 comments on commit 448118c

Please sign in to comment.